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.txt50
-rwxr-xr-xbuild_files/build_environment/install_deps.sh226
-rw-r--r--build_files/buildbot/config/user-config-cuda-glibc211-i686.py2
-rw-r--r--build_files/buildbot/config/user-config-cuda-glibc211-x86_64.py2
-rw-r--r--build_files/buildbot/config/user-config-glibc211-i686.py4
-rw-r--r--build_files/buildbot/config/user-config-glibc211-x86_64.py4
-rw-r--r--build_files/buildbot/config/user-config-player-glibc211-i686.py4
-rw-r--r--build_files/buildbot/config/user-config-player-glibc211-x86_64.py4
-rw-r--r--build_files/buildbot/slave_compile.py1
-rw-r--r--build_files/cmake/Modules/FindOpenEXR.cmake5
-rw-r--r--build_files/cmake/Modules/FindPythonLibsUnix.cmake4
-rwxr-xr-xbuild_files/cmake/cmake_netbeans_project.py2
-rwxr-xr-xbuild_files/cmake/cmake_qtcreator_project.py6
-rw-r--r--build_files/cmake/config/blender_lite.cmake5
-rwxr-xr-xbuild_files/cmake/project_info.py25
-rw-r--r--build_files/scons/config/Modules/FindPython.py2
-rw-r--r--build_files/scons/config/darwin-config.py6
-rw-r--r--build_files/scons/config/freebsd8-config.py205
-rw-r--r--build_files/scons/config/freebsd9-config.py210
-rw-r--r--build_files/scons/config/linux-config.py2
-rw-r--r--build_files/scons/config/linuxcross-config.py189
-rw-r--r--build_files/scons/config/win32-mingw-config.py8
-rw-r--r--build_files/scons/config/win32-vc-config.py8
-rw-r--r--build_files/scons/config/win64-mingw-config.py9
-rw-r--r--build_files/scons/config/win64-vc-config.py8
-rw-r--r--build_files/scons/tools/Blender.py21
-rw-r--r--doc/python_api/rst_from_bmesh_opdefines.py2
-rw-r--r--doc/python_api/sphinx_doc_gen.py3
-rw-r--r--extern/bullet2/CMakeLists.txt10
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverBody.h7
-rw-r--r--extern/bullet2/src/SConscript16
-rw-r--r--extern/carve/carve-capi.cc45
-rw-r--r--extern/carve/carve-util.cc117
-rw-r--r--extern/carve/carve-util.h39
-rw-r--r--extern/libmv/CMakeLists.txt7
-rw-r--r--extern/libmv/ChangeLog346
-rw-r--r--extern/libmv/SConscript3
-rwxr-xr-xextern/libmv/bundle.sh4
-rw-r--r--extern/libmv/files.txt5
-rw-r--r--extern/libmv/libmv-capi.cc1033
-rw-r--r--extern/libmv/libmv-capi.h42
-rw-r--r--extern/libmv/libmv-capi_stub.cc43
-rw-r--r--extern/libmv/libmv-util.cc309
-rw-r--r--extern/libmv/libmv-util.h69
-rw-r--r--extern/libmv/libmv/base/aligned_malloc.cc74
-rw-r--r--extern/libmv/libmv/base/aligned_malloc.h34
-rw-r--r--extern/libmv/libmv/image/correlation.h28
-rw-r--r--extern/libmv/libmv/simple_pipeline/bundle.cc152
-rw-r--r--extern/libmv/libmv/simple_pipeline/bundle.h13
-rw-r--r--extern/libmv/libmv/simple_pipeline/camera_intrinsics.cc493
-rw-r--r--extern/libmv/libmv/simple_pipeline/camera_intrinsics.h470
-rw-r--r--extern/libmv/libmv/simple_pipeline/camera_intrinsics_impl.h192
-rw-r--r--extern/libmv/libmv/simple_pipeline/detect.cc56
-rw-r--r--extern/libmv/libmv/simple_pipeline/detect.h35
-rw-r--r--extern/libmv/libmv/simple_pipeline/distortion_models.cc197
-rw-r--r--extern/libmv/libmv/simple_pipeline/distortion_models.h131
-rw-r--r--extern/libmv/libmv/simple_pipeline/keyframe_selection.cc31
-rw-r--r--extern/libmv/libmv/simple_pipeline/keyframe_selection.h7
-rw-r--r--extern/libmv/libmv/tracking/brute_region_tracker.cc55
-rw-r--r--intern/audaspace/intern/AUD_AnimateableProperty.cpp20
-rw-r--r--intern/audaspace/intern/AUD_AnimateableProperty.h7
-rw-r--r--intern/audaspace/intern/AUD_Sequencer.cpp1
-rw-r--r--intern/audaspace/intern/AUD_SequencerEntry.cpp2
-rw-r--r--intern/cycles/CMakeLists.txt9
-rw-r--r--intern/cycles/SConscript6
-rw-r--r--intern/cycles/app/cycles_standalone.cpp28
-rw-r--r--intern/cycles/app/cycles_xml.cpp8
-rw-r--r--intern/cycles/app/cycles_xml.h11
-rw-r--r--intern/cycles/blender/CCL_api.h7
-rw-r--r--intern/cycles/blender/addon/__init__.py5
-rw-r--r--intern/cycles/blender/addon/engine.py6
-rw-r--r--intern/cycles/blender/addon/properties.py27
-rw-r--r--intern/cycles/blender/addon/ui.py97
-rw-r--r--intern/cycles/blender/blender_camera.cpp16
-rw-r--r--intern/cycles/blender/blender_mesh.cpp107
-rw-r--r--intern/cycles/blender/blender_object.cpp29
-rw-r--r--intern/cycles/blender/blender_python.cpp36
-rw-r--r--intern/cycles/blender/blender_session.cpp155
-rw-r--r--intern/cycles/blender/blender_session.h3
-rw-r--r--intern/cycles/blender/blender_shader.cpp3
-rw-r--r--intern/cycles/blender/blender_util.h15
-rw-r--r--intern/cycles/bvh/bvh_binning.cpp18
-rw-r--r--intern/cycles/bvh/bvh_build.cpp40
-rw-r--r--intern/cycles/bvh/bvh_build.h2
-rw-r--r--intern/cycles/bvh/bvh_params.h22
-rw-r--r--intern/cycles/bvh/bvh_split.cpp22
-rw-r--r--intern/cycles/bvh/bvh_split.h4
-rw-r--r--intern/cycles/device/device.h2
-rw-r--r--intern/cycles/device/device_cpu.cpp10
-rw-r--r--intern/cycles/device/device_cuda.cpp290
-rw-r--r--intern/cycles/device/device_multi.cpp2
-rw-r--r--intern/cycles/device/device_network.cpp4
-rw-r--r--intern/cycles/device/device_network.h6
-rw-r--r--intern/cycles/device/device_opencl.cpp124
-rw-r--r--intern/cycles/kernel/CMakeLists.txt20
-rw-r--r--intern/cycles/kernel/SConscript20
-rw-r--r--intern/cycles/kernel/closure/bsdf_hair.h14
-rw-r--r--intern/cycles/kernel/closure/bsdf_microfacet.h8
-rw-r--r--intern/cycles/kernel/closure/bsdf_phong_ramp.h4
-rw-r--r--intern/cycles/kernel/closure/bsdf_util.h13
-rw-r--r--intern/cycles/kernel/closure/bsdf_westin.h7
-rw-r--r--intern/cycles/kernel/geom/geom_bvh.h76
-rw-r--r--intern/cycles/kernel/geom/geom_bvh_shadow.h375
-rw-r--r--intern/cycles/kernel/geom/geom_bvh_subsurface.h13
-rw-r--r--intern/cycles/kernel/geom/geom_bvh_traversal.h27
-rw-r--r--intern/cycles/kernel/geom/geom_curve.h153
-rw-r--r--intern/cycles/kernel/geom/geom_object.h41
-rw-r--r--intern/cycles/kernel/geom/geom_primitive.h30
-rw-r--r--intern/cycles/kernel/kernel.cpp8
-rw-r--r--intern/cycles/kernel/kernel.cu96
-rw-r--r--intern/cycles/kernel/kernel_accumulate.h25
-rw-r--r--intern/cycles/kernel/kernel_avx.cpp2
-rw-r--r--intern/cycles/kernel/kernel_compat_cpu.h31
-rw-r--r--intern/cycles/kernel/kernel_compat_cuda.h2
-rw-r--r--intern/cycles/kernel/kernel_compat_opencl.h23
-rw-r--r--intern/cycles/kernel/kernel_displace.h302
-rw-r--r--intern/cycles/kernel/kernel_emission.h87
-rw-r--r--intern/cycles/kernel/kernel_light.h1
-rw-r--r--intern/cycles/kernel/kernel_passes.h3
-rw-r--r--intern/cycles/kernel/kernel_path.h236
-rw-r--r--intern/cycles/kernel/kernel_projection.h8
-rw-r--r--intern/cycles/kernel/kernel_shader.h143
-rw-r--r--intern/cycles/kernel/kernel_shadow.h218
-rw-r--r--intern/cycles/kernel/kernel_sse2.cpp2
-rw-r--r--intern/cycles/kernel/kernel_sse3.cpp2
-rw-r--r--intern/cycles/kernel/kernel_sse41.cpp2
-rw-r--r--intern/cycles/kernel/kernel_textures.h55
-rw-r--r--intern/cycles/kernel/kernel_types.h89
-rw-r--r--intern/cycles/kernel/kernel_volume.h8
-rw-r--r--intern/cycles/kernel/osl/osl_services.cpp61
-rw-r--r--intern/cycles/kernel/osl/osl_services.h6
-rw-r--r--intern/cycles/kernel/osl/osl_shader.cpp5
-rw-r--r--intern/cycles/kernel/shaders/node_absorption_volume.osl2
-rw-r--r--intern/cycles/kernel/shaders/node_fresnel.osl2
-rw-r--r--intern/cycles/kernel/shaders/node_glass_bsdf.osl2
-rw-r--r--intern/cycles/kernel/shaders/node_light_path.osl7
-rw-r--r--intern/cycles/kernel/shaders/node_math.osl2
-rw-r--r--intern/cycles/kernel/shaders/node_mix.osl2
-rw-r--r--intern/cycles/kernel/shaders/node_refraction_bsdf.osl2
-rw-r--r--intern/cycles/kernel/shaders/node_scatter_volume.osl2
-rw-r--r--intern/cycles/kernel/shaders/node_uv_map.osl23
-rw-r--r--intern/cycles/kernel/svm/svm.h20
-rw-r--r--intern/cycles/kernel/svm/svm_closure.h117
-rw-r--r--intern/cycles/kernel/svm/svm_geometry.h20
-rw-r--r--intern/cycles/kernel/svm/svm_image.h63
-rw-r--r--intern/cycles/kernel/svm/svm_light_path.h1
-rw-r--r--intern/cycles/kernel/svm/svm_math.h2
-rw-r--r--intern/cycles/kernel/svm/svm_mix.h2
-rw-r--r--intern/cycles/kernel/svm/svm_sepcomb_hsv.h12
-rw-r--r--intern/cycles/kernel/svm/svm_sky.h2
-rw-r--r--intern/cycles/kernel/svm/svm_types.h8
-rw-r--r--intern/cycles/kernel/svm/svm_vector_transform.h4
-rw-r--r--intern/cycles/kernel/svm/svm_wavelength.h54
-rw-r--r--intern/cycles/kernel/svm/svm_wireframe.h7
-rw-r--r--intern/cycles/render/CMakeLists.txt2
-rw-r--r--intern/cycles/render/attribute.cpp8
-rw-r--r--intern/cycles/render/attribute.h1
-rw-r--r--intern/cycles/render/bake.cpp206
-rw-r--r--intern/cycles/render/bake.h77
-rw-r--r--intern/cycles/render/blackbody.cpp54
-rw-r--r--intern/cycles/render/camera.cpp4
-rw-r--r--intern/cycles/render/curves.cpp2
-rw-r--r--intern/cycles/render/film.cpp7
-rw-r--r--intern/cycles/render/graph.cpp18
-rw-r--r--intern/cycles/render/graph.h2
-rw-r--r--intern/cycles/render/image.cpp45
-rw-r--r--intern/cycles/render/image.h13
-rw-r--r--intern/cycles/render/integrator.cpp16
-rw-r--r--intern/cycles/render/integrator.h2
-rw-r--r--intern/cycles/render/light.cpp9
-rw-r--r--intern/cycles/render/mesh.cpp20
-rw-r--r--intern/cycles/render/mesh.h1
-rw-r--r--intern/cycles/render/mesh_displace.cpp10
-rw-r--r--intern/cycles/render/nodes.cpp47
-rw-r--r--intern/cycles/render/nodes.h2
-rw-r--r--intern/cycles/render/object.cpp71
-rw-r--r--intern/cycles/render/object.h2
-rw-r--r--intern/cycles/render/scene.cpp21
-rw-r--r--intern/cycles/render/scene.h7
-rw-r--r--intern/cycles/render/session.cpp34
-rw-r--r--intern/cycles/render/session.h4
-rw-r--r--intern/cycles/render/sky_model.cpp2
-rw-r--r--intern/cycles/render/svm.cpp245
-rw-r--r--intern/cycles/render/svm.h11
-rw-r--r--intern/cycles/subd/subd_split.cpp2
-rw-r--r--intern/cycles/util/util_color.h34
-rw-r--r--intern/cycles/util/util_hash.h4
-rw-r--r--intern/cycles/util/util_math.h10
-rw-r--r--intern/cycles/util/util_md5.cpp2
-rw-r--r--intern/cycles/util/util_opencl.h4
-rw-r--r--intern/cycles/util/util_simd.h4
-rw-r--r--intern/cycles/util/util_system.cpp17
-rw-r--r--intern/cycles/util/util_transform.cpp9
-rw-r--r--intern/cycles/util/util_transform.h6
-rw-r--r--intern/cycles/util/util_types.h49
-rw-r--r--intern/cycles/util/util_view.cpp4
-rw-r--r--intern/ffmpeg/ffmpeg_compat.h4
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp26
-rw-r--r--intern/guardedalloc/intern/mallocn.c5
-rw-r--r--intern/guardedalloc/intern/mallocn_guarded_impl.c6
-rw-r--r--intern/guardedalloc/intern/mallocn_intern.h8
-rw-r--r--intern/guardedalloc/intern/mallocn_lockfree_impl.c13
-rw-r--r--intern/locale/SConscript6
-rw-r--r--release/datafiles/blender_icons.svg1679
-rw-r--r--release/datafiles/blender_icons16/icon16_action_tweak.datbin0 -> 1048 bytes
-rw-r--r--release/datafiles/blender_icons16/icon16_ipo_back.datbin0 -> 1048 bytes
-rw-r--r--release/datafiles/blender_icons16/icon16_ipo_bezier.datbin0 -> 1048 bytes
-rw-r--r--release/datafiles/blender_icons16/icon16_ipo_bounce.datbin0 -> 1048 bytes
-rw-r--r--release/datafiles/blender_icons16/icon16_ipo_circ.datbin0 -> 1048 bytes
-rw-r--r--release/datafiles/blender_icons16/icon16_ipo_constant.datbin0 -> 1048 bytes
-rw-r--r--release/datafiles/blender_icons16/icon16_ipo_cubic.datbin0 -> 1048 bytes
-rw-r--r--release/datafiles/blender_icons16/icon16_ipo_ease_in.datbin0 -> 1048 bytes
-rw-r--r--release/datafiles/blender_icons16/icon16_ipo_ease_in_out.datbin0 -> 1048 bytes
-rw-r--r--release/datafiles/blender_icons16/icon16_ipo_ease_out.datbin0 -> 1048 bytes
-rw-r--r--release/datafiles/blender_icons16/icon16_ipo_elastic.datbin0 -> 1048 bytes
-rw-r--r--release/datafiles/blender_icons16/icon16_ipo_expo.datbin0 -> 1048 bytes
-rw-r--r--release/datafiles/blender_icons16/icon16_ipo_linear.datbin0 -> 1048 bytes
-rw-r--r--release/datafiles/blender_icons16/icon16_ipo_quad.datbin0 -> 1048 bytes
-rw-r--r--release/datafiles/blender_icons16/icon16_ipo_quart.datbin0 -> 1048 bytes
-rw-r--r--release/datafiles/blender_icons16/icon16_ipo_quint.datbin0 -> 1048 bytes
-rw-r--r--release/datafiles/blender_icons16/icon16_ipo_sine.datbin0 -> 1048 bytes
-rw-r--r--release/datafiles/blender_icons16/icon16_nla_pushdown.datbin0 -> 1048 bytes
-rw-r--r--release/datafiles/blender_icons32/icon32_action_tweak.datbin0 -> 4120 bytes
-rw-r--r--release/datafiles/blender_icons32/icon32_ipo_back.datbin0 -> 4120 bytes
-rw-r--r--release/datafiles/blender_icons32/icon32_ipo_bezier.datbin0 -> 4120 bytes
-rw-r--r--release/datafiles/blender_icons32/icon32_ipo_bounce.datbin0 -> 4120 bytes
-rw-r--r--release/datafiles/blender_icons32/icon32_ipo_circ.datbin0 -> 4120 bytes
-rw-r--r--release/datafiles/blender_icons32/icon32_ipo_constant.datbin0 -> 4120 bytes
-rw-r--r--release/datafiles/blender_icons32/icon32_ipo_cubic.datbin0 -> 4120 bytes
-rw-r--r--release/datafiles/blender_icons32/icon32_ipo_ease_in.datbin0 -> 4120 bytes
-rw-r--r--release/datafiles/blender_icons32/icon32_ipo_ease_in_out.datbin0 -> 4120 bytes
-rw-r--r--release/datafiles/blender_icons32/icon32_ipo_ease_out.datbin0 -> 4120 bytes
-rw-r--r--release/datafiles/blender_icons32/icon32_ipo_elastic.datbin0 -> 4120 bytes
-rw-r--r--release/datafiles/blender_icons32/icon32_ipo_expo.datbin0 -> 4120 bytes
-rw-r--r--release/datafiles/blender_icons32/icon32_ipo_linear.datbin0 -> 4120 bytes
-rw-r--r--release/datafiles/blender_icons32/icon32_ipo_quad.datbin0 -> 4120 bytes
-rw-r--r--release/datafiles/blender_icons32/icon32_ipo_quart.datbin0 -> 4120 bytes
-rw-r--r--release/datafiles/blender_icons32/icon32_ipo_quint.datbin0 -> 4120 bytes
-rw-r--r--release/datafiles/blender_icons32/icon32_ipo_sine.datbin0 -> 4120 bytes
-rw-r--r--release/datafiles/blender_icons32/icon32_nla_pushdown.datbin0 -> 4120 bytes
-rw-r--r--release/datafiles/brushicons/clone.pngbin8425 -> 10732 bytes
-rw-r--r--release/datafiles/brushicons/smear.pngbin7037 -> 8459 bytes
-rw-r--r--release/datafiles/brushicons/soften.pngbin6892 -> 7984 bytes
-rw-r--r--release/datafiles/brushicons/texdraw.pngbin6944 -> 9213 bytes
m---------release/datafiles/locale0
m---------release/scripts/addons0
m---------release/scripts/addons_contrib0
-rw-r--r--release/scripts/freestyle/modules/freestyle/chainingiterators.py6
-rw-r--r--release/scripts/freestyle/modules/freestyle/predicates.py36
-rw-r--r--release/scripts/freestyle/modules/freestyle/shaders.py2
-rw-r--r--release/scripts/freestyle/modules/freestyle/utils.py41
-rw-r--r--release/scripts/freestyle/modules/parameter_editor.py59
-rw-r--r--release/scripts/freestyle/styles/anisotropic_diffusion.py1
-rw-r--r--release/scripts/modules/addon_utils.py4
-rw-r--r--release/scripts/modules/animsys_refactor.py164
-rw-r--r--release/scripts/modules/bpy/ops.py8
-rw-r--r--release/scripts/modules/bpy_extras/view3d_utils.py5
-rw-r--r--release/scripts/modules/nodeitems_utils.py2
-rw-r--r--release/scripts/modules/rna_keymap_ui.py1
-rw-r--r--release/scripts/presets/keyconfig/3dsmax.py2
-rw-r--r--release/scripts/presets/keyconfig/maya.py2
-rw-r--r--release/scripts/startup/bl_operators/add_mesh_torus.py1
-rw-r--r--release/scripts/startup/bl_operators/anim.py83
-rw-r--r--release/scripts/startup/bl_operators/freestyle.py4
-rw-r--r--release/scripts/startup/bl_operators/mesh.py1
-rw-r--r--release/scripts/startup/bl_operators/node.py1
-rw-r--r--release/scripts/startup/bl_operators/object.py31
-rw-r--r--release/scripts/startup/bl_operators/rigidbody.py3
-rw-r--r--release/scripts/startup/bl_operators/uvcalc_smart_project.py3
-rw-r--r--release/scripts/startup/bl_operators/vertexpaint_dirt.py1
-rw-r--r--release/scripts/startup/bl_operators/view3d.py1
-rw-r--r--release/scripts/startup/bl_operators/wm.py2
-rw-r--r--release/scripts/startup/bl_ui/__init__.py1
-rw-r--r--release/scripts/startup/bl_ui/properties_constraint.py28
-rw-r--r--release/scripts/startup/bl_ui/properties_data_armature.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_data_mesh.py4
-rw-r--r--release/scripts/startup/bl_ui/properties_data_modifier.py31
-rw-r--r--release/scripts/startup/bl_ui/properties_freestyle.py63
-rw-r--r--release/scripts/startup/bl_ui/properties_mask_common.py1
-rw-r--r--release/scripts/startup/bl_ui/properties_material.py31
-rw-r--r--release/scripts/startup/bl_ui/properties_object.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_render_layer.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_scene.py1
-rw-r--r--release/scripts/startup/bl_ui/properties_texture.py34
-rw-r--r--release/scripts/startup/bl_ui/space_clip.py20
-rw-r--r--release/scripts/startup/bl_ui/space_dopesheet.py1
-rw-r--r--release/scripts/startup/bl_ui/space_graph.py1
-rw-r--r--release/scripts/startup/bl_ui/space_image.py3
-rw-r--r--release/scripts/startup/bl_ui/space_nla.py8
-rw-r--r--release/scripts/startup/bl_ui/space_node.py5
-rw-r--r--release/scripts/startup/bl_ui/space_sequencer.py12
-rw-r--r--release/scripts/startup/bl_ui/space_time.py4
-rw-r--r--release/scripts/startup/bl_ui/space_view3d.py28
-rw-r--r--release/scripts/startup/bl_ui/space_view3d_toolbar.py39
-rw-r--r--release/scripts/templates_py/custom_nodes.py13
-rw-r--r--release/scripts/templates_py/operator_modal_view3d_raycast.py1
-rw-r--r--release/scripts/templates_py/ui_panel.py8
m---------scons0
-rw-r--r--source/blender/blenfont/intern/blf_font.c5
-rw-r--r--source/blender/blenfont/intern/blf_lang.c1
-rw-r--r--source/blender/blenkernel/BKE_DerivedMesh.h29
-rw-r--r--source/blender/blenkernel/BKE_anim.h14
-rw-r--r--source/blender/blenkernel/BKE_animsys.h10
-rw-r--r--source/blender/blenkernel/BKE_blender.h8
-rw-r--r--source/blender/blenkernel/BKE_cdderivedmesh.h2
-rw-r--r--source/blender/blenkernel/BKE_constraint.h50
-rw-r--r--source/blender/blenkernel/BKE_context.h1
-rw-r--r--source/blender/blenkernel/BKE_crazyspace.h54
-rw-r--r--source/blender/blenkernel/BKE_curve.h1
-rw-r--r--source/blender/blenkernel/BKE_fcurve.h5
-rw-r--r--source/blender/blenkernel/BKE_freestyle.h8
-rw-r--r--source/blender/blenkernel/BKE_global.h2
-rw-r--r--source/blender/blenkernel/BKE_library.h2
-rw-r--r--source/blender/blenkernel/BKE_mesh.h7
-rw-r--r--source/blender/blenkernel/BKE_nla.h24
-rw-r--r--source/blender/blenkernel/BKE_node.h2
-rw-r--r--source/blender/blenkernel/BKE_object.h2
-rw-r--r--source/blender/blenkernel/BKE_paint.h31
-rw-r--r--source/blender/blenkernel/BKE_pbvh.h12
-rw-r--r--source/blender/blenkernel/BKE_scene.h1
-rw-r--r--source/blender/blenkernel/BKE_sound.h4
-rw-r--r--source/blender/blenkernel/BKE_texture.h3
-rw-r--r--source/blender/blenkernel/BKE_tracking.h3
-rw-r--r--source/blender/blenkernel/CMakeLists.txt4
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c244
-rw-r--r--source/blender/blenkernel/intern/action.c26
-rw-r--r--source/blender/blenkernel/intern/anim.c27
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c82
-rw-r--r--source/blender/blenkernel/intern/armature.c139
-rw-r--r--source/blender/blenkernel/intern/blender.c74
-rw-r--r--source/blender/blenkernel/intern/brush.c13
-rw-r--r--source/blender/blenkernel/intern/bvhutils.c73
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c355
-rw-r--r--source/blender/blenkernel/intern/collision.c8
-rw-r--r--source/blender/blenkernel/intern/colortools.c5
-rw-r--r--source/blender/blenkernel/intern/constraint.c279
-rw-r--r--source/blender/blenkernel/intern/context.c43
-rw-r--r--source/blender/blenkernel/intern/crazyspace.c (renamed from source/blender/editors/util/crazyspace.c)21
-rw-r--r--source/blender/blenkernel/intern/curve.c78
-rw-r--r--source/blender/blenkernel/intern/customdata.c40
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c19
-rw-r--r--source/blender/blenkernel/intern/displist.c9
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c29
-rw-r--r--source/blender/blenkernel/intern/editderivedmesh.c176
-rw-r--r--source/blender/blenkernel/intern/editmesh.c2
-rw-r--r--source/blender/blenkernel/intern/editmesh_bvh.c2
-rw-r--r--source/blender/blenkernel/intern/effect.c21
-rw-r--r--source/blender/blenkernel/intern/fcurve.c51
-rw-r--r--source/blender/blenkernel/intern/fluidsim.c2
-rw-r--r--source/blender/blenkernel/intern/font.c2
-rw-r--r--source/blender/blenkernel/intern/freestyle.c27
-rw-r--r--source/blender/blenkernel/intern/gpencil.c2
-rw-r--r--source/blender/blenkernel/intern/group.c1
-rw-r--r--source/blender/blenkernel/intern/idprop.c14
-rw-r--r--source/blender/blenkernel/intern/image.c11
-rw-r--r--source/blender/blenkernel/intern/implicit.c3
-rw-r--r--source/blender/blenkernel/intern/ipo.c5
-rw-r--r--source/blender/blenkernel/intern/key.c10
-rw-r--r--source/blender/blenkernel/intern/lattice.c18
-rw-r--r--source/blender/blenkernel/intern/library.c20
-rw-r--r--source/blender/blenkernel/intern/library_query.c21
-rw-r--r--source/blender/blenkernel/intern/linestyle.c37
-rw-r--r--source/blender/blenkernel/intern/mask.c7
-rw-r--r--source/blender/blenkernel/intern/mask_evaluate.c24
-rw-r--r--source/blender/blenkernel/intern/mask_rasterize.c12
-rw-r--r--source/blender/blenkernel/intern/material.c54
-rw-r--r--source/blender/blenkernel/intern/mball.c3
-rw-r--r--source/blender/blenkernel/intern/mesh.c235
-rw-r--r--source/blender/blenkernel/intern/mesh_evaluate.c67
-rw-r--r--source/blender/blenkernel/intern/mesh_mapping.c3
-rw-r--r--source/blender/blenkernel/intern/mesh_validate.c10
-rw-r--r--source/blender/blenkernel/intern/modifier.c1
-rw-r--r--source/blender/blenkernel/intern/modifiers_bmesh.c12
-rw-r--r--source/blender/blenkernel/intern/movieclip.c43
-rw-r--r--source/blender/blenkernel/intern/nla.c57
-rw-r--r--source/blender/blenkernel/intern/node.c25
-rw-r--r--source/blender/blenkernel/intern/object.c66
-rw-r--r--source/blender/blenkernel/intern/object_dupli.c55
-rw-r--r--source/blender/blenkernel/intern/ocean.c1
-rw-r--r--source/blender/blenkernel/intern/packedFile.c99
-rw-r--r--source/blender/blenkernel/intern/paint.c254
-rw-r--r--source/blender/blenkernel/intern/particle.c1
-rw-r--r--source/blender/blenkernel/intern/particle_system.c55
-rw-r--r--source/blender/blenkernel/intern/pbvh.c118
-rw-r--r--source/blender/blenkernel/intern/pbvh_bmesh.c389
-rw-r--r--source/blender/blenkernel/intern/pbvh_intern.h14
-rw-r--r--source/blender/blenkernel/intern/pointcache.c11
-rw-r--r--source/blender/blenkernel/intern/rigidbody.c11
-rw-r--r--source/blender/blenkernel/intern/scene.c56
-rw-r--r--source/blender/blenkernel/intern/screen.c5
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c4
-rw-r--r--source/blender/blenkernel/intern/seqmodifier.c6
-rw-r--r--source/blender/blenkernel/intern/sequencer.c40
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.c1
-rw-r--r--source/blender/blenkernel/intern/smoke.c26
-rw-r--r--source/blender/blenkernel/intern/softbody.c1
-rw-r--r--source/blender/blenkernel/intern/sound.c226
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c338
-rw-r--r--source/blender/blenkernel/intern/text.c26
-rw-r--r--source/blender/blenkernel/intern/texture.c69
-rw-r--r--source/blender/blenkernel/intern/tracking.c89
-rw-r--r--source/blender/blenkernel/intern/tracking_detect.c2
-rw-r--r--source/blender/blenkernel/intern/tracking_solver.c63
-rw-r--r--source/blender/blenkernel/intern/tracking_stabilize.c2
-rw-r--r--source/blender/blenkernel/intern/tracking_util.c67
-rw-r--r--source/blender/blenkernel/intern/treehash.c16
-rw-r--r--source/blender/blenkernel/intern/unit.c2
-rw-r--r--source/blender/blenkernel/intern/writeffmpeg.c16
-rw-r--r--source/blender/blenkernel/tracking_private.h9
-rw-r--r--source/blender/blenlib/BLI_alloca.h3
-rw-r--r--source/blender/blenlib/BLI_compiler_attrs.h2
-rw-r--r--source/blender/blenlib/BLI_compiler_compat.h (renamed from source/blender/compositor/nodes/COM_CombineRGBANode.h)30
-rw-r--r--source/blender/blenlib/BLI_edgehash.h35
-rw-r--r--source/blender/blenlib/BLI_ghash.h50
-rw-r--r--source/blender/blenlib/BLI_link_utils.h (renamed from source/blender/editors/include/ED_fluidsim.h)50
-rw-r--r--source/blender/blenlib/BLI_linklist_stack.h32
-rw-r--r--source/blender/blenlib/BLI_math_base.h14
-rw-r--r--source/blender/blenlib/BLI_math_geom.h13
-rw-r--r--source/blender/blenlib/BLI_math_rotation.h3
-rw-r--r--source/blender/blenlib/BLI_math_vector.h3
-rw-r--r--source/blender/blenlib/BLI_path_util.h8
-rw-r--r--source/blender/blenlib/BLI_sys_types.h3
-rw-r--r--source/blender/blenlib/BLI_threads.h2
-rw-r--r--source/blender/blenlib/BLI_utildefines.h22
-rw-r--r--source/blender/blenlib/CMakeLists.txt2
-rw-r--r--source/blender/blenlib/intern/BLI_ghash.c111
-rw-r--r--source/blender/blenlib/intern/BLI_kdopbvh.c4
-rw-r--r--source/blender/blenlib/intern/BLI_mempool.c121
-rw-r--r--source/blender/blenlib/intern/boxpack2d.c415
-rw-r--r--source/blender/blenlib/intern/convexhull2d.c17
-rw-r--r--source/blender/blenlib/intern/easing.c73
-rw-r--r--source/blender/blenlib/intern/edgehash.c101
-rw-r--r--source/blender/blenlib/intern/fileops.c3
-rw-r--r--source/blender/blenlib/intern/freetypefont.c152
-rw-r--r--source/blender/blenlib/intern/math_base_inline.c12
-rw-r--r--source/blender/blenlib/intern/math_color.c2
-rw-r--r--source/blender/blenlib/intern/math_geom.c127
-rw-r--r--source/blender/blenlib/intern/math_geom_inline.c62
-rw-r--r--source/blender/blenlib/intern/math_rotation.c133
-rw-r--r--source/blender/blenlib/intern/math_vector.c47
-rw-r--r--source/blender/blenlib/intern/path_util.c228
-rw-r--r--source/blender/blenlib/intern/scanfill.c2
-rw-r--r--source/blender/blenlib/intern/scanfill_utils.c2
-rw-r--r--source/blender/blenlib/intern/smallhash.c1
-rw-r--r--source/blender/blenlib/intern/storage.c25
-rw-r--r--source/blender/blenlib/intern/string.c2
-rw-r--r--source/blender/blenlib/intern/string_utf8.c2
-rw-r--r--source/blender/blenlib/intern/threads.c33
-rw-r--r--source/blender/blenloader/intern/readblenentry.c10
-rw-r--r--source/blender/blenloader/intern/readfile.c72
-rw-r--r--source/blender/blenloader/intern/runtime.c4
-rw-r--r--source/blender/blenloader/intern/versioning_250.c3
-rw-r--r--source/blender/blenloader/intern/versioning_270.c173
-rw-r--r--source/blender/blenloader/intern/versioning_defaults.c15
-rw-r--r--source/blender/blenloader/intern/versioning_legacy.c6
-rw-r--r--source/blender/blenloader/intern/writefile.c22
-rw-r--r--source/blender/bmesh/bmesh_class.h13
-rw-r--r--source/blender/bmesh/intern/bmesh_construct.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_core.c166
-rw-r--r--source/blender/bmesh/intern/bmesh_delete.c1
-rw-r--r--source/blender/bmesh/intern/bmesh_edgeloop.c16
-rw-r--r--source/blender/bmesh/intern/bmesh_interp.c19
-rw-r--r--source/blender/bmesh/intern/bmesh_log.c101
-rw-r--r--source/blender/bmesh/intern/bmesh_log.h9
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.c271
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.h2
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_conv.c75
-rw-r--r--source/blender/bmesh/intern/bmesh_mods.c9
-rw-r--r--source/blender/bmesh/intern/bmesh_opdefines.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_operators.c40
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon.c106
-rw-r--r--source/blender/bmesh/intern/bmesh_private.h3
-rw-r--r--source/blender/bmesh/intern/bmesh_queries.c4
-rw-r--r--source/blender/bmesh/intern/bmesh_walkers.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_walkers_impl.c9
-rw-r--r--source/blender/bmesh/operators/bmo_connect.c1
-rw-r--r--source/blender/bmesh/operators/bmo_connect_nonplanar.c2
-rw-r--r--source/blender/bmesh/operators/bmo_connect_pair.c2
-rw-r--r--source/blender/bmesh/operators/bmo_edgenet.c2
-rw-r--r--source/blender/bmesh/operators/bmo_extrude.c2
-rw-r--r--source/blender/bmesh/operators/bmo_hull.c10
-rw-r--r--source/blender/bmesh/operators/bmo_inset.c77
-rw-r--r--source/blender/bmesh/operators/bmo_removedoubles.c2
-rw-r--r--source/blender/bmesh/operators/bmo_similar.c4
-rw-r--r--source/blender/bmesh/operators/bmo_subdivide.c4
-rw-r--r--source/blender/bmesh/tools/bmesh_beautify.c58
-rw-r--r--source/blender/bmesh/tools/bmesh_bevel.c16
-rw-r--r--source/blender/bmesh/tools/bmesh_decimate_collapse.c7
-rw-r--r--source/blender/bmesh/tools/bmesh_edgenet.c6
-rw-r--r--source/blender/collada/AnimationExporter.cpp10
-rw-r--r--source/blender/collada/DocumentImporter.cpp2
-rw-r--r--source/blender/collada/GeometryExporter.cpp86
-rw-r--r--source/blender/collada/GeometryExporter.h3
-rw-r--r--source/blender/collada/MeshImporter.cpp115
-rw-r--r--source/blender/collada/MeshImporter.h14
-rw-r--r--source/blender/collada/SceneExporter.cpp6
-rw-r--r--source/blender/compositor/CMakeLists.txt57
-rw-r--r--source/blender/compositor/COM_compositor.h4
-rw-r--r--source/blender/compositor/COM_defines.h2
-rw-r--r--source/blender/compositor/intern/COM_CPUDevice.cpp2
-rw-r--r--source/blender/compositor/intern/COM_CompositorContext.h6
-rw-r--r--source/blender/compositor/intern/COM_Converter.cpp151
-rw-r--r--source/blender/compositor/intern/COM_Converter.h38
-rw-r--r--source/blender/compositor/intern/COM_Debug.cpp141
-rw-r--r--source/blender/compositor/intern/COM_Debug.h31
-rw-r--r--source/blender/compositor/intern/COM_ExecutionGroup.cpp106
-rw-r--r--source/blender/compositor/intern/COM_ExecutionGroup.h49
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystem.cpp230
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystem.h91
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp171
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystemHelper.h126
-rw-r--r--source/blender/compositor/intern/COM_InputSocket.cpp159
-rw-r--r--source/blender/compositor/intern/COM_InputSocket.h149
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.cpp67
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.h1
-rw-r--r--source/blender/compositor/intern/COM_MemoryProxy.h1
-rw-r--r--source/blender/compositor/intern/COM_Node.cpp235
-rw-r--r--source/blender/compositor/intern/COM_Node.h234
-rw-r--r--source/blender/compositor/intern/COM_NodeBase.cpp96
-rw-r--r--source/blender/compositor/intern/COM_NodeBase.h185
-rw-r--r--source/blender/compositor/intern/COM_NodeConverter.cpp158
-rw-r--r--source/blender/compositor/intern/COM_NodeConverter.h114
-rw-r--r--source/blender/compositor/intern/COM_NodeGraph.cpp290
-rw-r--r--source/blender/compositor/intern/COM_NodeGraph.h115
-rw-r--r--source/blender/compositor/intern/COM_NodeOperation.cpp138
-rw-r--r--source/blender/compositor/intern/COM_NodeOperation.h175
-rw-r--r--source/blender/compositor/intern/COM_NodeOperationBuilder.cpp666
-rw-r--r--source/blender/compositor/intern/COM_NodeOperationBuilder.h158
-rw-r--r--source/blender/compositor/intern/COM_OpenCLDevice.cpp41
-rw-r--r--source/blender/compositor/intern/COM_OpenCLDevice.h2
-rw-r--r--source/blender/compositor/intern/COM_OutputSocket.cpp119
-rw-r--r--source/blender/compositor/intern/COM_SingleThreadedOperation.cpp (renamed from source/blender/compositor/intern/COM_SingleThreadedNodeOperation.cpp)12
-rw-r--r--source/blender/compositor/intern/COM_SingleThreadedOperation.h (renamed from source/blender/compositor/intern/COM_SingleThreadedNodeOperation.h)8
-rw-r--r--source/blender/compositor/intern/COM_Socket.cpp68
-rw-r--r--source/blender/compositor/intern/COM_Socket.h100
-rw-r--r--source/blender/compositor/intern/COM_SocketConnection.cpp95
-rw-r--r--source/blender/compositor/intern/COM_WorkScheduler.cpp12
-rw-r--r--source/blender/compositor/nodes/COM_AlphaOverNode.cpp24
-rw-r--r--source/blender/compositor/nodes/COM_AlphaOverNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_BilateralBlurNode.cpp14
-rw-r--r--source/blender/compositor/nodes/COM_BilateralBlurNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_BlurNode.cpp98
-rw-r--r--source/blender/compositor/nodes/COM_BlurNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_BokehBlurNode.cpp39
-rw-r--r--source/blender/compositor/nodes/COM_BokehBlurNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_BokehImageNode.cpp10
-rw-r--r--source/blender/compositor/nodes/COM_BokehImageNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_BoxMaskNode.cpp40
-rw-r--r--source/blender/compositor/nodes/COM_BoxMaskNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_BrightnessNode.cpp13
-rw-r--r--source/blender/compositor/nodes/COM_BrightnessNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_ChannelMatteNode.cpp56
-rw-r--r--source/blender/compositor/nodes/COM_ChannelMatteNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_ChromaMatteNode.cpp58
-rw-r--r--source/blender/compositor/nodes/COM_ChromaMatteNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_ColorBalanceNode.cpp19
-rw-r--r--source/blender/compositor/nodes/COM_ColorBalanceNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp14
-rw-r--r--source/blender/compositor/nodes/COM_ColorCorrectionNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_ColorCurveNode.cpp34
-rw-r--r--source/blender/compositor/nodes/COM_ColorCurveNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_ColorMatteNode.cpp57
-rw-r--r--source/blender/compositor/nodes/COM_ColorMatteNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_ColorNode.cpp9
-rw-r--r--source/blender/compositor/nodes/COM_ColorNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_ColorRampNode.cpp29
-rw-r--r--source/blender/compositor/nodes/COM_ColorRampNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_ColorSpillNode.cpp21
-rw-r--r--source/blender/compositor/nodes/COM_ColorSpillNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_ColorToBWNode.cpp13
-rw-r--r--source/blender/compositor/nodes/COM_ColorToBWNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_CombineColorNode.cpp96
-rw-r--r--source/blender/compositor/nodes/COM_CombineColorNode.h74
-rw-r--r--source/blender/compositor/nodes/COM_CombineHSVANode.cpp46
-rw-r--r--source/blender/compositor/nodes/COM_CombineHSVANode.h38
-rw-r--r--source/blender/compositor/nodes/COM_CombineRGBANode.cpp64
-rw-r--r--source/blender/compositor/nodes/COM_CombineYCCANode.cpp45
-rw-r--r--source/blender/compositor/nodes/COM_CombineYCCANode.h37
-rw-r--r--source/blender/compositor/nodes/COM_CombineYUVANode.cpp40
-rw-r--r--source/blender/compositor/nodes/COM_CombineYUVANode.h37
-rw-r--r--source/blender/compositor/nodes/COM_CompositorNode.cpp37
-rw-r--r--source/blender/compositor/nodes/COM_CompositorNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp12
-rw-r--r--source/blender/compositor/nodes/COM_ConvertAlphaNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_CornerPinNode.cpp35
-rw-r--r--source/blender/compositor/nodes/COM_CornerPinNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_CropNode.cpp9
-rw-r--r--source/blender/compositor/nodes/COM_CropNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_DefocusNode.cpp96
-rw-r--r--source/blender/compositor/nodes/COM_DefocusNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_DespeckleNode.cpp25
-rw-r--r--source/blender/compositor/nodes/COM_DespeckleNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp32
-rw-r--r--source/blender/compositor/nodes/COM_DifferenceMatteNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_DilateErodeNode.cpp101
-rw-r--r--source/blender/compositor/nodes/COM_DilateErodeNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp12
-rw-r--r--source/blender/compositor/nodes/COM_DirectionalBlurNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_DisplaceNode.cpp17
-rw-r--r--source/blender/compositor/nodes/COM_DisplaceNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_DistanceMatteNode.cpp83
-rw-r--r--source/blender/compositor/nodes/COM_DistanceMatteNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp11
-rw-r--r--source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_EllipseMaskNode.cpp42
-rw-r--r--source/blender/compositor/nodes/COM_EllipseMaskNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_FilterNode.cpp20
-rw-r--r--source/blender/compositor/nodes/COM_FilterNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_FlipNode.cpp12
-rw-r--r--source/blender/compositor/nodes/COM_FlipNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_GammaNode.cpp10
-rw-r--r--source/blender/compositor/nodes/COM_GammaNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_GlareNode.cpp46
-rw-r--r--source/blender/compositor/nodes/COM_GlareNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_GroupNode.cpp216
-rw-r--r--source/blender/compositor/nodes/COM_GroupNode.h61
-rw-r--r--source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp38
-rw-r--r--source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp38
-rw-r--r--source/blender/compositor/nodes/COM_HueSaturationValueNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_IDMaskNode.cpp19
-rw-r--r--source/blender/compositor/nodes/COM_IDMaskNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_ImageNode.cpp170
-rw-r--r--source/blender/compositor/nodes/COM_ImageNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_InpaintNode.cpp10
-rw-r--r--source/blender/compositor/nodes/COM_InpaintNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_InvertNode.cpp10
-rw-r--r--source/blender/compositor/nodes/COM_InvertNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_KeyingNode.cpp276
-rw-r--r--source/blender/compositor/nodes/COM_KeyingNode.h22
-rw-r--r--source/blender/compositor/nodes/COM_KeyingScreenNode.cpp22
-rw-r--r--source/blender/compositor/nodes/COM_KeyingScreenNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_LensDistortionNode.cpp33
-rw-r--r--source/blender/compositor/nodes/COM_LensDistortionNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp39
-rw-r--r--source/blender/compositor/nodes/COM_LuminanceMatteNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_MapRangeNode.cpp34
-rw-r--r--source/blender/compositor/nodes/COM_MapRangeNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_MapUVNode.cpp15
-rw-r--r--source/blender/compositor/nodes/COM_MapUVNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_MapValueNode.cpp15
-rw-r--r--source/blender/compositor/nodes/COM_MapValueNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_MaskNode.cpp16
-rw-r--r--source/blender/compositor/nodes/COM_MaskNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_MathNode.cpp21
-rw-r--r--source/blender/compositor/nodes/COM_MathNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_MixNode.cpp25
-rw-r--r--source/blender/compositor/nodes/COM_MixNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_MovieClipNode.cpp78
-rw-r--r--source/blender/compositor/nodes/COM_MovieClipNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_MovieDistortionNode.cpp15
-rw-r--r--source/blender/compositor/nodes/COM_MovieDistortionNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_MuteNode.cpp175
-rw-r--r--source/blender/compositor/nodes/COM_MuteNode.h51
-rw-r--r--source/blender/compositor/nodes/COM_NormalNode.cpp27
-rw-r--r--source/blender/compositor/nodes/COM_NormalNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_NormalizeNode.cpp9
-rw-r--r--source/blender/compositor/nodes/COM_NormalizeNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_OutputFileNode.cpp48
-rw-r--r--source/blender/compositor/nodes/COM_OutputFileNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_PixelateNode.cpp21
-rw-r--r--source/blender/compositor/nodes/COM_PixelateNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_PlaneTrackDeformNode.cpp62
-rw-r--r--source/blender/compositor/nodes/COM_PlaneTrackDeformNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_RenderLayersNode.cpp101
-rw-r--r--source/blender/compositor/nodes/COM_RenderLayersNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_RotateNode.cpp21
-rw-r--r--source/blender/compositor/nodes/COM_RotateNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_ScaleNode.cpp71
-rw-r--r--source/blender/compositor/nodes/COM_ScaleNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_SeparateColorNode.cpp120
-rw-r--r--source/blender/compositor/nodes/COM_SeparateColorNode.h74
-rw-r--r--source/blender/compositor/nodes/COM_SeparateHSVANode.cpp44
-rw-r--r--source/blender/compositor/nodes/COM_SeparateRGBANode.cpp76
-rw-r--r--source/blender/compositor/nodes/COM_SeparateYCCANode.cpp46
-rw-r--r--source/blender/compositor/nodes/COM_SeparateYUVANode.cpp42
-rw-r--r--source/blender/compositor/nodes/COM_SeparateYUVANode.h38
-rw-r--r--source/blender/compositor/nodes/COM_SetAlphaNode.cpp16
-rw-r--r--source/blender/compositor/nodes/COM_SetAlphaNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_SocketProxyNode.cpp96
-rw-r--r--source/blender/compositor/nodes/COM_SocketProxyNode.h13
-rw-r--r--source/blender/compositor/nodes/COM_SplitViewerNode.cpp25
-rw-r--r--source/blender/compositor/nodes/COM_SplitViewerNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_Stabilize2dNode.cpp61
-rw-r--r--source/blender/compositor/nodes/COM_Stabilize2dNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_SwitchNode.cpp26
-rw-r--r--source/blender/compositor/nodes/COM_SwitchNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_TextureNode.cpp37
-rw-r--r--source/blender/compositor/nodes/COM_TextureNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_TimeNode.cpp11
-rw-r--r--source/blender/compositor/nodes/COM_TimeNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_TonemapNode.cpp11
-rw-r--r--source/blender/compositor/nodes/COM_TonemapNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_TrackPositionNode.cpp27
-rw-r--r--source/blender/compositor/nodes/COM_TrackPositionNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_TransformNode.cpp47
-rw-r--r--source/blender/compositor/nodes/COM_TransformNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_TranslateNode.cpp53
-rw-r--r--source/blender/compositor/nodes/COM_TranslateNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_ValueNode.cpp9
-rw-r--r--source/blender/compositor/nodes/COM_ValueNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_VectorBlurNode.cpp17
-rw-r--r--source/blender/compositor/nodes/COM_VectorBlurNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_VectorCurveNode.cpp12
-rw-r--r--source/blender/compositor/nodes/COM_VectorCurveNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_ViewLevelsNode.cpp52
-rw-r--r--source/blender/compositor/nodes/COM_ViewLevelsNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_ViewerNode.cpp38
-rw-r--r--source/blender/compositor/nodes/COM_ViewerNode.h2
-rw-r--r--source/blender/compositor/nodes/COM_ZCombineNode.cpp96
-rw-r--r--source/blender/compositor/nodes/COM_ZCombineNode.h2
-rw-r--r--source/blender/compositor/operations/COM_BlurBaseOperation.cpp34
-rw-r--r--source/blender/compositor/operations/COM_BlurBaseOperation.h7
-rw-r--r--source/blender/compositor/operations/COM_CompositorOperation.cpp18
-rw-r--r--source/blender/compositor/operations/COM_CompositorOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp14
-rw-r--r--source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp34
-rw-r--r--source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_GlareBaseOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_GlareBaseOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_MaskOperation.cpp5
-rw-r--r--source/blender/compositor/operations/COM_MaskOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_MathBaseOperation.cpp13
-rw-r--r--source/blender/compositor/operations/COM_MathBaseOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_MixOperation.cpp16
-rw-r--r--source/blender/compositor/operations/COM_OutputFileOperation.cpp18
-rw-r--r--source/blender/compositor/operations/COM_OutputFileOperation.h13
-rw-r--r--source/blender/compositor/operations/COM_PlaneTrackOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_PreviewOperation.cpp1
-rw-r--r--source/blender/compositor/operations/COM_PreviewOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_ReadBufferOperation.h1
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersProg.cpp18
-rw-r--r--source/blender/compositor/operations/COM_SetVectorOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_SocketProxyOperation.cpp18
-rw-r--r--source/blender/compositor/operations/COM_SocketProxyOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_SplitOperation.cpp1
-rw-r--r--source/blender/compositor/operations/COM_TextureOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_TextureOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_TonemapOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ViewerOperation.cpp20
-rw-r--r--source/blender/compositor/operations/COM_ViewerOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_WriteBufferOperation.h3
-rwxr-xr-xsource/blender/datatoc/datatoc_icon_split.py3
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c436
-rw-r--r--source/blender/editors/animation/anim_channels_edit.c10
-rw-r--r--source/blender/editors/animation/anim_draw.c6
-rw-r--r--source/blender/editors/animation/anim_markers.c24
-rw-r--r--source/blender/editors/animation/anim_ops.c10
-rw-r--r--source/blender/editors/animation/drivers.c1
-rw-r--r--source/blender/editors/animation/fmodifier_ui.c8
-rw-r--r--source/blender/editors/animation/keyframes_draw.c221
-rw-r--r--source/blender/editors/animation/keyframes_edit.c28
-rw-r--r--source/blender/editors/animation/keyframes_general.c1
-rw-r--r--source/blender/editors/animation/keyframing.c43
-rw-r--r--source/blender/editors/animation/keyingsets.c16
-rw-r--r--source/blender/editors/armature/armature_add.c2
-rw-r--r--source/blender/editors/armature/armature_edit.c60
-rw-r--r--source/blender/editors/armature/armature_intern.h1
-rw-r--r--source/blender/editors/armature/armature_naming.c2
-rw-r--r--source/blender/editors/armature/armature_ops.c5
-rw-r--r--source/blender/editors/armature/armature_relations.c7
-rw-r--r--source/blender/editors/armature/armature_select.c10
-rw-r--r--source/blender/editors/armature/armature_skinning.c2
-rw-r--r--source/blender/editors/armature/armature_utils.c27
-rw-r--r--source/blender/editors/armature/editarmature_retarget.c9
-rw-r--r--source/blender/editors/armature/editarmature_sketch.c1
-rw-r--r--source/blender/editors/armature/meshlaplacian.c13
-rw-r--r--source/blender/editors/armature/pose_edit.c81
-rw-r--r--source/blender/editors/armature/pose_lib.c4
-rw-r--r--source/blender/editors/armature/pose_select.c3
-rw-r--r--source/blender/editors/armature/pose_slide.c2
-rw-r--r--source/blender/editors/curve/editcurve.c23
-rw-r--r--source/blender/editors/curve/editfont.c15
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c7
-rw-r--r--source/blender/editors/gpencil/editaction_gpencil.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_buttons.c1
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c8
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c14
-rw-r--r--source/blender/editors/include/BIF_gl.h9
-rw-r--r--source/blender/editors/include/ED_anim_api.h43
-rw-r--r--source/blender/editors/include/ED_armature.h5
-rw-r--r--source/blender/editors/include/ED_buttons.h1
-rw-r--r--source/blender/editors/include/ED_clip.h2
-rw-r--r--source/blender/editors/include/ED_image.h2
-rw-r--r--source/blender/editors/include/ED_keyframing.h3
-rw-r--r--source/blender/editors/include/ED_node.h2
-rw-r--r--source/blender/editors/include/ED_sculpt.h9
-rw-r--r--source/blender/editors/include/ED_transform.h2
-rw-r--r--source/blender/editors/include/ED_util.h8
-rw-r--r--source/blender/editors/include/UI_icons.h38
-rw-r--r--source/blender/editors/include/UI_interface.h4
-rw-r--r--source/blender/editors/include/UI_view2d.h33
-rw-r--r--source/blender/editors/interface/interface.c150
-rw-r--r--source/blender/editors/interface/interface_anim.c11
-rw-r--r--source/blender/editors/interface/interface_draw.c21
-rw-r--r--source/blender/editors/interface/interface_eyedropper.c11
-rw-r--r--source/blender/editors/interface/interface_handlers.c194
-rw-r--r--source/blender/editors/interface/interface_icons.c30
-rw-r--r--source/blender/editors/interface/interface_intern.h9
-rw-r--r--source/blender/editors/interface/interface_layout.c43
-rw-r--r--source/blender/editors/interface/interface_ops.c85
-rw-r--r--source/blender/editors/interface/interface_panel.c19
-rw-r--r--source/blender/editors/interface/interface_regions.c128
-rw-r--r--source/blender/editors/interface/interface_style.c6
-rw-r--r--source/blender/editors/interface/interface_templates.c34
-rw-r--r--source/blender/editors/interface/interface_utils.c1
-rw-r--r--source/blender/editors/interface/interface_widgets.c104
-rw-r--r--source/blender/editors/interface/resources.c12
-rw-r--r--source/blender/editors/interface/view2d.c292
-rw-r--r--source/blender/editors/interface/view2d_ops.c24
-rw-r--r--source/blender/editors/mask/mask_add.c1
-rw-r--r--source/blender/editors/mask/mask_draw.c18
-rw-r--r--source/blender/editors/mask/mask_edit.c4
-rw-r--r--source/blender/editors/mask/mask_editaction.c2
-rw-r--r--source/blender/editors/mask/mask_ops.c2
-rw-r--r--source/blender/editors/mask/mask_relationships.c5
-rw-r--r--source/blender/editors/mask/mask_select.c4
-rw-r--r--source/blender/editors/mask/mask_shapekey.c1
-rw-r--r--source/blender/editors/mesh/editface.c5
-rw-r--r--source/blender/editors/mesh/editmesh_add.c1
-rw-r--r--source/blender/editors/mesh/editmesh_bisect.c1
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c37
-rw-r--r--source/blender/editors/mesh/editmesh_loopcut.c4
-rw-r--r--source/blender/editors/mesh/editmesh_select.c7
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c38
-rw-r--r--source/blender/editors/mesh/editmesh_utils.c11
-rw-r--r--source/blender/editors/mesh/mesh_ops.c1
-rw-r--r--source/blender/editors/mesh/meshtools.c4
-rw-r--r--source/blender/editors/metaball/mball_edit.c3
-rw-r--r--source/blender/editors/object/CMakeLists.txt1
-rw-r--r--source/blender/editors/object/object_add.c30
-rw-r--r--source/blender/editors/object/object_bake.c4
-rw-r--r--source/blender/editors/object/object_bake_api.c1109
-rw-r--r--source/blender/editors/object/object_constraint.c45
-rw-r--r--source/blender/editors/object/object_edit.c18
-rw-r--r--source/blender/editors/object/object_group.c8
-rw-r--r--source/blender/editors/object/object_hook.c9
-rw-r--r--source/blender/editors/object/object_intern.h1
-rw-r--r--source/blender/editors/object/object_lod.c12
-rw-r--r--source/blender/editors/object/object_modifier.c22
-rw-r--r--source/blender/editors/object/object_ops.c3
-rw-r--r--source/blender/editors/object/object_relations.c52
-rw-r--r--source/blender/editors/object/object_select.c9
-rw-r--r--source/blender/editors/object/object_transform.c25
-rw-r--r--source/blender/editors/object/object_vgroup.c4
-rw-r--r--source/blender/editors/physics/particle_boids.c1
-rw-r--r--source/blender/editors/physics/particle_edit.c6
-rw-r--r--source/blender/editors/physics/physics_fluid.c31
-rw-r--r--source/blender/editors/physics/physics_pointcache.c7
-rw-r--r--source/blender/editors/physics/rigidbody_constraint.c5
-rw-r--r--source/blender/editors/physics/rigidbody_object.c1
-rw-r--r--source/blender/editors/physics/rigidbody_world.c9
-rw-r--r--source/blender/editors/render/render_internal.c21
-rw-r--r--source/blender/editors/render/render_opengl.c10
-rw-r--r--source/blender/editors/render/render_preview.c11
-rw-r--r--source/blender/editors/render/render_shading.c17
-rw-r--r--source/blender/editors/render/render_update.c9
-rw-r--r--source/blender/editors/render/render_view.c18
-rw-r--r--source/blender/editors/screen/area.c88
-rw-r--r--source/blender/editors/screen/glutil.c12
-rw-r--r--source/blender/editors/screen/screen_context.c1
-rw-r--r--source/blender/editors/screen/screen_edit.c12
-rw-r--r--source/blender/editors/screen/screen_intern.h3
-rw-r--r--source/blender/editors/screen/screen_ops.c56
-rw-r--r--source/blender/editors/screen/screendump.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c25
-rw-r--r--source/blender/editors/sculpt_paint/paint_hide.c23
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c85
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_2d.c40
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c132
-rw-r--r--source/blender/editors/sculpt_paint/paint_intern.h18
-rw-r--r--source/blender/editors/sculpt_paint/paint_mask.c13
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c1
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c40
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c175
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c21
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c397
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h6
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c48
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_uv.c53
-rw-r--r--source/blender/editors/sound/sound_ops.c1
-rw-r--r--source/blender/editors/space_action/action_draw.c1
-rw-r--r--source/blender/editors/space_action/action_edit.c86
-rw-r--r--source/blender/editors/space_action/action_ops.c1
-rw-r--r--source/blender/editors/space_action/action_select.c5
-rw-r--r--source/blender/editors/space_action/space_action.c24
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c107
-rw-r--r--source/blender/editors/space_buttons/buttons_texture.c44
-rw-r--r--source/blender/editors/space_buttons/space_buttons.c4
-rw-r--r--source/blender/editors/space_clip/clip_buttons.c2
-rw-r--r--source/blender/editors/space_clip/clip_dopesheet_draw.c8
-rw-r--r--source/blender/editors/space_clip/clip_dopesheet_ops.c5
-rw-r--r--source/blender/editors/space_clip/clip_draw.c27
-rw-r--r--source/blender/editors/space_clip/clip_editor.c27
-rw-r--r--source/blender/editors/space_clip/clip_graph_draw.c13
-rw-r--r--source/blender/editors/space_clip/clip_graph_ops.c21
-rw-r--r--source/blender/editors/space_clip/clip_ops.c23
-rw-r--r--source/blender/editors/space_clip/clip_utils.c2
-rw-r--r--source/blender/editors/space_clip/space_clip.c5
-rw-r--r--source/blender/editors/space_clip/tracking_ops.c28
-rw-r--r--source/blender/editors/space_clip/tracking_select.c24
-rw-r--r--source/blender/editors/space_console/console_draw.c8
-rw-r--r--source/blender/editors/space_console/console_ops.c3
-rw-r--r--source/blender/editors/space_console/space_console.c2
-rw-r--r--source/blender/editors/space_file/file_draw.c3
-rw-r--r--source/blender/editors/space_file/file_ops.c67
-rw-r--r--source/blender/editors/space_file/file_panels.c2
-rw-r--r--source/blender/editors/space_file/filelist.c7
-rw-r--r--source/blender/editors/space_file/filesel.c7
-rw-r--r--source/blender/editors/space_file/fsmenu.c4
-rw-r--r--source/blender/editors/space_file/space_file.c1
-rw-r--r--source/blender/editors/space_graph/graph_buttons.c41
-rw-r--r--source/blender/editors/space_graph/graph_draw.c16
-rw-r--r--source/blender/editors/space_graph/graph_edit.c54
-rw-r--r--source/blender/editors/space_graph/graph_ops.c18
-rw-r--r--source/blender/editors/space_graph/graph_select.c27
-rw-r--r--source/blender/editors/space_image/image_buttons.c9
-rw-r--r--source/blender/editors/space_image/image_draw.c26
-rw-r--r--source/blender/editors/space_image/image_edit.c8
-rw-r--r--source/blender/editors/space_image/image_ops.c65
-rw-r--r--source/blender/editors/space_image/space_image.c4
-rw-r--r--source/blender/editors/space_info/info_draw.c7
-rw-r--r--source/blender/editors/space_info/info_report.c10
-rw-r--r--source/blender/editors/space_info/info_stats.c3
-rw-r--r--source/blender/editors/space_info/space_info.c1
-rw-r--r--source/blender/editors/space_info/textview.c5
-rw-r--r--source/blender/editors/space_logic/logic_ops.c6
-rw-r--r--source/blender/editors/space_logic/logic_window.c132
-rw-r--r--source/blender/editors/space_logic/space_logic.c1
-rw-r--r--source/blender/editors/space_nla/nla_buttons.c9
-rw-r--r--source/blender/editors/space_nla/nla_channels.c101
-rw-r--r--source/blender/editors/space_nla/nla_draw.c237
-rw-r--r--source/blender/editors/space_nla/nla_edit.c238
-rw-r--r--source/blender/editors/space_nla/nla_intern.h8
-rw-r--r--source/blender/editors/space_nla/nla_ops.c19
-rw-r--r--source/blender/editors/space_nla/nla_select.c30
-rw-r--r--source/blender/editors/space_nla/space_nla.c1
-rw-r--r--source/blender/editors/space_node/drawnode.c5
-rw-r--r--source/blender/editors/space_node/node_draw.c13
-rw-r--r--source/blender/editors/space_node/node_edit.c63
-rw-r--r--source/blender/editors/space_node/node_group.c9
-rw-r--r--source/blender/editors/space_node/node_relationships.c313
-rw-r--r--source/blender/editors/space_node/node_select.c15
-rw-r--r--source/blender/editors/space_node/node_view.c22
-rw-r--r--source/blender/editors/space_node/space_node.c2
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c20
-rw-r--r--source/blender/editors/space_outliner/outliner_edit.c4
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c12
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c10
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c16
-rw-r--r--source/blender/editors/space_outliner/space_outliner.c2
-rw-r--r--source/blender/editors/space_sequencer/sequencer_add.c16
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c87
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c24
-rw-r--r--source/blender/editors/space_sequencer/sequencer_ops.c7
-rw-r--r--source/blender/editors/space_sequencer/sequencer_scopes.c16
-rw-r--r--source/blender/editors/space_sequencer/sequencer_select.c27
-rw-r--r--source/blender/editors/space_sequencer/sequencer_view.c4
-rw-r--r--source/blender/editors/space_sequencer/space_sequencer.c2
-rw-r--r--source/blender/editors/space_text/text_autocomplete.c4
-rw-r--r--source/blender/editors/space_text/text_header.c12
-rw-r--r--source/blender/editors/space_text/text_ops.c19
-rw-r--r--source/blender/editors/space_time/space_time.c30
-rw-r--r--source/blender/editors/space_time/time_ops.c4
-rw-r--r--source/blender/editors/space_view3d/drawanimviz.c17
-rw-r--r--source/blender/editors/space_view3d/drawarmature.c8
-rw-r--r--source/blender/editors/space_view3d/drawmesh.c4
-rw-r--r--source/blender/editors/space_view3d/drawobject.c281
-rw-r--r--source/blender/editors/space_view3d/drawvolume.c32
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c3
-rw-r--r--source/blender/editors/space_view3d/view3d_buttons.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c512
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c132
-rw-r--r--source/blender/editors/space_view3d/view3d_header.c12
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h28
-rw-r--r--source/blender/editors/space_view3d/view3d_iterators.c5
-rw-r--r--source/blender/editors/space_view3d/view3d_ops.c22
-rw-r--r--source/blender/editors/space_view3d/view3d_ruler.c16
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c7
-rw-r--r--source/blender/editors/space_view3d/view3d_snap.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_toolbar.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c125
-rw-r--r--source/blender/editors/space_view3d/view3d_walk.c38
-rw-r--r--source/blender/editors/transform/transform.c207
-rw-r--r--source/blender/editors/transform/transform.h33
-rw-r--r--source/blender/editors/transform/transform_constraints.c13
-rw-r--r--source/blender/editors/transform/transform_conversions.c105
-rw-r--r--source/blender/editors/transform/transform_generics.c257
-rw-r--r--source/blender/editors/transform/transform_input.c4
-rw-r--r--source/blender/editors/transform/transform_manipulator.c49
-rw-r--r--source/blender/editors/transform/transform_ops.c4
-rw-r--r--source/blender/editors/transform/transform_orientations.c38
-rw-r--r--source/blender/editors/transform/transform_snap.c59
-rw-r--r--source/blender/editors/util/CMakeLists.txt2
-rw-r--r--source/blender/editors/util/ed_util.c4
-rw-r--r--source/blender/editors/util/editmode_undo.c2
-rw-r--r--source/blender/editors/util/numinput.c15
-rw-r--r--source/blender/editors/util/undo.c17
-rw-r--r--source/blender/editors/uvedit/uvedit_buttons.c2
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c7
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c29
-rw-r--r--source/blender/editors/uvedit/uvedit_parametrizer.c4
-rw-r--r--source/blender/editors/uvedit/uvedit_smart_stitch.c8
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c5
-rw-r--r--source/blender/freestyle/CMakeLists.txt11
-rw-r--r--source/blender/freestyle/intern/application/AppConfig.cpp1
-rw-r--r--source/blender/freestyle/intern/application/AppConfig.h1
-rw-r--r--source/blender/freestyle/intern/application/AppView.h2
-rw-r--r--source/blender/freestyle/intern/application/Controller.cpp22
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp2
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h2
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp420
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h6
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h3
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderTextureManager.cpp101
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderTextureManager.h55
-rw-r--r--source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp10
-rw-r--r--source/blender/freestyle/intern/geometry/Bezier.h4
-rw-r--r--source/blender/freestyle/intern/geometry/FastGrid.cpp23
-rw-r--r--source/blender/freestyle/intern/geometry/FastGrid.h4
-rw-r--r--source/blender/freestyle/intern/geometry/FitCurve.h2
-rw-r--r--source/blender/freestyle/intern/geometry/GeomCleaner.h2
-rw-r--r--source/blender/freestyle/intern/geometry/GeomUtils.h21
-rw-r--r--source/blender/freestyle/intern/geometry/Grid.cpp5
-rw-r--r--source/blender/freestyle/intern/geometry/Grid.h4
-rw-r--r--source/blender/freestyle/intern/geometry/GridHelpers.cpp2
-rw-r--r--source/blender/freestyle/intern/geometry/HashGrid.h2
-rw-r--r--source/blender/freestyle/intern/geometry/Noise.h2
-rw-r--r--source/blender/freestyle/intern/geometry/matrix_util.cpp4
-rw-r--r--source/blender/freestyle/intern/geometry/matrix_util.h1
-rw-r--r--source/blender/freestyle/intern/geometry/normal_cycle.h2
-rw-r--r--source/blender/freestyle/intern/image/GaussianFilter.h2
-rw-r--r--source/blender/freestyle/intern/image/ImagePyramid.h4
-rw-r--r--source/blender/freestyle/intern/python/BPy_BBox.h2
-rw-r--r--source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.h2
-rw-r--r--source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.h2
-rw-r--r--source/blender/freestyle/intern/python/BPy_ContextFunctions.h2
-rw-r--r--source/blender/freestyle/intern/python/BPy_Convert.h3
-rw-r--r--source/blender/freestyle/intern/python/BPy_Freestyle.cpp19
-rw-r--r--source/blender/freestyle/intern/python/BPy_Freestyle.h4
-rw-r--r--source/blender/freestyle/intern/python/BPy_FrsMaterial.h2
-rw-r--r--source/blender/freestyle/intern/python/BPy_FrsNoise.h2
-rw-r--r--source/blender/freestyle/intern/python/BPy_Id.h3
-rw-r--r--source/blender/freestyle/intern/python/BPy_IntegrationType.h2
-rw-r--r--source/blender/freestyle/intern/python/BPy_Interface0D.h2
-rw-r--r--source/blender/freestyle/intern/python/BPy_Interface1D.h2
-rw-r--r--source/blender/freestyle/intern/python/BPy_Iterator.h2
-rw-r--r--source/blender/freestyle/intern/python/BPy_MediumType.h2
-rw-r--r--source/blender/freestyle/intern/python/BPy_Nature.h2
-rw-r--r--source/blender/freestyle/intern/python/BPy_Operators.h2
-rw-r--r--source/blender/freestyle/intern/python/BPy_SShape.h2
-rw-r--r--source/blender/freestyle/intern/python/BPy_StrokeAttribute.h2
-rw-r--r--source/blender/freestyle/intern/python/BPy_StrokeShader.cpp12
-rw-r--r--source/blender/freestyle/intern/python/BPy_StrokeShader.h2
-rw-r--r--source/blender/freestyle/intern/python/BPy_UnaryFunction0D.h2
-rw-r--r--source/blender/freestyle/intern/python/BPy_UnaryFunction1D.h2
-rw-r--r--source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.h2
-rw-r--r--source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.h2
-rw-r--r--source/blender/freestyle/intern/python/BPy_ViewMap.h2
-rw-r--r--source/blender/freestyle/intern/python/BPy_ViewShape.h2
-rw-r--r--source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.h2
-rw-r--r--source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.h2
-rw-r--r--source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.h2
-rw-r--r--source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.h2
-rw-r--r--source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.h2
-rw-r--r--source/blender/freestyle/intern/python/Director.cpp24
-rw-r--r--source/blender/freestyle/intern/python/Director.h14
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.h3
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.h4
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.h5
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.h3
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.h3
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.h3
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.h3
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.h3
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.h3
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.h6
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.h3
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.h3
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.h3
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.h4
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.h5
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.h5
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.h5
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.h6
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.h4
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.h5
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.h6
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.h5
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.h7
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.h2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.h2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.cpp125
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.h57
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.h2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.h2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_ColorVariationPatternShader.h2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.h2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.h2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.h2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.h2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.h2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.h2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.h2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.h2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.h2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.h2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureShader.h2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.cpp114
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.h55
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_TextureAssignerShader.h2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.h2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessVariationPatternShader.h2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.h2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_fstreamShader.h2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_streamShader.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetOccludeeF0D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetShapeF0D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_Curvature2DAngleF0D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_DensityF0D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedXF0D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedYF0D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedZF0D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetXF0D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetYF0D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetZF0D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_LocalAverageDepthF0D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_ZDiscontinuityF0D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetParameterF0D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadMapPixelF0D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.h2
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_WithinImageBoundaryUP1D.h2
-rw-r--r--source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h2
-rw-r--r--source/blender/freestyle/intern/scene_graph/LineRep.h2
-rw-r--r--source/blender/freestyle/intern/scene_graph/Node.h2
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeCamera.h6
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h2
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeGroup.h2
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeLight.h2
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeShape.h2
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeTransform.cpp2
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeTransform.h2
-rw-r--r--source/blender/freestyle/intern/scene_graph/OrientedLineRep.h2
-rw-r--r--source/blender/freestyle/intern/scene_graph/Rep.h2
-rw-r--r--source/blender/freestyle/intern/scene_graph/SceneVisitor.h2
-rw-r--r--source/blender/freestyle/intern/scene_graph/TriangleRep.h2
-rw-r--r--source/blender/freestyle/intern/scene_graph/VertexRep.h2
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedFunctions0D.h12
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedFunctions1D.h8
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp4
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h12
-rw-r--r--source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp93
-rw-r--r--source/blender/freestyle/intern/stroke/BasicStrokeShaders.h110
-rw-r--r--source/blender/freestyle/intern/stroke/Canvas.cpp2
-rw-r--r--source/blender/freestyle/intern/stroke/Canvas.h2
-rw-r--r--source/blender/freestyle/intern/stroke/Chain.cpp2
-rw-r--r--source/blender/freestyle/intern/stroke/ChainingIterators.cpp14
-rw-r--r--source/blender/freestyle/intern/stroke/ChainingIterators.h24
-rw-r--r--source/blender/freestyle/intern/stroke/ContextFunctions.h9
-rw-r--r--source/blender/freestyle/intern/stroke/Curve.cpp5
-rw-r--r--source/blender/freestyle/intern/stroke/Curve.h4
-rw-r--r--source/blender/freestyle/intern/stroke/CurveIterators.h14
-rw-r--r--source/blender/freestyle/intern/stroke/Operators.cpp8
-rw-r--r--source/blender/freestyle/intern/stroke/Operators.h2
-rw-r--r--source/blender/freestyle/intern/stroke/PSStrokeRenderer.h2
-rw-r--r--source/blender/freestyle/intern/stroke/Predicates0D.cpp (renamed from source/blender/compositor/nodes/COM_SeparateYCCANode.h)39
-rw-r--r--source/blender/freestyle/intern/stroke/Predicates0D.h16
-rw-r--r--source/blender/freestyle/intern/stroke/Predicates1D.cpp (renamed from source/blender/compositor/nodes/COM_SeparateHSVANode.h)40
-rw-r--r--source/blender/freestyle/intern/stroke/Predicates1D.h16
-rw-r--r--source/blender/freestyle/intern/stroke/Stroke.cpp17
-rw-r--r--source/blender/freestyle/intern/stroke/Stroke.h48
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeIO.h3
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeIterators.h14
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeRenderer.cpp4
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeRenderer.h6
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeRep.cpp287
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeRep.h54
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeShader.cpp (renamed from source/blender/compositor/nodes/COM_SeparateRGBANode.h)35
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeShader.h13
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeTesselator.cpp2
-rw-r--r--source/blender/freestyle/intern/stroke/TextStrokeRenderer.h2
-rw-r--r--source/blender/freestyle/intern/system/BaseObject.h4
-rw-r--r--source/blender/freestyle/intern/system/Exception.h4
-rw-r--r--source/blender/freestyle/intern/system/FreestyleConfig.h40
-rw-r--r--source/blender/freestyle/intern/system/Interpreter.h4
-rw-r--r--source/blender/freestyle/intern/system/PseudoNoise.cpp1
-rw-r--r--source/blender/freestyle/intern/system/PseudoNoise.h3
-rw-r--r--source/blender/freestyle/intern/system/PythonInterpreter.cpp7
-rw-r--r--source/blender/freestyle/intern/system/PythonInterpreter.h66
-rw-r--r--source/blender/freestyle/intern/system/RandGen.h4
-rw-r--r--source/blender/freestyle/intern/system/StringUtils.h7
-rw-r--r--source/blender/freestyle/intern/system/TimeStamp.cpp1
-rw-r--r--source/blender/freestyle/intern/system/TimeStamp.h4
-rw-r--r--source/blender/freestyle/intern/system/TimeUtils.h2
-rw-r--r--source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp2
-rw-r--r--source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp1
-rw-r--r--source/blender/freestyle/intern/view_map/FEdgeXDetector.h4
-rw-r--r--source/blender/freestyle/intern/view_map/Functions0D.cpp6
-rw-r--r--source/blender/freestyle/intern/view_map/Functions0D.h51
-rw-r--r--source/blender/freestyle/intern/view_map/Functions1D.cpp2
-rw-r--r--source/blender/freestyle/intern/view_map/Functions1D.h49
-rw-r--r--source/blender/freestyle/intern/view_map/Interface0D.cpp123
-rw-r--r--source/blender/freestyle/intern/view_map/Interface0D.h104
-rw-r--r--source/blender/freestyle/intern/view_map/Interface1D.cpp75
-rw-r--r--source/blender/freestyle/intern/view_map/Interface1D.h47
-rw-r--r--source/blender/freestyle/intern/view_map/Silhouette.h10
-rw-r--r--source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp7
-rw-r--r--source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h2
-rw-r--r--source/blender/freestyle/intern/view_map/SteerableViewMap.cpp4
-rw-r--r--source/blender/freestyle/intern/view_map/SteerableViewMap.h2
-rw-r--r--source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h2
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMap.cpp2
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMap.h12
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h18
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp240
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapBuilder.h2
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapIO.cpp14
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapIO.h8
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapIterators.h12
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapTesselator.h2
-rw-r--r--source/blender/freestyle/intern/winged_edge/Curvature.cpp3
-rw-r--r--source/blender/freestyle/intern/winged_edge/Curvature.h14
-rw-r--r--source/blender/freestyle/intern/winged_edge/WEdge.cpp1
-rw-r--r--source/blender/freestyle/intern/winged_edge/WEdge.h17
-rw-r--r--source/blender/freestyle/intern/winged_edge/WFillGrid.h2
-rw-r--r--source/blender/freestyle/intern/winged_edge/WSFillGrid.h2
-rw-r--r--source/blender/freestyle/intern/winged_edge/WXEdge.cpp70
-rw-r--r--source/blender/freestyle/intern/winged_edge/WXEdge.h2
-rw-r--r--source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.h2
-rw-r--r--source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h2
-rw-r--r--source/blender/gpu/CMakeLists.txt4
-rw-r--r--source/blender/gpu/GPU_buffers.h31
-rw-r--r--source/blender/gpu/GPU_material.h6
-rw-r--r--source/blender/gpu/SConscript2
-rw-r--r--source/blender/gpu/intern/gpu_buffers.c278
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c1
-rw-r--r--source/blender/gpu/intern/gpu_draw.c17
-rw-r--r--source/blender/gpu/intern/gpu_extensions.c2
-rw-r--r--source/blender/gpu/intern/gpu_material.c18
-rw-r--r--source/blender/gpu/shaders/gpu_shader_material.glsl21
-rw-r--r--source/blender/ikplugin/intern/iksolver_plugin.c4
-rw-r--r--source/blender/ikplugin/intern/itasc_plugin.cpp4
-rw-r--r--source/blender/imbuf/IMB_imbuf.h8
-rw-r--r--source/blender/imbuf/intern/allocimbuf.c3
-rw-r--r--source/blender/imbuf/intern/anim_movie.c4
-rw-r--r--source/blender/imbuf/intern/cineon/cineonlib.c5
-rw-r--r--source/blender/imbuf/intern/cineon/dpxlib.c5
-rw-r--r--source/blender/imbuf/intern/colormanagement.c23
-rw-r--r--source/blender/imbuf/intern/dds/DirectDrawSurface.cpp16
-rw-r--r--source/blender/imbuf/intern/divers.c127
-rw-r--r--source/blender/imbuf/intern/filter.c6
-rw-r--r--source/blender/imbuf/intern/imageprocess.c3
-rw-r--r--source/blender/imbuf/intern/indexer.c2
-rw-r--r--source/blender/imbuf/intern/iris.c2
-rw-r--r--source/blender/imbuf/intern/jpeg.c1
-rw-r--r--source/blender/imbuf/intern/moviecache.c6
-rw-r--r--source/blender/imbuf/intern/oiio/openimageio_api.cpp26
-rw-r--r--source/blender/imbuf/intern/radiance_hdr.c1
-rw-r--r--source/blender/imbuf/intern/readimage.c12
-rw-r--r--source/blender/imbuf/intern/scaling.c8
-rw-r--r--source/blender/imbuf/intern/targa.c6
-rw-r--r--source/blender/imbuf/intern/thumbs.c54
-rw-r--r--source/blender/imbuf/intern/util.c13
-rw-r--r--source/blender/makesdna/DNA_action_types.h6
-rw-r--r--source/blender/makesdna/DNA_actuator_types.h3
-rw-r--r--source/blender/makesdna/DNA_anim_types.h3
-rw-r--r--source/blender/makesdna/DNA_constraint_types.h18
-rw-r--r--source/blender/makesdna/DNA_controller_types.h1
-rw-r--r--source/blender/makesdna/DNA_curve_types.h8
-rw-r--r--source/blender/makesdna/DNA_customdata_types.h14
-rw-r--r--source/blender/makesdna/DNA_linestyle_types.h34
-rw-r--r--source/blender/makesdna/DNA_material_types.h8
-rw-r--r--source/blender/makesdna/DNA_mesh_types.h8
-rw-r--r--source/blender/makesdna/DNA_node_types.h3
-rw-r--r--source/blender/makesdna/DNA_object_types.h17
-rw-r--r--source/blender/makesdna/DNA_scene_types.h133
-rw-r--r--source/blender/makesdna/DNA_sensor_types.h1
-rw-r--r--source/blender/makesdna/DNA_space_types.h2
-rw-r--r--source/blender/makesdna/DNA_texture_types.h1
-rw-r--r--source/blender/makesdna/DNA_tracking_types.h17
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h5
-rw-r--r--source/blender/makesdna/intern/SConscript10
-rw-r--r--source/blender/makesdna/intern/dna_genfile.c51
-rw-r--r--source/blender/makesdna/intern/makesdna.c8
-rw-r--r--source/blender/makesrna/RNA_access.h23
-rw-r--r--source/blender/makesrna/RNA_enum_types.h9
-rw-r--r--source/blender/makesrna/intern/SConscript5
-rw-r--r--source/blender/makesrna/intern/makesrna.c14
-rw-r--r--source/blender/makesrna/intern/rna_access.c40
-rw-r--r--source/blender/makesrna/intern/rna_actuator.c7
-rw-r--r--source/blender/makesrna/intern/rna_armature.c15
-rw-r--r--source/blender/makesrna/intern/rna_brush.c15
-rw-r--r--source/blender/makesrna/intern/rna_constraint.c157
-rw-r--r--source/blender/makesrna/intern/rna_controller.c5
-rw-r--r--source/blender/makesrna/intern/rna_curve.c32
-rw-r--r--source/blender/makesrna/intern/rna_define.c2
-rw-r--r--source/blender/makesrna/intern/rna_fcurve.c28
-rw-r--r--source/blender/makesrna/intern/rna_linestyle.c226
-rw-r--r--source/blender/makesrna/intern/rna_main_api.c205
-rw-r--r--source/blender/makesrna/intern/rna_material.c6
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c125
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c2
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c3
-rw-r--r--source/blender/makesrna/intern/rna_object.c19
-rw-r--r--source/blender/makesrna/intern/rna_pose.c10
-rw-r--r--source/blender/makesrna/intern/rna_render.c171
-rw-r--r--source/blender/makesrna/intern/rna_scene.c276
-rw-r--r--source/blender/makesrna/intern/rna_screen.c4
-rw-r--r--source/blender/makesrna/intern/rna_sensor.c5
-rw-r--r--source/blender/makesrna/intern/rna_sequencer.c4
-rw-r--r--source/blender/makesrna/intern/rna_space.c76
-rw-r--r--source/blender/makesrna/intern/rna_speaker.c14
-rw-r--r--source/blender/makesrna/intern/rna_texture.c3
-rw-r--r--source/blender/makesrna/intern/rna_tracking.c38
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c10
-rw-r--r--source/blender/modifiers/intern/MOD_array.c6
-rw-r--r--source/blender/modifiers/intern/MOD_bevel.c4
-rw-r--r--source/blender/modifiers/intern/MOD_boolean_util.c91
-rw-r--r--source/blender/modifiers/intern/MOD_build.c1
-rw-r--r--source/blender/modifiers/intern/MOD_cast.c1
-rw-r--r--source/blender/modifiers/intern/MOD_collision.c2
-rw-r--r--source/blender/modifiers/intern/MOD_curve.c1
-rw-r--r--source/blender/modifiers/intern/MOD_displace.c2
-rw-r--r--source/blender/modifiers/intern/MOD_dynamicpaint.c2
-rw-r--r--source/blender/modifiers/intern/MOD_explode.c3
-rw-r--r--source/blender/modifiers/intern/MOD_fluidsim_util.c3
-rw-r--r--source/blender/modifiers/intern/MOD_hook.c2
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciandeform.c1
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciansmooth.c6
-rw-r--r--source/blender/modifiers/intern/MOD_mask.c2
-rw-r--r--source/blender/modifiers/intern/MOD_meshcache_pc2.c1
-rw-r--r--source/blender/modifiers/intern/MOD_meshcache_util.c4
-rw-r--r--source/blender/modifiers/intern/MOD_meshdeform.c21
-rw-r--r--source/blender/modifiers/intern/MOD_mirror.c1
-rw-r--r--source/blender/modifiers/intern/MOD_ocean.c5
-rw-r--r--source/blender/modifiers/intern/MOD_particlesystem.c2
-rw-r--r--source/blender/modifiers/intern/MOD_remesh.c1
-rw-r--r--source/blender/modifiers/intern/MOD_screw.c2
-rw-r--r--source/blender/modifiers/intern/MOD_shapekey.c4
-rw-r--r--source/blender/modifiers/intern/MOD_simpledeform.c2
-rw-r--r--source/blender/modifiers/intern/MOD_skin.c5
-rw-r--r--source/blender/modifiers/intern/MOD_smooth.c1
-rw-r--r--source/blender/modifiers/intern/MOD_solidify.c5
-rw-r--r--source/blender/modifiers/intern/MOD_util.c1
-rw-r--r--source/blender/modifiers/intern/MOD_uvproject.c2
-rw-r--r--source/blender/modifiers/intern/MOD_uvwarp.c1
-rw-r--r--source/blender/modifiers/intern/MOD_warp.c1
-rw-r--r--source/blender/modifiers/intern/MOD_wave.c2
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgedit.c3
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgmix.c3
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgproximity.c2
-rw-r--r--source/blender/nodes/composite/node_composite_tree.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_common.c2
-rw-r--r--source/blender/nodes/intern/node_common.c58
-rw-r--r--source/blender/nodes/intern/node_exec.c1
-rw-r--r--source/blender/nodes/intern/node_socket.c1
-rw-r--r--source/blender/nodes/intern/node_util.c1
-rw-r--r--source/blender/nodes/shader/node_shader_util.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bump.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_camera.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_common.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_light_path.c1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_math.c9
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_squeeze.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_texture.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_vectMath.c2
-rw-r--r--source/blender/nodes/texture/node_texture_tree.c13
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_common.c2
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_coord.c2
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_distance.c2
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_image.c2
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_math.c11
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_output.c2
-rw-r--r--source/blender/python/bmesh/bmesh_py_ops_call.c2
-rw-r--r--source/blender/python/bmesh/bmesh_py_types.c12
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_customdata.c1
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_select.c2
-rw-r--r--source/blender/python/generic/bgl.c2
-rw-r--r--source/blender/python/generic/blf_py_api.c8
-rw-r--r--source/blender/python/generic/bpy_internal_import.c13
-rw-r--r--source/blender/python/generic/idprop_py_api.c15
-rw-r--r--source/blender/python/generic/py_capi_utils.c25
-rw-r--r--source/blender/python/generic/py_capi_utils.h4
-rw-r--r--source/blender/python/intern/bpy.c6
-rw-r--r--source/blender/python/intern/bpy_app_build_options.c1
-rw-r--r--source/blender/python/intern/bpy_app_handlers.c2
-rw-r--r--source/blender/python/intern/bpy_driver.c2
-rw-r--r--source/blender/python/intern/bpy_interface.c39
-rw-r--r--source/blender/python/intern/bpy_library.c1
-rw-r--r--source/blender/python/intern/bpy_operator.c10
-rw-r--r--source/blender/python/intern/bpy_operator_wrap.c2
-rw-r--r--source/blender/python/intern/bpy_props.c20
-rw-r--r--source/blender/python/intern/bpy_rna.c6
-rw-r--r--source/blender/python/intern/bpy_rna_anim.c9
-rw-r--r--source/blender/python/intern/bpy_rna_array.c6
-rw-r--r--source/blender/python/intern/bpy_rna_callback.c6
-rw-r--r--source/blender/python/intern/bpy_traceback.c34
-rw-r--r--source/blender/python/intern/bpy_util.c2
-rw-r--r--source/blender/python/intern/bpy_util.h4
-rw-r--r--source/blender/python/intern/gpu.c2
-rw-r--r--source/blender/python/mathutils/mathutils_Matrix.c304
-rw-r--r--source/blender/python/mathutils/mathutils_Vector.c36
-rw-r--r--source/blender/python/mathutils/mathutils_geometry.c2
-rw-r--r--source/blender/python/mathutils/mathutils_noise.c3
-rw-r--r--source/blender/render/CMakeLists.txt3
-rw-r--r--source/blender/render/extern/include/RE_bake.h105
-rw-r--r--source/blender/render/extern/include/RE_engine.h4
-rw-r--r--source/blender/render/extern/include/RE_pipeline.h1
-rw-r--r--source/blender/render/extern/include/RE_shader_ext.h4
-rw-r--r--source/blender/render/intern/include/rayintersection.h2
-rw-r--r--source/blender/render/intern/include/rayobject.h1
-rw-r--r--source/blender/render/intern/include/render_types.h5
-rw-r--r--source/blender/render/intern/include/renderdatabase.h7
-rw-r--r--source/blender/render/intern/raytrace/rayobject.cpp37
-rw-r--r--source/blender/render/intern/raytrace/rayobject_blibvh.cpp169
-rw-r--r--source/blender/render/intern/raytrace/reorganize.h17
-rw-r--r--source/blender/render/intern/source/bake.c9
-rw-r--r--source/blender/render/intern/source/bake_api.c867
-rw-r--r--source/blender/render/intern/source/convertblender.c451
-rw-r--r--source/blender/render/intern/source/envmap.c11
-rw-r--r--source/blender/render/intern/source/external_engine.c83
-rw-r--r--source/blender/render/intern/source/imagetexture.c15
-rw-r--r--source/blender/render/intern/source/initrender.c11
-rw-r--r--source/blender/render/intern/source/multires_bake.c17
-rw-r--r--source/blender/render/intern/source/occlusion.c4
-rw-r--r--source/blender/render/intern/source/pipeline.c19
-rw-r--r--source/blender/render/intern/source/pixelblending.c2
-rw-r--r--source/blender/render/intern/source/pixelshading.c5
-rw-r--r--source/blender/render/intern/source/pointdensity.c4
-rw-r--r--source/blender/render/intern/source/rayshade.c11
-rw-r--r--source/blender/render/intern/source/render_result.c16
-rw-r--r--source/blender/render/intern/source/render_texture.c42
-rw-r--r--source/blender/render/intern/source/rendercore.c33
-rw-r--r--source/blender/render/intern/source/renderdatabase.c4
-rw-r--r--source/blender/render/intern/source/shadbuf.c14
-rw-r--r--source/blender/render/intern/source/shadeinput.c27
-rw-r--r--source/blender/render/intern/source/sss.c5
-rw-r--r--source/blender/render/intern/source/strand.c4
-rw-r--r--source/blender/render/intern/source/sunsky.c5
-rw-r--r--source/blender/render/intern/source/volume_precache.c5
-rw-r--r--source/blender/render/intern/source/volumetric.c9
-rw-r--r--source/blender/render/intern/source/voxeldata.c2
-rw-r--r--source/blender/render/intern/source/zbuf.c37
-rw-r--r--source/blender/windowmanager/WM_api.h2
-rw-r--r--source/blender/windowmanager/intern/wm.c1
-rw-r--r--source/blender/windowmanager/intern/wm_cursors.c4
-rw-r--r--source/blender/windowmanager/intern/wm_dragdrop.c5
-rw-r--r--source/blender/windowmanager/intern/wm_draw.c2
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c2
-rw-r--r--source/blender/windowmanager/intern/wm_files.c13
-rw-r--r--source/blender/windowmanager/intern/wm_gesture.c4
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c6
-rw-r--r--source/blender/windowmanager/intern/wm_jobs.c5
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c2
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c47
-rw-r--r--source/blender/windowmanager/intern/wm_playanim.c60
-rw-r--r--source/blender/windowmanager/intern/wm_subwindow.c2
-rw-r--r--source/blender/windowmanager/intern/wm_window.c7
-rw-r--r--source/blenderplayer/bad_level_call_stubs/stubs.c9
-rw-r--r--source/creator/creator.c1
-rw-r--r--source/gameengine/Converter/BL_ActionActuator.cpp19
-rw-r--r--source/gameengine/Converter/BL_ActionActuator.h3
-rw-r--r--source/gameengine/Converter/BL_ArmatureActuator.cpp2
-rw-r--r--source/gameengine/Converter/BL_ArmatureObject.cpp133
-rw-r--r--source/gameengine/Converter/BL_ArmatureObject.h24
-rw-r--r--source/gameengine/Converter/BL_BlenderDataConversion.cpp397
-rw-r--r--source/gameengine/Converter/BL_ModifierDeformer.cpp18
-rw-r--r--source/gameengine/Converter/BL_ShapeDeformer.cpp38
-rw-r--r--source/gameengine/Converter/BL_ShapeDeformer.h2
-rw-r--r--source/gameengine/Converter/BL_SkinDeformer.cpp95
-rw-r--r--source/gameengine/Converter/BL_SkinDeformer.h2
-rw-r--r--source/gameengine/Converter/KX_BlenderSceneConverter.cpp146
-rw-r--r--source/gameengine/Converter/KX_ConvertActuators.cpp4
-rw-r--r--source/gameengine/Converter/KX_ConvertControllers.cpp19
-rw-r--r--source/gameengine/Converter/KX_ConvertControllers.h3
-rw-r--r--source/gameengine/Converter/KX_ConvertSensors.cpp27
-rw-r--r--source/gameengine/Converter/KX_SoftBodyDeformer.cpp1
-rw-r--r--source/gameengine/GameLogic/SCA_EventManager.h1
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_ghost.cpp201
-rw-r--r--source/gameengine/Ketsji/BL_Action.cpp66
-rw-r--r--source/gameengine/Ketsji/BL_Action.h6
-rw-r--r--source/gameengine/Ketsji/BL_ActionManager.cpp88
-rw-r--r--source/gameengine/Ketsji/BL_ActionManager.h27
-rw-r--r--source/gameengine/Ketsji/CMakeLists.txt2
-rw-r--r--source/gameengine/Ketsji/KX_ConstraintActuator.cpp1
-rw-r--r--source/gameengine/Ketsji/KX_ConvertPhysicsObject.h155
-rw-r--r--source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp584
-rw-r--r--source/gameengine/Ketsji/KX_FontObject.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_FontObject.h2
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp18
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.h6
-rw-r--r--source/gameengine/Ketsji/KX_KetsjiEngine.cpp6
-rw-r--r--source/gameengine/Ketsji/KX_KetsjiEngine.h6
-rw-r--r--source/gameengine/Ketsji/KX_LightIpoSGController.h2
-rw-r--r--source/gameengine/Ketsji/KX_MeshProxy.cpp1
-rw-r--r--source/gameengine/Ketsji/KX_RaySensor.cpp3
-rw-r--r--source/gameengine/Ketsji/KX_Scene.cpp163
-rw-r--r--source/gameengine/Ketsji/KX_TouchEventManager.h1
-rw-r--r--source/gameengine/Ketsji/KX_TouchSensor.cpp4
-rw-r--r--source/gameengine/Ketsji/KX_TrackToActuator.cpp2
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsController.cpp35
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsController.h9
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp542
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h15
-rw-r--r--source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h20
-rw-r--r--source/gameengine/Physics/common/PHY_IPhysicsController.h5
-rw-r--r--source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h23
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp2
-rw-r--r--source/gameengine/VideoTexture/VideoFFmpeg.cpp15
-rw-r--r--source/tests/bl_rna_wiki_reference.py2
-rw-r--r--source/tests/bl_run_operators.py2
-rw-r--r--source/tests/pep8.py15
-rw-r--r--source/tests/rst_to_doctree_mini.py1
1584 files changed, 31646 insertions, 20940 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8b57251f176..dafcf15141c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -155,15 +155,7 @@ mark_as_advanced(WITH_HEADLESS)
option(WITH_AUDASPACE "Build with blenders audio library (only disable if you know what you're doing!)" ON)
mark_as_advanced(WITH_AUDASPACE)
-# (unix defaults to OpenMP On)
-if((UNIX AND NOT APPLE) OR (MINGW))
- set(PLATFORM_DEFAULT ON)
-else()
- set(PLATFORM_DEFAULT OFF)
-endif()
-option(WITH_OPENMP "Enable OpenMP (has to be supported by the compiler)" ${PLATFORM_DEFAULT})
-unset(PLATFORM_DEFAULT)
-
+option(WITH_OPENMP "Enable OpenMP (has to be supported by the compiler)" ON)
if(UNIX AND NOT APPLE)
option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support and unicode input)" ON)
@@ -272,7 +264,7 @@ option(WITH_CYCLES_STANDALONE "Build cycles standalone application" OFF)
option(WITH_CYCLES_STANDALONE_GUI "Build cycles standalone with GUI" OFF)
option(WITH_CYCLES_OSL "Build Cycles with OSL support" OFF)
option(WITH_CYCLES_CUDA_BINARIES "Build cycles CUDA binaries" OFF)
-set(CYCLES_CUDA_BINARIES_ARCH sm_20 sm_21 sm_30 sm_35 CACHE STRING "CUDA architectures to build binaries for")
+set(CYCLES_CUDA_BINARIES_ARCH sm_20 sm_21 sm_30 sm_35 sm_50 CACHE STRING "CUDA architectures to build binaries for")
mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH)
unset(PLATFORM_DEFAULT)
@@ -564,14 +556,14 @@ set(PLATFORM_LINKFLAGS_DEBUG "")
# For alternate Python locations the commandline can be used to override detected/default cache settings, e.g:
# On Unix:
# cmake ../blender \
-# -D PYTHON_VERSION=3.3 \
-# -D PYTHON_INCLUDE_DIR=/opt/py33/include/python3.3d \
-# -D PYTHON_LIBRARY=/opt/py33/lib/libpython3.3d.so
+# -D PYTHON_VERSION=3.4 \
+# -D PYTHON_INCLUDE_DIR=/opt/py34/include/python3.4d \
+# -D PYTHON_LIBRARY=/opt/py34/lib/libpython3.4d.so
#
# On Macs:
# cmake ../blender \
-# -D PYTHON_INCLUDE_DIR=/System/Library/Frameworks/Python.framework/Versions/3.3/include/python3.3 \
-# -D PYTHON_LIBPATH=/System/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/config \
+# -D PYTHON_INCLUDE_DIR=/System/Library/Frameworks/Python.framework/Versions/3.4/include/python3.4 \
+# -D PYTHON_LIBPATH=/System/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/config \
# -G Xcode
#
# When changing any of this remember to update the notes in doc/build_systems/cmake.txt
@@ -599,7 +591,7 @@ if(UNIX AND NOT APPLE)
find_package_wrapper(Freetype REQUIRED)
if(WITH_PYTHON)
- # No way to set py33. remove for now.
+ # No way to set py34. remove for now.
# find_package(PythonLibs)
# Use our own instead, since wothout py is such a rare case,
@@ -828,6 +820,7 @@ if(UNIX AND NOT APPLE)
OUTPUT_VARIABLE LLVM_LIBPATH
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(LLVM_LIBPATH ${LLVM_LIBPATH} CACHE PATH "Path to the LLVM library path")
+ mark_as_advanced(LLVM_LIBPATH)
endif()
if(LLVM_STATIC)
@@ -964,6 +957,7 @@ elseif(WIN32)
add_definitions(-DWIN32)
if(MSVC)
+
set(PLATFORM_LINKLIBS ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 advapi32 shfolder shell32 ole32 oleaut32 uuid psapi)
# MSVC11 SDL is not hard linked to dxguid.lib
@@ -1095,6 +1089,9 @@ elseif(WIN32)
set(PNG_LIBPATH ${PNG}/lib) # not cmake defined
endif()
+ if(MSVC90)
+ set(JPEG_NAMES ${JPEG_NAMES} libjpeg)
+ endif()
find_package(jpeg REQUIRED)
set(PTHREADS_INCLUDE_DIRS ${LIBDIR}/pthreads/include)
@@ -1208,7 +1205,7 @@ elseif(WIN32)
endif()
if(WITH_PYTHON)
- set(PYTHON_VERSION 3.3) # CACHE STRING)
+ set(PYTHON_VERSION 3.4) # CACHE STRING)
string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
# Use shared libs for vc2008 and vc2010 until we actually have vc2010 libs
@@ -1362,8 +1359,6 @@ elseif(WIN32)
set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} -lpthread")
add_definitions(-DFREE_WINDOWS64 -DMS_WIN64)
- # Turn off OpenMP since it causes crashes on render for subsurfed/multiresolution meshes
- set(WITH_OPENMP OFF)
endif()
add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE)
@@ -1462,9 +1457,11 @@ elseif(WIN32)
if(WITH_PYTHON)
# normally cached but not since we include them with blender
- set(PYTHON_VERSION 3.3) # CACHE STRING)
+ set(PYTHON_VERSION 3.4) # CACHE STRING)
+ string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}") # CACHE PATH)
- set(PYTHON_LIBRARY "${LIBDIR}/python/lib/python33mw.lib") # CACHE FILEPATH)
+ set(PYTHON_LIBRARY "${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}mw.lib") # CACHE FILEPATH)
+ unset(_PYTHON_VERSION_NO_DOTS)
# uncached vars
set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
@@ -1652,8 +1649,8 @@ elseif(APPLE)
endif()
if(WITH_PYTHON)
- # we use precompiled libraries for py 3.3 and up by default
- set(PYTHON_VERSION 3.3)
+ # we use precompiled libraries for py 3.4 and up by default
+ set(PYTHON_VERSION 3.4)
if(NOT WITH_PYTHON_MODULE AND NOT WITH_PYTHON_FRAMEWORK)
# normally cached but not since we include them with blender
set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}m")
@@ -1813,7 +1810,6 @@ elseif(APPLE)
set(BOOST_LIBRARIES boost_date_time-mt boost_filesystem-mt boost_regex-mt boost_system-mt boost_thread-mt boost_wave-mt)
if(WITH_INTERNATIONAL)
list(APPEND BOOST_LIBRARIES boost_locale-mt)
- set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -liconv") # boost_locale needs it !
endif()
if(WITH_CYCLES_NETWORK)
list(APPEND BOOST_LIBRARIES boost_serialization-mt)
@@ -1821,6 +1817,10 @@ elseif(APPLE)
set(BOOST_LIBPATH ${BOOST}/lib)
set(BOOST_DEFINITIONS)
endif()
+
+ if(WITH_INTERNATIONAL OR WITH_CODEC_FFMPEG)
+ set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -liconv") # boost_locale and ffmpeg needs it !
+ endif()
if(WITH_OPENIMAGEIO)
set(OPENIMAGEIO ${LIBDIR}/openimageio)
@@ -1898,7 +1898,7 @@ elseif(APPLE)
set(OpenMP_CXX_FLAGS "-fopenmp" CACHE STRING "C++ compiler flags for OpenMP parallization" FORCE)
include_directories(${LIBDIR}/openmp/include)
LINK_DIRECTORIES(${LIBDIR}/openmp/lib)
- execute_process(COMMAND cp ${LIBDIR}/openmp/lib/libiomp5.dylib ${CMAKE_BINARY_DIR}/bin/libiomp5.dylib) # for intermediate binaries, lib id is @loader_path
+ execute_process(COMMAND ditto -arch ${CMAKE_OSX_ARCHITECTURES} ${LIBDIR}/openmp/lib/libiomp5.dylib ${CMAKE_BINARY_DIR}/bin/libiomp5.dylib) # for intermediate binaries, lib id is @loader_path
else()
set(OpenMP_C_FLAGS "" CACHE STRING "C compiler flags for OpenMP parallization" FORCE) # unset
set(OpenMP_CXX_FLAGS "" CACHE STRING "C++ compiler flags for OpenMP parallization" FORCE) # unset
diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh
index b56581183ed..4fa7946bb8b 100755
--- a/build_files/build_environment/install_deps.sh
+++ b/build_files/build_environment/install_deps.sh
@@ -25,8 +25,8 @@
ARGS=$( \
getopt \
-o s:i:t:h \
---long source:,install:,tmp:,threads:,help,no-sudo,with-all,with-opencollada,force-all,\
-force-python,force-numpy,force-boost,force-ocio,force-oiio,force-llvm,force-osl,force-opencollada,\
+--long source:,install:,tmp:,threads:,help,no-sudo,with-all,with-opencollada,ver-ocio:,ver-oiio:,ver-llvm:,ver-osl:,\
+force-all,force-python,force-numpy,force-boost,force-ocio,force-oiio,force-llvm,force-osl,force-opencollada,\
force-ffmpeg,skip-python,skip-numpy,skip-boost,skip-ocio,skip-oiio,skip-llvm,skip-osl,skip-ffmpeg,\
skip-opencollada,required-numpy,libyaml-cpp-ver: \
-- "$@" \
@@ -89,6 +89,22 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
--with-opencollada
Build and install the OpenCOLLADA libraries.
+ --ver-ocio=<ver>
+ Force version of OCIO library.
+
+ --ver-oiio=<ver>
+ Force version of OIIO library.
+
+ --ver-llvm=<ver>
+ Force version of LLVM library.
+
+ --ver-osl=<ver>
+ Force version of OSL library.
+
+ Note about the --ver-foo options:
+ It may not always work as expected (some libs are actually checked out from a git rev...), yet it might help
+ to fix some build issues (like LLVM mismatch with the version used by your graphic system).
+
--force-all
Force the rebuild of all built libraries.
@@ -161,7 +177,7 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
--required-numpy
Use this in case your distro features a valid python package, but no matching Numpy one.
- It will force compilation of both python 3.3 and numpy 1.7.
+ It will force compilation of both python and numpy
--libyaml-cpp-ver=<ver>
Ubuntu hack: you may have to force installation of a non-defaut version of libyaml-cpp
@@ -171,28 +187,23 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
SUDO="sudo"
-PYTHON_VERSION="3.3.3"
-PYTHON_VERSION_MIN="3.3"
-PYTHON_SOURCE="http://python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tar.bz2"
+PYTHON_VERSION="3.4.0"
+PYTHON_VERSION_MIN="3.4"
PYTHON_FORCE_REBUILD=false
PYTHON_SKIP=false
-NUMPY_VERSION="1.7.0"
-NUMPY_VERSION_MIN="1.7"
-NUMPY_SOURCE="http://sourceforge.net/projects/numpy/files/NumPy/$NUMPY_VERSION/numpy-$NUMPY_VERSION.tar.gz"
+NUMPY_VERSION="1.8.1"
+NUMPY_VERSION_MIN="1.8"
NUMPY_FORCE_REBUILD=false
NUMPY_SKIP=false
NUMPY_REQUIRED=false
BOOST_VERSION="1.51.0"
-_boost_version_nodots=`echo "$BOOST_VERSION" | sed -r 's/\./_/g'`
-BOOST_SOURCE="http://sourceforge.net/projects/boost/files/boost/$BOOST_VERSION/boost_$_boost_version_nodots.tar.bz2/download"
BOOST_VERSION_MIN="1.49"
BOOST_FORCE_REBUILD=false
BOOST_SKIP=false
OCIO_VERSION="1.0.7"
-OCIO_SOURCE="https://github.com/imageworks/OpenColorIO/tarball/v$OCIO_VERSION"
OCIO_VERSION_MIN="1.0"
OCIO_FORCE_REBUILD=false
OCIO_SKIP=false
@@ -201,49 +212,34 @@ LIBYAML_CPP_VER="0.0"
OPENEXR_VERSION="2.1.0"
OPENEXR_VERSION_MIN="2.0.1"
-#OPENEXR_SOURCE="http://download.savannah.nongnu.org/releases/openexr/openexr-$OPENEXR_VERSION.tar.gz"
-OPENEXR_SOURCE="https://github.com/mont29/openexr.git"
-OPENEXR_REPO_UID="2787aa1cf652d244ed45ae124eb1553f6cff11ee"
ILMBASE_VERSION="2.1.0"
-ILMBASE_SOURCE="http://download.savannah.nongnu.org/releases/openexr/ilmbase-$ILMBASE_VERSION.tar.gz"
OPENEXR_FORCE_REBUILD=false
OPENEXR_SKIP=false
_with_built_openexr=false
-OIIO_VERSION="1.3.9"
-OIIO_VERSION_MIN="1.3.9"
-#OIIO_SOURCE="https://github.com/OpenImageIO/oiio/archive/Release-$OIIO_VERSION.tar.gz"
-OIIO_SOURCE="https://github.com/mont29/oiio.git"
-OIIO_REPO_UID="99113d12619c90cf44721195a759674ea61f02b1"
+OIIO_VERSION="1.4.0"
+OIIO_VERSION_MIN="1.4.0"
OIIO_FORCE_REBUILD=false
OIIO_SKIP=false
LLVM_VERSION="3.3"
LLVM_VERSION_MIN="3.3"
LLVM_VERSION_FOUND=""
-LLVM_SOURCE="http://llvm.org/releases/$LLVM_VERSION/llvm-$LLVM_VERSION.src.tar.gz"
-LLVM_CLANG_SOURCE="http://llvm.org/releases/$LLVM_VERSION/clang-$LLVM_VERSION.src.tar.gz"
LLVM_FORCE_REBUILD=false
LLVM_SKIP=false
# OSL needs to be compiled for now!
OSL_VERSION="1.4.0"
OSL_VERSION_MIN=$OSL_VERSION
-#OSL_SOURCE="https://github.com/imageworks/OpenShadingLanguage/archive/Release-$OSL_VERSION.tar.gz"
-OSL_SOURCE="https://github.com/mont29/OpenShadingLanguage.git"
-OSL_REPO_UID="175989f2610a7d54e8edfb5ace0143e28e11ac70"
OSL_FORCE_REBUILD=false
OSL_SKIP=false
# Version??
OPENCOLLADA_VERSION="1.3"
-OPENCOLLADA_SOURCE="https://github.com/KhronosGroup/OpenCOLLADA.git"
-OPENCOLLADA_REPO_UID="18da7f4109a8eafaa290a33f5550501cc4c8bae8"
OPENCOLLADA_FORCE_REBUILD=false
OPENCOLLADA_SKIP=false
-FFMPEG_VERSION="1.0"
-FFMPEG_SOURCE="http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2"
+FFMPEG_VERSION="2.1.4"
FFMPEG_VERSION_MIN="0.7.6"
FFMPEG_FORCE_REBUILD=false
FFMPEG_SKIP=false
@@ -356,6 +352,27 @@ while true; do
--with-opencollada)
WITH_OPENCOLLADA=true; shift; continue
;;
+ --ver-ocio)
+ OCIO_VERSION="$2"
+ OCIO_VERSION_MIN=$OCIO_VERSION
+ echo $OCIO_VERSION
+ shift; shift; continue
+ ;;
+ --ver-oiio)
+ OIIO_VERSION="$2"
+ OIIO_VERSION_MIN=$OIIO_VERSION
+ shift; shift; continue
+ ;;
+ --ver-llvm)
+ LLVM_VERSION="$2"
+ LLVM_VERSION_MIN=$LLVM_VERSION
+ shift; shift; continue
+ ;;
+ --ver-osl)
+ OSL_VERSION="$2"
+ OSL_VERSION_MIN=$OSL_VERSION
+ shift; shift; continue
+ ;;
--force-all)
PYTHON_FORCE_REBUILD=true
NUMPY_FORCE_REBUILD=true
@@ -459,6 +476,35 @@ if $WITH_ALL; then
WITH_OPENCOLLADA=true
fi
+
+# This has to be done here, because user might force some versions...
+PYTHON_SOURCE="http://python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz"
+NUMPY_SOURCE="http://sourceforge.net/projects/numpy/files/NumPy/$NUMPY_VERSION/numpy-$NUMPY_VERSION.tar.gz"
+_boost_version_nodots=`echo "$BOOST_VERSION" | sed -r 's/\./_/g'`
+BOOST_SOURCE="http://sourceforge.net/projects/boost/files/boost/$BOOST_VERSION/boost_$_boost_version_nodots.tar.bz2/download"
+
+OCIO_SOURCE="https://github.com/imageworks/OpenColorIO/tarball/v$OCIO_VERSION"
+#OPENEXR_SOURCE="http://download.savannah.nongnu.org/releases/openexr/openexr-$OPENEXR_VERSION.tar.gz"
+OPENEXR_SOURCE="https://github.com/mont29/openexr.git"
+OPENEXR_REPO_UID="2787aa1cf652d244ed45ae124eb1553f6cff11ee"
+ILMBASE_SOURCE="http://download.savannah.nongnu.org/releases/openexr/ilmbase-$ILMBASE_VERSION.tar.gz"
+
+#OIIO_SOURCE="https://github.com/OpenImageIO/oiio/archive/Release-$OIIO_VERSION.tar.gz"
+OIIO_SOURCE="https://github.com/mont29/oiio.git"
+OIIO_REPO_UID="99113d12619c90cf44721195a759674ea61f02b1"
+
+LLVM_SOURCE="http://llvm.org/releases/$LLVM_VERSION/llvm-$LLVM_VERSION.src.tar.gz"
+LLVM_CLANG_SOURCE="http://llvm.org/releases/$LLVM_VERSION/clang-$LLVM_VERSION.src.tar.gz"
+#OSL_SOURCE="https://github.com/imageworks/OpenShadingLanguage/archive/Release-$OSL_VERSION.tar.gz"
+#OSL_SOURCE="https://github.com/mont29/OpenShadingLanguage.git"
+OSL_SOURCE="https://github.com/imageworks/OpenShadingLanguage.git"
+OSL_REPO_UID="4abd672ed3979e5e965323201a5ba5ab802a76a9"
+
+OPENCOLLADA_SOURCE="https://github.com/KhronosGroup/OpenCOLLADA.git"
+OPENCOLLADA_REPO_UID="18da7f4109a8eafaa290a33f5550501cc4c8bae8"
+FFMPEG_SOURCE="http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2"
+
+
##### Generic Helpers #####
# Return 0 if $1 = $2 (i.e. 1.01.0 = 1.1, but 1.1.1 != 1.1), else 1.
@@ -611,7 +657,7 @@ _init_python() {
_src=$SRC/Python-$PYTHON_VERSION
_git=false
_inst=$INST/python-$PYTHON_VERSION
- _inst_shortcut=$INST/python-3.3
+ _inst_shortcut=$INST/python-$PYTHON_VERSION_MIN
}
clean_Python() {
@@ -638,10 +684,10 @@ compile_Python() {
if [ ! -d $_src ]; then
mkdir -p $SRC
- wget -c $PYTHON_SOURCE -O $_src.tar.bz2
+ wget -c $PYTHON_SOURCE -O $_src.tgz
INFO "Unpacking Python-$PYTHON_VERSION"
- tar -C $SRC -xf $_src.tar.bz2
+ tar -C $SRC -xf $_src.tgz
fi
cd $_src
@@ -676,7 +722,7 @@ _init_numpy() {
_git=false
_inst=$INST/numpy-$NUMPY_VERSION
_python=$INST/python-$PYTHON_VERSION
- _site=lib/python3.3/site-packages
+ _site=lib/python$PYTHON_VERSION_MIN/site-packages
_inst_shortcut=$_python/$_site/numpy
}
@@ -1156,11 +1202,12 @@ compile_OIIO() {
cmake_d="$cmake_d -D BUILDSTATIC=OFF"
cmake_d="$cmake_d -D LINKSTATIC=OFF"
+ cmake_d="$cmake_d -D ILMBASE_VERSION=$ILMBASE_VERSION"
+ cmake_d="$cmake_d -D OPENEXR_VERSION=$OPENEXR_VERSION"
+
if [ $_with_built_openexr == true ]; then
cmake_d="$cmake_d -D ILMBASE_HOME=$INST/openexr"
- cmake_d="$cmake_d -D ILMBASE_VERSION=$ILMBASE_VERSION"
cmake_d="$cmake_d -D OPENEXR_HOME=$INST/openexr"
- cmake_d="$cmake_d -D OPENEXR_VERSION=$OPENEXR_VERSION"
fi
# Optional tests and cmd tools
@@ -1290,6 +1337,7 @@ EOF
cmake_d="$cmake_d -D CMAKE_INSTALL_PREFIX=$_inst"
cmake_d="$cmake_d -D LLVM_ENABLE_FFI=ON"
cmake_d="$cmake_d -D LLVM_TARGETS_TO_BUILD=X86"
+ cmake_d="$cmake_d -D -DLLVM_ENABLE_TERMINFO=OFF"
if [ -d $_FFI_INCLUDE_DIR ]; then
cmake_d="$cmake_d -D FFI_INCLUDE_DIR=$_FFI_INCLUDE_DIR"
@@ -1335,7 +1383,7 @@ clean_OSL() {
compile_OSL() {
# To be changed each time we make edits that would modify the compiled result!
- osl_magic=14
+ osl_magic=15
_init_osl
# Clean install if needed!
@@ -1364,8 +1412,10 @@ compile_OSL() {
cd $_src
+ git remote set-url origin $OSL_SOURCE
+
# XXX For now, always update from latest repo...
- git pull origin master
+ git pull -X theirs origin master
# Stick to same rev as windows' libs...
git checkout $OSL_REPO_UID
@@ -1384,9 +1434,10 @@ compile_OSL() {
cmake_d="$cmake_d -D STOP_ON_WARNING=OFF"
cmake_d="$cmake_d -D BUILDSTATIC=OFF"
+ cmake_d="$cmake_d -D ILMBASE_VERSION=$ILMBASE_VERSION"
+
if [ $_with_built_openexr == true ]; then
cmake_d="$cmake_d -D ILMBASE_HOME=$INST/openexr"
- cmake_d="$cmake_d -D ILMBASE_VERSION=$ILMBASE_VERSION"
fi
if [ -d $INST/boost ]; then
@@ -1587,8 +1638,9 @@ compile_FFmpeg() {
--disable-bzlib --disable-libgsm --disable-libspeex \
--enable-pthreads --enable-zlib --enable-stripping --enable-runtime-cpudetect \
--disable-vaapi --disable-libfaac --disable-nonfree --enable-gpl \
- --disable-postproc --disable-x11grab --disable-librtmp --disable-libopencore-amrnb \
+ --disable-postproc --disable-librtmp --disable-libopencore-amrnb \
--disable-libopencore-amrwb --disable-libdc1394 --disable-version3 --disable-outdev=sdl \
+ --disable-outdev=xv \
--disable-outdev=alsa --disable-indev=sdl --disable-indev=alsa --disable-indev=jack \
--disable-indev=lavfi $extra
@@ -1860,9 +1912,9 @@ install_DEB() {
if $NUMPY_SKIP; then
WARNING "Skipping NumPy installation, as requested..."
else
- check_package_DEB python$PYTHON_VERSION_MIN-numpy
+ check_package_DEB python3-numpy
if [ $? -eq 0 ]; then
- install_packages_DEB python$PYTHON_VERSION_MIN-numpy
+ install_packages_DEB python3-numpy
elif $NUMPY_REQUIRED; then
WARNING "Valid python package but no valid numpy package!" \
" Building both Python and Numpy from sources!"
@@ -2891,21 +2943,29 @@ print_info() {
_buildargs="$_buildargs $_1"
fi
- _1="-D WITH_CYCLES_OSL=ON"
- _2="-D WITH_LLVM=ON"
- _3="-D LLVM_VERSION=$LLVM_VERSION_FOUND"
- PRINT " $_1"
- PRINT " $_2"
- PRINT " $_3"
- _buildargs="$_buildargs $_1 $_2 $_3"
- if [ -d $INST/osl ]; then
- _1="-D CYCLES_OSL=$INST/osl"
+ if [ "$OSL_SKIP" = false ]; then
+ _1="-D WITH_CYCLES_OSL=ON"
+ _2="-D WITH_LLVM=ON"
+ _3="-D LLVM_VERSION=$LLVM_VERSION_FOUND"
PRINT " $_1"
- _buildargs="$_buildargs $_1"
- fi
- if [ -d $INST/llvm ]; then
- _1="-D LLVM_DIRECTORY=$INST/llvm"
- _2="-D LLVM_STATIC=ON"
+ PRINT " $_2"
+ PRINT " $_3"
+ _buildargs="$_buildargs $_1 $_2 $_3"
+ if [ -d $INST/osl ]; then
+ _1="-D CYCLES_OSL=$INST/osl"
+ PRINT " $_1"
+ _buildargs="$_buildargs $_1"
+ fi
+ if [ -d $INST/llvm ]; then
+ _1="-D LLVM_DIRECTORY=$INST/llvm"
+ _2="-D LLVM_STATIC=ON"
+ PRINT " $_1"
+ PRINT " $_2"
+ _buildargs="$_buildargs $_1 $_2"
+ fi
+ else
+ _1="-D WITH_CYCLES_OSL=OFF"
+ _2="-D WITH_LLVM=OFF"
PRINT " $_1"
PRINT " $_2"
_buildargs="$_buildargs $_1 $_2"
@@ -2917,15 +2977,17 @@ print_info() {
_buildargs="$_buildargs $_1"
fi
- _1="-D WITH_CODEC_FFMPEG=ON"
- _2="-D FFMPEG_LIBRARIES='avformat;avcodec;avutil;avdevice;swscale;rt;`print_info_ffmpeglink`'"
- PRINT " $_1"
- PRINT " $_2"
- _buildargs="$_buildargs $_1 $_2"
- if [ -d $INST/ffmpeg ]; then
- _1="-D FFMPEG=$INST/ffmpeg"
+ if [ "$FFMPEG_SKIP" = false ]; then
+ _1="-D WITH_CODEC_FFMPEG=ON"
+ _2="-D FFMPEG_LIBRARIES='avformat;avcodec;avutil;avdevice;swscale;rt;`print_info_ffmpeglink`'"
PRINT " $_1"
- _buildargs="$_buildargs $_1"
+ PRINT " $_2"
+ _buildargs="$_buildargs $_1 $_2"
+ if [ -d $INST/ffmpeg ]; then
+ _1="-D FFMPEG=$INST/ffmpeg"
+ PRINT " $_1"
+ _buildargs="$_buildargs $_1"
+ fi
fi
PRINT ""
@@ -2940,9 +3002,11 @@ print_info() {
PRINT "BF_PYTHON_ABI_FLAGS = 'm'"
fi
- PRINT "WITH_BF_OCIO = True"
- if [ -d $INST/ocio ]; then
- PRINT "BF_OCIO = '$INST/ocio'"
+ if [ "$OCIO_SKIP" = false ]; then
+ PRINT "WITH_BF_OCIO = True"
+ if [ -d $INST/ocio ]; then
+ PRINT "BF_OCIO = '$INST/ocio'"
+ fi
fi
if [ -d $INST/openexr ]; then
@@ -2960,9 +3024,11 @@ print_info() {
PRINT "WITH_BF_STATICOPENEXR = True"
fi
- PRINT "WITH_BF_OIIO = True"
- if [ -d $INST/oiio ]; then
- PRINT "BF_OIIO = '$INST/oiio'"
+ if [ "$OIIO_SKIP" = false ]; then
+ PRINT "WITH_BF_OIIO = True"
+ if [ -d $INST/oiio ]; then
+ PRINT "BF_OIIO = '$INST/oiio'"
+ fi
fi
PRINT "WITH_BF_CYCLES = True"
@@ -2971,9 +3037,11 @@ print_info() {
PRINT "BF_OSL = '$INST/osl'"
fi
- PRINT "WITH_BF_BOOST = True"
- if [ -d $INST/boost ]; then
- PRINT "BF_BOOST = '$INST/boost'"
+ if [ "$BOOST_SKIP" = false ]; then
+ PRINT "WITH_BF_BOOST = True"
+ if [ -d $INST/boost ]; then
+ PRINT "BF_BOOST = '$INST/boost'"
+ fi
fi
if $WITH_OPENCOLLADA; then
@@ -2983,13 +3051,15 @@ print_info() {
fi
fi
- _ffmpeg_list_sep=" "
- if [ -d $INST/ffmpeg ]; then
- PRINT "BF_FFMPEG = '$INST/ffmpeg'"
+ if [ "$FFMPEG_SKIP" = false ]; then
+ _ffmpeg_list_sep=" "
+ if [ -d $INST/ffmpeg ]; then
+ PRINT "BF_FFMPEG = '$INST/ffmpeg'"
+ fi
+ PRINT "BF_FFMPEG_LIB = 'avformat avcodec swscale avutil avdevice `print_info_ffmpeglink`'"
fi
- PRINT "BF_FFMPEG_LIB = 'avformat avcodec swscale avutil avdevice `print_info_ffmpeglink`'"
- if ! $WITH_ALL; then
+ if [ "$WITH_ALL" = false ]; then
PRINT "WITH_BF_3DMOUSE = False"
# No libspacenav in official arch repos...
elif [ "$DISTRO" = "ARCH" ]; then
diff --git a/build_files/buildbot/config/user-config-cuda-glibc211-i686.py b/build_files/buildbot/config/user-config-cuda-glibc211-i686.py
index 69053d7ff39..854f535398b 100644
--- a/build_files/buildbot/config/user-config-cuda-glibc211-i686.py
+++ b/build_files/buildbot/config/user-config-cuda-glibc211-i686.py
@@ -2,4 +2,4 @@ BF_BUILDDIR = '../blender-build/linux-glibc211-i686'
BF_INSTALLDIR = '../blender-install/linux-glibc211-i686'
BF_NUMJOBS = 1
-BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35']
+BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35', 'sm_50']
diff --git a/build_files/buildbot/config/user-config-cuda-glibc211-x86_64.py b/build_files/buildbot/config/user-config-cuda-glibc211-x86_64.py
index c9b765f55ac..7e928948762 100644
--- a/build_files/buildbot/config/user-config-cuda-glibc211-x86_64.py
+++ b/build_files/buildbot/config/user-config-cuda-glibc211-x86_64.py
@@ -2,4 +2,4 @@ BF_BUILDDIR = '../blender-build/linux-glibc211-x86_64'
BF_INSTALLDIR = '../blender-install/linux-glibc211-x86_64'
BF_NUMJOBS = 1
-BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35']
+BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35', 'sm_50']
diff --git a/build_files/buildbot/config/user-config-glibc211-i686.py b/build_files/buildbot/config/user-config-glibc211-i686.py
index 763ddfbbad4..41d6a4a78dc 100644
--- a/build_files/buildbot/config/user-config-glibc211-i686.py
+++ b/build_files/buildbot/config/user-config-glibc211-i686.py
@@ -4,9 +4,9 @@ BF_NUMJOBS = 4
WITHOUT_BF_OVERWRITE_INSTALL = True
# Python configuration
-BF_PYTHON_VERSION = '3.3'
+BF_PYTHON_VERSION = '3.4'
BF_PYTHON_ABI_FLAGS = 'm'
-BF_PYTHON = '/opt/lib/python-3.3'
+BF_PYTHON = '/opt/lib/python-3.4'
WITH_BF_PYTHON_INSTALL_NUMPY = True
WITH_BF_PYTHON_INSTALL_REQUESTS = True
diff --git a/build_files/buildbot/config/user-config-glibc211-x86_64.py b/build_files/buildbot/config/user-config-glibc211-x86_64.py
index 0a5ffbe29e0..d94923cc39d 100644
--- a/build_files/buildbot/config/user-config-glibc211-x86_64.py
+++ b/build_files/buildbot/config/user-config-glibc211-x86_64.py
@@ -4,9 +4,9 @@ BF_NUMJOBS = 4
WITHOUT_BF_OVERWRITE_INSTALL = True
# Python configuration
-BF_PYTHON_VERSION = '3.3'
+BF_PYTHON_VERSION = '3.4'
BF_PYTHON_ABI_FLAGS = 'm'
-BF_PYTHON = '/opt/lib/python-3.3'
+BF_PYTHON = '/opt/lib/python-3.4'
WITH_BF_PYTHON_INSTALL_NUMPY = True
WITH_BF_PYTHON_INSTALL_REQUESTS = True
diff --git a/build_files/buildbot/config/user-config-player-glibc211-i686.py b/build_files/buildbot/config/user-config-player-glibc211-i686.py
index 2ccceaa82c1..641dbe082ad 100644
--- a/build_files/buildbot/config/user-config-player-glibc211-i686.py
+++ b/build_files/buildbot/config/user-config-player-glibc211-i686.py
@@ -3,9 +3,9 @@ BF_INSTALLDIR = '../blender-install/linux-glibc211-i686'
BF_NUMJOBS = 4
# Python configuration
-BF_PYTHON_VERSION = '3.3'
+BF_PYTHON_VERSION = '3.4'
BF_PYTHON_ABI_FLAGS = 'm'
-BF_PYTHON = '/opt/lib/python-3.3'
+BF_PYTHON = '/opt/lib/python-3.4'
WITH_BF_PYTHON_INSTALL_NUMPY = True
WITH_BF_PYTHON_INSTALL_REQUESTS = True
diff --git a/build_files/buildbot/config/user-config-player-glibc211-x86_64.py b/build_files/buildbot/config/user-config-player-glibc211-x86_64.py
index 9d9ba78a6dd..80503268b44 100644
--- a/build_files/buildbot/config/user-config-player-glibc211-x86_64.py
+++ b/build_files/buildbot/config/user-config-player-glibc211-x86_64.py
@@ -3,9 +3,9 @@ BF_INSTALLDIR = '../blender-install/linux-glibc211-x86_64'
BF_NUMJOBS = 4
# Python configuration
-BF_PYTHON_VERSION = '3.3'
+BF_PYTHON_VERSION = '3.4'
BF_PYTHON_ABI_FLAGS = 'm'
-BF_PYTHON = '/opt/lib/python-3.3'
+BF_PYTHON = '/opt/lib/python-3.4'
WITH_BF_PYTHON_INSTALL_NUMPY = True
WITH_BF_PYTHON_INSTALL_REQUESTS = True
diff --git a/build_files/buildbot/slave_compile.py b/build_files/buildbot/slave_compile.py
index 2d8548cbba0..8d5d3a5eb79 100644
--- a/build_files/buildbot/slave_compile.py
+++ b/build_files/buildbot/slave_compile.py
@@ -64,6 +64,7 @@ else:
install_dir = os.path.join('..', 'install', builder)
# Clean install directory so we'll be sure there's no
+ # residual libs and files remained from the previous install.
if os.path.isdir(install_dir):
shutil.rmtree(install_dir)
diff --git a/build_files/cmake/Modules/FindOpenEXR.cmake b/build_files/cmake/Modules/FindOpenEXR.cmake
index 547f3e0dc38..7190cfc5a88 100644
--- a/build_files/cmake/Modules/FindOpenEXR.cmake
+++ b/build_files/cmake/Modules/FindOpenEXR.cmake
@@ -126,7 +126,10 @@ IF(OPENEXR_FOUND)
SET(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR} ${OPENEXR_INCLUDE_DIR}/OpenEXR)
ENDIF()
-MARK_AS_ADVANCED(OPENEXR_INCLUDE_DIR)
+MARK_AS_ADVANCED(
+ OPENEXR_INCLUDE_DIR
+ OPENEXR_VERSION
+)
FOREACH(COMPONENT ${_openexr_FIND_COMPONENTS})
STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
MARK_AS_ADVANCED(OPENEXR_${UPPERCOMPONENT}_LIBRARY)
diff --git a/build_files/cmake/Modules/FindPythonLibsUnix.cmake b/build_files/cmake/Modules/FindPythonLibsUnix.cmake
index 30019eb0b70..5656d33c934 100644
--- a/build_files/cmake/Modules/FindPythonLibsUnix.cmake
+++ b/build_files/cmake/Modules/FindPythonLibsUnix.cmake
@@ -37,7 +37,7 @@ IF(NOT PYTHON_ROOT_DIR AND NOT $ENV{PYTHON_ROOT_DIR} STREQUAL "")
SET(PYTHON_ROOT_DIR $ENV{PYTHON_ROOT_DIR})
ENDIF()
-SET(PYTHON_VERSION 3.3 CACHE STRING "Python Version (major and minor only)")
+SET(PYTHON_VERSION 3.4 CACHE STRING "Python Version (major and minor only)")
MARK_AS_ADVANCED(PYTHON_VERSION)
@@ -188,7 +188,7 @@ IF(PYTHONLIBSUNIX_FOUND)
SET(PYTHON_LIBRARIES ${PYTHON_LIBRARY})
# we need this for installation
- # XXX No more valid with debian-like py3.3 packages...
+ # XXX No more valid with debian-like py3.4 packages...
# GET_FILENAME_COMPONENT(PYTHON_LIBPATH ${PYTHON_LIBRARY} PATH)
# not used
diff --git a/build_files/cmake/cmake_netbeans_project.py b/build_files/cmake/cmake_netbeans_project.py
index 17490e36bb3..17668f10c0c 100755
--- a/build_files/cmake/cmake_netbeans_project.py
+++ b/build_files/cmake/cmake_netbeans_project.py
@@ -68,7 +68,7 @@ def create_nb_project_main():
PROJECT_NAME = "Blender"
else:
# be tricky, get the project name from SVN if we can!
- PROJECT_NAME = project_name_get(SOURCE_DIR)
+ PROJECT_NAME = project_name_get()
# --------------- NB spesific
defines = [("%s=%s" % cdef) if cdef[1] else cdef[0] for cdef in defines]
diff --git a/build_files/cmake/cmake_qtcreator_project.py b/build_files/cmake/cmake_qtcreator_project.py
index 4cf854aad77..76f1efa6ccb 100755
--- a/build_files/cmake/cmake_qtcreator_project.py
+++ b/build_files/cmake/cmake_qtcreator_project.py
@@ -92,8 +92,8 @@ def create_qtc_project_main():
if 0:
PROJECT_NAME = "Blender"
else:
- # be tricky, get the project name from SVN if we can!
- PROJECT_NAME = project_name_get(SOURCE_DIR)
+ # be tricky, get the project name from CMake if we can!
+ PROJECT_NAME = project_name_get()
FILE_NAME = PROJECT_NAME.lower()
f = open(os.path.join(PROJECT_DIR, "%s.files" % FILE_NAME), 'w')
@@ -134,7 +134,7 @@ def create_qtc_project_python():
PROJECT_NAME = "Blender_Python"
else:
# be tricky, get the project name from SVN if we can!
- PROJECT_NAME = project_name_get(SOURCE_DIR) + "_Python"
+ PROJECT_NAME = project_name_get() + "_Python"
FILE_NAME = PROJECT_NAME.lower()
f = open(os.path.join(PROJECT_DIR, "%s.files" % FILE_NAME), 'w')
diff --git a/build_files/cmake/config/blender_lite.cmake b/build_files/cmake/config/blender_lite.cmake
index ca9aadd649c..bf5c4f9e103 100644
--- a/build_files/cmake/config/blender_lite.cmake
+++ b/build_files/cmake/config/blender_lite.cmake
@@ -51,3 +51,8 @@ set(WITH_RAYOPTIMIZATION OFF CACHE BOOL "" FORCE)
set(WITH_SDL OFF CACHE BOOL "" FORCE)
set(WITH_X11_XINPUT OFF CACHE BOOL "" FORCE)
set(WITH_X11_XF86VMODE OFF CACHE BOOL "" FORCE)
+
+if(APPLE)
+ set(WITH_CODEC_QUICKTIME OFF CACHE BOOL "" FORCE)
+endif()
+
diff --git a/build_files/cmake/project_info.py b/build_files/cmake/project_info.py
index 5d756a6320f..fcd4501f231 100755
--- a/build_files/cmake/project_info.py
+++ b/build_files/cmake/project_info.py
@@ -239,26 +239,5 @@ def cmake_compiler_defines():
return lines
-def project_name_get(path, fallback="Blender", prefix="Blender_"):
- if not os.path.isdir(os.path.join(path, ".svn")):
- return fallback
-
- import subprocess
- try:
- info = subprocess.Popen(["svn", "info", path],
- stdout=subprocess.PIPE).communicate()[0]
- except:
- # possibly 'svn' isnt found/installed
- return fallback
-
- # string version, we only want the URL
- info = info.decode(encoding="utf-8", errors="ignore")
-
- for l in info.split("\n"):
- l = l.strip()
- if l.startswith("URL"):
- # https://svn.blender.org/svnroot/bf-blender/branches/bmesh/blender
- # --> bmesh
- if "/branches/" in l:
- return prefix + l.rsplit("/branches/", 1)[-1].split("/", 1)[0]
- return fallback
+def project_name_get():
+ return cmake_cache_var("CMAKE_PROJECT_NAME")
diff --git a/build_files/scons/config/Modules/FindPython.py b/build_files/scons/config/Modules/FindPython.py
index f7956e96580..a0ead88ebb4 100644
--- a/build_files/scons/config/Modules/FindPython.py
+++ b/build_files/scons/config/Modules/FindPython.py
@@ -6,7 +6,7 @@ def FindPython():
python = "/usr"
abi_flags = "m" # Most common for linux distros
- version = "3.3"
+ version = "3.4"
_arch = platform.uname()[4] + "-linux-gnu"
diff --git a/build_files/scons/config/darwin-config.py b/build_files/scons/config/darwin-config.py
index b025cd8f8d4..aac7ed4fa04 100644
--- a/build_files/scons/config/darwin-config.py
+++ b/build_files/scons/config/darwin-config.py
@@ -26,10 +26,10 @@ BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib'
BF_FFMPEG_LIB = 'avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg bz2'
#bz2 is a standard osx dynlib
-BF_PYTHON_VERSION = '3.3'
+BF_PYTHON_VERSION = '3.4'
WITH_OSX_STATICPYTHON = True
-# python 3.3 uses precompiled libraries in bf svn /lib by default
+# python 3.4 uses precompiled libraries in bf svn /lib by default
BF_PYTHON = LIBDIR + '/python'
BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}m'
# BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}'
@@ -199,7 +199,7 @@ BF_BOOST_LIBPATH = '${BF_BOOST}/lib'
WITH_BF_CYCLES_CUDA_BINARIES = False
BF_CYCLES_CUDA_NVCC = '/usr/local/cuda/bin/nvcc'
-BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35']
+BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35', 'sm_50']
#Freestyle
WITH_BF_FREESTYLE = True
diff --git a/build_files/scons/config/freebsd8-config.py b/build_files/scons/config/freebsd8-config.py
deleted file mode 100644
index b7c6fed45c2..00000000000
--- a/build_files/scons/config/freebsd8-config.py
+++ /dev/null
@@ -1,205 +0,0 @@
-CC = 'gcc44'
-CXX = 'g++44'
-
-LCGDIR = '../lib/freebsd8'
-LIBDIR = "${LCGDIR}"
-
-BF_PYTHON_ABI_FLAGS = ''
-BF_PYTHON = '/usr/local'
-BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib'
-BF_PYTHON_VERSION = '3.3'
-WITH_BF_STATICPYTHON = False
-BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}${BF_PYTHON_ABI_FLAGS}'
-BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}'
-BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION}${BF_PYTHON_ABI_FLAGS}'
-BF_PYTHON_LIB_STATIC = '${BF_PYTHON}/lib/libpython${BF_PYTHON_VERSION}${BF_PYTHON_ABI_FLAGS}.a'
-
-WITH_BF_OPENAL = True
-WITH_BF_STATICOPENAL = False
-BF_OPENAL = '/usr/local'
-BF_OPENAL_INC = '${BF_OPENAL}/include'
-BF_OPENAL_LIB = 'openal'
-BF_OPENAL_LIB_STATIC = '${BF_OPENAL}/lib/libopenal.a'
-
-BF_CXX = '/usr/local'
-WITH_BF_STATICCXX = False
-BF_CXX_LIB_STATIC = '${BF_CXX}/lib/libstdc++.a'
-
-WITH_BF_JACK = True
-BF_JACK = '/usr/local'
-BF_JACK_INC = '${BF_JACK}/include/jack'
-BF_JACK_LIB = 'jack'
-BF_JACK_LIBPATH = '${BF_JACK}/lib'
-
-WITH_BF_SNDFILE = True
-BF_SNDFILE = '/usr/local'
-BF_SNDFILE_INC = '${BF_SNDFILE}/include/sndfile'
-BF_SNDFILE_LIB = 'sndfile'
-BF_SNDFILE_LIBPATH = '${BF_SNDFILE}/lib'
-
-WITH_BF_SDL = True
-BF_SDL = '/usr/local' #$(shell sdl-config --prefix)
-BF_SDL_INC = '${BF_SDL}/include/SDL' #$(shell $(BF_SDL)/bin/sdl-config --cflags)
-BF_SDL_LIB = 'SDL' #BF_SDL #$(shell $(BF_SDL)/bin/sdl-config --libs) -lSDL_mixer
-
-WITH_BF_OPENEXR = True
-WITH_BF_STATICOPENEXR = False
-BF_OPENEXR = '/usr/local'
-# when compiling with your own openexr lib you might need to set...
-# BF_OPENEXR_INC = '${BF_OPENEXR}/include/OpenEXR ${BF_OPENEXR}/include'
-
-BF_OPENEXR_INC = '${BF_OPENEXR}/include/OpenEXR'
-BF_OPENEXR_LIB = 'Half IlmImf Iex Imath '
-BF_OPENEXR_LIB_STATIC = '${BF_OPENEXR}/lib/libHalf.a ${BF_OPENEXR}/lib/libIlmImf.a ${BF_OPENEXR}/lib/libIex.a ${BF_OPENEXR}/lib/libImath.a ${BF_OPENEXR}/lib/libIlmThread.a'
-# BF_OPENEXR_LIBPATH = '${BF_OPENEXR}/lib'
-
-WITH_BF_DDS = True
-
-WITH_BF_JPEG = True
-BF_JPEG = '/usr/local'
-BF_JPEG_INC = '${BF_JPEG}/include'
-BF_JPEG_LIB = 'jpeg'
-
-WITH_BF_PNG = True
-BF_PNG = '/usr/local'
-BF_PNG_INC = '${BF_PNG}/include'
-BF_PNG_LIB = 'png'
-
-WITH_BF_TIFF = True
-BF_TIFF = '/usr/local'
-BF_TIFF_INC = '${BF_TIFF}/include'
-BF_TIFF_LIB = 'tiff'
-
-WITH_BF_ZLIB = True
-BF_ZLIB = '/usr'
-BF_ZLIB_INC = '${BF_ZLIB}/include'
-BF_ZLIB_LIB = 'z'
-
-WITH_BF_INTERNATIONAL = True
-
-WITH_BF_GAMEENGINE = False
-WITH_BF_PLAYER = True
-WITH_BF_OCEANSIM = True
-
-WITH_BF_BULLET = True
-BF_BULLET = '#extern/bullet2/src'
-BF_BULLET_INC = '${BF_BULLET}'
-BF_BULLET_LIB = 'extern_bullet'
-
-BF_FREETYPE = '/usr/local'
-BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2'
-BF_FREETYPE_LIB = 'freetype'
-
-WITH_BF_ICONV = True
-BF_ICONV = LIBDIR + "/iconv"
-BF_ICONV_INC = '${BF_ICONV}/include'
-BF_ICONV_LIB = 'iconv'
-BF_ICONV_LIBPATH = '${BF_ICONV}/lib'
-
-WITH_BF_BINRELOC = True
-
-# enable ffmpeg support
-WITH_BF_FFMPEG = True
-BF_FFMPEG = '/usr/local'
-BF_FFMPEG_LIB = 'avformat avcodec swscale avutil avdevice'
-BF_FFMPEG_INC = '${BF_FFMPEG}/include'
-BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib'
-
-# enable ogg, vorbis and theora in ffmpeg
-WITH_BF_OGG = True
-BF_OGG = '/usr/local'
-BF_OGG_INC = '${BF_OGG}/include'
-BF_OGG_LIB = 'ogg vorbis vorbisenc theoraenc theoradec'
-
-WITH_BF_OPENJPEG = True
-BF_OPENJPEG = '#extern/libopenjpeg'
-BF_OPENJPEG_LIB = ''
-BF_OPENJPEG_INC = '${BF_OPENJPEG}'
-BF_OPENJPEG_LIBPATH='${BF_OPENJPEG}/lib'
-
-WITH_BF_FFTW3 = True
-BF_FFTW3 = LIBDIR + '/usr/local'
-BF_FFTW3_INC = '${BF_FFTW3}/include'
-BF_FFTW3_LIB = 'fftw3'
-BF_FFTW3_LIBPATH = '${BF_FFTW3}/lib'
-
-WITH_BF_REDCODE = False
-BF_REDCODE = '#extern/libredcode'
-BF_REDCODE_LIB = ''
-# BF_REDCODE_INC = '${BF_REDCODE}/include'
-BF_REDCODE_INC = '${BF_REDCODE}/../' #C files request "libredcode/format.h" which is in "#extern/libredcode/format.h", stupid but compiles for now.
-BF_REDCODE_LIBPATH='${BF_REDCODE}/lib'
-
-# Mesa Libs should go here if your using them as well....
-WITH_BF_STATICOPENGL = False
-BF_OPENGL = '/usr/local'
-BF_OPENGL_INC = '${BF_OPENGL}/include'
-BF_OPENGL_LIB = 'GL GLU X11 Xi Xxf86vm'
-BF_OPENGL_LIBPATH = '/usr/X11R6/lib'
-BF_OPENGL_LIB_STATIC = '${BF_OPENGL_LIBPATH}/libGL.a ${BF_OPENGL_LIBPATH}/libGLU.a ${BF_OPENGL_LIBPATH}/libXxf86vm.a ${BF_OPENGL_LIBPATH}/libX11.a ${BF_OPENGL_LIBPATH}/libXi.a ${BF_OPENGL_LIBPATH}/libXext.a ${BF_OPENGL_LIBPATH}/libXxf86vm.a'
-
-WITH_BF_COLLADA = False
-BF_COLLADA = '#source/blender/collada'
-BF_COLLADA_INC = '${BF_COLLADA}'
-BF_COLLADA_LIB = 'bf_collada'
-BF_OPENCOLLADA = '/usr'
-BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}'
-BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver pcre buffer ftoa'
-BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib'
-BF_PCRE = '/usr/local'
-BF_PCRE_LIB = 'pcre'
-BF_PCRE_LIBPATH = '${BF_PCRE}/lib'
-BF_EXPAT = '/usr/local'
-BF_EXPAT_LIB = 'expat'
-BF_EXPAT_LIBPATH = '${BF_EXPAT}/lib'
-
-WITH_BF_OPENMP = True
-
-WITH_GHOST_XDND = False
-
-#Freestyle
-WITH_BF_FREESTYLE = True
-
-#Ray trace optimization
-WITH_BF_RAYOPTIMIZATION = True
-BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse','-pthread']
-
-CCFLAGS = ['-pipe','-fPIC','-funsigned-char','-fno-strict-aliasing','-D_LARGEFILE_SOURCE','-D_FILE_OFFSET_BITS=64','-D_LARGEFILE64_SOURCE']
-
-CPPFLAGS = []
-CXXFLAGS = []
-if WITH_BF_FFMPEG:
- # libavutil needs UINT64_C()
- CXXFLAGS += ['-D__STDC_CONSTANT_MACROS', ]
-REL_CFLAGS = []
-REL_CXXFLAGS = []
-REL_CCFLAGS = ['-DNDEBUG', '-O2']
-##BF_DEPEND = True
-##
-##AR = ar
-##ARFLAGS = ruv
-##ARFLAGSQUIET = ru
-##
-C_WARN = ['-Wno-char-subscripts', '-Wdeclaration-after-statement', '-Wstrict-prototypes']
-CC_WARN = ['-Wall']
-CXX_WARN = ['-Wno-invalid-offsetof', '-Wno-sign-compare']
-
-
-##FIX_STUBS_WARNINGS = -Wno-unused
-
-LLIBS = ['util', 'c', 'm', 'pthread', 'stdc++']
-##LOPTS = --dynamic
-##DYNLDFLAGS = -shared $(LDFLAGS)
-
-BF_PROFILE = False
-BF_PROFILE_CCFLAGS = ['-pg','-g']
-BF_PROFILE_LINKFLAGS = ['-pg']
-
-BF_DEBUG = False
-BF_DEBUG_CCFLAGS = ['-g', '-D_DEBUG']
-
-BF_BUILDDIR = '../build/freebsd8'
-BF_INSTALLDIR='../install/freebsd8'
-
-#Link against pthread
-PLATFORM_LINKFLAGS = ['-pthread']
diff --git a/build_files/scons/config/freebsd9-config.py b/build_files/scons/config/freebsd9-config.py
deleted file mode 100644
index 8535ececb24..00000000000
--- a/build_files/scons/config/freebsd9-config.py
+++ /dev/null
@@ -1,210 +0,0 @@
-CC = 'gcc44'
-CXX = 'g++44'
-
-LCGDIR = '../lib/freebsd9'
-LIBDIR = "${LCGDIR}"
-
-BF_PYTHON_ABI_FLAGS = ''
-BF_PYTHON = '/usr/local'
-BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib'
-BF_PYTHON_VERSION = '3.3'
-WITH_BF_STATICPYTHON = False
-BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}${BF_PYTHON_ABI_FLAGS}'
-BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}'
-BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION}${BF_PYTHON_ABI_FLAGS}'
-BF_PYTHON_LIB_STATIC = '${BF_PYTHON}/lib/libpython${BF_PYTHON_VERSION}${BF_PYTHON_ABI_FLAGS}.a'
-
-WITH_BF_OPENAL = True
-WITH_BF_STATICOPENAL = False
-BF_OPENAL = '/usr/local'
-BF_OPENAL_INC = '${BF_OPENAL}/include'
-BF_OPENAL_LIB = 'openal'
-BF_OPENAL_LIB_STATIC = '${BF_OPENAL}/lib/libopenal.a'
-
-BF_CXX = '/usr/local'
-WITH_BF_STATICCXX = False
-BF_CXX_LIB_STATIC = '${BF_CXX}/lib/libstdc++.a'
-
-WITH_BF_JACK = True
-BF_JACK = '/usr/local'
-BF_JACK_INC = '${BF_JACK}/include/jack'
-BF_JACK_LIB = 'jack'
-BF_JACK_LIBPATH = '${BF_JACK}/lib'
-
-WITH_BF_SNDFILE = True
-BF_SNDFILE = '/usr/local'
-BF_SNDFILE_INC = '${BF_SNDFILE}/include/sndfile'
-BF_SNDFILE_LIB = 'sndfile'
-BF_SNDFILE_LIBPATH = '${BF_SNDFILE}/lib'
-
-WITH_BF_SDL = True
-BF_SDL = '/usr/local' #$(shell sdl-config --prefix)
-BF_SDL_INC = '${BF_SDL}/include/SDL' #$(shell $(BF_SDL)/bin/sdl-config --cflags)
-BF_SDL_LIB = 'SDL' #BF_SDL #$(shell $(BF_SDL)/bin/sdl-config --libs) -lSDL_mixer
-
-WITH_BF_OPENEXR = True
-WITH_BF_STATICOPENEXR = False
-BF_OPENEXR = '/usr/local'
-# when compiling with your own openexr lib you might need to set...
-# BF_OPENEXR_INC = '${BF_OPENEXR}/include/OpenEXR ${BF_OPENEXR}/include'
-
-BF_OPENEXR_INC = '${BF_OPENEXR}/include/OpenEXR'
-BF_OPENEXR_LIB = 'Half IlmImf Iex Imath '
-BF_OPENEXR_LIB_STATIC = '${BF_OPENEXR}/lib/libHalf.a ${BF_OPENEXR}/lib/libIlmImf.a ${BF_OPENEXR}/lib/libIex.a ${BF_OPENEXR}/lib/libImath.a ${BF_OPENEXR}/lib/libIlmThread.a'
-# BF_OPENEXR_LIBPATH = '${BF_OPENEXR}/lib'
-
-WITH_BF_DDS = True
-
-WITH_BF_JPEG = True
-BF_JPEG = '/usr/local'
-BF_JPEG_INC = '${BF_JPEG}/include'
-BF_JPEG_LIB = 'jpeg'
-
-WITH_BF_PNG = True
-BF_PNG = '/usr/local'
-BF_PNG_INC = '${BF_PNG}/include'
-BF_PNG_LIB = 'png'
-
-WITH_BF_TIFF = True
-BF_TIFF = '/usr/local'
-BF_TIFF_INC = '${BF_TIFF}/include'
-BF_TIFF_LIB = 'tiff'
-
-WITH_BF_ZLIB = True
-BF_ZLIB = '/usr'
-BF_ZLIB_INC = '${BF_ZLIB}/include'
-BF_ZLIB_LIB = 'z'
-
-WITH_BF_INTERNATIONAL = True
-
-WITH_BF_GAMEENGINE = False
-WITH_BF_PLAYER = True
-WITH_BF_OCEANSIM = True
-
-WITH_BF_BULLET = True
-BF_BULLET = '#extern/bullet2/src'
-BF_BULLET_INC = '${BF_BULLET}'
-BF_BULLET_LIB = 'extern_bullet'
-
-BF_FREETYPE = '/usr/local'
-BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2'
-BF_FREETYPE_LIB = 'freetype'
-
-### XXX Find what this actually wants; it doesn't want libquicktime.
-WITH_BF_QUICKTIME = False
-BF_QUICKTIME = '/usr/local'
-BF_QUICKTIME_INC = '${BF_QUICKTIME}/include'
-
-WITH_BF_ICONV = True
-BF_ICONV = LIBDIR + "/iconv"
-BF_ICONV_INC = '${BF_ICONV}/include'
-BF_ICONV_LIB = 'iconv'
-BF_ICONV_LIBPATH = '${BF_ICONV}/lib'
-
-WITH_BF_BINRELOC = True
-
-# enable ffmpeg support
-WITH_BF_FFMPEG = True
-BF_FFMPEG = '/usr/local'
-BF_FFMPEG_LIB = 'avformat avcodec swscale avutil avdevice'
-BF_FFMPEG_INC = '${BF_FFMPEG}/include'
-BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib'
-
-# enable ogg, vorbis and theora in ffmpeg
-WITH_BF_OGG = True
-BF_OGG = '/usr/local'
-BF_OGG_INC = '${BF_OGG}/include'
-BF_OGG_LIB = 'ogg vorbis vorbisenc theoraenc theoradec'
-
-WITH_BF_OPENJPEG = True
-BF_OPENJPEG = '#extern/libopenjpeg'
-BF_OPENJPEG_LIB = ''
-BF_OPENJPEG_INC = '${BF_OPENJPEG}'
-BF_OPENJPEG_LIBPATH='${BF_OPENJPEG}/lib'
-
-WITH_BF_FFTW3 = True
-BF_FFTW3 = LIBDIR + '/usr/local'
-BF_FFTW3_INC = '${BF_FFTW3}/include'
-BF_FFTW3_LIB = 'fftw3'
-BF_FFTW3_LIBPATH = '${BF_FFTW3}/lib'
-
-WITH_BF_REDCODE = False
-BF_REDCODE = '#extern/libredcode'
-BF_REDCODE_LIB = ''
-# BF_REDCODE_INC = '${BF_REDCODE}/include'
-BF_REDCODE_INC = '${BF_REDCODE}/../' #C files request "libredcode/format.h" which is in "#extern/libredcode/format.h", stupid but compiles for now.
-BF_REDCODE_LIBPATH='${BF_REDCODE}/lib'
-
-# Mesa Libs should go here if your using them as well....
-WITH_BF_STATICOPENGL = False
-BF_OPENGL = '/usr/local'
-BF_OPENGL_INC = '${BF_OPENGL}/include'
-BF_OPENGL_LIB = 'GL GLU X11 Xi Xxf86vm'
-BF_OPENGL_LIBPATH = '/usr/X11R6/lib'
-BF_OPENGL_LIB_STATIC = '${BF_OPENGL_LIBPATH}/libGL.a ${BF_OPENGL_LIBPATH}/libGLU.a ${BF_OPENGL_LIBPATH}/libXxf86vm.a ${BF_OPENGL_LIBPATH}/libX11.a ${BF_OPENGL_LIBPATH}/libXi.a ${BF_OPENGL_LIBPATH}/libXext.a ${BF_OPENGL_LIBPATH}/libXxf86vm.a'
-
-WITH_BF_COLLADA = False
-BF_COLLADA = '#source/blender/collada'
-BF_COLLADA_INC = '${BF_COLLADA}'
-BF_COLLADA_LIB = 'bf_collada'
-BF_OPENCOLLADA = '/usr'
-BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}'
-BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver pcre buffer ftoa'
-BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib'
-BF_PCRE = '/usr/local'
-BF_PCRE_LIB = 'pcre'
-BF_PCRE_LIBPATH = '${BF_PCRE}/lib'
-BF_EXPAT = '/usr/local'
-BF_EXPAT_LIB = 'expat'
-BF_EXPAT_LIBPATH = '${BF_EXPAT}/lib'
-
-WITH_BF_OPENMP = True
-
-WITH_GHOST_XDND = False
-
-#Freestyle
-WITH_BF_FREESTYLE = True
-
-#Ray trace optimization
-WITH_BF_RAYOPTIMIZATION = True
-BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse','-pthread']
-
-CCFLAGS = ['-pipe','-fPIC','-funsigned-char','-fno-strict-aliasing','-D_LARGEFILE_SOURCE','-D_FILE_OFFSET_BITS=64','-D_LARGEFILE64_SOURCE']
-CXXFLAGS = []
-
-CPPFLAGS = []
-if WITH_BF_FFMPEG:
- # libavutil needs UINT64_C()
- CXXFLAGS += ['-D__STDC_CONSTANT_MACROS', ]
-REL_CFLAGS = []
-REL_CXXFLAGS = []
-REL_CCFLAGS = ['-DNDEBUG', '-O2']
-##BF_DEPEND = True
-##
-##AR = ar
-##ARFLAGS = ruv
-##ARFLAGSQUIET = ru
-##
-C_WARN = ['-Wno-char-subscripts', '-Wdeclaration-after-statement', '-Wstrict-prototypes']
-CC_WARN = ['-Wall']
-CXX_WARN = ['-Wno-invalid-offsetof', '-Wno-sign-compare']
-
-
-##FIX_STUBS_WARNINGS = -Wno-unused
-
-LLIBS = ['util', 'c', 'm', 'pthread', 'stdc++']
-##LOPTS = --dynamic
-##DYNLDFLAGS = -shared $(LDFLAGS)
-
-BF_PROFILE = False
-BF_PROFILE_CCFLAGS = ['-pg','-g']
-BF_PROFILE_LINKFLAGS = ['-pg']
-
-BF_DEBUG = False
-BF_DEBUG_CCFLAGS = ['-g', '-D_DEBUG']
-
-BF_BUILDDIR = '../build/freebsd9'
-BF_INSTALLDIR='../install/freebsd9'
-
-#Link against pthread
-PLATFORM_LINKFLAGS = ['-pthread']
diff --git a/build_files/scons/config/linux-config.py b/build_files/scons/config/linux-config.py
index ce2d07f782c..8f2c5ca30f4 100644
--- a/build_files/scons/config/linux-config.py
+++ b/build_files/scons/config/linux-config.py
@@ -206,7 +206,7 @@ WITH_BF_CYCLES = WITH_BF_OIIO and WITH_BF_BOOST
WITH_BF_CYCLES_CUDA_BINARIES = False
BF_CYCLES_CUDA_NVCC = '/usr/local/cuda/bin/nvcc'
-BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35']
+BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35', 'sm_50']
WITH_BF_OPENMP = True
diff --git a/build_files/scons/config/linuxcross-config.py b/build_files/scons/config/linuxcross-config.py
deleted file mode 100644
index 36b29a309af..00000000000
--- a/build_files/scons/config/linuxcross-config.py
+++ /dev/null
@@ -1,189 +0,0 @@
-LCGDIR = '#../lib/windows'
-LIBDIR = '${LCGDIR}'
-
-BF_PYTHON = LIBDIR + '/python'
-BF_PYTHON_VERSION = '3.3'
-BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}'
-BF_PYTHON_BINARY = 'python'
-BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION[0]}${BF_PYTHON_VERSION[2]}mw'
-BF_PYTHON_DLL = 'python31'
-BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib'
-
-WITH_BF_OPENAL = True
-WITH_BF_STATICOPENAL = False
-BF_OPENAL = LIBDIR + '/openal'
-BF_OPENAL_INC = '${BF_OPENAL}/include'
-BF_OPENAL_LIB = 'OpenAL32 wrap_oal'
-BF_OPENAL_LIBPATH = '${BF_OPENAL}/lib'
-# Warning, this static lib configuration is untested! users of this OS please confirm.
-BF_OPENAL_LIB_STATIC = '${BF_OPENAL}/lib/libopenal.a'
-
-# Warning, this static lib configuration is untested! users of this OS please confirm.
-BF_CXX = '/usr'
-WITH_BF_STATICCXX = False
-BF_CXX_LIB_STATIC = '${BF_CXX}/lib/libstdc++.a'
-
-WITH_BF_SDL = True
-BF_SDL = LIBDIR + '/sdl'
-BF_SDL_INC = '${BF_SDL}/include'
-BF_SDL_LIB = 'SDL'
-BF_SDL_LIBPATH = '${BF_SDL}/lib'
-
-WITH_BF_JACK = False
-BF_JACK = LIBDIR + '/jack'
-BF_JACK_INC = '${BF_JACK}/include'
-BF_JACK_LIB = 'jack'
-BF_JACK_LIBPATH = '${BF_JACK}/lib'
-
-WITH_BF_SNDFILE = False
-BF_SNDFILE = LIBDIR + '/sndfile'
-BF_SNDFILE_INC = '${BF_SNDFILE}/include'
-BF_SNDFILE_LIB = 'sndfile-1'
-BF_SNDFILE_LIBPATH = '${BF_SNDFILE}/lib'
-
-BF_PTHREADS = LIBDIR + '/pthreads'
-BF_PTHREADS_INC = '${BF_PTHREADS}/include'
-BF_PTHREADS_LIB = 'pthreadGC2'
-BF_PTHREADS_LIBPATH = '${BF_PTHREADS}/lib'
-
-WITH_BF_OPENEXR = True
-WITH_BF_STATICOPENEXR = False
-BF_OPENEXR = LIBDIR + '/gcc/openexr'
-BF_OPENEXR_INC = '${BF_OPENEXR}/include ${BF_OPENEXR}/include/OpenEXR'
-BF_OPENEXR_LIB = ' Half IlmImf Iex IlmThread '
-BF_OPENEXR_LIBPATH = '${BF_OPENEXR}/lib'
-# Warning, this static lib configuration is untested! users of this OS please confirm.
-BF_OPENEXR_LIB_STATIC = '${BF_OPENEXR}/lib/libHalf.a ${BF_OPENEXR}/lib/libIlmImf.a ${BF_OPENEXR}/lib/libIex.a ${BF_OPENEXR}/lib/libImath.a ${BF_OPENEXR}/lib/libIlmThread.a'
-
-WITH_BF_DDS = True
-
-WITH_BF_JPEG = True
-BF_JPEG = LIBDIR + '/jpeg'
-BF_JPEG_INC = '${BF_JPEG}/include'
-BF_JPEG_LIB = 'libjpeg'
-BF_JPEG_LIBPATH = '${BF_JPEG}/lib'
-
-WITH_BF_PNG = True
-BF_PNG = LIBDIR + '/png'
-BF_PNG_INC = '${BF_PNG}/include'
-BF_PNG_LIB = 'png'
-BF_PNG_LIBPATH = '${BF_PNG}/lib'
-
-WITH_BF_TIFF = True
-BF_TIFF = LIBDIR + '/gcc/tiff'
-BF_TIFF_INC = '${BF_TIFF}/include'
-BF_TIFF_LIB = 'tiff'
-BF_TIFF_LIBPATH = '${BF_TIFF}/lib'
-
-WITH_BF_ZLIB = True
-BF_ZLIB = LIBDIR + '/zlib'
-BF_ZLIB_INC = '${BF_ZLIB}/include'
-BF_ZLIB_LIB = 'libz_st'
-BF_ZLIB_LIBPATH = '${BF_ZLIB}/lib'
-
-WITH_BF_INTERNATIONAL = True
-
-WITH_BF_GAMEENGINE = True
-WITH_BF_PLAYER = False
-WITH_BF_OCEANSIM = True
-
-WITH_BF_BULLET = True
-BF_BULLET = '#extern/bullet2/src'
-BF_BULLET_INC = '${BF_BULLET}'
-BF_BULLET_LIB = 'extern_bullet'
-
-BF_WINTAB = LIBDIR + '/wintab'
-BF_WINTAB_INC = '${BF_WINTAB}/INCLUDE'
-
-BF_WITH_FREETYPE = True
-BF_FREETYPE = LIBDIR + '/gcc/freetype'
-BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2'
-BF_FREETYPE_LIB = 'freetype'
-BF_FREETYPE_LIBPATH = '${BF_FREETYPE}/lib'
-
-WITH_BF_ICONV = False
-BF_ICONV = LIBDIR + "/gcc/iconv"
-BF_ICONV_INC = '${BF_ICONV}/include'
-BF_ICONV_LIB = 'iconv'
-BF_ICONV_LIBPATH = '${BF_ICONV}/lib'
-
-WITH_BF_BINRELOC = False
-
-# enable ffmpeg support
-WITH_BF_FFMPEG = True
-BF_FFMPEG = LIBDIR + '/ffmpeg'
-BF_FFMPEG_LIB = 'avformat-53 avcodec-53 avdevice-53 avutil-51 swscale-2'
-BF_FFMPEG_DLL = '${BF_FFMPEG_LIBPATH}/avformat-53.dll ${BF_FFMPEG_LIBPATH}/avcodec-53.dll ${BF_FFMPEG_LIBPATH}/avdevice-53.dll ${BF_FFMPEG_LIBPATH}/avutil-51.dll ${BF_FFMPEG_LIBPATH}/swscale-2.dll'
-BF_FFMPEG_INC = '${BF_FFMPEG}/include'
-BF_FFMPEG_LIBPATH = '${BF_FFMPEG}/lib'
-BF_FFMPEG_DLL = '${BF_FFMPEG_LIBPATH}/avformat-53.dll ${BF_FFMPEG_LIBPATH}/avcodec-53.dll ${BF_FFMPEG_LIBPATH}/avdevice-53.dll ${BF_FFMPEG_LIBPATH}/avutil-51.dll ${BF_FFMPEG_LIBPATH}/swscale-2.dll'
-
-WITH_BF_OPENJPEG = True
-BF_OPENJPEG = '#extern/libopenjpeg'
-BF_OPENJPEG_LIB = ''
-BF_OPENJPEG_INC = '${BF_OPENJPEG}'
-BF_OPENJPEG_LIBPATH='${BF_OPENJPEG}/lib'
-
-WITH_BF_FFTW3 = False
-BF_FFTW3 = LIBDIR + '/gcc/fftw3'
-BF_FFTW3_INC = '${BF_FFTW3}/include'
-BF_FFTW3_LIB = 'fftw3'
-BF_FFTW3_LIBPATH = '${BF_FFTW3}/lib'
-
-WITH_BF_REDCODE = False
-BF_REDCODE_INC = '#extern'
-
-# Mesa Libs should go here if your using them as well....
-WITH_BF_STATICOPENGL = False
-BF_OPENGL = 'C:\\MingW'
-BF_OPENGL_INC = '${BF_OPENGL}/include'
-BF_OPENGL_LIBINC = '${BF_OPENGL}/lib'
-BF_OPENGL_LIB = 'opengl32 glu32'
-BF_OPENGL_LIB_STATIC = [ '${BF_OPENGL}/lib/libGL.a', '${BF_OPENGL}/lib/libGLU.a']
-
-WITH_BF_OPENMP = False
-BF_OPENMP = LIBDIR + '/gcc/gomp'
-BF_OPENMP_INC = '${BF_OPENMP}/include'
-BF_OPENMP_LIBPATH = '${BF_OPENMP}/lib'
-
-WITH_BF_COLLADA = False
-BF_COLLADA = '#source/blender/collada'
-BF_COLLADA_INC = '${BF_COLLADA}'
-BF_COLLADA_LIB = 'bf_collada'
-
-BF_OPENCOLLADA = LIBDIR + '/gcc/opencollada'
-BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}/include'
-BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver expat pcre buffer ftoa'
-BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib ${BF_ICONV_LIBPATH}'
-
-#Freestyle
-WITH_BF_FREESTYLE = True
-
-#Ray trace optimization
-WITH_BF_RAYOPTIMIZATION = True
-BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse']
-
-CCFLAGS = [ '-pipe', '-funsigned-char', '-fno-strict-aliasing' ]
-CXXFLAGS = []
-
-CPPFLAGS = ['-DWIN32', '-DFREE_WINDOWS', '-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE64_SOURCE']
-REL_CFLAGS = []
-REL_CXXFLAGS = []
-REL_CCFLAGS = ['-DNDEBUG', '-O2']
-C_WARN = ['-Wall', '-Wstrict-prototypes', '-Wno-char-subscripts', '-Wdeclaration-after-statement']
-
-CC_WARN = [ '-Wall' ]
-
-LLIBS = [ '-ldxguid', '-lgdi32', '-lmsvcrt', '-lwinmm', '-lmingw32', '-lm', '-lws2_32', '-lz', '-lstdc++', '-luuid', '-lole32'] #'-lutil', '-lc', '-lm', '-ldl', '-lpthread' ]
-
-PLATFORM_LINKFLAGS = ['--stack,2097152']
-
-BF_DEBUG = False
-BF_DEBUG_CCFLAGS = ['-g', '-D_DEBUG']
-
-BF_PROFILE = False
-BF_PROFILE_CCFLAGS = ['-pg','-g']
-BF_PROFILE_LINKFLAGS = ['-pg']
-
-BF_BUILDDIR = '../build/linuxcross'
-BF_INSTALLDIR='../install/linuxcross'
diff --git a/build_files/scons/config/win32-mingw-config.py b/build_files/scons/config/win32-mingw-config.py
index 470987bfad6..a6d1a7d7996 100644
--- a/build_files/scons/config/win32-mingw-config.py
+++ b/build_files/scons/config/win32-mingw-config.py
@@ -2,12 +2,12 @@ LCGDIR = '#../lib/mingw32'
LIBDIR = "${LCGDIR}"
BF_PYTHON = LIBDIR + '/python'
-BF_PYTHON_VERSION = '3.3'
+BF_PYTHON_VERSION = '3.4'
WITH_BF_STATICPYTHON = False
BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}'
BF_PYTHON_BINARY = 'python'
BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION[0]}${BF_PYTHON_VERSION[2]}mw'
-BF_PYTHON_DLL = 'python33'
+BF_PYTHON_DLL = 'python${BF_PYTHON_VERSION[0]}${BF_PYTHON_VERSION[2]}'
BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib'
BF_PYTHON_LIB_STATIC = '${BF_PYTHON}/lib/libpython${BF_PYTHON_VERSION[0]}${BF_PYTHON_VERSION[2]}.a'
@@ -145,7 +145,7 @@ BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib/opencollada'
WITH_BF_CYCLES = True
WITH_BF_CYCLES_CUDA_BINARIES = False
BF_CYCLES_CUDA_NVCC = "" # Path to the NVIDIA CUDA compiler
-BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35']
+BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35', 'sm_50']
WITH_BF_OIIO = True
BF_OIIO = LIBDIR + '/openimageio'
@@ -175,7 +175,7 @@ WITH_BF_OPENMP = True
#CUDA
WITH_BF_CYCLES_CUDA_BINARIES = False
#BF_CYCLES_CUDA_NVCC = "" # Path to the nvidia compiler
-BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30']
+BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35', 'sm_50']
#Freestyle
WITH_BF_FREESTYLE = True
diff --git a/build_files/scons/config/win32-vc-config.py b/build_files/scons/config/win32-vc-config.py
index b01d5aa85f3..54ab4af318e 100644
--- a/build_files/scons/config/win32-vc-config.py
+++ b/build_files/scons/config/win32-vc-config.py
@@ -31,13 +31,15 @@ else:
BF_FFMPEG_DLL = '${BF_FFMPEG_LIBPATH}/avformat-55.dll ${BF_FFMPEG_LIBPATH}/avcodec-55.dll ${BF_FFMPEG_LIBPATH}/avdevice-55.dll ${BF_FFMPEG_LIBPATH}/avutil-52.dll ${BF_FFMPEG_LIBPATH}/swscale-2.dll'
BF_PYTHON = LIBDIR + '/python'
-BF_PYTHON_VERSION = '3.3'
+BF_PYTHON_VERSION = '3.4'
BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}'
BF_PYTHON_BINARY = 'python'
-BF_PYTHON_LIB = 'python33'
+BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION[0]}${BF_PYTHON_VERSION[2]}'
BF_PYTHON_DLL = '${BF_PYTHON_LIB}'
BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib'
+WITH_BF_PYTHON_INSTALL_NUMPY = False
+
WITH_BF_OPENAL = True
BF_OPENAL = LIBDIR + '/openal'
BF_OPENAL_INC = '${BF_OPENAL}/include '
@@ -226,7 +228,7 @@ WITH_BF_CYCLES_CUDA_BINARIES = False
if VC_VERSION == '11.0':
BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30']
else:
- BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35']
+ BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35', 'sm_50']
#Ray trace optimization
WITH_BF_RAYOPTIMIZATION = True
diff --git a/build_files/scons/config/win64-mingw-config.py b/build_files/scons/config/win64-mingw-config.py
index bb55354d591..dcdea6583d7 100644
--- a/build_files/scons/config/win64-mingw-config.py
+++ b/build_files/scons/config/win64-mingw-config.py
@@ -2,12 +2,12 @@ LCGDIR = '#../lib/mingw64'
LIBDIR = "${LCGDIR}"
BF_PYTHON = LIBDIR + '/python'
-BF_PYTHON_VERSION = '3.3'
+BF_PYTHON_VERSION = '3.4'
WITH_BF_STATICPYTHON = False
BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}'
BF_PYTHON_BINARY = 'python'
BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION[0]}${BF_PYTHON_VERSION[2]}mw'
-BF_PYTHON_DLL = 'python33'
+BF_PYTHON_DLL = 'python${BF_PYTHON_VERSION[0]}${BF_PYTHON_VERSION[2]}'
BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib'
WITH_BF_OPENAL = True
@@ -144,7 +144,7 @@ BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib/opencollada'
WITH_BF_CYCLES = True
WITH_BF_CYCLES_CUDA_BINARIES = False
BF_CYCLES_CUDA_NVCC = "" # Path to the NVIDIA CUDA compiler
-BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35']
+BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35', 'sm_50']
WITH_BF_OIIO = True
BF_OIIO = LIBDIR + '/openimageio'
@@ -169,8 +169,7 @@ BF_BOOST_LIBPATH = '${BF_BOOST}/lib'
WITH_BF_RAYOPTIMIZATION = True
BF_RAYOPTIMIZATION_SSE_FLAGS = ['-mmmx', '-msse', '-msse2']
-#May produce errors with unsupported MinGW-w64 builds
-WITH_BF_OPENMP = False
+WITH_BF_OPENMP = True
#Freestyle
WITH_BF_FREESTYLE = True
diff --git a/build_files/scons/config/win64-vc-config.py b/build_files/scons/config/win64-vc-config.py
index 5922c77e50c..87af137814f 100644
--- a/build_files/scons/config/win64-vc-config.py
+++ b/build_files/scons/config/win64-vc-config.py
@@ -32,13 +32,15 @@ else:
BF_PYTHON = LIBDIR + '/python'
-BF_PYTHON_VERSION = '3.3'
+BF_PYTHON_VERSION = '3.4'
BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}'
BF_PYTHON_BINARY = 'python'
-BF_PYTHON_LIB = 'python33'
+BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION[0]}${BF_PYTHON_VERSION[2]}'
BF_PYTHON_DLL = '${BF_PYTHON_LIB}'
BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib'
+WITH_BF_PYTHON_INSTALL_NUMPY = False
+
WITH_BF_OPENAL = True
BF_OPENAL = LIBDIR + '/openal'
BF_OPENAL_INC = '${BF_OPENAL}/include '
@@ -224,7 +226,7 @@ BF_BOOST_LIBPATH = '${BF_BOOST}/lib'
#CUDA
WITH_BF_CYCLES_CUDA_BINARIES = False
#BF_CYCLES_CUDA_NVCC = "" # Path to the nvidia compiler
-BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35']
+BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35', 'sm_50']
#Ray trace optimization
WITH_BF_RAYOPTIMIZATION = True
diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py
index 29e04baf955..496f90d0bea 100644
--- a/build_files/scons/tools/Blender.py
+++ b/build_files/scons/tools/Blender.py
@@ -629,16 +629,17 @@ def WinPyBundle(target=None, source=None, env=None):
# -------------
# Extract Numpy
- py_tar = env.subst(env['LCGDIR']).lstrip("#")
- py_tar += '/release/python' + env['BF_PYTHON_VERSION'].replace('.','') + '_numpy_1.8.tar.gz'
-
- py_target = env.subst(env['BF_INSTALLDIR']).lstrip("#")
- py_target = os.path.join(py_target, VERSION, 'python', 'lib', 'site-packages')
- # rmtree handled above
- # files are cleaned up in their archive
- exclude_re = []
- print("Unpacking '" + py_tar + "' to '" + py_target + "'")
- untar_pybundle(py_tar, py_target, exclude_re)
+ if env['WITH_BF_PYTHON_INSTALL_NUMPY']:
+ py_tar = env.subst(env['LCGDIR']).lstrip("#")
+ py_tar += '/release/python' + env['BF_PYTHON_VERSION'].replace('.','') + '_numpy_1.8.tar.gz'
+
+ py_target = env.subst(env['BF_INSTALLDIR']).lstrip("#")
+ py_target = os.path.join(py_target, VERSION, 'python', 'lib', 'site-packages')
+ # rmtree handled above
+ # files are cleaned up in their archive
+ exclude_re = []
+ print("Unpacking '" + py_tar + "' to '" + py_target + "'")
+ untar_pybundle(py_tar, py_target, exclude_re)
# --------------------
# Copy 'site-packages'
diff --git a/doc/python_api/rst_from_bmesh_opdefines.py b/doc/python_api/rst_from_bmesh_opdefines.py
index 977d3171393..32afe335089 100644
--- a/doc/python_api/rst_from_bmesh_opdefines.py
+++ b/doc/python_api/rst_from_bmesh_opdefines.py
@@ -113,7 +113,7 @@ def main():
fsrc.close()
del fsrc
- # namespace hack
+ # namespace hack
vars = (
"BMO_OP_SLOT_ELEMENT_BUF",
"BMO_OP_SLOT_BOOL",
diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py
index 4cea81d5cf0..98bf6bf2eed 100644
--- a/doc/python_api/sphinx_doc_gen.py
+++ b/doc/python_api/sphinx_doc_gen.py
@@ -62,7 +62,7 @@ Sphinx: PDF generation
try:
import bpy # blender module
-except:
+except ImportError:
print("\nERROR: this script must run from inside Blender")
print(SCRIPT_HELP_MSG)
import sys
@@ -982,6 +982,7 @@ context_type_map = {
"image_paint_object": ("Object", False),
"lamp": ("Lamp", False),
"lattice": ("Lattice", False),
+ "line_style": ("FreestyleLineStyle", False),
"material": ("Material", False),
"material_slot": ("MaterialSlot", False),
"mesh": ("Mesh", False),
diff --git a/extern/bullet2/CMakeLists.txt b/extern/bullet2/CMakeLists.txt
index a05f20eab64..2b2c18c0685 100644
--- a/extern/bullet2/CMakeLists.txt
+++ b/extern/bullet2/CMakeLists.txt
@@ -401,16 +401,6 @@ set(SRC
if(CMAKE_COMPILER_IS_GNUCXX)
# needed for gcc 4.6+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
-
-endif()
-
-if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER_ID MATCHES "Clang")
- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffast-math")
-endif()
-
-# Tentative fix for bullet misbehavior (T38746), needs further clarification what flags conflict here
-if(APPLE AND CMAKE_C_COMPILER_ID MATCHES "Clang" AND NOT ${CMAKE_C_COMPILER_VERSION} VERSION_LESS '3.4')
- SET_SOURCE_FILES_PROPERTIES(src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp COMPILE_FLAGS "-O0")
endif()
blender_add_lib(extern_bullet "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverBody.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverBody.h
index 27ccefe4169..8e4456e617a 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverBody.h
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverBody.h
@@ -37,8 +37,13 @@ struct btSimdScalar
{
}
-
+/* workaround for clang 3.4 ( == apple clang 5.1 ) issue, friction would fail with forced inlining */
+#if (defined(__clang__) && defined(__apple_build_version__) && (__clang_major__ == 5) && (__clang_minor__ == 1)) \
+|| (defined(__clang__) && !defined(__apple_build_version__) && (__clang_major__ == 3) && (__clang_minor__ == 4))
+ inline __attribute__ ((noinline)) btSimdScalar(float fl)
+#else
SIMD_FORCE_INLINE btSimdScalar(float fl)
+#endif
:m_vec128 (_mm_set1_ps(fl))
{
}
diff --git a/extern/bullet2/src/SConscript b/extern/bullet2/src/SConscript
index 58c97f0ca4f..20a87d5d12c 100644
--- a/extern/bullet2/src/SConscript
+++ b/extern/bullet2/src/SConscript
@@ -19,8 +19,7 @@ elif env['OURPLATFORM'] in ('linux', 'freebsd4', 'freebsd5'):
cflags += ['-O2']
elif sys.platform=='darwin':
defs += ' NDEBUG'
- bt_flags = env['CCFLAGS'] + ['-fPIC', '-msse','-msse2', '-msse3', '-mssse3', '-ffast-math'] # basic -O0 optimization
- bt_opt_flags = bt_flags + ['-O3']
+ cflags += ['-O3','-fPIC']
bullet2_src = env.Glob("LinearMath/*.cpp")
bullet2_src += env.Glob("BulletCollision/BroadphaseCollision/*.cpp")
@@ -38,15 +37,4 @@ bullet2_src += env.Glob("BulletSoftBody/*.cpp")
incs = '. BulletCollision BulletDynamics LinearMath BulletSoftBody'
-if sys.platform=='darwin':
- if env['C_COMPILER_ID'] == 'clang' and env['CCVERSION'] >= '3.4':
- # Due some bugs in bullet, clang 3.4 produces wrong code when optimized > -O0
- # to avoid too much speed penalty when compiling whole bullet lib non-optimized,
- # we build seperate non-optimized/optimized parts and just link together finally
- bullet2_src.remove("BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp")
- bullet2_fix_src = env.Glob("BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp")
- env.BlenderLib ( libname = 'extern_fix_bullet2', sources=bullet2_fix_src, includes=Split(incs), defines=Split(defs), libtype=['extern','player'], priority=[20,137], cc_compileflags=bt_flags, cxx_compileflags=bt_flags )
-
- env.BlenderLib ( libname = 'extern_bullet2', sources=bullet2_src, includes=Split(incs), defines=Split(defs), libtype=['extern','player'], priority=[20,137], cc_compileflags=bt_opt_flags, cxx_compileflags=bt_opt_flags )
-else:
- env.BlenderLib ( libname = 'extern_bullet2', sources=bullet2_src, includes=Split(incs), defines=Split(defs), libtype=['extern','player'], priority=[20,137], compileflags=cflags )
+env.BlenderLib ( libname = 'extern_bullet2', sources=bullet2_src, includes=Split(incs), defines=Split(defs), libtype=['extern','player'], priority=[20,137], compileflags=cflags )
diff --git a/extern/carve/carve-capi.cc b/extern/carve/carve-capi.cc
index a65d1a8d766..af9ecad685d 100644
--- a/extern/carve/carve-capi.cc
+++ b/extern/carve/carve-capi.cc
@@ -38,7 +38,7 @@ typedef std::pair<int, int> OrigIndex;
typedef std::pair<MeshSet<3>::vertex_t *, MeshSet<3>::vertex_t *> VertexPair;
typedef carve::interpolate::VertexAttr<OrigIndex> OrigVertMapping;
typedef carve::interpolate::FaceAttr<OrigIndex> OrigFaceMapping;
-typedef carve::interpolate::FaceEdgeAttr<OrigIndex> OrigFaceEdgeMapping;
+typedef carve::interpolate::SwapableFaceEdgeAttr<OrigIndex> OrigFaceEdgeMapping;
typedef carve::interpolate::SimpleFaceEdgeAttr<bool> FaceEdgeTriangulatedFlag;
typedef struct CarveMeshDescr {
@@ -522,6 +522,39 @@ public:
}
};
+template <typename Interpolator>
+void copyFaceEdgeAttrs(const MeshSet<3> *poly,
+ Interpolator *old_interpolator,
+ Interpolator *new_interpolator)
+{
+ for (MeshSet<3>::const_face_iter face_iter = poly->faceBegin();
+ face_iter != poly->faceEnd();
+ ++face_iter)
+ {
+ const MeshSet<3>::face_t *face = *face_iter;
+
+ for (int edge_index = 0;
+ edge_index < face->nEdges();
+ ++edge_index)
+ {
+ new_interpolator->copyAttribute(face,
+ edge_index,
+ old_interpolator);
+ }
+ }
+}
+
+template <typename Interpolator>
+void cleanupFaceEdgeAttrs(const MeshSet<3> *left,
+ const MeshSet<3> *right,
+ Interpolator *interpolator)
+{
+ Interpolator new_interpolator;
+ copyFaceEdgeAttrs(left, interpolator, &new_interpolator);
+ copyFaceEdgeAttrs(right, interpolator, &new_interpolator);
+ interpolator->swapAttributes(&new_interpolator);
+}
+
} // namespace
CarveMeshDescr *carve_addMesh(struct ImportMeshData *import_data,
@@ -698,7 +731,15 @@ bool carve_performBooleanOperation(CarveMeshDescr *left_mesh,
// intersecting that meshes tessellation of operation result can't be
// done properly. The only way to make such situations working is to
// union intersecting meshes of the same operand.
- carve_unionIntersections(&csg, &left, &right);
+ if (carve_unionIntersections(&csg, &left, &right)) {
+ cleanupFaceEdgeAttrs(left,
+ right,
+ &output_descr->face_edge_triangulated_flag);
+ cleanupFaceEdgeAttrs(left,
+ right,
+ &output_descr->orig_face_edge_mapping);
+ }
+
left_mesh->poly = left;
right_mesh->poly = right;
diff --git a/extern/carve/carve-util.cc b/extern/carve/carve-util.cc
index ac6dcbc1a94..d02b786fd2a 100644
--- a/extern/carve/carve-util.cc
+++ b/extern/carve/carve-util.cc
@@ -49,84 +49,53 @@ namespace {
// Functions adopted from BLI_math.h to use Carve Vector and Matrix.
-void axis_angle_normalized_to_mat3(const Vector &normal,
- const double angle,
- Matrix3 *matrix)
+void transpose_m3__bli(double mat[3][3])
{
- double nsi[3], co, si, ico;
-
- /* now convert this to a 3x3 matrix */
- co = cos(angle);
- si = sin(angle);
-
- ico = (1.0 - co);
- nsi[0] = normal[0] * si;
- nsi[1] = normal[1] * si;
- nsi[2] = normal[2] * si;
-
- matrix->m[0][0] = ((normal[0] * normal[0]) * ico) + co;
- matrix->m[0][1] = ((normal[0] * normal[1]) * ico) + nsi[2];
- matrix->m[0][2] = ((normal[0] * normal[2]) * ico) - nsi[1];
- matrix->m[1][0] = ((normal[0] * normal[1]) * ico) - nsi[2];
- matrix->m[1][1] = ((normal[1] * normal[1]) * ico) + co;
- matrix->m[1][2] = ((normal[1] * normal[2]) * ico) + nsi[0];
- matrix->m[2][0] = ((normal[0] * normal[2]) * ico) + nsi[1];
- matrix->m[2][1] = ((normal[1] * normal[2]) * ico) - nsi[0];
- matrix->m[2][2] = ((normal[2] * normal[2]) * ico) + co;
+ double t;
+
+ t = mat[0][1];
+ mat[0][1] = mat[1][0];
+ mat[1][0] = t;
+ t = mat[0][2];
+ mat[0][2] = mat[2][0];
+ mat[2][0] = t;
+ t = mat[1][2];
+ mat[1][2] = mat[2][1];
+ mat[2][1] = t;
}
-void axis_angle_to_mat3(const Vector &axis,
- const double angle,
- Matrix3 *matrix)
+void ortho_basis_v3v3_v3__bli(double r_n1[3], double r_n2[3], const double n[3])
{
- if (axis.length2() < FLT_EPSILON) {
- *matrix = Matrix3();
- return;
+ const double eps = FLT_EPSILON;
+ const double f = (n[0] * n[0]) + (n[1] * n[1]);
+
+ if (f > eps) {
+ const double d = 1.0f / sqrt(f);
+
+ r_n1[0] = n[1] * d;
+ r_n1[1] = -n[0] * d;
+ r_n1[2] = 0.0f;
+ r_n2[0] = -n[2] * r_n1[1];
+ r_n2[1] = n[2] * r_n1[0];
+ r_n2[2] = n[0] * r_n1[1] - n[1] * r_n1[0];
+ }
+ else {
+ /* degenerate case */
+ r_n1[0] = (n[2] < 0.0f) ? -1.0f : 1.0f;
+ r_n1[1] = r_n1[2] = r_n2[0] = r_n2[2] = 0.0f;
+ r_n2[1] = 1.0f;
}
-
- Vector nor = axis;
- nor.normalize();
-
- axis_angle_normalized_to_mat3(nor, angle, matrix);
-}
-
-inline double saacos(double fac)
-{
- if (fac <= -1.0) return M_PI;
- else if (fac >= 1.0) return 0.0;
- else return acos(fac);
}
-bool axis_dominant_v3_to_m3(const Vector &normal,
- Matrix3 *matrix)
+void axis_dominant_v3_to_m3__bli(Matrix3 *r_mat, const Vector &normal)
{
- Vector up;
- Vector axis;
- double angle;
-
- up.x = 0.0;
- up.y = 0.0;
- up.z = 1.0;
-
- axis = carve::geom::cross(normal, up);
- angle = saacos(carve::geom::dot(normal, up));
-
- if (angle >= FLT_EPSILON) {
- if (axis.length2() < FLT_EPSILON) {
- axis[0] = 0.0;
- axis[1] = 1.0;
- axis[2] = 0.0;
- }
+ memcpy(r_mat->m[2], normal.v, sizeof(double[3]));
+ ortho_basis_v3v3_v3__bli(r_mat->m[0], r_mat->m[1], r_mat->m[2]);
- axis_angle_to_mat3(axis, angle, matrix);
- return true;
- }
- else {
- *matrix = Matrix3();
- return false;
- }
+ transpose_m3__bli(r_mat->m);
}
+
void meshset_minmax(const MeshSet<3> *mesh,
Vector *min,
Vector *max)
@@ -486,14 +455,15 @@ MeshSet<3> *unionIntersectingMeshes(carve::csg::CSG *csg,
// TODO(sergey): This function is to be totally re-implemented to make it
// more clear what's going on and hopefully optimize it as well.
-void carve_unionIntersections(carve::csg::CSG *csg,
+bool carve_unionIntersections(carve::csg::CSG *csg,
MeshSet<3> **left_r,
MeshSet<3> **right_r)
{
MeshSet<3> *left = *left_r, *right = *right_r;
+ bool changed = false;
if (left->meshes.size() == 1 && right->meshes.size() == 0) {
- return;
+ return false;
}
MeshSet<3>::aabb_t leftAABB = left->getAABB();
@@ -503,14 +473,19 @@ void carve_unionIntersections(carve::csg::CSG *csg,
right = unionIntersectingMeshes(csg, right, leftAABB);
if (left != *left_r) {
+ changed = true;
delete *left_r;
}
- if (right != *right_r)
+ if (right != *right_r) {
+ changed = true;
delete *right_r;
+ }
*left_r = left;
*right_r = right;
+
+ return changed;
}
static inline void add_newell_cross_v3_v3v3(const Vector &v_prev,
@@ -575,7 +550,7 @@ bool carve_checkPolyPlanarAndGetNormal(const std::vector<Vector> &vertices,
double magnitude = normal.length2();
normal.normalize();
- axis_dominant_v3_to_m3(normal, axis_matrix_r);
+ axis_dominant_v3_to_m3__bli(axis_matrix_r, normal);
Vector first_projected = *axis_matrix_r * vertices[verts_of_poly[0]];
double min_z = first_projected[2], max_z = first_projected[2];
diff --git a/extern/carve/carve-util.h b/extern/carve/carve-util.h
index a658b2fea96..f650810e9e3 100644
--- a/extern/carve/carve-util.h
+++ b/extern/carve/carve-util.h
@@ -70,7 +70,7 @@ void carve_getRescaleMinMax(const carve::mesh::MeshSet<3> *left,
carve::geom3d::Vector *min,
carve::geom3d::Vector *max);
-void carve_unionIntersections(carve::csg::CSG *csg,
+bool carve_unionIntersections(carve::csg::CSG *csg,
carve::mesh::MeshSet<3> **left_r,
carve::mesh::MeshSet<3> **right_r);
@@ -115,8 +115,8 @@ namespace carve {
attrs.find(new_edge_iter->vert);
if (found == attrs.end()) {
for (const_edge_iter_t orig_edge_iter = orig_face->begin();
- orig_edge_iter != orig_face->end();
- ++orig_edge_iter)
+ orig_edge_iter != orig_face->end();
+ ++orig_edge_iter)
{
if ((orig_edge_iter->vert->v - new_edge_iter->vert->v).length2() < 1e-5) {
attrs[new_edge_iter->vert] = attrs[orig_edge_iter->vert];
@@ -236,6 +236,20 @@ namespace carve {
attrs[std::make_pair(f, e)] = attr;
}
+ void copyAttribute(const meshset_t::face_t *face,
+ unsigned edge,
+ SimpleFaceEdgeAttr<attr_t> *interpolator) {
+ key_t key(face, edge);
+ typename attrmap_t::const_iterator fv = interpolator->attrs.find(key);
+ if (fv != interpolator->attrs.end()) {
+ attrs[key] = (*fv).second;
+ }
+ }
+
+ void swapAttributes(SimpleFaceEdgeAttr<attr_t> *interpolator) {
+ attrs.swap(interpolator->attrs);
+ }
+
SimpleFaceEdgeAttr() : Interpolator() {
}
@@ -243,6 +257,25 @@ namespace carve {
}
};
+ template<typename attr_t>
+ class SwapableFaceEdgeAttr : public FaceEdgeAttr<attr_t> {
+ public:
+ typedef carve::mesh::MeshSet<3> meshset_t;
+
+ void copyAttribute(const meshset_t::face_t *face,
+ unsigned edge,
+ SwapableFaceEdgeAttr<attr_t> *interpolator) {
+ typename FaceEdgeAttr<attr_t>::key_t key(face, edge);
+ typename FaceEdgeAttr<attr_t>::attrmap_t::const_iterator fv = interpolator->attrs.find(key);
+ if (fv != interpolator->attrs.end()) {
+ this->attrs[key] = (*fv).second;
+ }
+ }
+
+ void swapAttributes(SwapableFaceEdgeAttr<attr_t> *interpolator) {
+ this->attrs.swap(interpolator->attrs);
+ }
+ };
} // namespace interpolate
} // namespace carve
diff --git a/extern/libmv/CMakeLists.txt b/extern/libmv/CMakeLists.txt
index f7173c3b1e1..c3c5143cc16 100644
--- a/extern/libmv/CMakeLists.txt
+++ b/extern/libmv/CMakeLists.txt
@@ -58,6 +58,8 @@ if(WITH_LIBMV)
list(APPEND SRC
libmv-capi.cc
+ libmv-util.cc
+ libmv/base/aligned_malloc.cc
libmv/image/array_nd.cc
libmv/image/convolve.cc
libmv/multiview/conditioning.cc
@@ -72,6 +74,7 @@ if(WITH_LIBMV)
libmv/simple_pipeline/bundle.cc
libmv/simple_pipeline/camera_intrinsics.cc
libmv/simple_pipeline/detect.cc
+ libmv/simple_pipeline/distortion_models.cc
libmv/simple_pipeline/initialize_reconstruction.cc
libmv/simple_pipeline/intersect.cc
libmv/simple_pipeline/keyframe_selection.cc
@@ -93,6 +96,8 @@ if(WITH_LIBMV)
third_party/gflags/gflags_completions.cc
third_party/gflags/gflags_reporting.cc
+ libmv-util.h
+ libmv/base/aligned_malloc.h
libmv/base/id_generator.h
libmv/base/scoped_ptr.h
libmv/base/vector.h
@@ -123,7 +128,9 @@ if(WITH_LIBMV)
libmv/simple_pipeline/bundle.h
libmv/simple_pipeline/callbacks.h
libmv/simple_pipeline/camera_intrinsics.h
+ libmv/simple_pipeline/camera_intrinsics_impl.h
libmv/simple_pipeline/detect.h
+ libmv/simple_pipeline/distortion_models.h
libmv/simple_pipeline/initialize_reconstruction.h
libmv/simple_pipeline/intersect.h
libmv/simple_pipeline/keyframe_selection.h
diff --git a/extern/libmv/ChangeLog b/extern/libmv/ChangeLog
index 6ec5e0aa502..276fbb2ff0d 100644
--- a/extern/libmv/ChangeLog
+++ b/extern/libmv/ChangeLog
@@ -1,3 +1,198 @@
+commit 0b7d83dc9627447dc7df64d7e3a468aefe9ddc13
+Author: Sergey Sharybin <sergey.vfx@gmail.com>
+Date: Wed Apr 23 19:14:55 2014 +0600
+
+ Fix compilation on OSX after previous commit
+
+ EXPECT_EQ wasn't defined in the scope.
+
+commit d14049e00dabf8fdf49056779f0a3718fbb39e8f
+Author: Sergey Sharybin <sergey.vfx@gmail.com>
+Date: Wed Apr 23 15:08:16 2014 +0600
+
+ Move aligned malloc implementation into own file
+
+ It was rather stupid having it in brute region tracker,
+ now it is in own file in base library (which was also
+ added in this commit, before this it consist of header
+ files only).
+
+ Reviewers: keir
+
+ Reviewed By: keir
+
+ Differential Revision: https://developer.blender.org/D479
+
+commit 0ddf3851bfcb8de43660b119a25a77a25674200d
+Author: Sergey Sharybin <sergey.vfx@gmail.com>
+Date: Mon Apr 21 14:14:03 2014 +0600
+
+ Optimization of PearsonProductMomentCorrelation
+
+ Pass the arrays by reference rather than by value,
+ should give some percent of speedup.
+
+ Also don't pass the dimensions to the function but
+ get them from the images themselves.
+
+ Hopefully this will give some %% of tracker speedup.
+
+commit f68fdbe5896a6c5bd8b500caeec61b876c5e44c6
+Author: Sergey Sharybin <sergey.vfx@gmail.com>
+Date: Mon Apr 21 14:10:43 2014 +0600
+
+ Fix wrong assert in ResizeImage()
+
+ The assert didn't make any sense because ComputeBoundingBox()
+ is intended to return bounding box in the following way:
+ (xmin, xmax, ymin, ymax).
+
+commit 1d386b6775a71c499e9b8e4a288c0785c4937677
+Author: Sergey Sharybin <sergey.vfx@gmail.com>
+Date: Thu Apr 17 18:42:43 2014 +0600
+
+ Add unit tests for buffer (un)distortion
+
+ Currently only uses identity camera intrinsics just to
+ see whether lookup grids are properly allocated.
+
+ Should prevent accidents like that one happened recently
+ with crashing Blender after Libmv re-integration.
+
+commit e1fe41b6604771ba769a9b15eb2f489fbf7af251
+Author: Sergey Sharybin <sergey.vfx@gmail.com>
+Date: Thu Apr 17 17:52:23 2014 +0600
+
+ Fix offset array not being properly allocated
+
+ We really do need unit test for buffer (un)distortion,
+ didn't notice this bug for until new Libmv has been
+ integrated into Blender.
+
+commit ee21415a353396df67ef21e82adaffab2a8d2a0a
+Author: Sergey Sharybin <sergey.vfx@gmail.com>
+Date: Thu Apr 17 16:26:12 2014 +0600
+
+ Support multiple distortion models, including a new division model
+
+ This commit makes it so CameraIntrinsics is no longer hardcoded
+ to use the traditional polynomial radial distortion model. Currently
+ the distortion code has generic logic which is shared between
+ different distortion models, but had no other models until now.
+
+ This moves everything specific to the polynomial radial distortion
+ to a subclass PolynomialDistortionCameraIntrinsics(), and adds a
+ new division distortion model suitable for cameras such as the
+ GoPro which have much stronger distortion due to their fisheye lens.
+
+ This also cleans up the internal API of CameraIntrinsics to make
+ it easier to understand and reduces old C-style code.
+
+ Reviewers: keir
+
+ Reviewed By: keir
+
+ CC: jta
+
+ Differential Revision: https://developer.blender.org/D335
+
+commit 313252083f6dfa69a93c287bed81dec616503c1b
+Author: Sergey Sharybin <sergey.vfx@gmail.com>
+Date: Tue Apr 15 18:23:38 2014 +0600
+
+ Fix failure of the image transform linear test
+
+ Mainly was caused by the flakyness of image rotation in cases
+ when image has even size. The test was expecting the transform
+ code to rotate the image around pixel corner, which isn't a
+ common behavior in image processing applications. Rotation
+ is usually done around the pixel center.
+
+ So now made it so RotateImage() rotates the image around the
+ pixel center which gives 100% proper result for odd sized images
+ (i.e. center pixel stays untouched).
+
+ Also made the tests to use odd image sizes which are more
+ predictable by the humans. We can use even sized images in the
+ tests as well but their result wouldn't be so much spectacular.
+
+ Another issue with the tests was caused by RescaleImageTranslation
+ test which did expect things which are not happening in the
+ function.
+
+ Reviewers: keir
+
+ Reviewed By: keir
+
+ Differential Revision: https://developer.blender.org/D463
+
+commit 80d6945bf5f996b97cd41df0e422afce5e10e7f9
+Author: Sergey Sharybin <sergey.vfx@gmail.com>
+Date: Mon Apr 14 00:01:32 2014 +0600
+
+ Unit tests for feature detector
+
+ Currently covers only simplest cases with synthetic images.
+ Also at this point mainly Harris detector is being testes,
+ other detectors behaves a bit unexpected on synthetic images
+ and this is to be investigated further.
+
+ Tests will be extended further later.
+
+ Additional change:
+
+ - Added constructor to Feature structure
+ - Added operator << for feature for easier debug dumps.
+
+ TODO: Some tests are not giving the result which i was expected
+ to. This is to be investigated further by finding the reference
+ detector implementation. For until then keeping that tests
+ commented out.
+
+ Reviewers: keir
+
+ Reviewed By: keir
+
+ Differential Revision: https://developer.blender.org/D316
+
+commit 397c3d3ed46eb4967eb285c8369cc125bea4b132
+Author: Sergey Sharybin <sergey.vfx@gmail.com>
+Date: Fri Apr 4 16:17:57 2014 +0600
+
+ Compilation error fix
+
+ Not totally sure why this is needed, but multiview indeed
+ uses V3D library still, so it needs to be linked against it.
+
+ Patc by Martijn Berger, thanks!
+
+commit 1c36279239cbffe152493106eb04e55df7ebd649
+Author: Sergey Sharybin <sergey.vfx@gmail.com>
+Date: Fri Apr 4 14:03:43 2014 +0600
+
+ Upgrade Eigen to 3.2.1 version
+
+ To main reasons for this:
+ - Probably this would solve strict compiler warnings
+ - It brings new stuff like sparse LU decomposition which
+ might be useful in the future.
+
+commit de698f442934f475478463445f78a00ea632e823
+Author: Sergey Sharybin <sergey.vfx@gmail.com>
+Date: Thu Apr 3 15:08:26 2014 +0600
+
+ Fix compilation error when using make from the sources root
+
+ - Don't force flann to be static. It's a general rule on linux
+ to have dynamic libraries for all the bits instead of having
+ statically-linked dynamic libraries.
+
+ - Some weirdo stuff was happening around OpenExif, it was only
+ built on Apple, so don't link targets against this lib on
+ other platforms.
+
+ - Some libraries were missing for qt-tracker.
+
commit 901b146f28825d3e05f4157ca2a34ae00261b91a
Author: Sergey Sharybin <sergey.vfx@gmail.com>
Date: Wed Mar 26 17:44:09 2014 +0600
@@ -482,154 +677,3 @@ Date: Wed Sep 25 16:01:19 2013 +0600
that point".
Original patch by Keir Mierle made to Blender repository.
-
-commit 0d98e9bbde5d57f6cd9515ce8ff2786d322f29ea
-Author: Sergey Sharybin <sergey.vfx@gmail.com>
-Date: Tue Jun 18 19:24:07 2013 +0600
-
- Compilation error when using clang
-
- Where couple of issues:
-
- - Overloaded assignment operator usage ambiguity
- around some of the Eigen matrix assignment.
-
- - Using -O4 flag here on linux ended up in lots
- of cryptic linker issues, even when using recently
- release clang 3.3.
-
- Disabled forcing optimization flag for now.
- We could end up with something smarter in the
- future, but for now i'm not as much fan of
- forcing compiler's flag.
-
-commit 2b90b3915671cb629f7aabed30a88f28450294f8
-Author: Sergey Sharybin <sergey.vfx@gmail.com>
-Date: Sat Jun 1 16:20:35 2013 +0600
-
- Pass vectors by a reference
-
- Saves couple of time which used to waste on copying objects,
- also solves win32 compilation errors caused by alignment.
-
-commit 994c02d0ec55e9ae14a93a3ada6e5d4939247fc3
-Author: Sergey Sharybin <sergey.vfx@gmail.com>
-Date: Thu May 30 18:00:03 2013 +0600
-
- Code cleanup
-
- - Made some arguments passing to detector const.
- - Remove unneeded include from track_region header.
-
-commit 7d0c5325a38e61929f44206761b8aa3565631af5
-Author: Sergey Sharybin <sergey.vfx@gmail.com>
-Date: Mon May 13 04:44:14 2013 +0600
-
- Pass ApplyRadialDistortionCameraIntrinsics input arguments by reference
-
- This shall save some CPU time on calling copy constructor and give
- some boost of bundle adjuster (where jet could take some time to
- be passed by value).
-
-commit eb2e567df4567a54887d602aa95d6744aa154d8b
-Author: Sergey Sharybin <sergey.vfx@gmail.com>
-Date: Mon May 13 04:22:05 2013 +0600
-
- Minor code style cleanup.
-
-commit ad3dbaaef10ea721230694311a359df152c7a44a
-Author: Sergey Sharybin <sergey.vfx@gmail.com>
-Date: Sun May 12 22:34:54 2013 +0600
-
- Cleanup in simple pipeline's bundler
-
- - Better match Google's code style conventions.
- - Move evaluation part into own function, makes
- bundling itself easier to follow.
- - Made evaluation an optional parameter.
- - Removed note about unsupported camera intrinsics
- refining flags. Technically, all combinations
- are possible.
-
-commit 4432eb80f27e929f8750229aaada625d4f3ac5ee
-Author: Sergey Sharybin <sergey.vfx@gmail.com>
-Date: Sun May 12 22:19:31 2013 +0600
-
- Remove check for zero focal length in BA cost functor
-
- This check is actually redundant, because empty intrinsics
- will have focal length of 1.0, which means original comment
- about BundleIntrinsics was not truth.
-
- It is possible that external user will send focal length of
- zero to be refined, but blender prevents this from happening.
-
-commit 34a91c9b8acb0dba3382866fbd29bb9884edb98a
-Author: Sergey Sharybin <sergey.vfx@gmail.com>
-Date: Sat May 11 20:33:54 2013 +0600
-
- Fix compilation error with msvc2012
-
- Using change from glog's upstream for this.
-
-commit 87be4f030d025e4b29d9243d12bc458b2bb6762a
-Author: Sergey Sharybin <sergey.vfx@gmail.com>
-Date: Sat May 11 19:50:57 2013 +0600
-
- Style cleanup, mainly pointed by Sameer in Ceres's codereview
-
-commit 7fa9c0b83d5e0fbd331add2952045076c2028d1b
-Author: Sergey Sharybin <sergey.vfx@gmail.com>
-Date: Fri May 10 18:30:40 2013 +0600
-
- Keyframe selection improvements
-
- Added additional criteria, which ignores
- keyframe pair if success intersection factor
- is lower than current candidate pair factor.
-
- This solves issue with keyframe pair at which
- most of the tracks are intersecting behind the
- camera is accepted (because variance in this
- case is really small),
-
- Also tweaked generalized inverse function,
- which now doesn't scale epsilon by maximal
- matrix element. This gave issues at really bad
- candidates with unstable covariance. In this
- case almost all eigen values getting zeroed
- on inverse leading to small expected error.
-
-commit 0477ef1aa8fc92848f03c45e32539210be583b80
-Author: Sergey Sharybin <sergey.vfx@gmail.com>
-Date: Fri May 10 17:59:40 2013 +0600
-
- Keyframe selection code cleanup
-
- - Updated comments in code.
- - Removed currently unused functions.
- Actually, they'd better be moved to some generic
- logging module, but we don't have it now so was
- lazy to create one now. Could happen later using
- code from git history
- - Renamed function to match better to what's going
- on in it.
-
-commit fee2d7cc6003942f628c9a24b74008fd491b85b9
-Author: Sergey Sharybin <sergey.vfx@gmail.com>
-Date: Fri May 10 17:44:49 2013 +0600
-
- Optimization for reconstruction variance
-
- Achieved by replacing SVD-based pseudo-inverse with
- an eigen solver pseudo inverse.
-
- New function works in the same way: it decomposes
- matrix to V*D*V^-1, then inverts diagonal of D
- and composes matrix back.
-
- The same way is used to deal with gauges - last
- 7 eigen values are getting zeroed.
-
- In own tests gives approx 2x boost, without
- visible affect on selected keyframe quality.
diff --git a/extern/libmv/SConscript b/extern/libmv/SConscript
index 796819faa55..dc129501847 100644
--- a/extern/libmv/SConscript
+++ b/extern/libmv/SConscript
@@ -18,7 +18,8 @@ if env['WITH_BF_LIBMV']:
defs.append('WITH_LIBMV_GUARDED_ALLOC')
defs.append('LIBMV_NO_FAST_DETECTOR')
- src = env.Glob("libmv-capi.cc")
+ src = env.Glob('*.cc')
+ src += env.Glob('libmv/base/*.cc')
src += env.Glob('libmv/image/*.cc')
src += env.Glob('libmv/multiview/*.cc')
src += env.Glob('libmv/numeric/*.cc')
diff --git a/extern/libmv/bundle.sh b/extern/libmv/bundle.sh
index c98f8a31045..e8e698a89f2 100755
--- a/extern/libmv/bundle.sh
+++ b/extern/libmv/bundle.sh
@@ -146,10 +146,12 @@ if(WITH_LIBMV)
list(APPEND SRC
libmv-capi.cc
+ libmv-util.cc
${sources}
${third_sources}
+ libmv-util.h
${headers}
${third_headers}
@@ -232,7 +234,7 @@ if env['WITH_BF_LIBMV']:
defs.append('WITH_LIBMV_GUARDED_ALLOC')
defs.append('LIBMV_NO_FAST_DETECTOR')
- src = env.Glob("libmv-capi.cc")
+ src = env.Glob('*.cc')
$src
incs += ' ../Eigen3 third_party/gflags third_party/glog/src third_party/ceres/include ../../intern/guardedalloc'
diff --git a/extern/libmv/files.txt b/extern/libmv/files.txt
index cb6546ae8ff..60a99307835 100644
--- a/extern/libmv/files.txt
+++ b/extern/libmv/files.txt
@@ -1,3 +1,5 @@
+libmv/base/aligned_malloc.cc
+libmv/base/aligned_malloc.h
libmv/base/id_generator.h
libmv/base/scoped_ptr.h
libmv/base/vector.h
@@ -41,8 +43,11 @@ libmv/simple_pipeline/bundle.h
libmv/simple_pipeline/callbacks.h
libmv/simple_pipeline/camera_intrinsics.cc
libmv/simple_pipeline/camera_intrinsics.h
+libmv/simple_pipeline/camera_intrinsics_impl.h
libmv/simple_pipeline/detect.cc
libmv/simple_pipeline/detect.h
+libmv/simple_pipeline/distortion_models.cc
+libmv/simple_pipeline/distortion_models.h
libmv/simple_pipeline/initialize_reconstruction.cc
libmv/simple_pipeline/initialize_reconstruction.h
libmv/simple_pipeline/intersect.cc
diff --git a/extern/libmv/libmv-capi.cc b/extern/libmv/libmv-capi.cc
index 74e9e52094d..82143d50fbf 100644
--- a/extern/libmv/libmv-capi.cc
+++ b/extern/libmv/libmv-capi.cc
@@ -35,14 +35,10 @@
#undef DUMP_ALWAYS
#include "libmv-capi.h"
+#include "libmv-util.h"
-#include <cstdlib>
#include <cassert>
-#if defined(DUMP_FAILURE) || defined (DUMP_ALWAYS)
-# include <png.h>
-#endif
-
#include "libmv-capi_intern.h"
#include "libmv/logging/logging.h"
#include "libmv/multiview/homography.h"
@@ -58,27 +54,52 @@
#include "libmv/simple_pipeline/reconstruction_scale.h"
#include "libmv/simple_pipeline/keyframe_selection.h"
-#include "libmv/multiview/homography.h"
-
-#include "libmv/image/convolve.h"
-
#ifdef _MSC_VER
# define snprintf _snprintf
#endif
+using libmv::CameraIntrinsics;
+using libmv::DetectOptions;
+using libmv::DivisionCameraIntrinsics;
+using libmv::EuclideanCamera;
+using libmv::EuclideanPoint;
+using libmv::EuclideanReconstruction;
+using libmv::EuclideanScaleToUnity;
+using libmv::Feature;
+using libmv::FloatImage;
+using libmv::Marker;
+using libmv::PolynomialCameraIntrinsics;
+using libmv::ProgressUpdateCallback;
+using libmv::Tracks;
+using libmv::TrackRegionOptions;
+using libmv::TrackRegionResult;
+
+using libmv::Detect;
+using libmv::EuclideanBundle;
+using libmv::EuclideanCompleteReconstruction;
+using libmv::EuclideanReconstructTwoFrames;
+using libmv::EuclideanReprojectionError;
+using libmv::TrackRegion;
+using libmv::SamplePlanarPatch;
+
+typedef struct libmv_Tracks libmv_Tracks;
+typedef struct libmv_Reconstruction libmv_Reconstruction;
+typedef struct libmv_Features libmv_Features;
+typedef struct libmv_CameraIntrinsics libmv_CameraIntrinsics;
+
struct libmv_Reconstruction {
- libmv::EuclideanReconstruction reconstruction;
+ EuclideanReconstruction reconstruction;
/* used for per-track average error calculation after reconstruction */
- libmv::Tracks tracks;
- libmv::CameraIntrinsics intrinsics;
+ Tracks tracks;
+ CameraIntrinsics *intrinsics;
double error;
};
struct libmv_Features {
int count;
- libmv::Feature *features;
+ Feature *features;
};
/* ************ Logging ************ */
@@ -113,177 +134,6 @@ void libmv_setLoggingVerbosity(int verbosity)
google::SetCommandLineOption("v", val);
}
-/* ************ Utility ************ */
-
-static void byteBufToImage(const unsigned char *buf, int width, int height, int channels, libmv::FloatImage *image)
-{
- int x, y, k, a = 0;
-
- image->Resize(height, width, channels);
-
- for (y = 0; y < height; y++) {
- for (x = 0; x < width; x++) {
- for (k = 0; k < channels; k++) {
- (*image)(y, x, k) = (float)buf[a++] / 255.0f;
- }
- }
- }
-}
-
-static void floatBufToImage(const float *buf, int width, int height, int channels, libmv::FloatImage *image)
-{
- int x, y, k, a = 0;
-
- image->Resize(height, width, channels);
-
- for (y = 0; y < height; y++) {
- for (x = 0; x < width; x++) {
- for (k = 0; k < channels; k++) {
- (*image)(y, x, k) = buf[a++];
- }
- }
- }
-}
-
-static void imageToFloatBuf(const libmv::FloatImage *image, int channels, float *buf)
-{
- int x, y, k, a = 0;
-
- for (y = 0; y < image->Height(); y++) {
- for (x = 0; x < image->Width(); x++) {
- for (k = 0; k < channels; k++) {
- buf[a++] = (*image)(y, x, k);
- }
- }
- }
-}
-
-#if defined(DUMP_FAILURE) || defined (DUMP_ALWAYS)
-static void savePNGImage(png_bytep *row_pointers, int width, int height, int depth, int color_type,
- const char *file_name)
-{
- png_infop info_ptr;
- png_structp png_ptr;
- FILE *fp = fopen(file_name, "wb");
-
- if (!fp)
- return;
-
- /* Initialize stuff */
- png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
- info_ptr = png_create_info_struct(png_ptr);
-
- if (setjmp(png_jmpbuf(png_ptr))) {
- fclose(fp);
- return;
- }
-
- png_init_io(png_ptr, fp);
-
- /* write header */
- if (setjmp(png_jmpbuf(png_ptr))) {
- fclose(fp);
- return;
- }
-
- png_set_IHDR(png_ptr, info_ptr, width, height,
- depth, color_type, PNG_INTERLACE_NONE,
- PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
-
- png_write_info(png_ptr, info_ptr);
-
- /* write bytes */
- if (setjmp(png_jmpbuf(png_ptr))) {
- fclose(fp);
- return;
- }
-
- png_write_image(png_ptr, row_pointers);
-
- /* end write */
- if (setjmp(png_jmpbuf(png_ptr))) {
- fclose(fp);
- return;
- }
-
- png_write_end(png_ptr, NULL);
-
- fclose(fp);
-}
-
-static void saveImage(const char *prefix, libmv::FloatImage image, int x0, int y0)
-{
- int x, y;
- png_bytep *row_pointers;
-
- row_pointers = (png_bytep *) malloc(sizeof(png_bytep) * image.Height());
-
- for (y = 0; y < image.Height(); y++) {
- row_pointers[y] = (png_bytep) malloc(sizeof(png_byte) * 4 * image.Width());
-
- for (x = 0; x < image.Width(); x++) {
- if (x0 == x && image.Height() - y0 - 1 == y) {
- row_pointers[y][x * 4 + 0] = 255;
- row_pointers[y][x * 4 + 1] = 0;
- row_pointers[y][x * 4 + 2] = 0;
- row_pointers[y][x * 4 + 3] = 255;
- }
- else {
- float pixel = image(image.Height() - y - 1, x, 0);
- row_pointers[y][x * 4 + 0] = pixel * 255;
- row_pointers[y][x * 4 + 1] = pixel * 255;
- row_pointers[y][x * 4 + 2] = pixel * 255;
- row_pointers[y][x * 4 + 3] = 255;
- }
- }
- }
-
- {
- static int a = 0;
- char buf[128];
- snprintf(buf, sizeof(buf), "%s_%02d.png", prefix, ++a);
- savePNGImage(row_pointers, image.Width(), image.Height(), 8, PNG_COLOR_TYPE_RGBA, buf);
- }
-
- for (y = 0; y < image.Height(); y++) {
- free(row_pointers[y]);
- }
- free(row_pointers);
-}
-
-static void saveBytesImage(const char *prefix, unsigned char *data, int width, int height)
-{
- int x, y;
- png_bytep *row_pointers;
-
- row_pointers = (png_bytep *) malloc(sizeof(png_bytep) * height);
-
- for (y = 0; y < height; y++) {
- row_pointers[y] = (png_bytep) malloc(sizeof(png_byte) * 4 * width);
-
- for (x = 0; x < width; x++) {
- char pixel = data[width * y + x];
- row_pointers[y][x * 4 + 0] = pixel;
- row_pointers[y][x * 4 + 1] = pixel;
- row_pointers[y][x * 4 + 2] = pixel;
- row_pointers[y][x * 4 + 3] = 255;
- }
- }
-
- {
- static int a = 0;
- char buf[128];
- snprintf(buf, sizeof(buf), "%s_%02d.png", prefix, ++a);
- savePNGImage(row_pointers, width, height, 8, PNG_COLOR_TYPE_RGBA, buf);
- }
-
- for (y = 0; y < height; y++) {
- free(row_pointers[y]);
- }
- free(row_pointers);
-}
-#endif
-
/* ************ Planar tracker ************ */
/* TrackRegion */
@@ -306,13 +156,13 @@ int libmv_trackRegion(const libmv_TrackRegionOptions *options,
yy2[i] = y2[i];
}
- libmv::TrackRegionOptions track_region_options;
- libmv::FloatImage image1_mask;
+ TrackRegionOptions track_region_options;
+ FloatImage image1_mask;
switch (options->motion_model) {
#define LIBMV_CONVERT(the_model) \
- case libmv::TrackRegionOptions::the_model: \
- track_region_options.mode = libmv::TrackRegionOptions::the_model; \
+ case TrackRegionOptions::the_model: \
+ track_region_options.mode = TrackRegionOptions::the_model; \
break;
LIBMV_CONVERT(TRANSLATION)
LIBMV_CONVERT(TRANSLATION_ROTATION)
@@ -342,18 +192,28 @@ int libmv_trackRegion(const libmv_TrackRegionOptions *options,
track_region_options.use_normalized_intensities = options->use_normalization;
if (options->image1_mask) {
- floatBufToImage(options->image1_mask, image1_width, image1_height, 1, &image1_mask);
+ libmv_floatBufferToImage(options->image1_mask,
+ image1_width, image1_height, 1,
+ &image1_mask);
track_region_options.image1_mask = &image1_mask;
}
/* Convert from raw float buffers to libmv's FloatImage. */
- libmv::FloatImage old_patch, new_patch;
- floatBufToImage(image1, image1_width, image1_height, 1, &old_patch);
- floatBufToImage(image2, image2_width, image2_height, 1, &new_patch);
-
- libmv::TrackRegionResult track_region_result;
- libmv::TrackRegion(old_patch, new_patch, xx1, yy1, track_region_options, xx2, yy2, &track_region_result);
+ FloatImage old_patch, new_patch;
+ libmv_floatBufferToImage(image1,
+ image1_width, image1_height, 1,
+ &old_patch);
+ libmv_floatBufferToImage(image2,
+ image2_width, image2_height, 1,
+ &new_patch);
+
+ TrackRegionResult track_region_result;
+ TrackRegion(old_patch, new_patch,
+ xx1, yy1,
+ track_region_options,
+ xx2, yy2,
+ &track_region_result);
/* Convert to floats for the blender api. */
for (int i = 0; i < 5; ++i) {
@@ -362,78 +222,126 @@ int libmv_trackRegion(const libmv_TrackRegionOptions *options,
}
/* TODO(keir): Update the termination string with failure details. */
- if (track_region_result.termination == libmv::TrackRegionResult::CONVERGENCE ||
- track_region_result.termination == libmv::TrackRegionResult::NO_CONVERGENCE)
+ if (track_region_result.termination == TrackRegionResult::CONVERGENCE ||
+ track_region_result.termination == TrackRegionResult::NO_CONVERGENCE)
{
tracking_result = true;
}
+ /* Debug dump of patches. */
#if defined(DUMP_FAILURE) || defined(DUMP_ALWAYS)
-#if defined(DUMP_ALWAYS)
{
-#else
- if (!tracking_result) {
-#endif
- saveImage("old_patch", old_patch, x1[4], y1[4]);
- saveImage("new_patch", new_patch, x2[4], y2[4]);
+ bool need_dump = !tracking_result;
+
+# ifdef DUMP_ALWAYS
+ need_dump = true;
+# endif
- if (options->image1_mask)
- saveImage("mask", image1_mask, x2[4], y2[4]);
+ if (need_dump) {
+ libmv_saveImage(old_patch, "old_patch", x1[4], y1[4]);
+ libmv_saveImage(new_patch, "new_patch", x2[4], y2[4]);
+
+ if (options->image1_mask) {
+ libmv_saveImage(image1_mask, "mask", x2[4], y2[4]);
+ }
+ }
}
#endif
return tracking_result;
}
-void libmv_samplePlanarPatch(const float *image, int width, int height,
- int channels, const double *xs, const double *ys,
+void libmv_samplePlanarPatch(const float *image,
+ int width, int height, int channels,
+ const double *xs, const double *ys,
int num_samples_x, int num_samples_y,
- const float *mask, float *patch,
- double *warped_position_x, double *warped_position_y)
+ const float *mask,
+ float *patch,
+ double *warped_position_x,
+ double *warped_position_y)
+{
+ FloatImage libmv_image, libmv_patch, libmv_mask;
+ FloatImage *libmv_mask_for_sample = NULL;
+
+ libmv_floatBufferToImage(image, width, height, channels, &libmv_image);
+
+ if (mask) {
+ libmv_floatBufferToImage(mask, width, height, 1, &libmv_mask);
+
+ libmv_mask_for_sample = &libmv_mask;
+ }
+
+ SamplePlanarPatch(libmv_image,
+ xs, ys,
+ num_samples_x, num_samples_y,
+ libmv_mask_for_sample,
+ &libmv_patch,
+ warped_position_x,
+ warped_position_y);
+
+ libmv_imageToFloatBuffer(libmv_patch, patch);
+}
+
+ void libmv_samplePlanarPatchByte(const unsigned char *image,
+ int width, int height, int channels,
+ const double *xs, const double *ys,
+ int num_samples_x, int num_samples_y,
+ const float *mask,
+ unsigned char *patch,
+ double *warped_position_x, double *warped_position_y)
{
libmv::FloatImage libmv_image, libmv_patch, libmv_mask;
libmv::FloatImage *libmv_mask_for_sample = NULL;
- floatBufToImage(image, width, height, channels, &libmv_image);
+ libmv_byteBufferToImage(image, width, height, channels, &libmv_image);
if (mask) {
- floatBufToImage(mask, width, height, 1, &libmv_mask);
+ libmv_floatBufferToImage(mask, width, height, 1, &libmv_mask);
libmv_mask_for_sample = &libmv_mask;
}
- libmv::SamplePlanarPatch(libmv_image, xs, ys, num_samples_x, num_samples_y,
- libmv_mask_for_sample, &libmv_patch,
- warped_position_x, warped_position_y);
+ libmv::SamplePlanarPatch(libmv_image, xs, ys,
+ num_samples_x, num_samples_y,
+ libmv_mask_for_sample,
+ &libmv_patch,
+ warped_position_x,
+ warped_position_y);
- imageToFloatBuf(&libmv_patch, channels, patch);
+ libmv_imageToByteBuffer(libmv_patch, patch);
}
/* ************ Tracks ************ */
-struct libmv_Tracks *libmv_tracksNew(void)
+libmv_Tracks *libmv_tracksNew(void)
{
- libmv::Tracks *libmv_tracks = LIBMV_OBJECT_NEW(libmv::Tracks);
+ Tracks *libmv_tracks = LIBMV_OBJECT_NEW(Tracks);
- return (struct libmv_Tracks *)libmv_tracks;
+ return (libmv_Tracks *) libmv_tracks;
}
-void libmv_tracksDestroy(struct libmv_Tracks *libmv_tracks)
+void libmv_tracksDestroy(libmv_Tracks *libmv_tracks)
{
- using libmv::Tracks;
LIBMV_OBJECT_DELETE(libmv_tracks, Tracks);
}
-void libmv_tracksInsert(struct libmv_Tracks *libmv_tracks, int image, int track, double x, double y, double weight)
+void libmv_tracksInsert(libmv_Tracks *libmv_tracks,
+ int image, int track,
+ double x, double y,
+ double weight)
{
- ((libmv::Tracks*) libmv_tracks)->Insert(image, track, x, y, weight);
+ ((Tracks *) libmv_tracks)->Insert(image, track, x, y, weight);
}
/* ************ Reconstruction ************ */
-class ReconstructUpdateCallback : public libmv::ProgressUpdateCallback {
+namespace {
+
+class ReconstructUpdateCallback : public ProgressUpdateCallback {
public:
- ReconstructUpdateCallback(reconstruct_progress_update_cb progress_update_callback, void *callback_customdata)
+ ReconstructUpdateCallback(
+ reconstruct_progress_update_cb progress_update_callback,
+ void *callback_customdata)
{
progress_update_callback_ = progress_update_callback;
callback_customdata_ = callback_customdata;
@@ -450,13 +358,14 @@ protected:
void *callback_customdata_;
};
-static void libmv_solveRefineIntrinsics(const libmv::Tracks &tracks,
- const int refine_intrinsics,
- const int bundle_constraints,
- reconstruct_progress_update_cb progress_update_callback,
- void *callback_customdata,
- libmv::EuclideanReconstruction *reconstruction,
- libmv::CameraIntrinsics *intrinsics)
+void libmv_solveRefineIntrinsics(
+ const Tracks &tracks,
+ const int refine_intrinsics,
+ const int bundle_constraints,
+ reconstruct_progress_update_cb progress_update_callback,
+ void *callback_customdata,
+ EuclideanReconstruction *reconstruction,
+ CameraIntrinsics *intrinsics)
{
/* only a few combinations are supported but trust the caller */
int bundle_intrinsics = 0;
@@ -476,61 +385,37 @@ static void libmv_solveRefineIntrinsics(const libmv::Tracks &tracks,
progress_update_callback(callback_customdata, 1.0, "Refining solution");
- libmv::EuclideanBundleCommonIntrinsics(tracks,
- bundle_intrinsics,
- bundle_constraints,
- reconstruction,
- intrinsics);
-}
-
-static void cameraIntrinsicsFromOptions(const libmv_CameraIntrinsicsOptions *camera_intrinsics_options,
- libmv::CameraIntrinsics *camera_intrinsics)
-{
- camera_intrinsics->SetFocalLength(camera_intrinsics_options->focal_length,
- camera_intrinsics_options->focal_length);
-
- camera_intrinsics->SetPrincipalPoint(camera_intrinsics_options->principal_point_x,
- camera_intrinsics_options->principal_point_y);
-
- camera_intrinsics->SetRadialDistortion(camera_intrinsics_options->k1,
- camera_intrinsics_options->k2,
- camera_intrinsics_options->k3);
-
- camera_intrinsics->SetImageSize(camera_intrinsics_options->image_width,
- camera_intrinsics_options->image_height);
+ EuclideanBundleCommonIntrinsics(tracks,
+ bundle_intrinsics,
+ bundle_constraints,
+ reconstruction,
+ intrinsics);
}
-static libmv::Tracks getNormalizedTracks(const libmv::Tracks &tracks, const libmv::CameraIntrinsics &camera_intrinsics)
+void finishReconstruction(
+ const Tracks &tracks,
+ const CameraIntrinsics &camera_intrinsics,
+ libmv_Reconstruction *libmv_reconstruction,
+ reconstruct_progress_update_cb progress_update_callback,
+ void *callback_customdata)
{
- libmv::vector<libmv::Marker> markers = tracks.AllMarkers();
-
- for (int i = 0; i < markers.size(); ++i) {
- camera_intrinsics.InvertIntrinsics(markers[i].x, markers[i].y,
- &(markers[i].x), &(markers[i].y));
- }
-
- return libmv::Tracks(markers);
-}
-
-static void finishReconstruction(const libmv::Tracks &tracks, const libmv::CameraIntrinsics &camera_intrinsics,
- struct libmv_Reconstruction *libmv_reconstruction,
- reconstruct_progress_update_cb progress_update_callback,
- void *callback_customdata)
-{
- libmv::EuclideanReconstruction &reconstruction = libmv_reconstruction->reconstruction;
+ EuclideanReconstruction &reconstruction =
+ libmv_reconstruction->reconstruction;
/* reprojection error calculation */
progress_update_callback(callback_customdata, 1.0, "Finishing solution");
libmv_reconstruction->tracks = tracks;
- libmv_reconstruction->error = libmv::EuclideanReprojectionError(tracks, reconstruction, camera_intrinsics);
+ libmv_reconstruction->error = EuclideanReprojectionError(tracks,
+ reconstruction,
+ camera_intrinsics);
}
-static bool selectTwoKeyframesBasedOnGRICAndVariance(
- libmv::Tracks &tracks,
- libmv::Tracks &normalized_tracks,
- libmv::CameraIntrinsics &camera_intrinsics,
- int &keyframe1,
- int &keyframe2)
+bool selectTwoKeyframesBasedOnGRICAndVariance(
+ Tracks &tracks,
+ Tracks &normalized_tracks,
+ CameraIntrinsics &camera_intrinsics,
+ int &keyframe1,
+ int &keyframe2)
{
libmv::vector<int> keyframes;
@@ -560,25 +445,25 @@ static bool selectTwoKeyframesBasedOnGRICAndVariance(
int previous_keyframe = keyframes[0];
double best_error = std::numeric_limits<double>::max();
for (int i = 1; i < keyframes.size(); i++) {
- libmv::EuclideanReconstruction reconstruction;
+ EuclideanReconstruction reconstruction;
int current_keyframe = keyframes[i];
- libmv::vector<libmv::Marker> keyframe_markers =
+ libmv::vector<Marker> keyframe_markers =
normalized_tracks.MarkersForTracksInBothImages(previous_keyframe,
current_keyframe);
- libmv::Tracks keyframe_tracks(keyframe_markers);
+ Tracks keyframe_tracks(keyframe_markers);
/* get a solution from two keyframes only */
- libmv::EuclideanReconstructTwoFrames(keyframe_markers, &reconstruction);
- libmv::EuclideanBundle(keyframe_tracks, &reconstruction);
- libmv::EuclideanCompleteReconstruction(keyframe_tracks,
- &reconstruction, NULL);
+ EuclideanReconstructTwoFrames(keyframe_markers, &reconstruction);
+ EuclideanBundle(keyframe_tracks, &reconstruction);
+ EuclideanCompleteReconstruction(keyframe_tracks,
+ &reconstruction,
+ NULL);
- double current_error =
- libmv::EuclideanReprojectionError(tracks,
- reconstruction,
- camera_intrinsics);
+ double current_error = EuclideanReprojectionError(tracks,
+ reconstruction,
+ camera_intrinsics);
LG << "Error between " << previous_keyframe
<< " and " << current_keyframe
@@ -596,26 +481,35 @@ static bool selectTwoKeyframesBasedOnGRICAndVariance(
return true;
}
-struct libmv_Reconstruction *libmv_solveReconstruction(const struct libmv_Tracks *libmv_tracks,
- const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
- libmv_ReconstructionOptions *libmv_reconstruction_options,
- reconstruct_progress_update_cb progress_update_callback,
- void *callback_customdata)
+} // namespace
+
+libmv_Reconstruction *libmv_solveReconstruction(
+ const libmv_Tracks *libmv_tracks,
+ const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
+ libmv_ReconstructionOptions *libmv_reconstruction_options,
+ reconstruct_progress_update_cb progress_update_callback,
+ void *callback_customdata)
{
- struct libmv_Reconstruction *libmv_reconstruction = LIBMV_OBJECT_NEW(libmv_Reconstruction);
+ libmv_Reconstruction *libmv_reconstruction =
+ LIBMV_OBJECT_NEW(libmv_Reconstruction);
- libmv::Tracks &tracks = *((libmv::Tracks *) libmv_tracks);
- libmv::EuclideanReconstruction &reconstruction = libmv_reconstruction->reconstruction;
- libmv::CameraIntrinsics &camera_intrinsics = libmv_reconstruction->intrinsics;
+ Tracks &tracks = *((Tracks *) libmv_tracks);
+ EuclideanReconstruction &reconstruction =
+ libmv_reconstruction->reconstruction;
ReconstructUpdateCallback update_callback =
- ReconstructUpdateCallback(progress_update_callback, callback_customdata);
+ ReconstructUpdateCallback(progress_update_callback,
+ callback_customdata);
/* Retrieve reconstruction options from C-API to libmv API */
- cameraIntrinsicsFromOptions(libmv_camera_intrinsics_options, &camera_intrinsics);
+ CameraIntrinsics *camera_intrinsics;
+ camera_intrinsics = libmv_reconstruction->intrinsics =
+ libmv_cameraIntrinsicsCreateFromOptions(
+ libmv_camera_intrinsics_options);
/* Invert the camera intrinsics */
- libmv::Tracks normalized_tracks = getNormalizedTracks(tracks, camera_intrinsics);
+ Tracks normalized_tracks;
+ libmv_getNormalizedTracks(tracks, *camera_intrinsics, &normalized_tracks);
/* keyframe selection */
int keyframe1 = libmv_reconstruction_options->keyframe1,
@@ -628,7 +522,7 @@ struct libmv_Reconstruction *libmv_solveReconstruction(const struct libmv_Tracks
selectTwoKeyframesBasedOnGRICAndVariance(tracks,
normalized_tracks,
- camera_intrinsics,
+ *camera_intrinsics,
keyframe1,
keyframe2);
@@ -640,95 +534,118 @@ struct libmv_Reconstruction *libmv_solveReconstruction(const struct libmv_Tracks
/* actual reconstruction */
LG << "frames to init from: " << keyframe1 << " " << keyframe2;
- libmv::vector<libmv::Marker> keyframe_markers =
+ libmv::vector<Marker> keyframe_markers =
normalized_tracks.MarkersForTracksInBothImages(keyframe1, keyframe2);
LG << "number of markers for init: " << keyframe_markers.size();
update_callback.invoke(0, "Initial reconstruction");
- libmv::EuclideanReconstructTwoFrames(keyframe_markers, &reconstruction);
- libmv::EuclideanBundle(normalized_tracks, &reconstruction);
- libmv::EuclideanCompleteReconstruction(normalized_tracks,
- &reconstruction, &update_callback);
+ EuclideanReconstructTwoFrames(keyframe_markers, &reconstruction);
+ EuclideanBundle(normalized_tracks, &reconstruction);
+ EuclideanCompleteReconstruction(normalized_tracks,
+ &reconstruction,
+ &update_callback);
/* refinement */
if (libmv_reconstruction_options->refine_intrinsics) {
- libmv_solveRefineIntrinsics(tracks,
- libmv_reconstruction_options->refine_intrinsics,
- libmv::BUNDLE_NO_CONSTRAINTS,
- progress_update_callback,
- callback_customdata,
- &reconstruction,
- &camera_intrinsics);
+ libmv_solveRefineIntrinsics(
+ tracks,
+ libmv_reconstruction_options->refine_intrinsics,
+ libmv::BUNDLE_NO_CONSTRAINTS,
+ progress_update_callback,
+ callback_customdata,
+ &reconstruction,
+ camera_intrinsics);
}
/* set reconstruction scale to unity */
- libmv::EuclideanScaleToUnity(&reconstruction);
+ EuclideanScaleToUnity(&reconstruction);
/* finish reconstruction */
- finishReconstruction(tracks, camera_intrinsics, libmv_reconstruction,
- progress_update_callback, callback_customdata);
+ finishReconstruction(tracks,
+ *camera_intrinsics,
+ libmv_reconstruction,
+ progress_update_callback,
+ callback_customdata);
- return (struct libmv_Reconstruction *)libmv_reconstruction;
+ return (libmv_Reconstruction *) libmv_reconstruction;
}
-struct libmv_Reconstruction *libmv_solveModal(const struct libmv_Tracks *libmv_tracks,
- const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
- const libmv_ReconstructionOptions *libmv_reconstruction_options,
- reconstruct_progress_update_cb progress_update_callback,
- void *callback_customdata)
+libmv_Reconstruction *libmv_solveModal(
+ const libmv_Tracks *libmv_tracks,
+ const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
+ const libmv_ReconstructionOptions *libmv_reconstruction_options,
+ reconstruct_progress_update_cb progress_update_callback,
+ void *callback_customdata)
{
- struct libmv_Reconstruction *libmv_reconstruction = LIBMV_OBJECT_NEW(libmv_Reconstruction);
+ libmv_Reconstruction *libmv_reconstruction =
+ LIBMV_OBJECT_NEW(libmv_Reconstruction);
- libmv::Tracks &tracks = *((libmv::Tracks *) libmv_tracks);
- libmv::EuclideanReconstruction &reconstruction = libmv_reconstruction->reconstruction;
- libmv::CameraIntrinsics &camera_intrinsics = libmv_reconstruction->intrinsics;
+ Tracks &tracks = *((Tracks *) libmv_tracks);
+ EuclideanReconstruction &reconstruction =
+ libmv_reconstruction->reconstruction;
ReconstructUpdateCallback update_callback =
- ReconstructUpdateCallback(progress_update_callback, callback_customdata);
+ ReconstructUpdateCallback(progress_update_callback,
+ callback_customdata);
- cameraIntrinsicsFromOptions(libmv_camera_intrinsics_options, &camera_intrinsics);
+ /* Retrieve reconstruction options from C-API to libmv API */
+ CameraIntrinsics *camera_intrinsics;
+ camera_intrinsics = libmv_reconstruction->intrinsics =
+ libmv_cameraIntrinsicsCreateFromOptions(
+ libmv_camera_intrinsics_options);
/* Invert the camera intrinsics. */
- libmv::Tracks normalized_tracks = getNormalizedTracks(tracks, camera_intrinsics);
+ Tracks normalized_tracks;
+ libmv_getNormalizedTracks(tracks, *camera_intrinsics, &normalized_tracks);
/* Actual reconstruction. */
- libmv::ModalSolver(normalized_tracks, &reconstruction, &update_callback);
+ ModalSolver(normalized_tracks, &reconstruction, &update_callback);
- libmv::CameraIntrinsics empty_intrinsics;
- libmv::EuclideanBundleCommonIntrinsics(normalized_tracks,
- libmv::BUNDLE_NO_INTRINSICS,
- libmv::BUNDLE_NO_TRANSLATION,
- &reconstruction,
- &empty_intrinsics);
+ PolynomialCameraIntrinsics empty_intrinsics;
+ EuclideanBundleCommonIntrinsics(normalized_tracks,
+ libmv::BUNDLE_NO_INTRINSICS,
+ libmv::BUNDLE_NO_TRANSLATION,
+ &reconstruction,
+ &empty_intrinsics);
/* Refinement. */
if (libmv_reconstruction_options->refine_intrinsics) {
- libmv_solveRefineIntrinsics(tracks,
- libmv_reconstruction_options->refine_intrinsics,
- libmv::BUNDLE_NO_TRANSLATION,
- progress_update_callback, callback_customdata,
- &reconstruction,
- &camera_intrinsics);
+ libmv_solveRefineIntrinsics(
+ tracks,
+ libmv_reconstruction_options->refine_intrinsics,
+ libmv::BUNDLE_NO_TRANSLATION,
+ progress_update_callback, callback_customdata,
+ &reconstruction,
+ camera_intrinsics);
}
/* Finish reconstruction. */
- finishReconstruction(tracks, camera_intrinsics, libmv_reconstruction,
- progress_update_callback, callback_customdata);
+ finishReconstruction(tracks,
+ *camera_intrinsics,
+ libmv_reconstruction,
+ progress_update_callback,
+ callback_customdata);
- return (struct libmv_Reconstruction *)libmv_reconstruction;
+ return (libmv_Reconstruction *) libmv_reconstruction;
}
-void libmv_reconstructionDestroy(struct libmv_Reconstruction *libmv_reconstruction)
+void libmv_reconstructionDestroy(libmv_Reconstruction *libmv_reconstruction)
{
+ LIBMV_OBJECT_DELETE(libmv_reconstruction->intrinsics, CameraIntrinsics);
LIBMV_OBJECT_DELETE(libmv_reconstruction, libmv_Reconstruction);
}
-int libmv_reprojectionPointForTrack(const struct libmv_Reconstruction *libmv_reconstruction, int track, double pos[3])
+int libmv_reprojectionPointForTrack(
+ const libmv_Reconstruction *libmv_reconstruction,
+ int track,
+ double pos[3])
{
- const libmv::EuclideanReconstruction *reconstruction = &libmv_reconstruction->reconstruction;
- const libmv::EuclideanPoint *point = reconstruction->PointForTrack(track);
+ const EuclideanReconstruction *reconstruction =
+ &libmv_reconstruction->reconstruction;
+ const EuclideanPoint *point =
+ reconstruction->PointForTrack(track);
if (point) {
pos[0] = point->X[0];
@@ -741,35 +658,25 @@ int libmv_reprojectionPointForTrack(const struct libmv_Reconstruction *libmv_rec
return 0;
}
-static libmv::Marker ProjectMarker(const libmv::EuclideanPoint &point,
- const libmv::EuclideanCamera &camera,
- const libmv::CameraIntrinsics &intrinsics)
-{
- libmv::Vec3 projected = camera.R * point.X + camera.t;
- projected /= projected(2);
-
- libmv::Marker reprojected_marker;
- intrinsics.ApplyIntrinsics(projected(0), projected(1), &reprojected_marker.x, &reprojected_marker.y);
-
- reprojected_marker.image = camera.image;
- reprojected_marker.track = point.track;
-
- return reprojected_marker;
-}
-
-double libmv_reprojectionErrorForTrack(const struct libmv_Reconstruction *libmv_reconstruction, int track)
+double libmv_reprojectionErrorForTrack(
+ const libmv_Reconstruction *libmv_reconstruction,
+ int track)
{
- const libmv::EuclideanReconstruction *reconstruction = &libmv_reconstruction->reconstruction;
- const libmv::CameraIntrinsics *intrinsics = &libmv_reconstruction->intrinsics;
- libmv::vector<libmv::Marker> markers = libmv_reconstruction->tracks.MarkersForTrack(track);
+ const EuclideanReconstruction *reconstruction =
+ &libmv_reconstruction->reconstruction;
+ const CameraIntrinsics *intrinsics = libmv_reconstruction->intrinsics;
+ libmv::vector<Marker> markers =
+ libmv_reconstruction->tracks.MarkersForTrack(track);
int num_reprojected = 0;
double total_error = 0.0;
for (int i = 0; i < markers.size(); ++i) {
double weight = markers[i].weight;
- const libmv::EuclideanCamera *camera = reconstruction->CameraForImage(markers[i].image);
- const libmv::EuclideanPoint *point = reconstruction->PointForTrack(markers[i].track);
+ const EuclideanCamera *camera =
+ reconstruction->CameraForImage(markers[i].image);
+ const EuclideanPoint *point =
+ reconstruction->PointForTrack(markers[i].track);
if (!camera || !point || weight == 0.0) {
continue;
@@ -777,7 +684,8 @@ double libmv_reprojectionErrorForTrack(const struct libmv_Reconstruction *libmv_
num_reprojected++;
- libmv::Marker reprojected_marker = ProjectMarker(*point, *camera, *intrinsics);
+ Marker reprojected_marker =
+ libmv_projectMarker(*point, *camera, *intrinsics);
double ex = (reprojected_marker.x - markers[i].x) * weight;
double ey = (reprojected_marker.y - markers[i].y) * weight;
@@ -787,20 +695,26 @@ double libmv_reprojectionErrorForTrack(const struct libmv_Reconstruction *libmv_
return total_error / num_reprojected;
}
-double libmv_reprojectionErrorForImage(const struct libmv_Reconstruction *libmv_reconstruction, int image)
+double libmv_reprojectionErrorForImage(
+ const libmv_Reconstruction *libmv_reconstruction,
+ int image)
{
- const libmv::EuclideanReconstruction *reconstruction = &libmv_reconstruction->reconstruction;
- const libmv::CameraIntrinsics *intrinsics = &libmv_reconstruction->intrinsics;
- libmv::vector<libmv::Marker> markers = libmv_reconstruction->tracks.MarkersInImage(image);
- const libmv::EuclideanCamera *camera = reconstruction->CameraForImage(image);
+ const EuclideanReconstruction *reconstruction =
+ &libmv_reconstruction->reconstruction;
+ const CameraIntrinsics *intrinsics = libmv_reconstruction->intrinsics;
+ libmv::vector<Marker> markers =
+ libmv_reconstruction->tracks.MarkersInImage(image);
+ const EuclideanCamera *camera = reconstruction->CameraForImage(image);
int num_reprojected = 0;
double total_error = 0.0;
- if (!camera)
- return 0;
+ if (!camera) {
+ return 0.0;
+ }
for (int i = 0; i < markers.size(); ++i) {
- const libmv::EuclideanPoint *point = reconstruction->PointForTrack(markers[i].track);
+ const EuclideanPoint *point =
+ reconstruction->PointForTrack(markers[i].track);
if (!point) {
continue;
@@ -808,9 +722,10 @@ double libmv_reprojectionErrorForImage(const struct libmv_Reconstruction *libmv_
num_reprojected++;
- libmv::Marker reprojected_marker = ProjectMarker(*point, *camera, *intrinsics);
- double ex = reprojected_marker.x - markers[i].x;
- double ey = reprojected_marker.y - markers[i].y;
+ Marker reprojected_marker =
+ libmv_projectMarker(*point, *camera, *intrinsics);
+ double ex = (reprojected_marker.x - markers[i].x) * markers[i].weight;
+ double ey = (reprojected_marker.y - markers[i].y) * markers[i].weight;
total_error += sqrt(ex * ex + ey * ey);
}
@@ -818,11 +733,14 @@ double libmv_reprojectionErrorForImage(const struct libmv_Reconstruction *libmv_
return total_error / num_reprojected;
}
-int libmv_reprojectionCameraForImage(const struct libmv_Reconstruction *libmv_reconstruction,
- int image, double mat[4][4])
+int libmv_reprojectionCameraForImage(
+ const libmv_Reconstruction *libmv_reconstruction,
+ int image, double mat[4][4])
{
- const libmv::EuclideanReconstruction *reconstruction = &libmv_reconstruction->reconstruction;
- const libmv::EuclideanCamera *camera = reconstruction->CameraForImage(image);
+ const EuclideanReconstruction *reconstruction =
+ &libmv_reconstruction->reconstruction;
+ const EuclideanCamera *camera =
+ reconstruction->CameraForImage(image);
if (camera) {
for (int j = 0; j < 3; ++j) {
@@ -852,25 +770,27 @@ int libmv_reprojectionCameraForImage(const struct libmv_Reconstruction *libmv_re
return 0;
}
-double libmv_reprojectionError(const struct libmv_Reconstruction *libmv_reconstruction)
+double libmv_reprojectionError(
+ const libmv_Reconstruction *libmv_reconstruction)
{
return libmv_reconstruction->error;
}
-struct libmv_CameraIntrinsics *libmv_reconstructionExtractIntrinsics(struct libmv_Reconstruction *libmv_reconstruction)
+libmv_CameraIntrinsics *libmv_reconstructionExtractIntrinsics(
+ libmv_Reconstruction *libmv_reconstruction)
{
- return (struct libmv_CameraIntrinsics *)&libmv_reconstruction->intrinsics;
+ return (libmv_CameraIntrinsics *) libmv_reconstruction->intrinsics;
}
/* ************ Feature detector ************ */
static libmv_Features *libmv_featuresFromVector(
- const libmv::vector<libmv::Feature> &features)
+ const libmv::vector<Feature> &features)
{
- struct libmv_Features *libmv_features = LIBMV_STRUCT_NEW(libmv_Features, 1);
+ libmv_Features *libmv_features = LIBMV_STRUCT_NEW(libmv_Features, 1);
int count = features.size();
if (count) {
- libmv_features->features = LIBMV_STRUCT_NEW(libmv::Feature, count);
+ libmv_features->features = LIBMV_STRUCT_NEW(Feature, count);
for (int i = 0; i < count; i++) {
libmv_features->features[i] = features.at(i);
@@ -886,12 +806,12 @@ static libmv_Features *libmv_featuresFromVector(
}
static void libmv_convertDetectorOptions(libmv_DetectOptions *options,
- libmv::DetectOptions *detector_options)
+ DetectOptions *detector_options)
{
switch (options->detector) {
#define LIBMV_CONVERT(the_detector) \
case LIBMV_DETECTOR_ ## the_detector: \
- detector_options->type = libmv::DetectOptions::the_detector; \
+ detector_options->type = DetectOptions::the_detector; \
break;
LIBMV_CONVERT(FAST)
LIBMV_CONVERT(MORAVEC)
@@ -906,49 +826,52 @@ static void libmv_convertDetectorOptions(libmv_DetectOptions *options,
detector_options->harris_threshold = options->harris_threshold;
}
-struct libmv_Features *libmv_detectFeaturesByte(const unsigned char *image_buffer,
- int width, int height, int channels,
- libmv_DetectOptions *options)
+libmv_Features *libmv_detectFeaturesByte(
+ const unsigned char *image_buffer,
+ int width, int height,
+ int channels,
+ libmv_DetectOptions *options)
{
// Prepare the image.
- libmv::FloatImage image;
- byteBufToImage(image_buffer, width, height, channels, &image);
+ FloatImage image;
+ libmv_byteBufferToImage(image_buffer, width, height, channels, &image);
// Configure detector.
- libmv::DetectOptions detector_options;
+ DetectOptions detector_options;
libmv_convertDetectorOptions(options, &detector_options);
// Run the detector.
- libmv::vector<libmv::Feature> detected_features;
- libmv::Detect(image, detector_options, &detected_features);
+ libmv::vector<Feature> detected_features;
+ Detect(image, detector_options, &detected_features);
// Convert result to C-API.
libmv_Features *result = libmv_featuresFromVector(detected_features);
return result;
}
-struct libmv_Features *libmv_detectFeaturesFloat(const float *image_buffer,
- int width, int height, int channels,
- libmv_DetectOptions *options)
+libmv_Features *libmv_detectFeaturesFloat(const float *image_buffer,
+ int width, int height,
+ int channels,
+ libmv_DetectOptions *options)
{
// Prepare the image.
- libmv::FloatImage image;
- floatBufToImage(image_buffer, width, height, channels, &image);
+ FloatImage image;
+ libmv_floatBufferToImage(image_buffer, width, height, channels, &image);
// Configure detector.
- libmv::DetectOptions detector_options;
+ DetectOptions detector_options;
libmv_convertDetectorOptions(options, &detector_options);
// Run the detector.
- libmv::vector<libmv::Feature> detected_features;
- libmv::Detect(image, detector_options, &detected_features);
+ libmv::vector<Feature> detected_features;
+ Detect(image, detector_options, &detected_features);
// Convert result to C-API.
libmv_Features *result = libmv_featuresFromVector(detected_features);
return result;
}
-void libmv_featuresDestroy(struct libmv_Features *libmv_features)
+void libmv_featuresDestroy(libmv_Features *libmv_features)
{
if (libmv_features->features) {
LIBMV_STRUCT_DELETE(libmv_features->features);
@@ -957,14 +880,16 @@ void libmv_featuresDestroy(struct libmv_Features *libmv_features)
LIBMV_STRUCT_DELETE(libmv_features);
}
-int libmv_countFeatures(const struct libmv_Features *libmv_features)
+int libmv_countFeatures(const libmv_Features *libmv_features)
{
return libmv_features->count;
}
-void libmv_getFeature(const struct libmv_Features *libmv_features, int number, double *x, double *y, double *score, double *size)
+void libmv_getFeature(const libmv_Features *libmv_features,
+ int number,
+ double *x, double *y, double *score, double *size)
{
- libmv::Feature feature = libmv_features->features[number];
+ Feature &feature = libmv_features->features[number];
*x = feature.x;
*y = feature.y;
@@ -974,51 +899,67 @@ void libmv_getFeature(const struct libmv_Features *libmv_features, int number, d
/* ************ Camera intrinsics ************ */
-struct libmv_CameraIntrinsics *libmv_cameraIntrinsicsNewEmpty(void)
+libmv_CameraIntrinsics *libmv_cameraIntrinsicsNew(
+ const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options)
{
- libmv::CameraIntrinsics *camera_intrinsics = LIBMV_OBJECT_NEW(libmv::CameraIntrinsics);
+ CameraIntrinsics *camera_intrinsics =
+ libmv_cameraIntrinsicsCreateFromOptions(libmv_camera_intrinsics_options);
- return (struct libmv_CameraIntrinsics *) camera_intrinsics;
+ return (libmv_CameraIntrinsics *) camera_intrinsics;
}
-struct libmv_CameraIntrinsics *libmv_cameraIntrinsicsNew(const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options)
+libmv_CameraIntrinsics *libmv_cameraIntrinsicsCopy(
+ const libmv_CameraIntrinsics *libmvIntrinsics)
{
- libmv::CameraIntrinsics *camera_intrinsics = LIBMV_OBJECT_NEW(libmv::CameraIntrinsics);
-
- cameraIntrinsicsFromOptions(libmv_camera_intrinsics_options, camera_intrinsics);
-
- return (struct libmv_CameraIntrinsics *) camera_intrinsics;
-}
-
-struct libmv_CameraIntrinsics *libmv_cameraIntrinsicsCopy(const libmv_CameraIntrinsics *libmvIntrinsics)
-{
- libmv::CameraIntrinsics *orig_intrinsics = (libmv::CameraIntrinsics *) libmvIntrinsics;
- libmv::CameraIntrinsics *new_intrinsics = LIBMV_OBJECT_NEW(libmv::CameraIntrinsics, *orig_intrinsics);
+ const CameraIntrinsics *orig_intrinsics =
+ (const CameraIntrinsics *) libmvIntrinsics;
+
+ CameraIntrinsics *new_intrinsics = NULL;
+
+ switch (orig_intrinsics->GetDistortionModelType()) {
+ case libmv::DISTORTION_MODEL_POLYNOMIAL:
+ {
+ const PolynomialCameraIntrinsics *polynomial_intrinsics =
+ static_cast<const PolynomialCameraIntrinsics*>(orig_intrinsics);
+ new_intrinsics = LIBMV_OBJECT_NEW(PolynomialCameraIntrinsics,
+ *polynomial_intrinsics);
+ break;
+ }
+ case libmv::DISTORTION_MODEL_DIVISION:
+ {
+ const DivisionCameraIntrinsics *division_intrinsics =
+ static_cast<const DivisionCameraIntrinsics*>(orig_intrinsics);
+ new_intrinsics = LIBMV_OBJECT_NEW(DivisionCameraIntrinsics,
+ *division_intrinsics);
+ break;
+ }
+ default:
+ assert(!"Unknown distortion model");
+ }
- return (struct libmv_CameraIntrinsics *) new_intrinsics;
+ return (libmv_CameraIntrinsics *) new_intrinsics;
}
-void libmv_cameraIntrinsicsDestroy(struct libmv_CameraIntrinsics *libmvIntrinsics)
+void libmv_cameraIntrinsicsDestroy(libmv_CameraIntrinsics *libmvIntrinsics)
{
- using libmv::CameraIntrinsics;
LIBMV_OBJECT_DELETE(libmvIntrinsics, CameraIntrinsics);
}
-void libmv_cameraIntrinsicsUpdate(const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
- struct libmv_CameraIntrinsics *libmv_intrinsics)
+void libmv_cameraIntrinsicsUpdate(
+ const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
+ libmv_CameraIntrinsics *libmv_intrinsics)
{
- libmv::CameraIntrinsics *camera_intrinsics = (libmv::CameraIntrinsics *) libmv_intrinsics;
+ CameraIntrinsics *camera_intrinsics = (CameraIntrinsics *) libmv_intrinsics;
double focal_length = libmv_camera_intrinsics_options->focal_length;
double principal_x = libmv_camera_intrinsics_options->principal_point_x;
double principal_y = libmv_camera_intrinsics_options->principal_point_y;
- double k1 = libmv_camera_intrinsics_options->k1;
- double k2 = libmv_camera_intrinsics_options->k2;
- double k3 = libmv_camera_intrinsics_options->k3;
int image_width = libmv_camera_intrinsics_options->image_width;
int image_height = libmv_camera_intrinsics_options->image_height;
- /* try avoid unnecessary updates so pre-computed distortion grids are not freed */
+ /* Try avoid unnecessary updates,
+ * so pre-computed distortion grids are not freed.
+ */
if (camera_intrinsics->focal_length() != focal_length)
camera_intrinsics->SetFocalLength(focal_length, focal_length);
@@ -1029,105 +970,192 @@ void libmv_cameraIntrinsicsUpdate(const libmv_CameraIntrinsicsOptions *libmv_cam
camera_intrinsics->SetPrincipalPoint(principal_x, principal_y);
}
- if (camera_intrinsics->k1() != k1 ||
- camera_intrinsics->k2() != k2 ||
- camera_intrinsics->k3() != k3)
- {
- camera_intrinsics->SetRadialDistortion(k1, k2, k3);
- }
-
if (camera_intrinsics->image_width() != image_width ||
camera_intrinsics->image_height() != image_height)
{
camera_intrinsics->SetImageSize(image_width, image_height);
}
+
+ switch (libmv_camera_intrinsics_options->distortion_model) {
+ case LIBMV_DISTORTION_MODEL_POLYNOMIAL:
+ {
+ assert(camera_intrinsics->GetDistortionModelType() ==
+ libmv::DISTORTION_MODEL_POLYNOMIAL);
+
+ PolynomialCameraIntrinsics *polynomial_intrinsics =
+ (PolynomialCameraIntrinsics *) camera_intrinsics;
+
+ double k1 = libmv_camera_intrinsics_options->polynomial_k1;
+ double k2 = libmv_camera_intrinsics_options->polynomial_k2;
+ double k3 = libmv_camera_intrinsics_options->polynomial_k3;
+
+ if (polynomial_intrinsics->k1() != k1 ||
+ polynomial_intrinsics->k2() != k2 ||
+ polynomial_intrinsics->k3() != k3)
+ {
+ polynomial_intrinsics->SetRadialDistortion(k1, k2, k3);
+ }
+
+ break;
+ }
+
+ case LIBMV_DISTORTION_MODEL_DIVISION:
+ {
+ assert(camera_intrinsics->GetDistortionModelType() ==
+ libmv::DISTORTION_MODEL_DIVISION);
+
+ DivisionCameraIntrinsics *division_intrinsics =
+ (DivisionCameraIntrinsics *) camera_intrinsics;
+
+ double k1 = libmv_camera_intrinsics_options->division_k1;
+ double k2 = libmv_camera_intrinsics_options->division_k2;
+
+ if (division_intrinsics->k1() != k1 ||
+ division_intrinsics->k2() != k2)
+ {
+ division_intrinsics->SetDistortion(k1, k2);
+ }
+
+ break;
+ }
+
+ default:
+ assert(!"Unknown distortion model");
+ }
}
-void libmv_cameraIntrinsicsSetThreads(struct libmv_CameraIntrinsics *libmv_intrinsics, int threads)
+void libmv_cameraIntrinsicsSetThreads(
+ libmv_CameraIntrinsics *libmv_intrinsics, int threads)
{
- libmv::CameraIntrinsics *camera_intrinsics = (libmv::CameraIntrinsics *) libmv_intrinsics;
+ CameraIntrinsics *camera_intrinsics = (CameraIntrinsics *) libmv_intrinsics;
camera_intrinsics->SetThreads(threads);
}
-void libmv_cameraIntrinsicsExtract(const struct libmv_CameraIntrinsics *libmv_intrinsics, double *focal_length,
- double *principal_x, double *principal_y, double *k1, double *k2, double *k3,
- int *width, int *height)
+void libmv_cameraIntrinsicsExtractOptions(
+ const libmv_CameraIntrinsics *libmv_intrinsics,
+ libmv_CameraIntrinsicsOptions *camera_intrinsics_options)
{
- libmv::CameraIntrinsics *camera_intrinsics = (libmv::CameraIntrinsics *) libmv_intrinsics;
-
- *focal_length = camera_intrinsics->focal_length();
- *principal_x = camera_intrinsics->principal_point_x();
- *principal_y = camera_intrinsics->principal_point_y();
- *k1 = camera_intrinsics->k1();
- *k2 = camera_intrinsics->k2();
- *k3 = camera_intrinsics->k3();
-}
+ const CameraIntrinsics *camera_intrinsics =
+ (const CameraIntrinsics *) libmv_intrinsics;
+
+ // Fill in options which are common for all distortion models.
+ camera_intrinsics_options->focal_length = camera_intrinsics->focal_length();
+ camera_intrinsics_options->principal_point_x =
+ camera_intrinsics->principal_point_x();
+ camera_intrinsics_options->principal_point_y =
+ camera_intrinsics->principal_point_y();
+
+ camera_intrinsics_options->image_width = camera_intrinsics->image_width();
+ camera_intrinsics_options->image_height = camera_intrinsics->image_height();
+
+ switch (camera_intrinsics->GetDistortionModelType()) {
+ case libmv::DISTORTION_MODEL_POLYNOMIAL:
+ {
+ const PolynomialCameraIntrinsics *polynomial_intrinsics =
+ static_cast<const PolynomialCameraIntrinsics *>(camera_intrinsics);
+ camera_intrinsics_options->distortion_model = LIBMV_DISTORTION_MODEL_POLYNOMIAL;
+ camera_intrinsics_options->polynomial_k1 = polynomial_intrinsics->k1();
+ camera_intrinsics_options->polynomial_k2 = polynomial_intrinsics->k2();
+ camera_intrinsics_options->polynomial_k3 = polynomial_intrinsics->k3();
+ camera_intrinsics_options->polynomial_p1 = polynomial_intrinsics->p1();
+ camera_intrinsics_options->polynomial_p1 = polynomial_intrinsics->p2();
+ break;
+ }
-void libmv_cameraIntrinsicsUndistortByte(const struct libmv_CameraIntrinsics *libmv_intrinsics,
- unsigned char *src, unsigned char *dst, int width, int height,
- float overscan, int channels)
-{
- libmv::CameraIntrinsics *camera_intrinsics = (libmv::CameraIntrinsics *) libmv_intrinsics;
+ case libmv::DISTORTION_MODEL_DIVISION:
+ {
+ const DivisionCameraIntrinsics *division_intrinsics =
+ static_cast<const DivisionCameraIntrinsics *>(camera_intrinsics);
+ camera_intrinsics_options->distortion_model = LIBMV_DISTORTION_MODEL_DIVISION;
+ camera_intrinsics_options->division_k1 = division_intrinsics->k1();
+ camera_intrinsics_options->division_k2 = division_intrinsics->k2();
+ break;
+ }
- camera_intrinsics->Undistort(src, dst, width, height, overscan, channels);
+ default:
+ assert(!"Uknown distortion model");
+ }
}
-void libmv_cameraIntrinsicsUndistortFloat(const struct libmv_CameraIntrinsics *libmvIntrinsics,
- float *src, float *dst, int width, int height,
- float overscan, int channels)
+void libmv_cameraIntrinsicsUndistortByte(
+ const libmv_CameraIntrinsics *libmv_intrinsics,
+ unsigned char *src, unsigned char *dst, int width, int height,
+ float overscan, int channels)
{
- libmv::CameraIntrinsics *intrinsics = (libmv::CameraIntrinsics *) libmvIntrinsics;
-
- intrinsics->Undistort(src, dst, width, height, overscan, channels);
+ CameraIntrinsics *camera_intrinsics = (CameraIntrinsics *) libmv_intrinsics;
+ camera_intrinsics->UndistortBuffer(src,
+ width, height, overscan, channels,
+ dst);
}
-void libmv_cameraIntrinsicsDistortByte(const struct libmv_CameraIntrinsics *libmvIntrinsics,
- unsigned char *src, unsigned char *dst, int width, int height,
- float overscan, int channels)
+void libmv_cameraIntrinsicsUndistortFloat(
+ const libmv_CameraIntrinsics *libmvIntrinsics,
+ float *src, float *dst, int width, int height,
+ float overscan, int channels)
{
- libmv::CameraIntrinsics *intrinsics = (libmv::CameraIntrinsics *) libmvIntrinsics;
- intrinsics->Distort(src, dst, width, height, overscan, channels);
+ CameraIntrinsics *intrinsics = (CameraIntrinsics *) libmvIntrinsics;
+ intrinsics->UndistortBuffer(src,
+ width, height, overscan, channels,
+ dst);
}
-void libmv_cameraIntrinsicsDistortFloat(const struct libmv_CameraIntrinsics *libmvIntrinsics,
- float *src, float *dst, int width, int height,
- float overscan, int channels)
+void libmv_cameraIntrinsicsDistortByte(
+ const libmv_CameraIntrinsics *libmvIntrinsics,
+ unsigned char *src, unsigned char *dst, int width, int height,
+ float overscan, int channels)
{
- libmv::CameraIntrinsics *intrinsics = (libmv::CameraIntrinsics *) libmvIntrinsics;
-
- intrinsics->Distort(src, dst, width, height, overscan, channels);
+ CameraIntrinsics *intrinsics = (CameraIntrinsics *) libmvIntrinsics;
+ intrinsics->DistortBuffer(src,
+ width, height, overscan, channels,
+ dst);
}
-void libmv_cameraIntrinsicsApply(const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
- double x, double y, double *x1, double *y1)
+void libmv_cameraIntrinsicsDistortFloat(
+ const libmv_CameraIntrinsics *libmvIntrinsics,
+ float *src, float *dst, int width, int height,
+ float overscan, int channels)
{
- libmv::CameraIntrinsics camera_intrinsics;
-
- cameraIntrinsicsFromOptions(libmv_camera_intrinsics_options, &camera_intrinsics);
+ CameraIntrinsics *intrinsics = (CameraIntrinsics *) libmvIntrinsics;
+ intrinsics->DistortBuffer(src,
+ width, height, overscan, channels,
+ dst);
+}
+void libmv_cameraIntrinsicsApply(
+ const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
+ double x, double y, double *x1, double *y1)
+{
+ /* do a lens undistortion if focal length is non-zero only */
if (libmv_camera_intrinsics_options->focal_length) {
- /* do a lens undistortion if focal length is non-zero only */
+ CameraIntrinsics *camera_intrinsics =
+ libmv_cameraIntrinsicsCreateFromOptions(libmv_camera_intrinsics_options);
+
+ camera_intrinsics->ApplyIntrinsics(x, y, x1, y1);
- camera_intrinsics.ApplyIntrinsics(x, y, x1, y1);
+ LIBMV_OBJECT_DELETE(camera_intrinsics, CameraIntrinsics);
}
}
-void libmv_cameraIntrinsicsInvert(const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
- double x, double y, double *x1, double *y1)
+void libmv_cameraIntrinsicsInvert(
+ const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
+ double x, double y, double *x1, double *y1)
{
- libmv::CameraIntrinsics camera_intrinsics;
-
- cameraIntrinsicsFromOptions(libmv_camera_intrinsics_options, &camera_intrinsics);
-
+ /* do a lens distortion if focal length is non-zero only */
if (libmv_camera_intrinsics_options->focal_length) {
- /* do a lens distortion if focal length is non-zero only */
+ CameraIntrinsics *camera_intrinsics =
+ libmv_cameraIntrinsicsCreateFromOptions(libmv_camera_intrinsics_options);
+
+ camera_intrinsics->InvertIntrinsics(x, y, x1, y1);
- camera_intrinsics.InvertIntrinsics(x, y, x1, y1);
+ LIBMV_OBJECT_DELETE(camera_intrinsics, CameraIntrinsics);
}
}
-void libmv_homography2DFromCorrespondencesEuc(double (*x1)[2], double (*x2)[2], int num_points, double H[3][3])
+void libmv_homography2DFromCorrespondencesEuc(double (*x1)[2],
+ double (*x2)[2],
+ int num_points,
+ double H[3][3])
{
libmv::Mat x1_mat, x2_mat;
libmv::Mat3 H_mat;
@@ -1144,7 +1172,10 @@ void libmv_homography2DFromCorrespondencesEuc(double (*x1)[2], double (*x2)[2],
LG << "x2: " << x2_mat;
libmv::EstimateHomographyOptions options;
- libmv::EstimateHomography2DFromCorrespondences(x1_mat, x2_mat, options, &H_mat);
+ libmv::EstimateHomography2DFromCorrespondences(x1_mat,
+ x2_mat,
+ options,
+ &H_mat);
LG << "H: " << H_mat;
diff --git a/extern/libmv/libmv-capi.h b/extern/libmv/libmv-capi.h
index d183bc4cd41..5cd9936723b 100644
--- a/extern/libmv/libmv-capi.h
+++ b/extern/libmv/libmv-capi.h
@@ -64,11 +64,22 @@ int libmv_trackRegion(const libmv_TrackRegionOptions *options,
const double *x1, const double *y1,
libmv_TrackRegionResult *result,
double *x2, double *y2);
-void libmv_samplePlanarPatch(const float *image, int width, int height,
- int channels, const double *xs, const double *ys,
+void libmv_samplePlanarPatch(const float *image,
+ int width, int height,
+ int channels,
+ const double *xs, const double *ys,
int num_samples_x, int num_samples_y,
- const float *mask, float *patch,
+ const float *mask,
+ float *patch,
double *warped_position_x, double *warped_position_y);
+void libmv_samplePlanarPatchByte(const unsigned char *image,
+ int width, int height,
+ int channels,
+ const double *xs, const double *ys,
+ int num_samples_x, int num_samples_y,
+ const float *mask,
+ unsigned char *patch,
+ double *warped_position_x, double *warped_position_y);
/* Tracks */
struct libmv_Tracks *libmv_tracksNew(void);
@@ -81,12 +92,24 @@ void libmv_tracksInsert(struct libmv_Tracks *libmv_tracks, int image, int track,
#define LIBMV_REFINE_RADIAL_DISTORTION_K1 (1 << 2)
#define LIBMV_REFINE_RADIAL_DISTORTION_K2 (1 << 4)
+enum {
+ LIBMV_DISTORTION_MODEL_POLYNOMIAL = 0,
+ LIBMV_DISTORTION_MODEL_DIVISION = 1,
+};
+
typedef struct libmv_CameraIntrinsicsOptions {
+ /* Common settings of all distortion models. */
+ int distortion_model;
+ int image_width, image_height;
double focal_length;
double principal_point_x, principal_point_y;
- double k1, k2, k3;
- double p1, p2;
- int image_width, image_height;
+
+ /* Radial distortion model. */
+ double polynomial_k1, polynomial_k2, polynomial_k3;
+ double polynomial_p1, polynomial_p2;
+
+ /* Division distortion model. */
+ double division_k1, division_k2;
} libmv_CameraIntrinsicsOptions;
typedef struct libmv_ReconstructionOptions {
@@ -147,7 +170,6 @@ void libmv_getFeature(const struct libmv_Features *libmv_features, int number, d
double *size);
/* Camera intrinsics */
-struct libmv_CameraIntrinsics *libmv_cameraIntrinsicsNewEmpty(void);
struct libmv_CameraIntrinsics *libmv_cameraIntrinsicsNew(
const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options);
struct libmv_CameraIntrinsics *libmv_cameraIntrinsicsCopy(const struct libmv_CameraIntrinsics *libmv_intrinsics);
@@ -155,9 +177,9 @@ void libmv_cameraIntrinsicsDestroy(struct libmv_CameraIntrinsics *libmv_intrinsi
void libmv_cameraIntrinsicsUpdate(const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
struct libmv_CameraIntrinsics *libmv_intrinsics);
void libmv_cameraIntrinsicsSetThreads(struct libmv_CameraIntrinsics *libmv_intrinsics, int threads);
-void libmv_cameraIntrinsicsExtract(const struct libmv_CameraIntrinsics *libmv_intrinsics, double *focal_length,
- double *principal_x, double *principal_y, double *k1, double *k2, double *k3,
- int *width, int *height);
+void libmv_cameraIntrinsicsExtractOptions(
+ const struct libmv_CameraIntrinsics *libmv_intrinsics,
+ struct libmv_CameraIntrinsicsOptions *camera_intrinsics_options);
void libmv_cameraIntrinsicsUndistortByte(const struct libmv_CameraIntrinsics *libmv_intrinsics,
unsigned char *src, unsigned char *dst, int width, int height,
float overscan, int channels);
diff --git a/extern/libmv/libmv-capi_stub.cc b/extern/libmv/libmv-capi_stub.cc
index bd5d16c9077..36a3bc7ddee 100644
--- a/extern/libmv/libmv-capi_stub.cc
+++ b/extern/libmv/libmv-capi_stub.cc
@@ -68,11 +68,24 @@ int libmv_trackRegion(const libmv_TrackRegionOptions * /*options*/,
return false;
}
-void libmv_samplePlanarPatch(const float *image, int width, int height,
- int channels, const double *xs, const double *ys,
- int num_samples_x, int num_samples_y,
- const float *mask, float *patch,
- double *warped_position_x, double *warped_position_y)
+void libmv_samplePlanarPatch(const float * /*image*/,
+ int /*width*/, int /*height*/, int /*channels*/,
+ const double * /*xs*/, const double * /*ys*/,
+ int /*num_samples_x*/, int /*num_samples_y*/,
+ const float * /*mask*/,
+ float * /*patch*/,
+ double * /*warped_position_x*/, double * /*warped_position_y*/)
+{
+ /* TODO(sergey): implement */
+}
+
+void libmv_samplePlanarPatchByte(const unsigned char * /*image*/,
+ int /*width*/, int /*height*/, int /*channels*/,
+ const double * /*xs*/, const double * /*ys*/,
+ int /*num_samples_x*/, int /*num_samples_y*/,
+ const float * /*mask*/,
+ unsigned char * /*patch*/,
+ double * /*warped_position_x*/, double * /*warped_position_y*/)
{
/* TODO(sergey): implement */
}
@@ -186,11 +199,6 @@ struct libmv_CameraIntrinsics *libmv_reconstructionExtractIntrinsics(
return NULL;
}
-struct libmv_CameraIntrinsics *libmv_cameraIntrinsicsNewEmpty(void)
-{
- return NULL;
-}
-
struct libmv_CameraIntrinsics *libmv_cameraIntrinsicsNew(
const libmv_CameraIntrinsicsOptions * /*libmv_camera_intrinsics_options*/)
{
@@ -215,17 +223,12 @@ void libmv_cameraIntrinsicsSetThreads(struct libmv_CameraIntrinsics * /*libmv_in
{
}
-void libmv_cameraIntrinsicsExtract(const struct libmv_CameraIntrinsics * /*libmv_intrinsics*/, double * focal_length,
- double * principal_x, double *principal_y, double *k1, double *k2, double *k3,
- int *width, int *height)
+void libmv_cameraIntrinsicsExtractOptions(
+ const libmv_CameraIntrinsics */*libmv_intrinsics*/,
+ libmv_CameraIntrinsicsOptions *camera_intrinsics_options)
{
- *focal_length = 1.0;
- *principal_x = 0.0;
- *principal_y = 0.0;
- *k1 = 0.0;
- *k2 = 0.0;
- *width = 0.0;
- *height = 0.0;
+ memset(camera_intrinsics_options, 0, sizeof(libmv_CameraIntrinsicsOptions));
+ camera_intrinsics_options->focal_length = 1.0;
}
void libmv_cameraIntrinsicsUndistortByte(const struct libmv_CameraIntrinsics * /*libmv_intrinsics*/,
diff --git a/extern/libmv/libmv-util.cc b/extern/libmv/libmv-util.cc
new file mode 100644
index 00000000000..f969417d6c1
--- /dev/null
+++ b/extern/libmv/libmv-util.cc
@@ -0,0 +1,309 @@
+/*
+ * ***** 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) 2014 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation,
+ * Sergey Sharybin
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "libmv-util.h"
+#include "libmv-capi_intern.h"
+
+#include <cassert>
+#include <png.h>
+
+using libmv::CameraIntrinsics;
+using libmv::DivisionCameraIntrinsics;
+using libmv::EuclideanCamera;
+using libmv::EuclideanPoint;
+using libmv::FloatImage;
+using libmv::Marker;
+using libmv::PolynomialCameraIntrinsics;
+using libmv::Tracks;
+
+/* Image <-> buffers conversion */
+
+void libmv_byteBufferToImage(const unsigned char *buf,
+ int width, int height, int channels,
+ FloatImage *image)
+{
+ int x, y, k, a = 0;
+
+ image->Resize(height, width, channels);
+
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ for (k = 0; k < channels; k++) {
+ (*image)(y, x, k) = (float)buf[a++] / 255.0f;
+ }
+ }
+ }
+}
+
+void libmv_floatBufferToImage(const float *buf,
+ int width, int height, int channels,
+ FloatImage *image)
+{
+ image->Resize(height, width, channels);
+
+ for (int y = 0, a = 0; y < height; y++) {
+ for (int x = 0; x < width; x++) {
+ for (int k = 0; k < channels; k++) {
+ (*image)(y, x, k) = buf[a++];
+ }
+ }
+ }
+}
+
+void libmv_imageToFloatBuffer(const FloatImage &image,
+ float *buf)
+{
+ for (int y = 0, a = 0; y < image.Height(); y++) {
+ for (int x = 0; x < image.Width(); x++) {
+ for (int k = 0; k < image.Depth(); k++) {
+ buf[a++] = image(y, x, k);
+ }
+ }
+ }
+}
+
+void libmv_imageToByteBuffer(const libmv::FloatImage &image,
+ unsigned char *buf)
+{
+ for (int y = 0, a= 0; y < image.Height(); y++) {
+ for (int x = 0; x < image.Width(); x++) {
+ for (int k = 0; k < image.Depth(); k++) {
+ buf[a++] = image(y, x, k) * 255.0f;
+ }
+ }
+ }
+}
+
+/* Debugging */
+
+static void savePNGImage(png_bytep *row_pointers,
+ int width, int height, int depth, int color_type,
+ const char *file_name)
+{
+ png_infop info_ptr;
+ png_structp png_ptr;
+ FILE *fp = fopen(file_name, "wb");
+
+ if (!fp) {
+ return;
+ }
+
+ /* Initialize stuff */
+ png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+ info_ptr = png_create_info_struct(png_ptr);
+
+ if (setjmp(png_jmpbuf(png_ptr))) {
+ fclose(fp);
+ return;
+ }
+
+ png_init_io(png_ptr, fp);
+
+ /* write header */
+ if (setjmp(png_jmpbuf(png_ptr))) {
+ fclose(fp);
+ return;
+ }
+
+ png_set_IHDR(png_ptr, info_ptr,
+ width, height, depth, color_type,
+ PNG_INTERLACE_NONE,
+ PNG_COMPRESSION_TYPE_BASE,
+ PNG_FILTER_TYPE_BASE);
+
+ png_write_info(png_ptr, info_ptr);
+
+ /* write bytes */
+ if (setjmp(png_jmpbuf(png_ptr))) {
+ fclose(fp);
+ return;
+ }
+
+ png_write_image(png_ptr, row_pointers);
+
+ /* end write */
+ if (setjmp(png_jmpbuf(png_ptr))) {
+ fclose(fp);
+ return;
+ }
+
+ png_write_end(png_ptr, NULL);
+
+ fclose(fp);
+}
+
+void libmv_saveImage(const FloatImage &image,
+ const char *prefix,
+ int x0, int y0)
+{
+ int x, y;
+ png_bytep *row_pointers;
+
+ assert(image.Depth() == 1);
+
+ row_pointers = new png_bytep[image.Height()];
+
+ for (y = 0; y < image.Height(); y++) {
+ row_pointers[y] = new png_byte[4 * image.Width()];
+
+ for (x = 0; x < image.Width(); x++) {
+ if (x0 == x && image.Height() - y0 - 1 == y) {
+ row_pointers[y][x * 4 + 0] = 255;
+ row_pointers[y][x * 4 + 1] = 0;
+ row_pointers[y][x * 4 + 2] = 0;
+ row_pointers[y][x * 4 + 3] = 255;
+ }
+ else {
+ float pixel = image(image.Height() - y - 1, x, 0);
+ row_pointers[y][x * 4 + 0] = pixel * 255;
+ row_pointers[y][x * 4 + 1] = pixel * 255;
+ row_pointers[y][x * 4 + 2] = pixel * 255;
+ row_pointers[y][x * 4 + 3] = 255;
+ }
+ }
+ }
+
+ {
+ static int a = 0;
+ char buf[128];
+ snprintf(buf, sizeof(buf), "%s_%02d.png", prefix, ++a);
+ savePNGImage(row_pointers,
+ image.Width(), image.Height(), 8,
+ PNG_COLOR_TYPE_RGBA,
+ buf);
+ }
+
+ for (y = 0; y < image.Height(); y++) {
+ delete [] row_pointers[y];
+ }
+ delete [] row_pointers;
+}
+
+/* Camera intrinsics utility functions */
+
+void libmv_cameraIntrinsicsFillFromOptions(
+ const libmv_CameraIntrinsicsOptions *camera_intrinsics_options,
+ CameraIntrinsics *camera_intrinsics)
+{
+ camera_intrinsics->SetFocalLength(camera_intrinsics_options->focal_length,
+ camera_intrinsics_options->focal_length);
+
+ camera_intrinsics->SetPrincipalPoint(
+ camera_intrinsics_options->principal_point_x,
+ camera_intrinsics_options->principal_point_y);
+
+ camera_intrinsics->SetImageSize(camera_intrinsics_options->image_width,
+ camera_intrinsics_options->image_height);
+
+ switch (camera_intrinsics_options->distortion_model) {
+ case LIBMV_DISTORTION_MODEL_POLYNOMIAL:
+ {
+ PolynomialCameraIntrinsics *polynomial_intrinsics =
+ static_cast<PolynomialCameraIntrinsics*>(camera_intrinsics);
+
+ polynomial_intrinsics->SetRadialDistortion(
+ camera_intrinsics_options->polynomial_k1,
+ camera_intrinsics_options->polynomial_k2,
+ camera_intrinsics_options->polynomial_k3);
+
+ break;
+ }
+
+ case LIBMV_DISTORTION_MODEL_DIVISION:
+ {
+ DivisionCameraIntrinsics *division_intrinsics =
+ static_cast<DivisionCameraIntrinsics*>(camera_intrinsics);
+
+ division_intrinsics->SetDistortion(
+ camera_intrinsics_options->division_k1,
+ camera_intrinsics_options->division_k2);
+
+ break;
+ }
+
+ default:
+ assert(!"Unknown distortion model");
+ }
+}
+
+CameraIntrinsics *libmv_cameraIntrinsicsCreateFromOptions(
+ const libmv_CameraIntrinsicsOptions *camera_intrinsics_options)
+{
+ CameraIntrinsics *camera_intrinsics = NULL;
+
+ switch (camera_intrinsics_options->distortion_model) {
+ case LIBMV_DISTORTION_MODEL_POLYNOMIAL:
+ camera_intrinsics = LIBMV_OBJECT_NEW(PolynomialCameraIntrinsics);
+ break;
+
+ case LIBMV_DISTORTION_MODEL_DIVISION:
+ camera_intrinsics = LIBMV_OBJECT_NEW(DivisionCameraIntrinsics);
+ break;
+
+ default:
+ assert(!"Unknown distortion model");
+ }
+
+ libmv_cameraIntrinsicsFillFromOptions(camera_intrinsics_options, camera_intrinsics);
+
+ return camera_intrinsics;
+}
+
+/* Reconstruction utilities */
+
+void libmv_getNormalizedTracks(const Tracks &tracks,
+ const CameraIntrinsics &camera_intrinsics,
+ Tracks *normalized_tracks)
+{
+ libmv::vector<Marker> markers = tracks.AllMarkers();
+
+ for (int i = 0; i < markers.size(); ++i) {
+ Marker &marker = markers[i];
+ camera_intrinsics.InvertIntrinsics(marker.x, marker.y,
+ &marker.x, &marker.y);
+ normalized_tracks->Insert(marker.image, marker.track,
+ marker.x, marker.y,
+ marker.weight);
+ }
+}
+
+Marker libmv_projectMarker(const EuclideanPoint &point,
+ const EuclideanCamera &camera,
+ const CameraIntrinsics &intrinsics)
+{
+ libmv::Vec3 projected = camera.R * point.X + camera.t;
+ projected /= projected(2);
+
+ libmv::Marker reprojected_marker;
+ intrinsics.ApplyIntrinsics(projected(0), projected(1),
+ &reprojected_marker.x,
+ &reprojected_marker.y);
+
+ reprojected_marker.image = camera.image;
+ reprojected_marker.track = point.track;
+
+ return reprojected_marker;
+}
diff --git a/extern/libmv/libmv-util.h b/extern/libmv/libmv-util.h
new file mode 100644
index 00000000000..d755f98d06d
--- /dev/null
+++ b/extern/libmv/libmv-util.h
@@ -0,0 +1,69 @@
+/*
+ * ***** 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) 2014 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation,
+ * Sergey Sharybin
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef LIBMV_UTIL_H
+#define LIBMV_UTIL_H
+
+#include "libmv-capi.h"
+#include "libmv/image/image.h"
+#include "libmv/simple_pipeline/camera_intrinsics.h"
+#include "libmv/simple_pipeline/tracks.h"
+#include "libmv/simple_pipeline/reconstruction.h"
+
+void libmv_byteBufferToImage(const unsigned char *buf,
+ int width, int height, int channels,
+ libmv::FloatImage *image);
+
+void libmv_floatBufferToImage(const float *buf,
+ int width, int height, int channels,
+ libmv::FloatImage *image);
+
+void libmv_imageToFloatBuffer(const libmv::FloatImage &image,
+ float *buf);
+
+void libmv_imageToByteBuffer(const libmv::FloatImage &image,
+ unsigned char *buf);
+
+void libmv_saveImage(const libmv::FloatImage &image,
+ const char *prefix,
+ int x0, int y0);
+
+void libmv_cameraIntrinsicsFillFromOptions(
+ const libmv_CameraIntrinsicsOptions *camera_intrinsics_options,
+ libmv::CameraIntrinsics *camera_intrinsics);
+
+libmv::CameraIntrinsics *libmv_cameraIntrinsicsCreateFromOptions(
+ const libmv_CameraIntrinsicsOptions *camera_intrinsics_options);
+
+void libmv_getNormalizedTracks(const libmv::Tracks &tracks,
+ const libmv::CameraIntrinsics &camera_intrinsics,
+ libmv::Tracks *normalized_tracks);
+
+libmv::Marker libmv_projectMarker(const libmv::EuclideanPoint &point,
+ const libmv::EuclideanCamera &camera,
+ const libmv::CameraIntrinsics &intrinsics);
+
+#endif
diff --git a/extern/libmv/libmv/base/aligned_malloc.cc b/extern/libmv/libmv/base/aligned_malloc.cc
new file mode 100644
index 00000000000..9141186f196
--- /dev/null
+++ b/extern/libmv/libmv/base/aligned_malloc.cc
@@ -0,0 +1,74 @@
+// Copyright (c) 2014 libmv authors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+
+#include "libmv/base/aligned_malloc.h"
+#include "libmv/logging/logging.h"
+
+#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__)
+// Needed for memalign on Linux and _aligned_alloc on Windows.
+# ifdef FREE_WINDOWS
+/* make sure _aligned_malloc is included */
+# ifdef __MSVCRT_VERSION__
+# undef __MSVCRT_VERSION__
+# endif
+
+# define __MSVCRT_VERSION__ 0x0700
+# endif // FREE_WINDOWS
+
+# include <malloc.h>
+#else
+// Apple's malloc is 16-byte aligned, and does not have malloc.h, so include
+// stdilb instead.
+# include <cstdlib>
+#endif
+
+namespace libmv {
+
+void *aligned_malloc(int size, int alignment) {
+#ifdef _WIN32
+ return _aligned_malloc(size, alignment);
+#elif __APPLE__
+ // On Mac OS X, both the heap and the stack are guaranteed 16-byte aligned so
+ // they work natively with SSE types with no further work.
+ CHECK_EQ(alignment, 16);
+ return malloc(size);
+#elif defined(__FreeBSD__) || defined(__NetBSD__)
+ void *result;
+
+ if (posix_memalign(&result, alignment, size)) {
+ // non-zero means allocation error
+ // either no allocation or bad alignment value
+ return NULL;
+ }
+ return result;
+#else // This is for Linux.
+ return memalign(alignment, size);
+#endif
+}
+
+void aligned_free(void *ptr) {
+#ifdef _WIN32
+ _aligned_free(ptr);
+#else
+ free(ptr);
+#endif
+}
+
+} // namespace libmv
diff --git a/extern/libmv/libmv/base/aligned_malloc.h b/extern/libmv/libmv/base/aligned_malloc.h
new file mode 100644
index 00000000000..096ff6e2d7c
--- /dev/null
+++ b/extern/libmv/libmv/base/aligned_malloc.h
@@ -0,0 +1,34 @@
+// Copyright (c) 2014 libmv authors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+
+#ifndef LIBMV_BASE_ALIGNED_MALLOC_H_
+#define LIBMV_BASE_ALIGNED_MALLOC_H_
+
+namespace libmv {
+
+// Allocate block of size bytes at least aligned to a given value.
+void *aligned_malloc(int size, int alignment);
+
+// Free memory allocated by aligned_malloc.
+void aligned_free(void *ptr);
+
+} // namespace libmv
+
+#endif // LIBMV_BASE_ALIGNED_MALLOC_H_
diff --git a/extern/libmv/libmv/image/correlation.h b/extern/libmv/libmv/image/correlation.h
index ac1f8edab49..c354f7e891e 100644
--- a/extern/libmv/libmv/image/correlation.h
+++ b/extern/libmv/libmv/image/correlation.h
@@ -27,34 +27,40 @@
namespace libmv {
inline double PearsonProductMomentCorrelation(
- Array3Df image_and_gradient1_sampled,
- Array3Df image_and_gradient2_sampled,
- int width) {
+ const FloatImage &image_and_gradient1_sampled,
+ const FloatImage &image_and_gradient2_sampled) {
+ assert(image_and_gradient1_sampled.Width() ==
+ image_and_gradient2_sampled.Width());
+ assert(image_and_gradient1_sampled.Height() ==
+ image_and_gradient2_sampled.Height());
+
+ const int width = image_and_gradient1_sampled.Width(),
+ height = image_and_gradient1_sampled.Height();
double sX = 0, sY = 0, sXX = 0, sYY = 0, sXY = 0;
- for (int r = 0; r < width; ++r) {
+ for (int r = 0; r < height; ++r) {
for (int c = 0; c < width; ++c) {
double x = image_and_gradient1_sampled(r, c, 0);
double y = image_and_gradient2_sampled(r, c, 0);
sX += x;
sY += y;
- sXX += x*x;
- sYY += y*y;
- sXY += x*y;
+ sXX += x * x;
+ sYY += y * y;
+ sXY += x * y;
}
}
// Normalize.
- double N = width * width;
+ double N = width * height;
sX /= N;
sY /= N;
sXX /= N;
sYY /= N;
sXY /= N;
- double var_x = sXX - sX*sX;
- double var_y = sYY - sY*sY;
- double covariance_xy = sXY - sX*sY;
+ double var_x = sXX - sX * sX;
+ double var_y = sYY - sY * sY;
+ double covariance_xy = sXY - sX * sY;
double correlation = covariance_xy / sqrt(var_x * var_y);
LG << "Covariance xy: " << covariance_xy
diff --git a/extern/libmv/libmv/simple_pipeline/bundle.cc b/extern/libmv/libmv/simple_pipeline/bundle.cc
index f571b0fcaab..fc1882a0b72 100644
--- a/extern/libmv/libmv/simple_pipeline/bundle.cc
+++ b/extern/libmv/libmv/simple_pipeline/bundle.cc
@@ -32,6 +32,7 @@
#include "libmv/simple_pipeline/camera_intrinsics.h"
#include "libmv/simple_pipeline/reconstruction.h"
#include "libmv/simple_pipeline/tracks.h"
+#include "libmv/simple_pipeline/distortion_models.h"
#ifdef _OPENMP
# include <omp.h>
@@ -42,16 +43,27 @@ namespace libmv {
// The intrinsics need to get combined into a single parameter block; use these
// enums to index instead of numeric constants.
enum {
+ // Camera calibration values.
OFFSET_FOCAL_LENGTH,
OFFSET_PRINCIPAL_POINT_X,
OFFSET_PRINCIPAL_POINT_Y,
+
+ // Distortion model coefficients.
OFFSET_K1,
OFFSET_K2,
OFFSET_K3,
OFFSET_P1,
OFFSET_P2,
+
+ // Maximal possible offset.
+ OFFSET_MAX,
};
+#define FIRST_DISTORTION_COEFFICIENT OFFSET_K1
+#define LAST_DISTORTION_COEFFICIENT OFFSET_P2
+#define NUM_DISTORTION_COEFFICIENTS \
+ (LAST_DISTORTION_COEFFICIENT - FIRST_DISTORTION_COEFFICIENT + 1)
+
namespace {
// Cost functor which computes reprojection error of 3D point X
@@ -60,10 +72,12 @@ namespace {
//
// This functor uses a radial distortion model.
struct OpenCVReprojectionError {
- OpenCVReprojectionError(const double observed_x,
+ OpenCVReprojectionError(const DistortionModelType distortion_model,
+ const double observed_x,
const double observed_y,
const double weight)
- : observed_x_(observed_x), observed_y_(observed_y),
+ : distortion_model_(distortion_model),
+ observed_x_(observed_x), observed_y_(observed_y),
weight_(weight) {}
template <typename T>
@@ -76,11 +90,6 @@ struct OpenCVReprojectionError {
const T& focal_length = intrinsics[OFFSET_FOCAL_LENGTH];
const T& principal_point_x = intrinsics[OFFSET_PRINCIPAL_POINT_X];
const T& principal_point_y = intrinsics[OFFSET_PRINCIPAL_POINT_Y];
- const T& k1 = intrinsics[OFFSET_K1];
- const T& k2 = intrinsics[OFFSET_K2];
- const T& k3 = intrinsics[OFFSET_K3];
- const T& p1 = intrinsics[OFFSET_P1];
- const T& p2 = intrinsics[OFFSET_P2];
// Compute projective coordinates: x = RX + t.
T x[3];
@@ -104,15 +113,44 @@ struct OpenCVReprojectionError {
// Apply distortion to the normalized points to get (xd, yd).
// TODO(keir): Do early bailouts for zero distortion; these are expensive
// jet operations.
- ApplyRadialDistortionCameraIntrinsics(focal_length,
- focal_length,
- principal_point_x,
- principal_point_y,
- k1, k2, k3,
- p1, p2,
- xn, yn,
- &predicted_x,
- &predicted_y);
+ switch (distortion_model_) {
+ case DISTORTION_MODEL_POLYNOMIAL:
+ {
+ const T& k1 = intrinsics[OFFSET_K1];
+ const T& k2 = intrinsics[OFFSET_K2];
+ const T& k3 = intrinsics[OFFSET_K3];
+ const T& p1 = intrinsics[OFFSET_P1];
+ const T& p2 = intrinsics[OFFSET_P2];
+
+ ApplyPolynomialDistortionModel(focal_length,
+ focal_length,
+ principal_point_x,
+ principal_point_y,
+ k1, k2, k3,
+ p1, p2,
+ xn, yn,
+ &predicted_x,
+ &predicted_y);
+ break;
+ }
+ case DISTORTION_MODEL_DIVISION:
+ {
+ const T& k1 = intrinsics[OFFSET_K1];
+ const T& k2 = intrinsics[OFFSET_K2];
+
+ ApplyDivisionDistortionModel(focal_length,
+ focal_length,
+ principal_point_x,
+ principal_point_y,
+ k1, k2,
+ xn, yn,
+ &predicted_x,
+ &predicted_y);
+ break;
+ }
+ default:
+ LOG(FATAL) << "Unknown distortion model";
+ }
// The error is the difference between the predicted and observed position.
residuals[0] = (predicted_x - T(observed_x_)) * weight_;
@@ -120,6 +158,7 @@ struct OpenCVReprojectionError {
return true;
}
+ const DistortionModelType distortion_model_;
const double observed_x_;
const double observed_y_;
const double weight_;
@@ -154,32 +193,38 @@ void BundleIntrinsicsLogMessage(const int bundle_intrinsics) {
// Pack intrinsics from object to an array for easier
// and faster minimization.
void PackIntrinisicsIntoArray(const CameraIntrinsics &intrinsics,
- double ceres_intrinsics[8]) {
+ double ceres_intrinsics[OFFSET_MAX]) {
ceres_intrinsics[OFFSET_FOCAL_LENGTH] = intrinsics.focal_length();
ceres_intrinsics[OFFSET_PRINCIPAL_POINT_X] = intrinsics.principal_point_x();
ceres_intrinsics[OFFSET_PRINCIPAL_POINT_Y] = intrinsics.principal_point_y();
- ceres_intrinsics[OFFSET_K1] = intrinsics.k1();
- ceres_intrinsics[OFFSET_K2] = intrinsics.k2();
- ceres_intrinsics[OFFSET_K3] = intrinsics.k3();
- ceres_intrinsics[OFFSET_P1] = intrinsics.p1();
- ceres_intrinsics[OFFSET_P2] = intrinsics.p2();
+
+ int num_distortion_parameters = intrinsics.num_distortion_parameters();
+ assert(num_distortion_parameters <= NUM_DISTORTION_COEFFICIENTS);
+
+ const double *distortion_parameters = intrinsics.distortion_parameters();
+ for (int i = 0; i < num_distortion_parameters; ++i) {
+ ceres_intrinsics[FIRST_DISTORTION_COEFFICIENT + i] =
+ distortion_parameters[i];
+ }
}
// Unpack intrinsics back from an array to an object.
-void UnpackIntrinsicsFromArray(const double ceres_intrinsics[8],
- CameraIntrinsics *intrinsics) {
- intrinsics->SetFocalLength(ceres_intrinsics[OFFSET_FOCAL_LENGTH],
- ceres_intrinsics[OFFSET_FOCAL_LENGTH]);
+void UnpackIntrinsicsFromArray(const double ceres_intrinsics[OFFSET_MAX],
+ CameraIntrinsics *intrinsics) {
+ intrinsics->SetFocalLength(ceres_intrinsics[OFFSET_FOCAL_LENGTH],
+ ceres_intrinsics[OFFSET_FOCAL_LENGTH]);
- intrinsics->SetPrincipalPoint(ceres_intrinsics[OFFSET_PRINCIPAL_POINT_X],
- ceres_intrinsics[OFFSET_PRINCIPAL_POINT_Y]);
+ intrinsics->SetPrincipalPoint(ceres_intrinsics[OFFSET_PRINCIPAL_POINT_X],
+ ceres_intrinsics[OFFSET_PRINCIPAL_POINT_Y]);
- intrinsics->SetRadialDistortion(ceres_intrinsics[OFFSET_K1],
- ceres_intrinsics[OFFSET_K2],
- ceres_intrinsics[OFFSET_K3]);
+ int num_distortion_parameters = intrinsics->num_distortion_parameters();
+ assert(num_distortion_parameters <= NUM_DISTORTION_COEFFICIENTS);
- intrinsics->SetTangentialDistortion(ceres_intrinsics[OFFSET_P1],
- ceres_intrinsics[OFFSET_P2]);
+ double *distortion_parameters = intrinsics->distortion_parameters();
+ for (int i = 0; i < num_distortion_parameters; ++i) {
+ distortion_parameters[i] =
+ ceres_intrinsics[FIRST_DISTORTION_COEFFICIENT + i];
+ }
}
// Get a vector of camera's rotations denoted by angle axis
@@ -330,9 +375,10 @@ void EuclideanBundlerPerformEvaluation(const Tracks &tracks,
//
// At this point we only need to bundle points positions, cameras
// are to be totally still here.
-void EuclideanBundlePointsOnly(const vector<Marker> &markers,
+void EuclideanBundlePointsOnly(const DistortionModelType distortion_model,
+ const vector<Marker> &markers,
vector<Vec6> &all_cameras_R_t,
- double ceres_intrinsics[8],
+ double ceres_intrinsics[OFFSET_MAX],
EuclideanReconstruction *reconstruction) {
ceres::Problem::Options problem_options;
ceres::Problem problem(problem_options);
@@ -350,8 +396,9 @@ void EuclideanBundlePointsOnly(const vector<Marker> &markers,
double *current_camera_R_t = &all_cameras_R_t[camera->image](0);
problem.AddResidualBlock(new ceres::AutoDiffCostFunction<
- OpenCVReprojectionError, 2, 8, 6, 3>(
+ OpenCVReprojectionError, 2, OFFSET_MAX, 6, 3>(
new OpenCVReprojectionError(
+ distortion_model,
marker.x,
marker.y,
1.0)),
@@ -397,21 +444,22 @@ void EuclideanBundlePointsOnly(const vector<Marker> &markers,
void EuclideanBundle(const Tracks &tracks,
EuclideanReconstruction *reconstruction) {
- CameraIntrinsics intrinsics;
+ PolynomialCameraIntrinsics empty_intrinsics;
EuclideanBundleCommonIntrinsics(tracks,
BUNDLE_NO_INTRINSICS,
BUNDLE_NO_CONSTRAINTS,
reconstruction,
- &intrinsics,
+ &empty_intrinsics,
NULL);
}
-void EuclideanBundleCommonIntrinsics(const Tracks &tracks,
- const int bundle_intrinsics,
- const int bundle_constraints,
- EuclideanReconstruction *reconstruction,
- CameraIntrinsics *intrinsics,
- BundleEvaluation *evaluation) {
+void EuclideanBundleCommonIntrinsics(
+ const Tracks &tracks,
+ const int bundle_intrinsics,
+ const int bundle_constraints,
+ EuclideanReconstruction *reconstruction,
+ CameraIntrinsics *intrinsics,
+ BundleEvaluation *evaluation) {
LG << "Original intrinsics: " << *intrinsics;
vector<Marker> markers = tracks.AllMarkers();
@@ -421,7 +469,7 @@ void EuclideanBundleCommonIntrinsics(const Tracks &tracks,
// Residual blocks with 10 parameters are unwieldly with Ceres, so pack the
// intrinsics into a single block and rely on local parameterizations to
// control which intrinsics are allowed to vary.
- double ceres_intrinsics[8];
+ double ceres_intrinsics[OFFSET_MAX];
PackIntrinisicsIntoArray(*intrinsics, ceres_intrinsics);
// Convert cameras rotations to angle axis and merge with translation
@@ -468,8 +516,9 @@ void EuclideanBundleCommonIntrinsics(const Tracks &tracks,
// This way ceres is not gonna to go crazy.
if (marker.weight != 0.0) {
problem.AddResidualBlock(new ceres::AutoDiffCostFunction<
- OpenCVReprojectionError, 2, 8, 6, 3>(
+ OpenCVReprojectionError, 2, OFFSET_MAX, 6, 3>(
new OpenCVReprojectionError(
+ intrinsics->GetDistortionModelType(),
marker.x,
marker.y,
marker.weight)),
@@ -501,6 +550,12 @@ void EuclideanBundleCommonIntrinsics(const Tracks &tracks,
return;
}
+ if (intrinsics->GetDistortionModelType() == DISTORTION_MODEL_DIVISION &&
+ (bundle_intrinsics & BUNDLE_TANGENTIAL) != 0) {
+ LOG(FATAL) << "Division model doesn't support bundling "
+ "of tangential distortion";
+ }
+
BundleIntrinsicsLogMessage(bundle_intrinsics);
if (bundle_intrinsics == BUNDLE_NO_INTRINSICS) {
@@ -529,7 +584,7 @@ void EuclideanBundleCommonIntrinsics(const Tracks &tracks,
constant_intrinsics.push_back(OFFSET_K3);
ceres::SubsetParameterization *subset_parameterization =
- new ceres::SubsetParameterization(8, constant_intrinsics);
+ new ceres::SubsetParameterization(OFFSET_MAX, constant_intrinsics);
problem.SetParameterization(ceres_intrinsics, subset_parameterization);
}
@@ -585,7 +640,8 @@ void EuclideanBundleCommonIntrinsics(const Tracks &tracks,
if (zero_weight_markers.size()) {
LG << "Refining position of constant zero-weighted tracks";
- EuclideanBundlePointsOnly(zero_weight_markers,
+ EuclideanBundlePointsOnly(intrinsics->GetDistortionModelType(),
+ zero_weight_markers,
all_cameras_R_t,
ceres_intrinsics,
reconstruction);
diff --git a/extern/libmv/libmv/simple_pipeline/bundle.h b/extern/libmv/libmv/simple_pipeline/bundle.h
index d19eec16d6d..781bd8476fe 100644
--- a/extern/libmv/libmv/simple_pipeline/bundle.h
+++ b/extern/libmv/libmv/simple_pipeline/bundle.h
@@ -114,12 +114,13 @@ enum BundleConstraints {
BUNDLE_NO_CONSTRAINTS = 0,
BUNDLE_NO_TRANSLATION = 1,
};
-void EuclideanBundleCommonIntrinsics(const Tracks &tracks,
- const int bundle_intrinsics,
- const int bundle_constraints,
- EuclideanReconstruction *reconstruction,
- CameraIntrinsics *intrinsics,
- BundleEvaluation *evaluation = NULL);
+void EuclideanBundleCommonIntrinsics(
+ const Tracks &tracks,
+ const int bundle_intrinsics,
+ const int bundle_constraints,
+ EuclideanReconstruction *reconstruction,
+ CameraIntrinsics *intrinsics,
+ BundleEvaluation *evaluation = NULL);
/*!
Refine camera poses and 3D coordinates using bundle adjustment.
diff --git a/extern/libmv/libmv/simple_pipeline/camera_intrinsics.cc b/extern/libmv/libmv/simple_pipeline/camera_intrinsics.cc
index ddbbec58def..5e4e07b3c4c 100644
--- a/extern/libmv/libmv/simple_pipeline/camera_intrinsics.cc
+++ b/extern/libmv/libmv/simple_pipeline/camera_intrinsics.cc
@@ -19,358 +19,226 @@
// IN THE SOFTWARE.
#include "libmv/simple_pipeline/camera_intrinsics.h"
-#include "libmv/numeric/levenberg_marquardt.h"
-namespace libmv {
+#include "libmv/logging/logging.h"
+#include "libmv/simple_pipeline/distortion_models.h"
-struct Offset {
- short ix, iy;
- unsigned char fx, fy;
-};
+namespace libmv {
-struct Grid {
- struct Offset *offset;
- int width, height;
- double overscan;
-};
+namespace internal {
-static struct Grid *copyGrid(struct Grid *from) {
- struct Grid *to = NULL;
+LookupWarpGrid::LookupWarpGrid()
+ : offset_(NULL),
+ width_(0),
+ height_(0),
+ overscan_(0.0),
+ threads_(1) {}
- if (from) {
- to = new Grid;
+LookupWarpGrid::LookupWarpGrid(const LookupWarpGrid &from)
+ : offset_(NULL),
+ width_(from.width_),
+ height_(from.height_),
+ overscan_(from.overscan_),
+ threads_(from.threads_) {
+ if (from.offset_) {
+ offset_ = new Offset[width_ * height_];
+ memcpy(offset_, from.offset_, sizeof(Offset) * width_ * height_);
+ }
+}
- to->width = from->width;
- to->height = from->height;
- to->overscan = from->overscan;
+LookupWarpGrid::~LookupWarpGrid() {
+ delete [] offset_;
+}
- to->offset = new Offset[to->width*to->height];
- memcpy(to->offset, from->offset, sizeof(struct Offset)*to->width*to->height);
- }
+void LookupWarpGrid::Reset() {
+ delete [] offset_;
+ offset_ = NULL;
+}
- return to;
+// Set number of threads used for threaded buffer distortion/undistortion.
+void LookupWarpGrid::SetThreads(int threads) {
+ threads_ = threads;
}
+} // namespace internal
+
CameraIntrinsics::CameraIntrinsics()
- : K_(Mat3::Identity()),
- image_width_(0),
+ : image_width_(0),
image_height_(0),
- k1_(0),
- k2_(0),
- k3_(0),
- p1_(0),
- p2_(0),
- distort_(0),
- undistort_(0),
- threads_(1) {}
+ K_(Mat3::Identity()) {}
CameraIntrinsics::CameraIntrinsics(const CameraIntrinsics &from)
- : K_(from.K_),
- image_width_(from.image_width_),
+ : image_width_(from.image_width_),
image_height_(from.image_height_),
- k1_(from.k1_),
- k2_(from.k2_),
- k3_(from.k3_),
- p1_(from.p1_),
- p2_(from.p2_),
- threads_(from.threads_) {
- distort_ = copyGrid(from.distort_);
- undistort_ = copyGrid(from.undistort_);
-}
+ K_(from.K_),
+ distort_(from.distort_),
+ undistort_(from.undistort_) {}
-CameraIntrinsics::~CameraIntrinsics() {
- FreeLookupGrid();
+// Set the image size in pixels.
+void CameraIntrinsics::SetImageSize(int width, int height) {
+ image_width_ = width;
+ image_height_ = height;
+ ResetLookupGrids();
}
-/// Set the entire calibration matrix at once.
+// Set the entire calibration matrix at once.
void CameraIntrinsics::SetK(const Mat3 new_k) {
K_ = new_k;
- FreeLookupGrid();
+ ResetLookupGrids();
}
-/// Set both x and y focal length in pixels.
-void CameraIntrinsics::SetFocalLength(double focal_x, double focal_y) {
+// Set both x and y focal length in pixels.
+void CameraIntrinsics::SetFocalLength(double focal_x,
+ double focal_y) {
K_(0, 0) = focal_x;
K_(1, 1) = focal_y;
- FreeLookupGrid();
+ ResetLookupGrids();
}
-void CameraIntrinsics::SetPrincipalPoint(double cx, double cy) {
+// Set principal point in pixels.
+void CameraIntrinsics::SetPrincipalPoint(double cx,
+ double cy) {
K_(0, 2) = cx;
K_(1, 2) = cy;
- FreeLookupGrid();
+ ResetLookupGrids();
}
-void CameraIntrinsics::SetImageSize(int width, int height) {
- image_width_ = width;
- image_height_ = height;
- FreeLookupGrid();
+// Set number of threads used for threaded buffer distortion/undistortion.
+void CameraIntrinsics::SetThreads(int threads) {
+ distort_.SetThreads(threads);
+ undistort_.SetThreads(threads);
}
-void CameraIntrinsics::SetRadialDistortion(double k1, double k2, double k3) {
- k1_ = k1;
- k2_ = k2;
- k3_ = k3;
- FreeLookupGrid();
+void CameraIntrinsics::ImageSpaceToNormalized(double image_x,
+ double image_y,
+ double *normalized_x,
+ double *normalized_y) const {
+ *normalized_x = (image_x - principal_point_x()) / focal_length_x();
+ *normalized_y = (image_y - principal_point_y()) / focal_length_y();
}
-void CameraIntrinsics::SetTangentialDistortion(double p1, double p2) {
- p1_ = p1;
- p2_ = p2;
- FreeLookupGrid();
+void CameraIntrinsics::NormalizedToImageSpace(double normalized_x,
+ double normalized_y,
+ double *image_x,
+ double *image_y) const {
+ *image_x = normalized_x * focal_length_x() + principal_point_x();
+ *image_y = normalized_y * focal_length_y() + principal_point_y();
}
-void CameraIntrinsics::SetThreads(int threads) {
- threads_ = threads;
+// Reset lookup grids after changing the distortion model.
+void CameraIntrinsics::ResetLookupGrids() {
+ distort_.Reset();
+ undistort_.Reset();
}
-void CameraIntrinsics::ApplyIntrinsics(double normalized_x,
- double normalized_y,
- double *image_x,
- double *image_y) const {
- ApplyRadialDistortionCameraIntrinsics(focal_length_x(),
- focal_length_y(),
- principal_point_x(),
- principal_point_y(),
- k1(), k2(), k3(),
- p1(), p2(),
- normalized_x,
- normalized_y,
- image_x,
- image_y);
+PolynomialCameraIntrinsics::PolynomialCameraIntrinsics()
+ : CameraIntrinsics() {
+ SetRadialDistortion(0.0, 0.0, 0.0);
+ SetTangentialDistortion(0.0, 0.0);
}
-struct InvertIntrinsicsCostFunction {
- public:
- typedef Vec2 FMatrixType;
- typedef Vec2 XMatrixType;
-
- InvertIntrinsicsCostFunction(const CameraIntrinsics &intrinsics,
- double image_x, double image_y)
- : intrinsics(intrinsics), x(image_x), y(image_y) {}
-
- Vec2 operator()(const Vec2 &u) const {
- double xx, yy;
- intrinsics.ApplyIntrinsics(u(0), u(1), &xx, &yy);
- Vec2 fx;
- fx << (xx - x), (yy - y);
- return fx;
- }
- const CameraIntrinsics &intrinsics;
- double x, y;
-};
-
-void CameraIntrinsics::InvertIntrinsics(double image_x,
- double image_y,
- double *normalized_x,
- double *normalized_y) const {
- // Compute the initial guess. For a camera with no distortion, this will also
- // be the final answer; the LM iteration will terminate immediately.
- Vec2 normalized;
- normalized(0) = (image_x - principal_point_x()) / focal_length_x();
- normalized(1) = (image_y - principal_point_y()) / focal_length_y();
-
- typedef LevenbergMarquardt<InvertIntrinsicsCostFunction> Solver;
-
- InvertIntrinsicsCostFunction intrinsics_cost(*this, image_x, image_y);
- Solver::SolverParameters params;
- Solver solver(intrinsics_cost);
-
- /*Solver::Results results =*/ solver.minimize(params, &normalized);
-
- // TODO(keir): Better error handling.
-
- *normalized_x = normalized(0);
- *normalized_y = normalized(1);
+PolynomialCameraIntrinsics::PolynomialCameraIntrinsics(
+ const PolynomialCameraIntrinsics &from)
+ : CameraIntrinsics(from) {
+ SetRadialDistortion(from.k1(), from.k2(), from.k3());
+ SetTangentialDistortion(from.p1(), from.p2());
}
-// TODO(MatthiasF): downsample lookup
-template<typename WarpFunction>
-void CameraIntrinsics::ComputeLookupGrid(Grid* grid, int width, int height,
- double overscan) {
- double w = (double)width / (1 + overscan);
- double h = (double)height / (1 + overscan);
- double aspx = (double)w / image_width_;
- double aspy = (double)h / image_height_;
-#if defined(_OPENMP)
-# pragma omp parallel for schedule(dynamic) num_threads(threads_) \
- if (threads_ > 1 && height > 100)
-#endif
- for (int y = 0; y < height; y++) {
- for (int x = 0; x < width; x++) {
- double src_x = (x - 0.5 * overscan * w) / aspx,
- src_y = (y - 0.5 * overscan * h) / aspy;
- double warp_x, warp_y;
- WarpFunction(this, src_x, src_y, &warp_x, &warp_y);
- warp_x = warp_x*aspx + 0.5 * overscan * w;
- warp_y = warp_y*aspy + 0.5 * overscan * h;
- int ix = int(warp_x), iy = int(warp_y);
- int fx = round((warp_x-ix)*256), fy = round((warp_y-iy)*256);
- if (fx == 256) { fx = 0; ix++; } // NOLINT
- if (fy == 256) { fy = 0; iy++; } // NOLINT
- // Use nearest border pixel
- if (ix < 0) { ix = 0, fx = 0; } // NOLINT
- if (iy < 0) { iy = 0, fy = 0; } // NOLINT
- if (ix >= width - 2) ix = width-2;
- if (iy >= height - 2) iy = height-2;
-
- Offset offset = { (short)(ix-x), (short)(iy-y),
- (unsigned char)fx, (unsigned char)fy };
- grid->offset[y*width+x] = offset;
- }
- }
+void PolynomialCameraIntrinsics::SetRadialDistortion(double k1,
+ double k2,
+ double k3) {
+ parameters_[OFFSET_K1] = k1;
+ parameters_[OFFSET_K2] = k2;
+ parameters_[OFFSET_K3] = k3;
+ ResetLookupGrids();
}
-// TODO(MatthiasF): cubic B-Spline image sampling, bilinear lookup
-template<typename T>
-static void Warp(const Grid* grid, const T* src, T* dst,
- const int width, const int height, const int channels,
- const int threads) {
- (void) threads; // Ignored if OpenMP is disabled
-#if defined(_OPENMP)
-# pragma omp parallel for schedule(dynamic) num_threads(threads) \
- if (threads > 1 && height > 100)
-#endif
- for (int y = 0; y < height; y++) {
- for (int x = 0; x < width; x++) {
- Offset offset = grid->offset[y*width+x];
- const T* s = &src[((y + offset.iy) * width + (x + offset.ix)) * channels];
- for (int i = 0; i < channels; i++) {
- // TODO(sergey): Finally wrap this into ultiple lines nicely.
- dst[(y*width+x)*channels+i] =
- ((s[ i] * (256-offset.fx) + s[ channels+i] * offset.fx) * (256-offset.fy) // NOLINT
- +(s[width*channels+i] * (256-offset.fx) + s[width*channels+channels+i] * offset.fx) * offset.fy) / (256*256); // NOLINT
- }
- }
- }
+void PolynomialCameraIntrinsics::SetTangentialDistortion(double p1,
+ double p2) {
+ parameters_[OFFSET_P1] = p1;
+ parameters_[OFFSET_P2] = p2;
+ ResetLookupGrids();
}
-void CameraIntrinsics::FreeLookupGrid() {
- if (distort_) {
- delete distort_->offset;
- delete distort_;
- distort_ = NULL;
- }
-
- if (undistort_) {
- delete undistort_->offset;
- delete undistort_;
- undistort_ = NULL;
- }
+void PolynomialCameraIntrinsics::ApplyIntrinsics(double normalized_x,
+ double normalized_y,
+ double *image_x,
+ double *image_y) const {
+ ApplyPolynomialDistortionModel(focal_length_x(),
+ focal_length_y(),
+ principal_point_x(),
+ principal_point_y(),
+ k1(), k2(), k3(),
+ p1(), p2(),
+ normalized_x,
+ normalized_y,
+ image_x,
+ image_y);
}
-// FIXME: C++ templates limitations makes thing complicated,
-// but maybe there is a simpler method.
-struct ApplyIntrinsicsFunction {
- ApplyIntrinsicsFunction(CameraIntrinsics* intrinsics, double x, double y,
- double *warp_x, double *warp_y) {
- intrinsics->ApplyIntrinsics(
- (x-intrinsics->principal_point_x())/intrinsics->focal_length_x(),
- (y-intrinsics->principal_point_y())/intrinsics->focal_length_y(),
- warp_x, warp_y);
- }
-};
-struct InvertIntrinsicsFunction {
- InvertIntrinsicsFunction(CameraIntrinsics* intrinsics, double x, double y,
- double *warp_x, double *warp_y) {
- intrinsics->InvertIntrinsics(x, y, warp_x, warp_y);
-
- *warp_x = *warp_x * intrinsics->focal_length_x() +
- intrinsics->principal_point_x();
-
- *warp_y = *warp_y * intrinsics->focal_length_y() +
- intrinsics->principal_point_y();
- }
-};
-
-void CameraIntrinsics::CheckDistortLookupGrid(int width, int height,
- double overscan) {
- if (distort_) {
- if (distort_->width != width || distort_->height != height ||
- distort_->overscan != overscan) {
- delete [] distort_->offset;
- distort_->offset = NULL;
- }
- } else {
- distort_ = new Grid;
- distort_->offset = NULL;
- }
-
- if (!distort_->offset) {
- distort_->offset = new Offset[width * height];
- ComputeLookupGrid<InvertIntrinsicsFunction>(distort_, width,
- height, overscan);
- }
-
- distort_->width = width;
- distort_->height = height;
- distort_->overscan = overscan;
+void PolynomialCameraIntrinsics::InvertIntrinsics(
+ double image_x,
+ double image_y,
+ double *normalized_x,
+ double *normalized_y) const {
+ InvertPolynomialDistortionModel(focal_length_x(),
+ focal_length_y(),
+ principal_point_x(),
+ principal_point_y(),
+ k1(), k2(), k3(),
+ p1(), p2(),
+ image_x,
+ image_y,
+ normalized_x,
+ normalized_y);
}
-void CameraIntrinsics::CheckUndistortLookupGrid(int width, int height,
- double overscan) {
- if (undistort_) {
- if (undistort_->width != width || undistort_->height != height ||
- undistort_->overscan != overscan) {
- delete [] undistort_->offset;
- undistort_->offset = NULL;
- }
- } else {
- undistort_ = new Grid;
- undistort_->offset = NULL;
- }
-
- if (!undistort_->offset) {
- undistort_->offset = new Offset[width * height];
- ComputeLookupGrid<ApplyIntrinsicsFunction>(undistort_, width,
- height, overscan);
- }
-
- undistort_->width = width;
- undistort_->height = height;
- undistort_->overscan = overscan;
+DivisionCameraIntrinsics::DivisionCameraIntrinsics()
+ : CameraIntrinsics() {
+ SetDistortion(0.0, 0.0);
}
-void CameraIntrinsics::Distort(const float* src, float* dst,
- int width, int height,
- double overscan,
- int channels) {
- assert(channels >= 1);
- assert(channels <= 4);
- CheckDistortLookupGrid(width, height, overscan);
- Warp<float>(distort_, src, dst, width, height, channels, threads_);
+DivisionCameraIntrinsics::DivisionCameraIntrinsics(
+ const DivisionCameraIntrinsics &from)
+ : CameraIntrinsics(from) {
+ SetDistortion(from.k1(), from.k1());
}
-void CameraIntrinsics::Distort(const unsigned char* src,
- unsigned char* dst,
- int width, int height,
- double overscan,
- int channels) {
- assert(channels >= 1);
- assert(channels <= 4);
- CheckDistortLookupGrid(width, height, overscan);
- Warp<unsigned char>(distort_, src, dst, width, height, channels, threads_);
+void DivisionCameraIntrinsics::SetDistortion(double k1,
+ double k2) {
+ parameters_[OFFSET_K1] = k1;
+ parameters_[OFFSET_K2] = k2;
+ ResetLookupGrids();
}
-void CameraIntrinsics::Undistort(const float* src, float* dst,
- int width, int height,
- double overscan,
- int channels) {
- assert(channels >= 1);
- assert(channels <= 4);
- CheckUndistortLookupGrid(width, height, overscan);
- Warp<float>(undistort_, src, dst, width, height, channels, threads_);
+void DivisionCameraIntrinsics::ApplyIntrinsics(double normalized_x,
+ double normalized_y,
+ double *image_x,
+ double *image_y) const {
+ ApplyDivisionDistortionModel(focal_length_x(),
+ focal_length_y(),
+ principal_point_x(),
+ principal_point_y(),
+ k1(), k2(),
+ normalized_x,
+ normalized_y,
+ image_x,
+ image_y);
}
-void CameraIntrinsics::Undistort(const unsigned char* src,
- unsigned char* dst,
- int width, int height,
- double overscan,
- int channels) {
- assert(channels >= 1);
- assert(channels <= 4);
- CheckUndistortLookupGrid(width, height, overscan);
- Warp<unsigned char>(undistort_, src, dst, width, height, channels, threads_);
+void DivisionCameraIntrinsics::InvertIntrinsics(double image_x,
+ double image_y,
+ double *normalized_x,
+ double *normalized_y) const {
+ InvertDivisionDistortionModel(focal_length_x(),
+ focal_length_y(),
+ principal_point_x(),
+ principal_point_y(),
+ k1(), k2(),
+ image_x,
+ image_y,
+ normalized_x,
+ normalized_y);
}
std::ostream& operator <<(std::ostream &os,
@@ -386,11 +254,38 @@ std::ostream& operator <<(std::ostream &os,
<< " w=" << intrinsics.image_width()
<< " h=" << intrinsics.image_height();
- if (intrinsics.k1() != 0.0) { os << " k1=" << intrinsics.k1(); }
- if (intrinsics.k2() != 0.0) { os << " k2=" << intrinsics.k2(); }
- if (intrinsics.k3() != 0.0) { os << " k3=" << intrinsics.k3(); }
- if (intrinsics.p1() != 0.0) { os << " p1=" << intrinsics.p1(); }
- if (intrinsics.p2() != 0.0) { os << " p2=" << intrinsics.p2(); }
+#define PRINT_NONZERO_COEFFICIENT(intrinsics, coeff) \
+ { \
+ if (intrinsics->coeff() != 0.0) { \
+ os << " " #coeff "=" << intrinsics->coeff(); \
+ } \
+ } (void) 0
+
+ switch (intrinsics.GetDistortionModelType()) {
+ case DISTORTION_MODEL_POLYNOMIAL:
+ {
+ const PolynomialCameraIntrinsics *polynomial_intrinsics =
+ static_cast<const PolynomialCameraIntrinsics *>(&intrinsics);
+ PRINT_NONZERO_COEFFICIENT(polynomial_intrinsics, k1);
+ PRINT_NONZERO_COEFFICIENT(polynomial_intrinsics, k2);
+ PRINT_NONZERO_COEFFICIENT(polynomial_intrinsics, k3);
+ PRINT_NONZERO_COEFFICIENT(polynomial_intrinsics, p1);
+ PRINT_NONZERO_COEFFICIENT(polynomial_intrinsics, p2);
+ break;
+ }
+ case DISTORTION_MODEL_DIVISION:
+ {
+ const DivisionCameraIntrinsics *division_intrinsics =
+ static_cast<const DivisionCameraIntrinsics *>(&intrinsics);
+ PRINT_NONZERO_COEFFICIENT(division_intrinsics, k1);
+ PRINT_NONZERO_COEFFICIENT(division_intrinsics, k2);
+ break;
+ }
+ default:
+ LOG(FATAL) << "Unknown distortion model.";
+ }
+
+#undef PRINT_NONZERO_COEFFICIENT
return os;
}
diff --git a/extern/libmv/libmv/simple_pipeline/camera_intrinsics.h b/extern/libmv/libmv/simple_pipeline/camera_intrinsics.h
index 5a348899a11..6a3ade81089 100644
--- a/extern/libmv/libmv/simple_pipeline/camera_intrinsics.h
+++ b/extern/libmv/libmv/simple_pipeline/camera_intrinsics.h
@@ -26,181 +26,381 @@
#include <Eigen/Core>
+#include "libmv/numeric/numeric.h"
+#include "libmv/simple_pipeline/distortion_models.h"
+
namespace libmv {
-typedef Eigen::Matrix<double, 3, 3> Mat3;
+class CameraIntrinsics;
-struct Grid;
+namespace internal {
-class CameraIntrinsics {
+// This class is responsible to store a lookup grid to perform
+// image warping using this lookup grid. Such a magic is needed
+// to make (un)distortion as fast as possible in cases multiple
+// images are to be processed.
+class LookupWarpGrid {
public:
- CameraIntrinsics();
- CameraIntrinsics(const CameraIntrinsics &from);
- ~CameraIntrinsics();
-
- const Mat3 &K() const { return K_; }
- double focal_length() const { return K_(0, 0); }
- double focal_length_x() const { return K_(0, 0); }
- double focal_length_y() const { return K_(1, 1); }
- double principal_point_x() const { return K_(0, 2); }
- double principal_point_y() const { return K_(1, 2); }
- int image_width() const { return image_width_; }
- int image_height() const { return image_height_; }
- double k1() const { return k1_; }
- double k2() const { return k2_; }
- double k3() const { return k3_; }
- double p1() const { return p1_; }
- double p2() const { return p2_; }
-
- /// Set the entire calibration matrix at once.
- void SetK(const Mat3 new_k);
-
- /// Set both x and y focal length in pixels.
- void SetFocalLength(double focal_x, double focal_y);
-
- /// Set principal point in pixels.
- void SetPrincipalPoint(double cx, double cy);
-
- /// Set the image size in pixels.
- void SetImageSize(int width, int height);
-
- void SetRadialDistortion(double k1, double k2, double k3 = 0);
-
- void SetTangentialDistortion(double p1, double p2);
-
- /// Set number of threads using for buffer distortion/undistortion
+ LookupWarpGrid();
+ LookupWarpGrid(const LookupWarpGrid &from);
+ ~LookupWarpGrid();
+
+ // Width and height og the image, measured in pixels.
+ int width() const { return width_; }
+ int height() const { return height_; }
+
+ // Overscan factor of the image, so that
+ // - 0.0 is overscan of 0 pixels,
+ // - 1.0 is overscan of image weight pixels in horizontal direction
+ // and image height pixels in vertical direction.
+ double overscan() const { return overscan_; }
+
+ // Update lookup grid in order to be sure it's calculated for
+ // given image width, height and overscan.
+ //
+ // See comment for CameraIntrinsics::DistortBuffer to get more
+ // details about what overscan is.
+ template<typename WarpFunction>
+ void Update(const CameraIntrinsics &intrinsics,
+ int width,
+ int height,
+ double overscan);
+
+ // Apply coordinate lookup grid on a giver input buffer.
+ //
+ // See comment for CameraIntrinsics::DistortBuffer to get more
+ // details about template type.
+ template<typename PixelType>
+ void Apply(const PixelType *input_buffer,
+ int width,
+ int height,
+ int channels,
+ PixelType *output_buffer);
+
+ // Reset lookup grids.
+ // This will tag the grid for update without re-computing it.
+ void Reset();
+
+ // Set number of threads used for threaded buffer distortion/undistortion.
void SetThreads(int threads);
- /*!
- Apply camera intrinsics to the normalized point to get image coordinates.
-
- This applies the lens distortion to a point which is in normalized
- camera coordinates (i.e. the principal point is at (0, 0)) to get image
- coordinates in pixels.
- */
- void ApplyIntrinsics(double normalized_x, double normalized_y,
- double *image_x, double *image_y) const;
+ private:
+ // This structure contains an offset in both x,y directions
+ // in an optimized way sawing some bytes per pixel in the memory.
+ //
+ // TODO(sergey): This is rather questionable optimizations, memory
+ // is cheap nowadays and storing offset in such a way implies much
+ // more operations comparing to using bare floats.
+ struct Offset {
+ // Integer part of the offset.
+ short ix, iy;
+
+ // Float part of an offset, to get a real float value divide this
+ // value by 255.
+ unsigned char fx, fy;
+ };
+
+ // Compute coordinate lookup grid using a giver warp functor.
+ //
+ // width and height corresponds to a size of buffer which will
+ // be warped later.
+ template<typename WarpFunction>
+ void Compute(const CameraIntrinsics &intrinsics,
+ int width,
+ int height,
+ double overscan);
+
+ // This is a buffer which contains per-pixel offset of the
+ // pixels from input buffer to correspond the warping function.
+ Offset *offset_;
+
+ // Dimensions of the image this lookup grid processes.
+ int width_, height_;
+
+ // Overscan of the image being processed by this grid.
+ double overscan_;
+
+ // Number of threads which will be used for buffer istortion/undistortion.
+ int threads_;
+};
- /*!
- Invert camera intrinsics on the image point to get normalized coordinates.
+} // namespace internal
- This reverses the effect of lens distortion on a point which is in image
- coordinates to get normalized camera coordinates.
- */
- void InvertIntrinsics(double image_x, double image_y,
- double *normalized_x, double *normalized_y) const;
+class CameraIntrinsics {
+ public:
+ CameraIntrinsics();
+ CameraIntrinsics(const CameraIntrinsics &from);
+ virtual ~CameraIntrinsics() {}
- /*!
- Distort an image using the current camera instrinsics
+ virtual DistortionModelType GetDistortionModelType() const = 0;
- The distorted image is computed in \a dst using samples from \a src.
- both buffers should be \a width x \a height x \a channels sized.
+ int image_width() const { return image_width_; }
+ int image_height() const { return image_height_; }
- \note This is the reference implementation using floating point images.
- */
- void Distort(const float* src, float* dst,
- int width, int height, double overscan, int channels);
+ const Mat3 &K() const { return K_; }
- /*!
- Distort an image using the current camera instrinsics
+ double focal_length() const { return K_(0, 0); }
+ double focal_length_x() const { return K_(0, 0); }
+ double focal_length_y() const { return K_(1, 1); }
- The distorted image is computed in \a dst using samples from \a src.
- both buffers should be \a width x \a height x \a channels sized.
+ double principal_point_x() const { return K_(0, 2); }
+ double principal_point_y() const { return K_(1, 2); }
- \note This version is much faster.
- */
- void Distort(const unsigned char* src, unsigned char* dst,
- int width, int height, double overscan, int channels);
+ virtual int num_distortion_parameters() const = 0;
+ virtual double *distortion_parameters() = 0;
+ virtual const double *distortion_parameters() const = 0;
- /*!
- Undistort an image using the current camera instrinsics
+ // Set the image size in pixels.
+ // Image is the size of image camera intrinsics were calibrated with.
+ void SetImageSize(int width, int height);
- The undistorted image is computed in \a dst using samples from \a src.
- both buffers should be \a width x \a height x \a channels sized.
+ // Set the entire calibration matrix at once.
+ void SetK(const Mat3 new_k);
- \note This is the reference implementation using floating point images.
- */
- void Undistort(const float* src, float* dst,
- int width, int height, double overscan, int channels);
+ // Set both x and y focal length in pixels.
+ void SetFocalLength(double focal_x, double focal_y);
- /*!
- Undistort an image using the current camera instrinsics
+ // Set principal point in pixels.
+ void SetPrincipalPoint(double cx, double cy);
- The undistorted image is computed in \a dst using samples from \a src.
- both buffers should be \a width x \a height x \a channels sized.
+ // Set number of threads used for threaded buffer distortion/undistortion.
+ void SetThreads(int threads);
- \note This version is much faster.
- */
- void Undistort(const unsigned char* src, unsigned char* dst,
- int width, int height, double overscan, int channels);
+ // Convert image space coordinates to normalized.
+ void ImageSpaceToNormalized(double image_x,
+ double image_y,
+ double *normalized_x,
+ double *normalized_y) const;
+
+ // Convert normalized coordinates to image space.
+ void NormalizedToImageSpace(double normalized_x,
+ double normalized_y,
+ double *image_x,
+ double *image_y) const;
+
+ // Apply camera intrinsics to the normalized point to get image coordinates.
+ //
+ // This applies the lens distortion to a point which is in normalized
+ // camera coordinates (i.e. the principal point is at (0, 0)) to get image
+ // coordinates in pixels.
+ virtual void ApplyIntrinsics(double normalized_x,
+ double normalized_y,
+ double *image_x,
+ double *image_y) const = 0;
+
+ // Invert camera intrinsics on the image point to get normalized coordinates.
+ //
+ // This reverses the effect of lens distortion on a point which is in image
+ // coordinates to get normalized camera coordinates.
+ virtual void InvertIntrinsics(double image_x,
+ double image_y,
+ double *normalized_x,
+ double *normalized_y) const = 0;
+
+ // Distort an image using the current camera instrinsics
+ //
+ // The distorted image is computed in output_buffer using samples from
+ // input_buffer. Both buffers should be width x height x channels sized.
+ //
+ // Overscan is a percentage value of how much overcan the image have.
+ // For example overscal value of 0.2 means 20% of overscan in the
+ // buffers.
+ //
+ // Overscan is usually used in cases when one need to distort an image
+ // and don't have a barrel in the distorted buffer. For example, when
+ // one need to render properly distorted FullHD frame without barrel
+ // visible. For such cases renderers usually renders bigger images and
+ // crops them after the distortion.
+ //
+ // This method is templated to be able to distort byte and float buffers
+ // without having separate methods for this two types. So basically only
+ //
+ // But in fact PixelType might be any type for which multiplication by
+ // a scalar and addition are implemented. For example PixelType might be
+ // Vec3 as well.
+ template<typename PixelType>
+ void DistortBuffer(const PixelType *input_buffer,
+ int width,
+ int height,
+ double overscan,
+ int channels,
+ PixelType *output_buffer);
+
+ // Undistort an image using the current camera instrinsics
+ //
+ // The undistorted image is computed in output_buffer using samples from
+ // input_buffer. Both buffers should be width x height x channels sized.
+ //
+ // Overscan is a percentage value of how much overcan the image have.
+ // For example overscal value of 0.2 means 20% of overscan in the
+ // buffers.
+ //
+ // Overscan is usually used in cases when one need to distort an image
+ // and don't have a barrel in the distorted buffer. For example, when
+ // one need to render properly distorted FullHD frame without barrel
+ // visible. For such cases renderers usually renders bigger images and
+ // crops them after the distortion.
+ //
+ // This method is templated to be able to distort byte and float buffers
+ // without having separate methods for this two types. So basically only
+ //
+ // But in fact PixelType might be any type for which multiplication by
+ // a scalar and addition are implemented. For example PixelType might be
+ // Vec3 as well.
+ template<typename PixelType>
+ void UndistortBuffer(const PixelType *input_buffer,
+ int width,
+ int height,
+ double overscan,
+ int channels,
+ PixelType *output_buffer);
private:
- template<typename WarpFunction> void ComputeLookupGrid(struct Grid* grid,
- int width,
- int height,
- double overscan);
- void CheckUndistortLookupGrid(int width, int height, double overscan);
- void CheckDistortLookupGrid(int width, int height, double overscan);
- void FreeLookupGrid();
-
- // The traditional intrinsics matrix from x = K[R|t]X.
- Mat3 K_;
-
// This is the size of the image. This is necessary to, for example, handle
// the case of processing a scaled image.
int image_width_;
int image_height_;
+ // The traditional intrinsics matrix from x = K[R|t]X.
+ Mat3 K_;
+
+ // Coordinate lookup grids for distortion and undistortion.
+ internal::LookupWarpGrid distort_;
+ internal::LookupWarpGrid undistort_;
+
+ protected:
+ // Reset lookup grids after changing the distortion model.
+ void ResetLookupGrids();
+};
+
+class PolynomialCameraIntrinsics : public CameraIntrinsics {
+ public:
+ // This constants defines an offset of corresponding coefficients
+ // in the arameters_ array.
+ enum {
+ OFFSET_K1,
+ OFFSET_K2,
+ OFFSET_K3,
+ OFFSET_P1,
+ OFFSET_P2,
+
+ // This defines the size of array which we need to have in order
+ // to store all the coefficients.
+ NUM_PARAMETERS,
+ };
+
+ PolynomialCameraIntrinsics();
+ PolynomialCameraIntrinsics(const PolynomialCameraIntrinsics &from);
+
+ DistortionModelType GetDistortionModelType() const {
+ return DISTORTION_MODEL_POLYNOMIAL;
+ }
+
+ int num_distortion_parameters() const { return NUM_PARAMETERS; }
+ double *distortion_parameters() { return parameters_; };
+ const double *distortion_parameters() const { return parameters_; };
+
+ double k1() const { return parameters_[OFFSET_K1]; }
+ double k2() const { return parameters_[OFFSET_K2]; }
+ double k3() const { return parameters_[OFFSET_K3]; }
+ double p1() const { return parameters_[OFFSET_P1]; }
+ double p2() const { return parameters_[OFFSET_P2]; }
+
+ // Set radial distortion coeffcients.
+ void SetRadialDistortion(double k1, double k2, double k3);
+
+ // Set tangential distortion coeffcients.
+ void SetTangentialDistortion(double p1, double p2);
+
+ // Apply camera intrinsics to the normalized point to get image coordinates.
+ //
+ // This applies the lens distortion to a point which is in normalized
+ // camera coordinates (i.e. the principal point is at (0, 0)) to get image
+ // coordinates in pixels.
+ void ApplyIntrinsics(double normalized_x,
+ double normalized_y,
+ double *image_x,
+ double *image_y) const;
+
+ // Invert camera intrinsics on the image point to get normalized coordinates.
+ //
+ // This reverses the effect of lens distortion on a point which is in image
+ // coordinates to get normalized camera coordinates.
+ void InvertIntrinsics(double image_x,
+ double image_y,
+ double *normalized_x,
+ double *normalized_y) const;
+
+ private:
// OpenCV's distortion model with third order polynomial radial distortion
// terms and second order tangential distortion. The distortion is applied to
// the normalized coordinates before the focal length, which makes them
// independent of image size.
- double k1_, k2_, k3_, p1_, p2_;
+ double parameters_[NUM_PARAMETERS];
+};
- struct Grid *distort_;
- struct Grid *undistort_;
+class DivisionCameraIntrinsics : public CameraIntrinsics {
+ public:
+ // This constants defines an offset of corresponding coefficients
+ // in the arameters_ array.
+ enum {
+ OFFSET_K1,
+ OFFSET_K2,
+
+ // This defines the size of array which we need to have in order
+ // to store all the coefficients.
+ NUM_PARAMETERS,
+ };
+
+ DivisionCameraIntrinsics();
+ DivisionCameraIntrinsics(const DivisionCameraIntrinsics &from);
+
+ DistortionModelType GetDistortionModelType() const {
+ return DISTORTION_MODEL_DIVISION;
+ }
+
+ int num_distortion_parameters() const { return NUM_PARAMETERS; }
+ double *distortion_parameters() { return parameters_; };
+ const double *distortion_parameters() const { return parameters_; };
+
+ double k1() const { return parameters_[OFFSET_K1]; }
+ double k2() const { return parameters_[OFFSET_K2]; }
+
+ // Set radial distortion coeffcients.
+ void SetDistortion(double k1, double k2);
+
+ // Apply camera intrinsics to the normalized point to get image coordinates.
+ //
+ // This applies the lens distortion to a point which is in normalized
+ // camera coordinates (i.e. the principal point is at (0, 0)) to get image
+ // coordinates in pixels.
+ void ApplyIntrinsics(double normalized_x,
+ double normalized_y,
+ double *image_x,
+ double *image_y) const;
+
+ // Invert camera intrinsics on the image point to get normalized coordinates.
+ //
+ // This reverses the effect of lens distortion on a point which is in image
+ // coordinates to get normalized camera coordinates.
+ void InvertIntrinsics(double image_x,
+ double image_y,
+ double *normalized_x,
+ double *normalized_y) const;
- int threads_;
+ private:
+ // Double-parameter division distortion model.
+ double parameters_[NUM_PARAMETERS];
};
/// A human-readable representation of the camera intrinsic parameters.
std::ostream& operator <<(std::ostream &os,
const CameraIntrinsics &intrinsics);
-// Apply camera intrinsics to the normalized point to get image coordinates.
-// This applies the radial lens distortion to a point which is in normalized
-// camera coordinates (i.e. the principal point is at (0, 0)) to get image
-// coordinates in pixels. Templated for use with autodifferentiation.
-template <typename T>
-inline void ApplyRadialDistortionCameraIntrinsics(const T &focal_length_x,
- const T &focal_length_y,
- const T &principal_point_x,
- const T &principal_point_y,
- const T &k1,
- const T &k2,
- const T &k3,
- const T &p1,
- const T &p2,
- const T &normalized_x,
- const T &normalized_y,
- T *image_x,
- T *image_y) {
- T x = normalized_x;
- T y = normalized_y;
-
- // Apply distortion to the normalized points to get (xd, yd).
- T r2 = x*x + y*y;
- T r4 = r2 * r2;
- T r6 = r4 * r2;
- T r_coeff = (T(1) + k1*r2 + k2*r4 + k3*r6);
- T xd = x * r_coeff + T(2)*p1*x*y + p2*(r2 + T(2)*x*x);
- T yd = y * r_coeff + T(2)*p2*x*y + p1*(r2 + T(2)*y*y);
-
- // Apply focal length and principal point to get the final image coordinates.
- *image_x = focal_length_x * xd + principal_point_x;
- *image_y = focal_length_y * yd + principal_point_y;
-}
-
} // namespace libmv
+// Include implementation of all templated methods here,
+// so they're visible to the compiler.
+#include "libmv/simple_pipeline/camera_intrinsics_impl.h"
+
#endif // LIBMV_SIMPLE_PIPELINE_CAMERA_INTRINSICS_H_
diff --git a/extern/libmv/libmv/simple_pipeline/camera_intrinsics_impl.h b/extern/libmv/libmv/simple_pipeline/camera_intrinsics_impl.h
new file mode 100644
index 00000000000..97abee7ab01
--- /dev/null
+++ b/extern/libmv/libmv/simple_pipeline/camera_intrinsics_impl.h
@@ -0,0 +1,192 @@
+// Copyright (c) 2014 libmv authors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+
+namespace libmv {
+
+namespace {
+
+// FIXME: C++ templates limitations makes thing complicated,
+// but maybe there is a simpler method.
+struct ApplyIntrinsicsFunction {
+ ApplyIntrinsicsFunction(const CameraIntrinsics &intrinsics,
+ double x,
+ double y,
+ double *warp_x,
+ double *warp_y) {
+ double normalized_x, normalized_y;
+ intrinsics.ImageSpaceToNormalized(x, y, &normalized_x, &normalized_y);
+ intrinsics.ApplyIntrinsics(normalized_x, normalized_y, warp_x, warp_y);
+ }
+};
+
+struct InvertIntrinsicsFunction {
+ InvertIntrinsicsFunction(const CameraIntrinsics &intrinsics,
+ double x,
+ double y,
+ double *warp_x,
+ double *warp_y) {
+ double normalized_x, normalized_y;
+ intrinsics.InvertIntrinsics(x, y, &normalized_x, &normalized_y);
+ intrinsics.NormalizedToImageSpace(normalized_x, normalized_y, warp_x, warp_y);
+ }
+};
+
+} // namespace
+
+namespace internal {
+
+// TODO(MatthiasF): downsample lookup
+template<typename WarpFunction>
+void LookupWarpGrid::Compute(const CameraIntrinsics &intrinsics,
+ int width,
+ int height,
+ double overscan) {
+ double w = (double) width / (1.0 + overscan);
+ double h = (double) height / (1.0 + overscan);
+ double aspx = (double) w / intrinsics.image_width();
+ double aspy = (double) h / intrinsics.image_height();
+#if defined(_OPENMP)
+# pragma omp parallel for schedule(dynamic) num_threads(threads_) \
+ if (threads_ > 1 && height > 100)
+#endif
+ for (int y = 0; y < height; y++) {
+ for (int x = 0; x < width; x++) {
+ double src_x = (x - 0.5 * overscan * w) / aspx,
+ src_y = (y - 0.5 * overscan * h) / aspy;
+ double warp_x, warp_y;
+ WarpFunction(intrinsics, src_x, src_y, &warp_x, &warp_y);
+ warp_x = warp_x * aspx + 0.5 * overscan * w;
+ warp_y = warp_y * aspy + 0.5 * overscan * h;
+ int ix = int(warp_x), iy = int(warp_y);
+ int fx = round((warp_x - ix) * 256), fy = round((warp_y - iy) * 256);
+ if (fx == 256) { fx = 0; ix++; } // NOLINT
+ if (fy == 256) { fy = 0; iy++; } // NOLINT
+ // Use nearest border pixel
+ if (ix < 0) { ix = 0, fx = 0; } // NOLINT
+ if (iy < 0) { iy = 0, fy = 0; } // NOLINT
+ if (ix >= width - 2) ix = width - 2;
+ if (iy >= height - 2) iy = height - 2;
+
+ Offset offset = { (short) (ix - x),
+ (short) (iy - y),
+ (unsigned char) fx,
+ (unsigned char) fy };
+ offset_[y * width + x] = offset;
+ }
+ }
+}
+
+template<typename WarpFunction>
+void LookupWarpGrid::Update(const CameraIntrinsics &intrinsics,
+ int width,
+ int height,
+ double overscan) {
+ if (width_ != width ||
+ height_ != height ||
+ overscan_ != overscan) {
+ Reset();
+ }
+
+ if (offset_ == NULL) {
+ offset_ = new Offset[width * height];
+ Compute<WarpFunction>(intrinsics,
+ width,
+ height,
+ overscan);
+ }
+
+ width_ = width;
+ height_ = height;
+ overscan_ = overscan;
+}
+
+// TODO(MatthiasF): cubic B-Spline image sampling, bilinear lookup
+template<typename PixelType>
+void LookupWarpGrid::Apply(const PixelType *input_buffer,
+ int width,
+ int height,
+ int channels,
+ PixelType *output_buffer) {
+#if defined(_OPENMP)
+# pragma omp parallel for schedule(dynamic) num_threads(threads_) \
+ if (threads_ > 1 && height > 100)
+#endif
+ for (int y = 0; y < height; y++) {
+ for (int x = 0; x < width; x++) {
+ Offset offset = offset_[y * width + x];
+ const int pixel_index = ((y + offset.iy) * width +
+ (x + offset.ix)) * channels;
+ const PixelType *s = &input_buffer[pixel_index];
+ for (int i = 0; i < channels; i++) {
+ output_buffer[(y * width + x) * channels + i] =
+ ((s[i] * (256 - offset.fx) +
+ s[channels + i] * offset.fx) * (256 - offset.fy) +
+ (s[width * channels + i] * (256 - offset.fx) +
+ s[width * channels + channels + i] * offset.fx) * offset.fy)
+ / (256 * 256);
+ }
+ }
+ }
+}
+
+} // namespace internal
+
+template<typename PixelType>
+void CameraIntrinsics::DistortBuffer(const PixelType *input_buffer,
+ int width,
+ int height,
+ double overscan,
+ int channels,
+ PixelType *output_buffer) {
+ assert(channels >= 1);
+ assert(channels <= 4);
+ distort_.Update<InvertIntrinsicsFunction>(*this,
+ width,
+ height,
+ overscan);
+ distort_.Apply<PixelType>(input_buffer,
+ width,
+ height,
+ channels,
+ output_buffer);
+}
+
+template<typename PixelType>
+void CameraIntrinsics::UndistortBuffer(const PixelType *input_buffer,
+ int width,
+ int height,
+ double overscan,
+ int channels,
+ PixelType *output_buffer) {
+ assert(channels >= 1);
+ assert(channels <= 4);
+ undistort_.Update<ApplyIntrinsicsFunction>(*this,
+ width,
+ height,
+ overscan);
+
+ undistort_.Apply<PixelType>(input_buffer,
+ width,
+ height,
+ channels,
+ output_buffer);
+}
+
+} // namespace libmv
diff --git a/extern/libmv/libmv/simple_pipeline/detect.cc b/extern/libmv/libmv/simple_pipeline/detect.cc
index 4039c83210c..46599a4c49e 100644
--- a/extern/libmv/libmv/simple_pipeline/detect.cc
+++ b/extern/libmv/libmv/simple_pipeline/detect.cc
@@ -45,6 +45,14 @@ namespace libmv {
namespace {
+// Default value for FAST minimal trackness in the DetectOptions structure.
+// TODO(sergey): Think of a better default value here.
+int kDefaultFastMinTrackness = 128;
+
+// Default value for Harris threshold in the DetectOptions structure.
+// TODO(sergey): Think of a better default value here.
+double kDefaultHarrisThreshold = 1e-5;
+
class FeatureComparison {
public:
bool operator() (const Feature &left, const Feature &right) const {
@@ -134,11 +142,10 @@ void DetectFAST(const FloatImage &grayscale_image,
if (num_features) {
vector<Feature> all_features;
for (int i = 0; i < num_features; ++i) {
- Feature new_feature = {(float)nonmax[i].x + margin,
- (float)nonmax[i].y + margin,
- (float)scores[i],
- 0};
- all_features.push_back(new_feature);
+ all_features.push_back(Feature((float)nonmax[i].x + margin,
+ (float)nonmax[i].y + margin,
+ (float)scores[i],
+ 9.0));
}
FilterFeaturesByDistance(all_features, min_distance, detected_features);
}
@@ -233,15 +240,24 @@ void DetectMORAVEC(const FloatImage &grayscale_image,
int min = 255, total = 0;
for (; min > 0; min--) {
int h = histogram[min];
- if (total+h > count) break;
+ if (total + h > count) {
+ break;
+ }
total += h;
}
- for (int y = 16; y < height-16; y++) {
- for (int x = 16; x < width-16; x++) {
- int s = scores[y*width+x];
- Feature f = { (float)x+8.0f, (float)y+8.0f, (float)s, 16 };
+ for (int y = 16; y < height - 16; y++) {
+ for (int x = 16; x < width - 16; x++) {
+ int s = scores[y * width + x];
if (s > min) {
- detected_features->push_back(f);
+ // Currently SAD works with the patterns of 16x16 pixels.
+ //
+ // Score calculation above uses top left corner of the
+ // patch as the origin, here we need to convert this value
+ // to a pattrn center by adding 8 pixels.
+ detected_features->push_back(Feature((float) x + 8.0f,
+ (float) y + 8.0f,
+ (float) s,
+ 16.0f));
}
}
}
@@ -288,8 +304,10 @@ void DetectHarris(const FloatImage &grayscale_image,
double traceA = A.trace();
double harris_function = detA - alpha * traceA * traceA;
if (harris_function > threshold) {
- Feature new_feature = {(float)x, (float)y, (float)harris_function, 0.0f};
- all_features.push_back(new_feature);
+ all_features.push_back(Feature((float) x,
+ (float) y,
+ (float) harris_function,
+ 5.0f));
}
}
}
@@ -303,10 +321,10 @@ DetectOptions::DetectOptions()
: type(DetectOptions::HARRIS),
margin(0),
min_distance(120),
- fast_min_trackness(128),
+ fast_min_trackness(kDefaultFastMinTrackness),
moravec_max_count(0),
moravec_pattern(NULL),
- harris_threshold(0.0) {}
+ harris_threshold(kDefaultHarrisThreshold) {}
void Detect(const FloatImage &image,
const DetectOptions &options,
@@ -332,4 +350,12 @@ void Detect(const FloatImage &image,
}
}
+std::ostream& operator <<(std::ostream &os,
+ const Feature &feature) {
+ os << "x: " << feature.x << ", y: " << feature.y;
+ os << ", score: " << feature.score;
+ os << ", size: " << feature.size;
+ return os;
+}
+
} // namespace libmv
diff --git a/extern/libmv/libmv/simple_pipeline/detect.h b/extern/libmv/libmv/simple_pipeline/detect.h
index 2c782294d1b..1035287bcf2 100644
--- a/extern/libmv/libmv/simple_pipeline/detect.h
+++ b/extern/libmv/libmv/simple_pipeline/detect.h
@@ -25,6 +25,7 @@
#ifndef LIBMV_SIMPLE_PIPELINE_DETECT_H_
#define LIBMV_SIMPLE_PIPELINE_DETECT_H_
+#include <iostream>
#include <vector>
#include "libmv/base/vector.h"
@@ -34,22 +35,27 @@ namespace libmv {
typedef unsigned char ubyte;
-/*!
- A Feature is the 2D location of a detected feature in an image.
-
- \a x, \a y is the position of the feature in pixels from the top left corner.
- \a score is an estimate of how well the feature will be tracked.
- \a size can be used as an initial pattern size to track the feature.
-
- \sa Detect
-*/
+// A Feature is the 2D location of a detected feature in an image.
struct Feature {
- /// Position in pixels (from top-left corner)
- /// \note libmv might eventually support subpixel precision.
+ Feature(float x, float y) : x(x), y(y) {}
+ Feature(float x, float y, float score, float size)
+ : x(x), y(y), score(score), size(size) {}
+
+ // Position of the feature in pixels from top-left corner.
+ // Note: Libmv detector might eventually support subpixel precision.
float x, y;
- /// Trackness of the feature
+
+ // An estimate of how well the feature will be tracked.
+ //
+ // Absolute values totally depends on particular detector type
+ // used for detection. It's only guaranteed that features with
+ // higher score from the same Detect() result will be tracked better.
float score;
- /// Size of the feature in pixels
+
+ // An approximate feature size in pixels.
+ //
+ // If the feature is approximately a 5x5 square region, then size will be 5.
+ // It can be used as an initial pattern size to track the feature.
float size;
};
@@ -99,6 +105,9 @@ void Detect(const FloatImage &image,
const DetectOptions &options,
vector<Feature> *detected_features);
+std::ostream& operator <<(std::ostream &os,
+ const Feature &feature);
+
} // namespace libmv
#endif
diff --git a/extern/libmv/libmv/simple_pipeline/distortion_models.cc b/extern/libmv/libmv/simple_pipeline/distortion_models.cc
new file mode 100644
index 00000000000..9b6dca2678a
--- /dev/null
+++ b/extern/libmv/libmv/simple_pipeline/distortion_models.cc
@@ -0,0 +1,197 @@
+// Copyright (c) 2014 libmv authors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+
+#include "libmv/simple_pipeline/distortion_models.h"
+#include "libmv/numeric/levenberg_marquardt.h"
+
+namespace libmv {
+
+namespace {
+
+struct InvertPolynomialIntrinsicsCostFunction {
+ public:
+ typedef Vec2 FMatrixType;
+ typedef Vec2 XMatrixType;
+
+ InvertPolynomialIntrinsicsCostFunction(const double focal_length_x,
+ const double focal_length_y,
+ const double principal_point_x,
+ const double principal_point_y,
+ const double k1,
+ const double k2,
+ const double k3,
+ const double p1,
+ const double p2,
+ const double image_x,
+ const double image_y)
+ : focal_length_x_(focal_length_x),
+ focal_length_y_(focal_length_y),
+ principal_point_x_(principal_point_x),
+ principal_point_y_(principal_point_y),
+ k1_(k1), k2_(k2), k3_(k3),
+ p1_(p1), p2_(p2),
+ x_(image_x), y_(image_y) {}
+
+ Vec2 operator()(const Vec2 &u) const {
+ double xx, yy;
+
+ ApplyPolynomialDistortionModel(focal_length_x_,
+ focal_length_y_,
+ principal_point_x_,
+ principal_point_y_,
+ k1_, k2_, k3_,
+ p1_, p2_,
+ u(0), u(1),
+ &xx, &yy);
+
+ Vec2 fx;
+ fx << (xx - x_), (yy - y_);
+ return fx;
+ }
+ double focal_length_x_;
+ double focal_length_y_;
+ double principal_point_x_;
+ double principal_point_y_;
+ double k1_, k2_, k3_;
+ double p1_, p2_;
+ double x_, y_;
+};
+
+struct InvertDivisionIntrinsicsCostFunction {
+ public:
+ typedef Vec2 FMatrixType;
+ typedef Vec2 XMatrixType;
+
+ InvertDivisionIntrinsicsCostFunction(const double focal_length_x,
+ const double focal_length_y,
+ const double principal_point_x,
+ const double principal_point_y,
+ const double k1,
+ const double k2,
+ const double image_x,
+ const double image_y)
+ : focal_length_x_(focal_length_x),
+ focal_length_y_(focal_length_y),
+ principal_point_x_(principal_point_x),
+ principal_point_y_(principal_point_y),
+ k1_(k1), k2_(k2),
+ x_(image_x), y_(image_y) {}
+
+ Vec2 operator()(const Vec2 &u) const {
+ double xx, yy;
+
+ ApplyDivisionDistortionModel(focal_length_x_,
+ focal_length_y_,
+ principal_point_x_,
+ principal_point_y_,
+ k1_, k2_,
+ u(0), u(1),
+ &xx, &yy);
+
+ Vec2 fx;
+ fx << (xx - x_), (yy - y_);
+ return fx;
+ }
+ double focal_length_x_;
+ double focal_length_y_;
+ double principal_point_x_;
+ double principal_point_y_;
+ double k1_, k2_;
+ double x_, y_;
+};
+
+} // namespace
+
+void InvertPolynomialDistortionModel(const double focal_length_x,
+ const double focal_length_y,
+ const double principal_point_x,
+ const double principal_point_y,
+ const double k1,
+ const double k2,
+ const double k3,
+ const double p1,
+ const double p2,
+ const double image_x,
+ const double image_y,
+ double *normalized_x,
+ double *normalized_y) {
+ // Compute the initial guess. For a camera with no distortion, this will also
+ // be the final answer; the LM iteration will terminate immediately.
+ Vec2 normalized;
+ normalized(0) = (image_x - principal_point_x) / focal_length_x;
+ normalized(1) = (image_y - principal_point_y) / focal_length_y;
+
+ typedef LevenbergMarquardt<InvertPolynomialIntrinsicsCostFunction> Solver;
+
+ InvertPolynomialIntrinsicsCostFunction intrinsics_cost(focal_length_x,
+ focal_length_y,
+ principal_point_x,
+ principal_point_y,
+ k1, k2, k3,
+ p1, p2,
+ image_x, image_y);
+ Solver::SolverParameters params;
+ Solver solver(intrinsics_cost);
+
+ /*Solver::Results results =*/ solver.minimize(params, &normalized);
+
+ // TODO(keir): Better error handling.
+
+ *normalized_x = normalized(0);
+ *normalized_y = normalized(1);
+}
+
+void InvertDivisionDistortionModel(const double focal_length_x,
+ const double focal_length_y,
+ const double principal_point_x,
+ const double principal_point_y,
+ const double k1,
+ const double k2,
+ const double image_x,
+ const double image_y,
+ double *normalized_x,
+ double *normalized_y) {
+ // Compute the initial guess. For a camera with no distortion, this will also
+ // be the final answer; the LM iteration will terminate immediately.
+ Vec2 normalized;
+ normalized(0) = (image_x - principal_point_x) / focal_length_x;
+ normalized(1) = (image_y - principal_point_y) / focal_length_y;
+
+ // TODO(sergey): Use Ceres minimizer instead.
+ typedef LevenbergMarquardt<InvertDivisionIntrinsicsCostFunction> Solver;
+
+ InvertDivisionIntrinsicsCostFunction intrinsics_cost(focal_length_x,
+ focal_length_y,
+ principal_point_x,
+ principal_point_y,
+ k1, k2,
+ image_x, image_y);
+ Solver::SolverParameters params;
+ Solver solver(intrinsics_cost);
+
+ /*Solver::Results results =*/ solver.minimize(params, &normalized);
+
+ // TODO(keir): Better error handling.
+
+ *normalized_x = normalized(0);
+ *normalized_y = normalized(1);
+}
+
+} // namespace libmv
diff --git a/extern/libmv/libmv/simple_pipeline/distortion_models.h b/extern/libmv/libmv/simple_pipeline/distortion_models.h
new file mode 100644
index 00000000000..4f8e2295a0e
--- /dev/null
+++ b/extern/libmv/libmv/simple_pipeline/distortion_models.h
@@ -0,0 +1,131 @@
+// Copyright (c) 2014 libmv authors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+
+#ifndef LIBMV_SIMPLE_PIPELINE_DISTORTION_MODELS_H_
+#define LIBMV_SIMPLE_PIPELINE_DISTORTION_MODELS_H_
+
+namespace libmv {
+
+enum DistortionModelType {
+ DISTORTION_MODEL_POLYNOMIAL,
+ DISTORTION_MODEL_DIVISION
+};
+
+// Invert camera intrinsics on the image point to get normalized coordinates.
+// This inverts the radial lens distortion to a point which is in image pixel
+// coordinates to get normalized coordinates.
+void InvertPolynomialDistortionModel(const double focal_length_x,
+ const double focal_length_y,
+ const double principal_point_x,
+ const double principal_point_y,
+ const double k1,
+ const double k2,
+ const double k3,
+ const double p1,
+ const double p2,
+ const double image_x,
+ const double image_y,
+ double *normalized_x,
+ double *normalized_y);
+
+// Apply camera intrinsics to the normalized point to get image coordinates.
+// This applies the radial lens distortion to a point which is in normalized
+// camera coordinates (i.e. the principal point is at (0, 0)) to get image
+// coordinates in pixels. Templated for use with autodifferentiation.
+template <typename T>
+inline void ApplyPolynomialDistortionModel(const T &focal_length_x,
+ const T &focal_length_y,
+ const T &principal_point_x,
+ const T &principal_point_y,
+ const T &k1,
+ const T &k2,
+ const T &k3,
+ const T &p1,
+ const T &p2,
+ const T &normalized_x,
+ const T &normalized_y,
+ T *image_x,
+ T *image_y) {
+ T x = normalized_x;
+ T y = normalized_y;
+
+ // Apply distortion to the normalized points to get (xd, yd).
+ T r2 = x*x + y*y;
+ T r4 = r2 * r2;
+ T r6 = r4 * r2;
+ T r_coeff = (T(1) + k1*r2 + k2*r4 + k3*r6);
+ T xd = x * r_coeff + T(2)*p1*x*y + p2*(r2 + T(2)*x*x);
+ T yd = y * r_coeff + T(2)*p2*x*y + p1*(r2 + T(2)*y*y);
+
+ // Apply focal length and principal point to get the final image coordinates.
+ *image_x = focal_length_x * xd + principal_point_x;
+ *image_y = focal_length_y * yd + principal_point_y;
+}
+
+// Invert camera intrinsics on the image point to get normalized coordinates.
+// This inverts the radial lens distortion to a point which is in image pixel
+// coordinates to get normalized coordinates.
+//
+// Uses division distortion model.
+void InvertDivisionDistortionModel(const double focal_length_x,
+ const double focal_length_y,
+ const double principal_point_x,
+ const double principal_point_y,
+ const double k1,
+ const double k2,
+ const double image_x,
+ const double image_y,
+ double *normalized_x,
+ double *normalized_y);
+
+// Apply camera intrinsics to the normalized point to get image coordinates.
+// This applies the radial lens distortion to a point which is in normalized
+// camera coordinates (i.e. the principal point is at (0, 0)) to get image
+// coordinates in pixels. Templated for use with autodifferentiation.
+//
+// Uses division distortion model.
+template <typename T>
+inline void ApplyDivisionDistortionModel(const T &focal_length_x,
+ const T &focal_length_y,
+ const T &principal_point_x,
+ const T &principal_point_y,
+ const T &k1,
+ const T &k2,
+ const T &normalized_x,
+ const T &normalized_y,
+ T *image_x,
+ T *image_y) {
+
+ T x = normalized_x;
+ T y = normalized_y;
+ T r2 = x*x + y*y;
+ T r4 = r2 * r2;
+
+ T xd = x / (T(1) + k1 * r2 + k2 * r4);
+ T yd = y / (T(1) + k1 * r2 + k2 * r4);
+
+ // Apply focal length and principal point to get the final image coordinates.
+ *image_x = focal_length_x * xd + principal_point_x;
+ *image_y = focal_length_y * yd + principal_point_y;
+}
+
+} // namespace libmv
+
+#endif // LIBMV_SIMPLE_PIPELINE_DISTORTION_MODELS_H_
diff --git a/extern/libmv/libmv/simple_pipeline/keyframe_selection.cc b/extern/libmv/libmv/simple_pipeline/keyframe_selection.cc
index 64504e7af9a..7b90c28bbca 100644
--- a/extern/libmv/libmv/simple_pipeline/keyframe_selection.cc
+++ b/extern/libmv/libmv/simple_pipeline/keyframe_selection.cc
@@ -33,22 +33,6 @@
namespace libmv {
namespace {
-Vec2 NorrmalizedToPixelSpace(const Vec2 &vec,
- const CameraIntrinsics &intrinsics) {
- Vec2 result;
-
- double focal_length_x = intrinsics.focal_length_x();
- double focal_length_y = intrinsics.focal_length_y();
-
- double principal_point_x = intrinsics.principal_point_x();
- double principal_point_y = intrinsics.principal_point_y();
-
- result(0) = vec(0) * focal_length_x + principal_point_x;
- result(1) = vec(1) * focal_length_y + principal_point_y;
-
- return result;
-}
-
Mat3 IntrinsicsNormalizationMatrix(const CameraIntrinsics &intrinsics) {
Mat3 T = Mat3::Identity(), S = Mat3::Identity();
@@ -151,7 +135,7 @@ void filterZeroWeightMarkersFromTracks(const Tracks &tracks,
} // namespace
void SelectKeyframesBasedOnGRICAndVariance(const Tracks &_tracks,
- CameraIntrinsics &intrinsics,
+ const CameraIntrinsics &intrinsics,
vector<int> &keyframes) {
// Mirza Tahir Ahmed, Matthew N. Dailey
// Robust key frame extraction for 3D reconstruction from video streams
@@ -256,10 +240,13 @@ void SelectKeyframesBasedOnGRICAndVariance(const Tracks &_tracks,
H_e.resize(x1.cols());
F_e.resize(x1.cols());
for (int i = 0; i < x1.cols(); i++) {
- Vec2 current_x1 =
- NorrmalizedToPixelSpace(Vec2(x1(0, i), x1(1, i)), intrinsics);
- Vec2 current_x2 =
- NorrmalizedToPixelSpace(Vec2(x2(0, i), x2(1, i)), intrinsics);
+ Vec2 current_x1, current_x2;
+
+ intrinsics.NormalizedToImageSpace(x1(0, i), x1(1, i),
+ &current_x1(0), &current_x1(1));
+
+ intrinsics.NormalizedToImageSpace(x2(0, i), x2(1, i),
+ &current_x2(0), &current_x2(1));
H_e(i) = SymmetricGeometricDistance(H, current_x1, current_x2);
F_e(i) = SymmetricEpipolarDistance(F, current_x1, current_x2);
@@ -378,7 +365,7 @@ void SelectKeyframesBasedOnGRICAndVariance(const Tracks &_tracks,
success_intersects_factor_best = success_intersects_factor;
Tracks two_frames_tracks(tracked_markers);
- CameraIntrinsics empty_intrinsics;
+ PolynomialCameraIntrinsics empty_intrinsics;
BundleEvaluation evaluation;
evaluation.evaluate_jacobian = true;
diff --git a/extern/libmv/libmv/simple_pipeline/keyframe_selection.h b/extern/libmv/libmv/simple_pipeline/keyframe_selection.h
index da131010d35..aa3eeaf193d 100644
--- a/extern/libmv/libmv/simple_pipeline/keyframe_selection.h
+++ b/extern/libmv/libmv/simple_pipeline/keyframe_selection.h
@@ -43,9 +43,10 @@ namespace libmv {
// \param intrinsics is camera intrinsics
// \param keyframes will contain all images number which are considered
// good to be used for reconstruction
-void SelectKeyframesBasedOnGRICAndVariance(const Tracks &tracks,
- CameraIntrinsics &intrinsics,
- vector<int> &keyframes);
+void SelectKeyframesBasedOnGRICAndVariance(
+ const Tracks &tracks,
+ const CameraIntrinsics &intrinsics,
+ vector<int> &keyframes);
} // namespace libmv
diff --git a/extern/libmv/libmv/tracking/brute_region_tracker.cc b/extern/libmv/libmv/tracking/brute_region_tracker.cc
index 234aaa6ed00..4a2aef63a96 100644
--- a/extern/libmv/libmv/tracking/brute_region_tracker.cc
+++ b/extern/libmv/libmv/tracking/brute_region_tracker.cc
@@ -21,27 +21,10 @@
#include "libmv/tracking/brute_region_tracker.h"
#ifdef __SSE2__
-#include <emmintrin.h>
-#endif
-
-#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__)
-// Needed for memalign on Linux and _aligned_alloc on Windows.
-#ifdef FREE_WINDOWS
-/* make sure _aligned_malloc is included */
-#ifdef __MSVCRT_VERSION__
-#undef __MSVCRT_VERSION__
-#endif
-
-#define __MSVCRT_VERSION__ 0x0700
-#endif
-
-#include <malloc.h>
-#else
-// Apple's malloc is 16-byte aligned, and does not have malloc.h, so include
-// stdilb instead.
-#include <cstdlib>
+# include <emmintrin.h>
#endif
+#include "libmv/base/aligned_malloc.h"
#include "libmv/image/image.h"
#include "libmv/image/convolve.h"
#include "libmv/image/correlation.h"
@@ -51,37 +34,6 @@
namespace libmv {
namespace {
-// TODO(keir): It's stupid that this is needed here. Push this somewhere else.
-void *aligned_malloc(int size, int alignment) {
-#ifdef _WIN32
- return _aligned_malloc(size, alignment);
-#elif __APPLE__
- // On Mac OS X, both the heap and the stack are guaranteed 16-byte aligned so
- // they work natively with SSE types with no further work.
- CHECK_EQ(alignment, 16);
- return malloc(size);
-#elif defined(__FreeBSD__) || defined(__NetBSD__)
- void *result;
-
- if (posix_memalign(&result, alignment, size)) {
- // non-zero means allocation error
- // either no allocation or bad alignment value
- return NULL;
- }
- return result;
-#else // This is for Linux.
- return memalign(alignment, size);
-#endif
-}
-
-void aligned_free(void *ptr) {
-#ifdef _WIN32
- _aligned_free(ptr);
-#else
- free(ptr);
-#endif
-}
-
bool RegionIsInBounds(const FloatImage &image1,
double x, double y,
int half_window_size) {
@@ -364,8 +316,7 @@ bool BruteRegionTracker::Track(const FloatImage &image1,
// for sanity.
double correlation = PearsonProductMomentCorrelation(
image_and_gradient1_sampled,
- image_and_gradient2_sampled,
- pattern_width);
+ image_and_gradient2_sampled);
LG << "Final correlation: " << correlation;
diff --git a/intern/audaspace/intern/AUD_AnimateableProperty.cpp b/intern/audaspace/intern/AUD_AnimateableProperty.cpp
index 61adae4b34b..9f399a0b99f 100644
--- a/intern/audaspace/intern/AUD_AnimateableProperty.cpp
+++ b/intern/audaspace/intern/AUD_AnimateableProperty.cpp
@@ -47,6 +47,23 @@ AUD_AnimateableProperty::AUD_AnimateableProperty(int count) :
pthread_mutexattr_destroy(&attr);
}
+AUD_AnimateableProperty::AUD_AnimateableProperty(int count, float value) :
+ AUD_Buffer(count * sizeof(float)), m_count(count), m_isAnimated(false)
+{
+ sample_t* buf = getBuffer();
+
+ for(int i = 0; i < count; i++)
+ buf[i] = value;
+
+ pthread_mutexattr_t attr;
+ pthread_mutexattr_init(&attr);
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+
+ pthread_mutex_init(&m_mutex, &attr);
+
+ pthread_mutexattr_destroy(&attr);
+}
+
void AUD_AnimateableProperty::updateUnknownCache(int start, int end)
{
float* buf = getBuffer();
@@ -104,7 +121,8 @@ void AUD_AnimateableProperty::write(const float* data, int position, int count)
if(pos == 0)
{
- memset(buf, 0, position * m_count * sizeof(float));
+ for(int i = 0; i < position; i++)
+ memcpy(buf + i * m_count, data, m_count * sizeof(float));
}
else
updateUnknownCache(pos, position - 1);
diff --git a/intern/audaspace/intern/AUD_AnimateableProperty.h b/intern/audaspace/intern/AUD_AnimateableProperty.h
index 37eb8f84550..f07e5916b25 100644
--- a/intern/audaspace/intern/AUD_AnimateableProperty.h
+++ b/intern/audaspace/intern/AUD_AnimateableProperty.h
@@ -76,6 +76,13 @@ public:
AUD_AnimateableProperty(int count = 1);
/**
+ * Creates a new animateable property.
+ * \param count The count of floats for a single property.
+ * \param count The value that the property should get initialized with. All count floats will be initialized to the same value.
+ */
+ AUD_AnimateableProperty(int count, float value);
+
+ /**
* Destroys the animateable property.
*/
~AUD_AnimateableProperty();
diff --git a/intern/audaspace/intern/AUD_Sequencer.cpp b/intern/audaspace/intern/AUD_Sequencer.cpp
index c59c56a4479..6c5e48c73f0 100644
--- a/intern/audaspace/intern/AUD_Sequencer.cpp
+++ b/intern/audaspace/intern/AUD_Sequencer.cpp
@@ -42,6 +42,7 @@ AUD_Sequencer::AUD_Sequencer(AUD_Specs specs, float fps, bool muted) :
m_speed_of_sound(434),
m_doppler_factor(1),
m_distance_model(AUD_DISTANCE_MODEL_INVERSE_CLAMPED),
+ m_volume(1, 1.0f),
m_location(3),
m_orientation(4)
{
diff --git a/intern/audaspace/intern/AUD_SequencerEntry.cpp b/intern/audaspace/intern/AUD_SequencerEntry.cpp
index 005557bbed1..6ef8479cdb8 100644
--- a/intern/audaspace/intern/AUD_SequencerEntry.cpp
+++ b/intern/audaspace/intern/AUD_SequencerEntry.cpp
@@ -53,6 +53,8 @@ AUD_SequencerEntry::AUD_SequencerEntry(boost::shared_ptr<AUD_IFactory> sound, fl
m_cone_angle_outer(360),
m_cone_angle_inner(360),
m_cone_volume_outer(0),
+ m_volume(1, 1.0f),
+ m_pitch(1, 1.0f),
m_location(3),
m_orientation(4)
{
diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt
index 0d13c4b61d9..a1b0030491e 100644
--- a/intern/cycles/CMakeLists.txt
+++ b/intern/cycles/CMakeLists.txt
@@ -1,4 +1,3 @@
-
# Standalone or with Blender
if(NOT WITH_BLENDER AND WITH_CYCLES_STANDALONE)
set(CYCLES_INSTALL_PATH "")
@@ -127,6 +126,14 @@ include_directories(
${OPENEXR_INCLUDE_DIRS}
)
+
+# Warnings
+if(CMAKE_COMPILER_IS_GNUCXX)
+ ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS _has_cxxflag_float_conversion "-Werror=float-conversion")
+ unset(_has_cxxflag_float_conversion)
+endif()
+
+
# Subdirectories
if(WITH_CYCLES_BLENDER)
diff --git a/intern/cycles/SConscript b/intern/cycles/SConscript
index 1aa873c7eb5..532238b9d7e 100644
--- a/intern/cycles/SConscript
+++ b/intern/cycles/SConscript
@@ -72,6 +72,12 @@ if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
else:
cxxflags.append('-ffast-math'.split())
+# Warnings
+# XXX Not supported by gcc < 4.9, since we do not have any 'supported flags' test as in cmake,
+# simpler to comment for now.
+#if env['C_COMPILER_ID'] == 'gcc':
+# cxxflags.append(['-Werror=float-conversion'])
+
if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'):
incs.append(env['BF_PTHREADS_INC'])
diff --git a/intern/cycles/app/cycles_standalone.cpp b/intern/cycles/app/cycles_standalone.cpp
index 75ecb78b200..7ea1ca2d8fb 100644
--- a/intern/cycles/app/cycles_standalone.cpp
+++ b/intern/cycles/app/cycles_standalone.cpp
@@ -177,8 +177,14 @@ static void display_info(Progress& progress)
interactive = options.interactive? "On":"Off";
- str = string_printf("%s Time: %.2f Latency: %.4f Sample: %d Average: %.4f Interactive: %s",
- status.c_str(), total_time, latency, sample, sample_time, interactive.c_str());
+ str = string_printf(
+ "%s"
+ " Time: %.2f"
+ " Latency: %.4f"
+ " Sample: %d"
+ " Average: %.4f"
+ " Interactive: %s",
+ status.c_str(), total_time, latency, sample, sample_time, interactive.c_str());
view_display_info(str.c_str());
@@ -208,11 +214,11 @@ static void motion(int x, int y, int button)
/* Rotate */
else if(button == 2) {
- float4 r1= make_float4(x * 0.1f, 0.0f, 1.0f, 0.0f);
- matrix = matrix * transform_rotate(r1.x * M_PI/180.0f, make_float3(r1.y, r1.z, r1.w));
+ float4 r1 = make_float4((float)x * 0.1f, 0.0f, 1.0f, 0.0f);
+ matrix = matrix * transform_rotate(DEG2RADF(r1.x), make_float3(r1.y, r1.z, r1.w));
- float4 r2 = make_float4(y * 0.1, 1.0f, 0.0f, 0.0f);
- matrix = matrix * transform_rotate(r2.x * M_PI/180.0f, make_float3(r2.y, r2.z, r2.w));
+ float4 r2 = make_float4(y * 0.1f, 1.0f, 0.0f, 0.0f);
+ matrix = matrix * transform_rotate(DEG2RADF(r2.x), make_float3(r2.y, r2.z, r2.w));
}
/* Update and Reset */
@@ -371,15 +377,13 @@ static void options_parse(int argc, const char **argv)
else if(ssname == "svm")
options.scene_params.shadingsystem = SceneParams::SVM;
-#ifdef WITH_CYCLES_STANDALONE_GUI
- /* Progressive rendering for GUI */
- if(!options.session_params.background)
- options.session_params.progressive = true;
-#else
- /* When building without GUI, set background */
+#ifndef WITH_CYCLES_STANDALONE_GUI
options.session_params.background = true;
#endif
+ /* Use progressive rendering */
+ options.session_params.progressive = true;
+
/* find matching device */
DeviceType device_type = Device::type_from_string(devicename.c_str());
vector<DeviceInfo>& devices = Device::available_devices();
diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp
index 1faf290f0ea..d5ef30e5c6f 100644
--- a/intern/cycles/app/cycles_xml.cpp
+++ b/intern/cycles/app/cycles_xml.cpp
@@ -105,7 +105,7 @@ static bool xml_read_float(float *value, pugi::xml_node node, const char *name)
pugi::xml_attribute attr = node.attribute(name);
if(attr) {
- *value = atof(attr.value());
+ *value = (float)atof(attr.value());
return true;
}
@@ -121,7 +121,7 @@ static bool xml_read_float_array(vector<float>& value, pugi::xml_node node, cons
string_split(tokens, attr.value());
foreach(const string& token, tokens)
- value.push_back(atof(token.c_str()));
+ value.push_back((float)atof(token.c_str()));
return true;
}
@@ -322,7 +322,7 @@ static void xml_read_camera(const XMLReadState& state, pugi::xml_node node)
xml_read_int(&cam->height, node, "height");
if(xml_read_float(&cam->fov, node, "fov"))
- cam->fov *= M_PI/180.0f;
+ cam->fov = DEG2RADF(cam->fov);
xml_read_float(&cam->nearclip, node, "nearclip");
xml_read_float(&cam->farclip, node, "farclip");
@@ -1032,7 +1032,7 @@ static void xml_read_transform(pugi::xml_node node, Transform& tfm)
if(node.attribute("rotate")) {
float4 rotate = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
xml_read_float4(&rotate, node, "rotate");
- tfm = tfm * transform_rotate(rotate.x*M_PI/180.0f, make_float3(rotate.y, rotate.z, rotate.w));
+ tfm = tfm * transform_rotate(DEG2RADF(rotate.x), make_float3(rotate.y, rotate.z, rotate.w));
}
if(node.attribute("scale")) {
diff --git a/intern/cycles/app/cycles_xml.h b/intern/cycles/app/cycles_xml.h
index 1e3ed411312..96bc79c35d8 100644
--- a/intern/cycles/app/cycles_xml.h
+++ b/intern/cycles/app/cycles_xml.h
@@ -14,8 +14,8 @@
* limitations under the License
*/
-#ifndef __CYCLES_XML__
-#define __CYCLES_XML__
+#ifndef __CYCLES_XML_H__
+#define __CYCLES_XML_H__
CCL_NAMESPACE_BEGIN
@@ -23,7 +23,10 @@ class Scene;
void xml_read_file(Scene *scene, const char *filepath);
-CCL_NAMESPACE_END
+/* macros for importing */
+#define RAD2DEGF(_rad) ((_rad) * (float)(180.0 / M_PI))
+#define DEG2RADF(_deg) ((_deg) * (float)(M_PI / 180.0))
-#endif /* __CYCLES_XML__ */
+CCL_NAMESPACE_END
+#endif /* __CYCLES_XML_H__ */
diff --git a/intern/cycles/blender/CCL_api.h b/intern/cycles/blender/CCL_api.h
index 6532315cf39..2772b9ac8a7 100644
--- a/intern/cycles/blender/CCL_api.h
+++ b/intern/cycles/blender/CCL_api.h
@@ -14,8 +14,8 @@
* limitations under the License
*/
-#ifndef CCL_API_H
-#define CCL_API_H
+#ifndef __CCL_API_H__
+#define __CCL_API_H__
#ifdef __cplusplus
extern "C" {
@@ -40,5 +40,4 @@ void *CCL_python_module_init(void);
}
#endif
-#endif /* CCL_API_H */
-
+#endif /* __CCL_API_H__ */
diff --git a/intern/cycles/blender/addon/__init__.py b/intern/cycles/blender/addon/__init__.py
index afd26945d6c..27d986900c8 100644
--- a/intern/cycles/blender/addon/__init__.py
+++ b/intern/cycles/blender/addon/__init__.py
@@ -19,7 +19,7 @@
bl_info = {
"name": "Cycles Render Engine",
"author": "",
- "blender": (2, 67, 0),
+ "blender": (2, 70, 0),
"location": "Info header, render engine menu",
"description": "Cycles Render Engine integration",
"warning": "",
@@ -67,6 +67,9 @@ class CyclesRender(bpy.types.RenderEngine):
def render(self, scene):
engine.render(self)
+ def bake(self, scene, obj, pass_type, pixel_array, num_pixels, depth, result):
+ engine.bake(self, obj, pass_type, pixel_array, num_pixels, depth, result)
+
# viewport render
def view_update(self, context):
if not self.session:
diff --git a/intern/cycles/blender/addon/engine.py b/intern/cycles/blender/addon/engine.py
index b9ce65588df..25a9e97a99b 100644
--- a/intern/cycles/blender/addon/engine.py
+++ b/intern/cycles/blender/addon/engine.py
@@ -59,6 +59,12 @@ def render(engine):
_cycles.render(engine.session)
+def bake(engine, obj, pass_type, pixel_array, num_pixels, depth, result):
+ import _cycles
+ session = getattr(engine, "session", None)
+ if session is not None:
+ _cycles.bake(engine.session, obj.as_pointer(), pass_type, pixel_array.as_pointer(), num_pixels, depth, result.as_pointer())
+
def reset(engine, data, scene):
import _cycles
data = data.as_pointer()
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index 2b05c2148eb..7205a272395 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -471,6 +471,33 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
default=False,
)
+ cls.bake_type = EnumProperty(
+ name="Bake Type",
+ default='COMBINED',
+ description="Type of pass to bake",
+ items = (
+ ('COMBINED', "Combined", ""),
+ ('AO', "Ambient Occlusion", ""),
+ ('SHADOW', "Shadow", ""),
+ ('NORMAL', "Normal", ""),
+ ('UV', "UV", ""),
+ ('EMIT', "Emit", ""),
+ ('ENVIRONMENT', "Environment", ""),
+ ('DIFFUSE_DIRECT', "Diffuse Direct", ""),
+ ('DIFFUSE_INDIRECT', "Diffuse Indirect", ""),
+ ('DIFFUSE_COLOR', "Diffuse Color", ""),
+ ('GLOSSY_DIRECT', "Glossy Direct", ""),
+ ('GLOSSY_INDIRECT', "Glossy Indirect", ""),
+ ('GLOSSY_COLOR', "Glossy Color", ""),
+ ('TRANSMISSION_DIRECT', "Transmission Direct", ""),
+ ('TRANSMISSION_INDIRECT', "Transmission Indirect", ""),
+ ('TRANSMISSION_COLOR', "Transmission Color", ""),
+ ('SUBSURFACE_DIRECT', "Subsurface Direct", ""),
+ ('SUBSURFACE_INDIRECT', "Subsurface Indirect", ""),
+ ('SUBSURFACE_COLOR', "Subsurface Color", ""),
+ ),
+ )
+
@classmethod
def unregister(cls):
del bpy.types.Scene.cycles
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index 6c7c66d14fb..5c8115b6612 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -47,12 +47,12 @@ class CyclesButtonsPanel():
def poll(cls, context):
rd = context.scene.render
return rd.engine in cls.COMPAT_ENGINES
-
-
+
+
def use_cpu(context):
cscene = context.scene.cycles
device_type = context.user_preferences.system.compute_device_type
-
+
return (device_type == 'NONE' or cscene.device == 'CPU')
@@ -556,28 +556,6 @@ class Cycles_PT_mesh_displacement(CyclesButtonsPanel, Panel):
layout.prop(cdata, "dicing_rate")
-class Cycles_PT_mesh_normals(CyclesButtonsPanel, Panel):
- bl_label = "Normals"
- bl_context = "data"
-
- @classmethod
- def poll(cls, context):
- return CyclesButtonsPanel.poll(context) and context.mesh
-
- def draw(self, context):
- layout = self.layout
-
- mesh = context.mesh
-
- split = layout.split()
-
- col = split.column()
- col.prop(mesh, "show_double_sided")
-
- col = split.column()
- col.label()
-
-
class CyclesObject_PT_motion_blur(CyclesButtonsPanel, Panel):
bl_label = "Motion Blur"
bl_context = "object"
@@ -593,7 +571,7 @@ class CyclesObject_PT_motion_blur(CyclesButtonsPanel, Panel):
rd = context.scene.render
scene = context.scene
- cscene = scene.cycles
+ # cscene = scene.cycles
layout.active = rd.use_motion_blur
@@ -607,7 +585,7 @@ class CyclesObject_PT_motion_blur(CyclesButtonsPanel, Panel):
rd = context.scene.render
scene = context.scene
- cscene = scene.cycles
+ # cscene = scene.cycles
ob = context.object
cob = ob.cycles
@@ -631,7 +609,8 @@ class CyclesObject_PT_ray_visibility(CyclesButtonsPanel, Panel):
def poll(cls, context):
ob = context.object
return (CyclesButtonsPanel.poll(context) and
- ob and ob.type in {'MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT', 'META', 'LAMP'})
+ ob and ob.type in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META', 'LAMP'} or
+ ob and ob.dupli_type == 'GROUP' and ob.dupli_group)
def draw(self, context):
layout = self.layout
@@ -885,9 +864,10 @@ class CyclesWorld_PT_mist(CyclesButtonsPanel, Panel):
@classmethod
def poll(cls, context):
if CyclesButtonsPanel.poll(context):
- for rl in context.scene.render.layers:
- if rl.use_pass_mist:
- return True
+ if context.world:
+ for rl in context.scene.render.layers:
+ if rl.use_pass_mist:
+ return True
return False
@@ -1147,7 +1127,7 @@ class CyclesTexture_PT_colors(CyclesButtonsPanel, Panel):
def poll(cls, context):
# node = context.texture_node
return False
- #return node and CyclesButtonsPanel.poll(context)
+ # return node and CyclesButtonsPanel.poll(context)
def draw(self, context):
layout = self.layout
@@ -1215,7 +1195,7 @@ class CyclesRender_PT_CurveRendering(CyclesButtonsPanel, Panel):
@classmethod
def poll(cls, context):
scene = context.scene
- cscene = scene.cycles
+ # cscene = scene.cycles
psys = context.particle_system
return CyclesButtonsPanel.poll(context) and psys and psys.settings.type == 'HAIR'
@@ -1247,6 +1227,54 @@ class CyclesRender_PT_CurveRendering(CyclesButtonsPanel, Panel):
row.prop(ccscene, "maximum_width", text="Max Ext.")
+class CyclesRender_PT_bake(CyclesButtonsPanel, Panel):
+ bl_label = "Bake"
+ bl_context = "render"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'CYCLES'}
+
+ def draw(self, context):
+ layout = self.layout
+
+ scene = context.scene
+ cscene = scene.cycles
+
+ cbk = scene.render.bake
+
+ layout.operator("object.bake", icon='RENDER_STILL').type = \
+ cscene.bake_type
+
+ col = layout.column()
+ col.prop(cscene, "bake_type")
+
+ col.separator()
+ split = layout.split()
+
+ sub = split.column()
+ sub.prop(cbk, "use_clear")
+ sub.prop(cbk, "margin")
+
+ sub = split.column()
+ sub.prop(cbk, "use_selected_to_active")
+ sub = sub.column()
+
+ sub.active = cbk.use_selected_to_active
+ sub.prop(cbk, "cage_extrusion", text="Distance")
+ sub.prop_search(cbk, "cage", scene, "objects")
+
+ if cscene.bake_type == 'NORMAL':
+ col.separator()
+ box = col.box()
+ box.label(text="Normal Settings:")
+ box.prop(cbk, "normal_space", text="Space")
+
+ row = box.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="")
+
+
class CyclesParticle_PT_CurveSettings(CyclesButtonsPanel, Panel):
bl_label = "Cycles Hair Settings"
bl_context = "particle"
@@ -1254,7 +1282,7 @@ class CyclesParticle_PT_CurveSettings(CyclesButtonsPanel, Panel):
@classmethod
def poll(cls, context):
scene = context.scene
- cscene = scene.cycles
+ # cscene = scene.cycles
ccscene = scene.cycles_curves
psys = context.particle_system
use_curves = ccscene.use_curves and psys
@@ -1355,6 +1383,7 @@ def get_panels():
"DATA_PT_context_camera",
"DATA_PT_context_lamp",
"DATA_PT_context_speaker",
+ "DATA_PT_normals",
"DATA_PT_texture_space",
"DATA_PT_curve_texture_space",
"DATA_PT_mball_texture_space",
diff --git a/intern/cycles/blender/blender_camera.cpp b/intern/cycles/blender/blender_camera.cpp
index 6bbd4106a96..1a85561c6d5 100644
--- a/intern/cycles/blender/blender_camera.cpp
+++ b/intern/cycles/blender/blender_camera.cpp
@@ -212,8 +212,8 @@ static void blender_camera_viewplane(BlenderCamera *bcam, int width, int height,
BoundBox2D *viewplane, float *aspectratio, float *sensor_size)
{
/* dimensions */
- float xratio = width*bcam->pixelaspect.x;
- float yratio = height*bcam->pixelaspect.y;
+ float xratio = (float)width*bcam->pixelaspect.x;
+ float yratio = (float)height*bcam->pixelaspect.y;
/* compute x/y aspect and ratio */
float xaspect, yaspect;
@@ -288,8 +288,8 @@ static void blender_camera_sync(Camera *cam, BlenderCamera *bcam, int width, int
/* panorama sensor */
if (bcam->type == CAMERA_PANORAMA && bcam->panorama_type == PANORAMA_FISHEYE_EQUISOLID) {
- float fit_xratio = bcam->full_width*bcam->pixelaspect.x;
- float fit_yratio = bcam->full_height*bcam->pixelaspect.y;
+ float fit_xratio = (float)bcam->full_width*bcam->pixelaspect.x;
+ float fit_yratio = (float)bcam->full_height*bcam->pixelaspect.y;
bool horizontal_fit;
float sensor_size;
@@ -565,10 +565,10 @@ BufferParams BlenderSync::get_buffer_params(BL::RenderSettings b_render, BL::Sce
if(use_border) {
/* border render */
- params.full_x = cam->border.left*width;
- params.full_y = cam->border.bottom*height;
- params.width = (int)(cam->border.right*width) - params.full_x;
- params.height = (int)(cam->border.top*height) - params.full_y;
+ params.full_x = (int)(cam->border.left * (float)width);
+ params.full_y = (int)(cam->border.bottom * (float)height);
+ params.width = (int)(cam->border.right * (float)width) - params.full_x;
+ params.height = (int)(cam->border.top * (float)height) - params.full_y;
/* survive in case border goes out of view or becomes too small */
params.width = max(params.width, 1);
diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp
index fb667d1ba2f..83514879477 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -222,7 +222,7 @@ static void create_mesh_volume_attribute(BL::Object b_ob, Mesh *mesh, ImageManag
volume_data->manager = image_manager;
volume_data->slot = image_manager->add_image(Attribute::standard_name(std),
- b_ob.ptr.data, animated, is_float, is_linear, INTERPOLATION_LINEAR);
+ b_ob.ptr.data, animated, is_float, is_linear, INTERPOLATION_LINEAR, true);
}
static void create_mesh_volume_attributes(Scene *scene, BL::Object b_ob, Mesh *mesh)
@@ -248,6 +248,7 @@ static void create_mesh(Scene *scene, Mesh *mesh, BL::Mesh b_mesh, const vector<
int numverts = b_mesh.vertices.length();
int numfaces = b_mesh.tessfaces.length();
int numtris = 0;
+ bool use_loop_normals = b_mesh.use_auto_smooth();
BL::Mesh::vertices_iterator v;
BL::Mesh::tessfaces_iterator f;
@@ -270,6 +271,21 @@ static void create_mesh(Scene *scene, Mesh *mesh, BL::Mesh b_mesh, const vector<
for(b_mesh.vertices.begin(v); v != b_mesh.vertices.end(); ++v, ++N)
*N = get_float3(v->normal());
+ N = attr_N->data_float3();
+
+ /* create generated coordinates from undeformed coordinates */
+ if(mesh->need_attribute(scene, ATTR_STD_GENERATED)) {
+ Attribute *attr = mesh->attributes.add(ATTR_STD_GENERATED);
+
+ float3 loc, size;
+ mesh_texture_space(b_mesh, loc, size);
+
+ float3 *generated = attr->data_float3();
+ size_t i = 0;
+
+ for(b_mesh.vertices.begin(v); v != b_mesh.vertices.end(); ++v)
+ generated[i++] = get_float3(v->undeformed_co())*size - loc;
+ }
/* create faces */
vector<int> nverts(numfaces);
@@ -282,9 +298,32 @@ static void create_mesh(Scene *scene, Mesh *mesh, BL::Mesh b_mesh, const vector<
int shader = used_shaders[mi];
bool smooth = f->use_smooth();
+ /* split vertices if normal is different
+ *
+ * note all vertex attributes must have been set here so we can split
+ * and copy attributes in split_vertex without remapping later */
+ if(use_loop_normals) {
+ BL::Array<float, 12> loop_normals = f->split_normals();
+
+ for(int i = 0; i < n; i++) {
+ float3 loop_N = make_float3(loop_normals[i * 3], loop_normals[i * 3 + 1], loop_normals[i * 3 + 2]);
+
+ if(N[vi[i]] != loop_N) {
+ int new_vi = mesh->split_vertex(vi[i]);
+
+ /* set new normal and vertex index */
+ N = attr_N->data_float3();
+ N[new_vi] = loop_N;
+ vi[i] = new_vi;
+ }
+ }
+ }
+
+ /* create triangles */
if(n == 4) {
if(is_zero(cross(mesh->verts[vi[1]] - mesh->verts[vi[0]], mesh->verts[vi[2]] - mesh->verts[vi[0]])) ||
- is_zero(cross(mesh->verts[vi[2]] - mesh->verts[vi[0]], mesh->verts[vi[3]] - mesh->verts[vi[0]]))) {
+ is_zero(cross(mesh->verts[vi[2]] - mesh->verts[vi[0]], mesh->verts[vi[3]] - mesh->verts[vi[0]])))
+ {
mesh->set_triangle(ti++, vi[0], vi[1], vi[3], shader, smooth);
mesh->set_triangle(ti++, vi[2], vi[3], vi[1], shader, smooth);
}
@@ -382,20 +421,6 @@ static void create_mesh(Scene *scene, Mesh *mesh, BL::Mesh b_mesh, const vector<
}
}
- /* create generated coordinates from undeformed coordinates */
- if(mesh->need_attribute(scene, ATTR_STD_GENERATED)) {
- Attribute *attr = mesh->attributes.add(ATTR_STD_GENERATED);
-
- float3 loc, size;
- mesh_texture_space(b_mesh, loc, size);
-
- float3 *generated = attr->data_float3();
- size_t i = 0;
-
- for(b_mesh.vertices.begin(v); v != b_mesh.vertices.end(); ++v)
- generated[i++] = get_float3(v->undeformed_co())*size - loc;
- }
-
/* for volume objects, create a matrix to transform from object space to
* mesh texture space. this does not work with deformations but that can
* probably only be done well with a volume grid mapping of coordinates */
@@ -623,20 +648,53 @@ void BlenderSync::sync_mesh_motion(BL::Object b_ob, Object *object, float motion
return;
}
- /* skip objects without deforming modifiers. this is not totally reliable,
- * would need a more extensive check to see which objects are animated */
+ /* skip empty meshes */
size_t numverts = mesh->verts.size();
size_t numkeys = mesh->curve_keys.size();
- if((!numverts && !numkeys) || !ccl::BKE_object_is_deform_modified(b_ob, b_scene, preview))
+ if(!numverts && !numkeys)
return;
- /* get derived mesh */
- BL::Mesh b_mesh = object_to_mesh(b_data, b_ob, b_scene, true, !preview, false);
+ /* skip objects without deforming modifiers. this is not totally reliable,
+ * would need a more extensive check to see which objects are animated */
+ BL::Mesh b_mesh(PointerRNA_NULL);
+
+ if(ccl::BKE_object_is_deform_modified(b_ob, b_scene, preview)) {
+ /* get derived mesh */
+ b_mesh = object_to_mesh(b_data, b_ob, b_scene, true, !preview, false);
+ }
+
+ if(!b_mesh) {
+ /* if we have no motion blur on this frame, but on other frames, copy */
+ if(numverts) {
+ /* triangles */
+ Attribute *attr_mP = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
+
+ if(attr_mP) {
+ Attribute *attr_mN = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_NORMAL);
+ Attribute *attr_N = mesh->attributes.find(ATTR_STD_VERTEX_NORMAL);
+ float3 *P = &mesh->verts[0];
+ float3 *N = (attr_N)? attr_N->data_float3(): NULL;
+
+ memcpy(attr_mP->data_float3() + time_index*numverts, P, sizeof(float3)*numverts);
+ if(attr_mN)
+ memcpy(attr_mN->data_float3() + time_index*numverts, N, sizeof(float3)*numverts);
+ }
+ }
+
+ if(numkeys) {
+ /* curves */
+ Attribute *attr_mP = mesh->curve_attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
+
+ if(attr_mP) {
+ float4 *keys = &mesh->curve_keys[0];
+ memcpy(attr_mP->data_float4() + time_index*numkeys, keys, sizeof(float4)*numkeys);
+ }
+ }
- if(!b_mesh)
return;
-
+ }
+
if(numverts) {
/* find attributes */
Attribute *attr_mP = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
@@ -682,7 +740,8 @@ void BlenderSync::sync_mesh_motion(BL::Object b_ob, Object *object, float motion
for(int step = 0; step < time_index; step++) {
memcpy(attr_mP->data_float3() + step*numverts, P, sizeof(float3)*numverts);
- memcpy(attr_mN->data_float3() + step*numverts, N, sizeof(float3)*numverts);
+ if(attr_mN)
+ memcpy(attr_mN->data_float3() + step*numverts, N, sizeof(float3)*numverts);
}
}
}
diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp
index f553fe23b8b..167647608a5 100644
--- a/intern/cycles/blender/blender_object.cpp
+++ b/intern/cycles/blender/blender_object.cpp
@@ -455,7 +455,7 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, float motion_time)
}
/* object loop */
- BL::Scene::objects_iterator b_ob;
+ BL::Scene::object_bases_iterator b_base;
BL::Scene b_sce = b_scene;
/* modifier result type (not exposed as enum in C++ API)
* 1 : eModifierMode_Realtime
@@ -466,21 +466,22 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, float motion_time)
bool cancel = false;
for(; b_sce && !cancel; b_sce = b_sce.background_set()) {
- for(b_sce.objects.begin(b_ob); b_ob != b_sce.objects.end() && !cancel; ++b_ob) {
- bool hide = (render_layer.use_viewport_visibility)? b_ob->hide(): b_ob->hide_render();
- uint ob_layer = get_layer(b_ob->layers(), b_ob->layers_local_view(), render_layer.use_localview, object_is_light(*b_ob));
+ for(b_sce.object_bases.begin(b_base); b_base != b_sce.object_bases.end() && !cancel; ++b_base) {
+ BL::Object b_ob = b_base->object();
+ bool hide = (render_layer.use_viewport_visibility)? b_ob.hide(): b_ob.hide_render();
+ uint ob_layer = get_layer(b_base->layers(), b_base->layers_local_view(), render_layer.use_localview, object_is_light(b_ob));
hide = hide || !(ob_layer & scene_layer);
if(!hide) {
- progress.set_sync_status("Synchronizing object", (*b_ob).name());
+ progress.set_sync_status("Synchronizing object", b_ob.name());
- if(b_ob->is_duplicator() && !object_render_hide_duplis(*b_ob)) {
+ if(b_ob.is_duplicator() && !object_render_hide_duplis(b_ob)) {
/* dupli objects */
- b_ob->dupli_list_create(b_scene, dupli_settings);
+ b_ob.dupli_list_create(b_scene, dupli_settings);
BL::Object::dupli_list_iterator b_dup;
- for(b_ob->dupli_list.begin(b_dup); b_dup != b_ob->dupli_list.end(); ++b_dup) {
+ for(b_ob.dupli_list.begin(b_dup); b_dup != b_ob.dupli_list.end(); ++b_dup) {
Transform tfm = get_transform(b_dup->matrix());
BL::Object b_dup_ob = b_dup->object();
bool dup_hide = (b_v3d)? b_dup_ob.hide(): b_dup_ob.hide_render();
@@ -493,27 +494,27 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, float motion_time)
BL::Array<int, OBJECT_PERSISTENT_ID_SIZE> persistent_id = b_dup->persistent_id();
/* sync object and mesh or light data */
- Object *object = sync_object(*b_ob, persistent_id.data, *b_dup, tfm, ob_layer, motion_time, hide_tris);
+ Object *object = sync_object(b_ob, persistent_id.data, *b_dup, tfm, ob_layer, motion_time, hide_tris);
/* sync possible particle data, note particle_id
* starts counting at 1, first is dummy particle */
if(!motion && object) {
- sync_dupli_particle(*b_ob, *b_dup, object);
+ sync_dupli_particle(b_ob, *b_dup, object);
}
}
}
- b_ob->dupli_list_clear();
+ b_ob.dupli_list_clear();
}
/* 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)) {
/* object itself */
- Transform tfm = get_transform(b_ob->matrix_world());
- sync_object(*b_ob, NULL, PointerRNA_NULL, tfm, ob_layer, motion_time, hide_tris);
+ Transform tfm = get_transform(b_ob.matrix_world());
+ sync_object(b_ob, NULL, PointerRNA_NULL, tfm, ob_layer, motion_time, hide_tris);
}
}
diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp
index 8b04a869a85..872f891cc2a 100644
--- a/intern/cycles/blender/blender_python.cpp
+++ b/intern/cycles/blender/blender_python.cpp
@@ -147,6 +147,38 @@ static PyObject *render_func(PyObject *self, PyObject *value)
Py_RETURN_NONE;
}
+/* pixel_array and result passed as pointers */
+static PyObject *bake_func(PyObject *self, PyObject *args)
+{
+ PyObject *pysession, *pyobject;
+ PyObject *pypixel_array, *pyresult;
+ const char *pass_type;
+ int num_pixels, depth;
+
+ if(!PyArg_ParseTuple(args, "OOsOiiO", &pysession, &pyobject, &pass_type, &pypixel_array, &num_pixels, &depth, &pyresult))
+ return NULL;
+
+ Py_BEGIN_ALLOW_THREADS
+
+ BlenderSession *session = (BlenderSession*)PyLong_AsVoidPtr(pysession);
+
+ PointerRNA objectptr;
+ RNA_id_pointer_create((ID*)PyLong_AsVoidPtr(pyobject), &objectptr);
+ BL::Object b_object(objectptr);
+
+ void *b_result = PyLong_AsVoidPtr(pyresult);
+
+ PointerRNA bakepixelptr;
+ RNA_id_pointer_create((ID*)PyLong_AsVoidPtr(pypixel_array), &bakepixelptr);
+ BL::BakePixel b_bake_pixel(bakepixelptr);
+
+ session->bake(b_object, pass_type, b_bake_pixel, num_pixels, depth, (float *)b_result);
+
+ Py_END_ALLOW_THREADS
+
+ Py_RETURN_NONE;
+}
+
static PyObject *draw_func(PyObject *self, PyObject *args)
{
PyObject *pysession, *pyv3d, *pyrv3d;
@@ -285,7 +317,8 @@ static PyObject *osl_update_node_func(PyObject *self, PyObject *args)
}
else if(param->type.vecsemantics == TypeDesc::POINT ||
param->type.vecsemantics == TypeDesc::VECTOR ||
- param->type.vecsemantics == TypeDesc::NORMAL) {
+ param->type.vecsemantics == TypeDesc::NORMAL)
+ {
socket_type = "NodeSocketVector";
data_type = BL::NodeSocket::type_VECTOR;
@@ -418,6 +451,7 @@ static PyMethodDef methods[] = {
{"create", create_func, METH_VARARGS, ""},
{"free", free_func, METH_O, ""},
{"render", render_func, METH_O, ""},
+ {"bake", bake_func, METH_VARARGS, ""},
{"draw", draw_func, METH_VARARGS, ""},
{"sync", sync_func, METH_O, ""},
{"reset", reset_func, METH_VARARGS, ""},
diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index f5e696bc582..01a5acd8982 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -14,6 +14,8 @@
* limitations under the License
*/
+#include <stdlib.h>
+
#include "background.h"
#include "buffers.h"
#include "camera.h"
@@ -21,6 +23,8 @@
#include "integrator.h"
#include "film.h"
#include "light.h"
+#include "mesh.h"
+#include "object.h"
#include "scene.h"
#include "session.h"
#include "shader.h"
@@ -259,6 +263,58 @@ static PassType get_pass_type(BL::RenderPass b_pass)
return PASS_NONE;
}
+static ShaderEvalType get_shader_type(const string& pass_type)
+{
+ const char *shader_type = pass_type.c_str();
+
+ /* data passes */
+ if(strcmp(shader_type, "NORMAL")==0)
+ return SHADER_EVAL_NORMAL;
+ else if(strcmp(shader_type, "UV")==0)
+ return SHADER_EVAL_UV;
+ else if(strcmp(shader_type, "DIFFUSE_COLOR")==0)
+ return SHADER_EVAL_DIFFUSE_COLOR;
+ else if(strcmp(shader_type, "GLOSSY_COLOR")==0)
+ return SHADER_EVAL_GLOSSY_COLOR;
+ else if(strcmp(shader_type, "TRANSMISSION_COLOR")==0)
+ return SHADER_EVAL_TRANSMISSION_COLOR;
+ else if(strcmp(shader_type, "SUBSURFACE_COLOR")==0)
+ return SHADER_EVAL_SUBSURFACE_COLOR;
+ else if(strcmp(shader_type, "EMIT")==0)
+ return SHADER_EVAL_EMISSION;
+
+ /* light passes */
+ else if(strcmp(shader_type, "AO")==0)
+ return SHADER_EVAL_AO;
+ else if(strcmp(shader_type, "COMBINED")==0)
+ return SHADER_EVAL_COMBINED;
+ else if(strcmp(shader_type, "SHADOW")==0)
+ return SHADER_EVAL_SHADOW;
+ else if(strcmp(shader_type, "DIFFUSE_DIRECT")==0)
+ return SHADER_EVAL_DIFFUSE_DIRECT;
+ else if(strcmp(shader_type, "GLOSSY_DIRECT")==0)
+ return SHADER_EVAL_GLOSSY_DIRECT;
+ else if(strcmp(shader_type, "TRANSMISSION_DIRECT")==0)
+ return SHADER_EVAL_TRANSMISSION_DIRECT;
+ else if(strcmp(shader_type, "SUBSURFACE_DIRECT")==0)
+ return SHADER_EVAL_SUBSURFACE_DIRECT;
+ else if(strcmp(shader_type, "DIFFUSE_INDIRECT")==0)
+ return SHADER_EVAL_DIFFUSE_INDIRECT;
+ else if(strcmp(shader_type, "GLOSSY_INDIRECT")==0)
+ return SHADER_EVAL_GLOSSY_INDIRECT;
+ else if(strcmp(shader_type, "TRANSMISSION_INDIRECT")==0)
+ return SHADER_EVAL_TRANSMISSION_INDIRECT;
+ else if(strcmp(shader_type, "SUBSURFACE_INDIRECT")==0)
+ return SHADER_EVAL_SUBSURFACE_INDIRECT;
+
+ /* extra */
+ else if(strcmp(shader_type, "ENVIRONMENT")==0)
+ return SHADER_EVAL_ENVIRONMENT;
+
+ else
+ return SHADER_EVAL_BAKE;
+}
+
static BL::RenderResult begin_render_result(BL::RenderEngine b_engine, int x, int y, int w, int h, const char *layername)
{
return b_engine.begin_result(x, y, w, h, layername);
@@ -425,6 +481,105 @@ void BlenderSession::render()
sync = NULL;
}
+static void populate_bake_data(BakeData *data, BL::BakePixel pixel_array, const int num_pixels)
+{
+ BL::BakePixel bp = pixel_array;
+
+ int i;
+ for(i=0; i < num_pixels; i++) {
+ data->set(i, bp.primitive_id(), bp.uv(), bp.du_dx(), bp.du_dy(), bp.dv_dx(), bp.dv_dy());
+ bp = bp.next();
+ }
+}
+
+static bool is_light_pass(ShaderEvalType type)
+{
+ switch (type) {
+ case SHADER_EVAL_AO:
+ case SHADER_EVAL_COMBINED:
+ case SHADER_EVAL_SHADOW:
+ case SHADER_EVAL_DIFFUSE_DIRECT:
+ case SHADER_EVAL_GLOSSY_DIRECT:
+ case SHADER_EVAL_TRANSMISSION_DIRECT:
+ case SHADER_EVAL_SUBSURFACE_DIRECT:
+ case SHADER_EVAL_DIFFUSE_INDIRECT:
+ case SHADER_EVAL_GLOSSY_INDIRECT:
+ case SHADER_EVAL_TRANSMISSION_INDIRECT:
+ case SHADER_EVAL_SUBSURFACE_INDIRECT:
+ return true;
+ default:
+ return false;
+ }
+}
+
+void BlenderSession::bake(BL::Object b_object, const string& pass_type, BL::BakePixel pixel_array, int num_pixels, int depth, float result[])
+{
+ ShaderEvalType shader_type = get_shader_type(pass_type);
+ size_t object_index = OBJECT_NONE;
+ int tri_offset = 0;
+
+ if(shader_type == SHADER_EVAL_UV) {
+ /* force UV to be available */
+ Pass::add(PASS_UV, scene->film->passes);
+ }
+
+ if(is_light_pass(shader_type)) {
+ /* force use_light_pass to be true */
+ Pass::add(PASS_LIGHT, scene->film->passes);
+ }
+
+ /* create device and update scene */
+ scene->film->tag_update(scene);
+ scene->integrator->tag_update(scene);
+
+ /* update scene */
+ sync->sync_camera(b_render, b_engine.camera_override(), width, height);
+ sync->sync_data(b_v3d, b_engine.camera_override(), &python_thread_state);
+
+ /* get buffer parameters */
+ SessionParams session_params = BlenderSync::get_session_params(b_engine, b_userpref, b_scene, background);
+ BufferParams buffer_params = BlenderSync::get_buffer_params(b_render, b_scene, b_v3d, b_rv3d, scene->camera, width, height);
+
+ scene->bake_manager->set_baking(true);
+
+ /* set number of samples */
+ session->tile_manager.set_samples(session_params.samples);
+ session->reset(buffer_params, session_params.samples);
+ session->update_scene();
+
+ /* find object index. todo: is arbitrary - copied from mesh_displace.cpp */
+ for(size_t i = 0; i < scene->objects.size(); i++) {
+ if(strcmp(scene->objects[i]->name.c_str(), b_object.name().c_str()) == 0) {
+ object_index = i;
+ tri_offset = scene->objects[i]->mesh->tri_offset;
+ break;
+ }
+ }
+
+ /* when used, non-instanced convention: object = ~object */
+ int object = ~object_index;
+
+ BakeData *bake_data = scene->bake_manager->init(object, tri_offset, num_pixels);
+
+ populate_bake_data(bake_data, pixel_array, num_pixels);
+
+ /* set number of samples */
+ session->tile_manager.set_samples(session_params.samples);
+ session->reset(buffer_params, session_params.samples);
+ session->update_scene();
+
+ scene->bake_manager->bake(scene->device, &scene->dscene, scene, session->progress, shader_type, bake_data, result);
+
+ /* free all memory used (host and device), so we wouldn't leave render
+ * engine with extra memory allocated
+ */
+
+ session->device_free();
+
+ delete sync;
+ sync = NULL;
+}
+
void BlenderSession::do_write_update_render_result(BL::RenderResult b_rr, BL::RenderLayer b_rlay, RenderTile& rtile, bool do_update_only)
{
RenderBuffers *buffers = rtile.buffers;
diff --git a/intern/cycles/blender/blender_session.h b/intern/cycles/blender/blender_session.h
index d30e3eda870..0e44493d674 100644
--- a/intern/cycles/blender/blender_session.h
+++ b/intern/cycles/blender/blender_session.h
@@ -20,6 +20,7 @@
#include "device.h"
#include "scene.h"
#include "session.h"
+#include "bake.h"
#include "util_vector.h"
@@ -51,6 +52,8 @@ public:
/* offline render */
void render();
+ void bake(BL::Object b_object, const string& pass_type, BL::BakePixel pixel_array, int num_pixels, int depth, float pixels[]);
+
void write_render_result(BL::RenderResult b_rr, BL::RenderLayer b_rlay, RenderTile& rtile);
void write_render_tile(RenderTile& rtile);
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index 2eafcecf026..ddbb40da7db 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -546,6 +546,7 @@ static ShaderNode *add_node(Scene *scene, BL::BlendData b_data, BL::Scene b_scen
}
image->animated = b_image_node.image_user().use_auto_refresh();
+ image->use_alpha = b_image.use_alpha();
}
image->color_space = ImageTextureNode::color_space_enum[(int)b_image_node.color_space()];
image->projection = ImageTextureNode::projection_enum[(int)b_image_node.projection()];
@@ -574,6 +575,8 @@ static ShaderNode *add_node(Scene *scene, BL::BlendData b_data, BL::Scene b_scen
env->animated = b_env_node.image_user().use_auto_refresh();
env->builtin_data = NULL;
}
+
+ env->use_alpha = b_image.use_alpha();
}
env->color_space = EnvironmentTextureNode::color_space_enum[(int)b_env_node.color_space()];
env->projection = EnvironmentTextureNode::projection_enum[(int)b_env_node.projection()];
diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h
index 45ca0e17550..35e417d8069 100644
--- a/intern/cycles/blender/blender_util.h
+++ b/intern/cycles/blender/blender_util.h
@@ -42,7 +42,14 @@ void python_thread_state_restore(void **python_thread_state);
static inline BL::Mesh object_to_mesh(BL::BlendData data, BL::Object object, BL::Scene scene, bool apply_modifiers, bool render, bool calc_undeformed)
{
- return data.meshes.new_from_object(scene, object, apply_modifiers, (render)? 2: 1, true, calc_undeformed);
+ BL::Mesh me = data.meshes.new_from_object(scene, object, apply_modifiers, (render)? 2: 1, false, calc_undeformed);
+ if ((bool)me) {
+ if (me.use_auto_smooth()) {
+ me.calc_normals_split(me.auto_smooth_angle());
+ }
+ me.calc_tessface();
+ }
+ return me;
}
static inline void colorramp_to_array(BL::ColorRamp ramp, float4 *data, int size)
@@ -50,7 +57,7 @@ static inline void colorramp_to_array(BL::ColorRamp ramp, float4 *data, int size
for(int i = 0; i < size; i++) {
float color[4];
- ramp.evaluate(i/(float)(size-1), color);
+ ramp.evaluate((float)i/(float)(size-1), color);
data[i] = make_float4(color[0], color[1], color[2], color[3]);
}
}
@@ -67,7 +74,7 @@ static inline void curvemapping_color_to_array(BL::CurveMapping cumap, float4 *d
BL::CurveMap mapI = cumap.curves[3];
for(int i = 0; i < size; i++) {
- float t = i/(float)(size-1);
+ float t = (float)i/(float)(size-1);
data[i][0] = mapR.evaluate(mapI.evaluate(t));
data[i][1] = mapG.evaluate(mapI.evaluate(t));
@@ -76,7 +83,7 @@ static inline void curvemapping_color_to_array(BL::CurveMapping cumap, float4 *d
}
else {
for(int i = 0; i < size; i++) {
- float t = i/(float)(size-1);
+ float t = (float)i/(float)(size-1);
data[i][0] = mapR.evaluate(t);
data[i][1] = mapG.evaluate(t);
diff --git a/intern/cycles/bvh/bvh_binning.cpp b/intern/cycles/bvh/bvh_binning.cpp
index 05a674a47a7..bd37ffbcf38 100644
--- a/intern/cycles/bvh/bvh_binning.cpp
+++ b/intern/cycles/bvh/bvh_binning.cpp
@@ -83,14 +83,14 @@ BVHObjectBinning::BVHObjectBinning(const BVHRange& job, BVHReference *prims)
int4 bin1 = get_bin(prim1.bounds());
/* increase bounds for bins for even primitive */
- int b00 = extract<0>(bin0); bin_count[b00][0]++; bin_bounds[b00][0].grow(prim0.bounds());
- int b01 = extract<1>(bin0); bin_count[b01][1]++; bin_bounds[b01][1].grow(prim0.bounds());
- int b02 = extract<2>(bin0); bin_count[b02][2]++; bin_bounds[b02][2].grow(prim0.bounds());
+ int b00 = (int)extract<0>(bin0); bin_count[b00][0]++; bin_bounds[b00][0].grow(prim0.bounds());
+ int b01 = (int)extract<1>(bin0); bin_count[b01][1]++; bin_bounds[b01][1].grow(prim0.bounds());
+ int b02 = (int)extract<2>(bin0); bin_count[b02][2]++; bin_bounds[b02][2].grow(prim0.bounds());
/* increase bounds of bins for odd primitive */
- int b10 = extract<0>(bin1); bin_count[b10][0]++; bin_bounds[b10][0].grow(prim1.bounds());
- int b11 = extract<1>(bin1); bin_count[b11][1]++; bin_bounds[b11][1].grow(prim1.bounds());
- int b12 = extract<2>(bin1); bin_count[b12][2]++; bin_bounds[b12][2].grow(prim1.bounds());
+ int b10 = (int)extract<0>(bin1); bin_count[b10][0]++; bin_bounds[b10][0].grow(prim1.bounds());
+ int b11 = (int)extract<1>(bin1); bin_count[b11][1]++; bin_bounds[b11][1].grow(prim1.bounds());
+ int b12 = (int)extract<2>(bin1); bin_count[b12][2]++; bin_bounds[b12][2].grow(prim1.bounds());
}
/* for uneven number of primitives */
@@ -100,9 +100,9 @@ BVHObjectBinning::BVHObjectBinning(const BVHRange& job, BVHReference *prims)
int4 bin0 = get_bin(prim0.bounds());
/* increase bounds of bins */
- int b00 = extract<0>(bin0); bin_count[b00][0]++; bin_bounds[b00][0].grow(prim0.bounds());
- int b01 = extract<1>(bin0); bin_count[b01][1]++; bin_bounds[b01][1].grow(prim0.bounds());
- int b02 = extract<2>(bin0); bin_count[b02][2]++; bin_bounds[b02][2].grow(prim0.bounds());
+ int b00 = (int)extract<0>(bin0); bin_count[b00][0]++; bin_bounds[b00][0].grow(prim0.bounds());
+ int b01 = (int)extract<1>(bin0); bin_count[b01][1]++; bin_bounds[b01][1].grow(prim0.bounds());
+ int b02 = (int)extract<2>(bin0); bin_count[b02][2]++; bin_bounds[b02][2].grow(prim0.bounds());
}
}
diff --git a/intern/cycles/bvh/bvh_build.cpp b/intern/cycles/bvh/bvh_build.cpp
index 814fbf22e23..eb4cca92b6b 100644
--- a/intern/cycles/bvh/bvh_build.cpp
+++ b/intern/cycles/bvh/bvh_build.cpp
@@ -298,18 +298,41 @@ void BVHBuild::thread_build_node(InnerNode *inner, int child, BVHObjectBinning *
}
}
+bool BVHBuild::range_within_max_leaf_size(const BVHRange& range)
+{
+ size_t size = range.size();
+ size_t max_leaf_size = max(params.max_triangle_leaf_size, params.max_curve_leaf_size);
+
+ if(size > max_leaf_size)
+ return false;
+
+ size_t num_triangles = 0;
+ size_t num_curves = 0;
+
+ for(int i = 0; i < size; i++) {
+ BVHReference& ref = references[range.start() + i];
+
+ if(ref.prim_type() & PRIMITIVE_ALL_CURVE)
+ num_curves++;
+ else if(ref.prim_type() & PRIMITIVE_ALL_TRIANGLE)
+ num_triangles++;
+ }
+
+ return (num_triangles < params.max_triangle_leaf_size) && (num_curves < params.max_curve_leaf_size);
+}
+
/* multithreaded binning builder */
BVHNode* BVHBuild::build_node(const BVHObjectBinning& range, int level)
{
size_t size = range.size();
- float leafSAH = params.sah_triangle_cost * range.leafSAH;
- float splitSAH = params.sah_node_cost * range.bounds().half_area() + params.sah_triangle_cost * range.splitSAH;
+ float leafSAH = params.sah_primitive_cost * range.leafSAH;
+ float splitSAH = params.sah_node_cost * range.bounds().half_area() + params.sah_primitive_cost * range.splitSAH;
/* have at least one inner node on top level, for performance and correct
* visibility tests, since object instances do not check visibility flag */
if(!(range.size() > 0 && params.top_level && level == 0)) {
/* make leaf node when threshold reached or SAH tells us */
- if(params.small_enough_for_leaf(size, level) || (size <= params.max_leaf_size && leafSAH < splitSAH))
+ if(params.small_enough_for_leaf(size, level) || (range_within_max_leaf_size(range) && leafSAH < splitSAH))
return create_leaf_node(range);
}
@@ -511,7 +534,7 @@ void BVHBuild::rotate(BVHNode *node, int max_depth)
/* find best rotation. we pick a target child of a first child, and swap
* this with an other child. we perform the best such swap. */
float best_cost = FLT_MAX;
- int best_child = -1, bets_target = -1, best_other = -1;
+ int best_child = -1, best_target = -1, best_other = -1;
for(size_t c = 0; c < 2; c++) {
/* ignore leaf nodes as we cannot descent into */
@@ -535,11 +558,11 @@ void BVHBuild::rotate(BVHNode *node, int max_depth)
if(cost0 < cost1) {
best_cost = cost0;
- bets_target = 0;
+ best_target = 0;
}
else {
best_cost = cost0;
- bets_target = 1;
+ best_target = 1;
}
}
}
@@ -548,10 +571,13 @@ void BVHBuild::rotate(BVHNode *node, int max_depth)
if(best_cost >= 0)
return;
+ assert(best_child == 0 || best_child == 1);
+ assert(best_target != -1);
+
/* perform the best found tree rotation */
InnerNode *child = (InnerNode*)parent->children[best_child];
- swap(parent->children[best_other], child->children[bets_target]);
+ swap(parent->children[best_other], child->children[best_target]);
child->m_bounds = merge(child->children[0]->m_bounds, child->children[1]->m_bounds);
}
diff --git a/intern/cycles/bvh/bvh_build.h b/intern/cycles/bvh/bvh_build.h
index ba10eb49412..a6b9916de9b 100644
--- a/intern/cycles/bvh/bvh_build.h
+++ b/intern/cycles/bvh/bvh_build.h
@@ -70,6 +70,8 @@ protected:
BVHNode *create_leaf_node(const BVHRange& range);
BVHNode *create_object_leaf_nodes(const BVHReference *ref, int start, int num);
+ bool range_within_max_leaf_size(const BVHRange& range);
+
/* threads */
enum { THREAD_TASK_SIZE = 4096 };
void thread_build_node(InnerNode *node, int child, BVHObjectBinning *range, int level);
diff --git a/intern/cycles/bvh/bvh_params.h b/intern/cycles/bvh/bvh_params.h
index 3e93c0c56a0..ed67690a07f 100644
--- a/intern/cycles/bvh/bvh_params.h
+++ b/intern/cycles/bvh/bvh_params.h
@@ -33,11 +33,12 @@ public:
/* SAH costs */
float sah_node_cost;
- float sah_triangle_cost;
+ float sah_primitive_cost;
- /* number of triangles in leaf */
+ /* number of primitives in leaf */
int min_leaf_size;
- int max_leaf_size;
+ int max_triangle_leaf_size;
+ int max_curve_leaf_size;
/* object or mesh level bvh */
int top_level;
@@ -62,11 +63,14 @@ public:
use_spatial_split = true;
spatial_split_alpha = 1e-5f;
+ /* todo: see if splitting up primitive cost to be separate for triangles
+ * and curves can help. so far in tests it doesn't help, but why? */
sah_node_cost = 1.0f;
- sah_triangle_cost = 1.0f;
+ sah_primitive_cost = 1.0f;
min_leaf_size = 1;
- max_leaf_size = 8;
+ max_triangle_leaf_size = 8;
+ max_curve_leaf_size = 2;
top_level = false;
use_cache = false;
@@ -75,11 +79,11 @@ public:
}
/* SAH costs */
- __forceinline float cost(int num_nodes, int num_tris) const
- { return node_cost(num_nodes) + triangle_cost(num_tris); }
+ __forceinline float cost(int num_nodes, int num_primitives) const
+ { return node_cost(num_nodes) + primitive_cost(num_primitives); }
- __forceinline float triangle_cost(int n) const
- { return n*sah_triangle_cost; }
+ __forceinline float primitive_cost(int n) const
+ { return n*sah_primitive_cost; }
__forceinline float node_cost(int n) const
{ return n*sah_node_cost; }
diff --git a/intern/cycles/bvh/bvh_split.cpp b/intern/cycles/bvh/bvh_split.cpp
index e293e8f4c3f..07c35c08c18 100644
--- a/intern/cycles/bvh/bvh_split.cpp
+++ b/intern/cycles/bvh/bvh_split.cpp
@@ -54,8 +54,8 @@ BVHObjectSplit::BVHObjectSplit(BVHBuild *builder, const BVHRange& range, float n
right_bounds = builder->spatial_right_bounds[i - 1];
float sah = nodeSAH +
- left_bounds.safe_area() * builder->params.triangle_cost(i) +
- right_bounds.safe_area() * builder->params.triangle_cost(range.size() - i);
+ left_bounds.safe_area() * builder->params.primitive_cost(i) +
+ right_bounds.safe_area() * builder->params.primitive_cost(range.size() - i);
if(sah < min_sah) {
min_sah = sah;
@@ -150,8 +150,8 @@ BVHSpatialSplit::BVHSpatialSplit(BVHBuild *builder, const BVHRange& range, float
rightNum -= builder->spatial_bins[dim][i - 1].exit;
float sah = nodeSAH +
- left_bounds.safe_area() * builder->params.triangle_cost(leftNum) +
- builder->spatial_right_bounds[i - 1].safe_area() * builder->params.triangle_cost(rightNum);
+ left_bounds.safe_area() * builder->params.primitive_cost(leftNum) +
+ builder->spatial_right_bounds[i - 1].safe_area() * builder->params.primitive_cost(rightNum);
if(sah < this->sah) {
this->sah = sah;
@@ -209,10 +209,10 @@ void BVHSpatialSplit::split(BVHBuild *builder, BVHRange& left, BVHRange& right,
ldb.grow(lref.bounds());
rdb.grow(rref.bounds());
- float lac = builder->params.triangle_cost(left_end - left_start);
- float rac = builder->params.triangle_cost(right_end - right_start);
- float lbc = builder->params.triangle_cost(left_end - left_start + 1);
- float rbc = builder->params.triangle_cost(right_end - right_start + 1);
+ float lac = builder->params.primitive_cost(left_end - left_start);
+ float rac = builder->params.primitive_cost(right_end - right_start);
+ float lbc = builder->params.primitive_cost(left_end - left_start + 1);
+ float rbc = builder->params.primitive_cost(right_end - right_start + 1);
float unsplitLeftSAH = lub.safe_area() * lbc + right_bounds.safe_area() * rac;
float unsplitRightSAH = left_bounds.safe_area() * lac + rub.safe_area() * rbc;
@@ -284,8 +284,10 @@ void BVHSpatialSplit::split_reference(BVHBuild *builder, BVHReference& left, BVH
/* curve split: NOTE - Currently ignores curve width and needs to be fixed.*/
const int k0 = mesh->curves[ref.prim_index()].first_key + PRIMITIVE_UNPACK_SEGMENT(ref.prim_type());
const int k1 = k0 + 1;
- const float3 v0 = float4_to_float3(mesh->curve_keys[k0]);
- const float3 v1 = float4_to_float3(mesh->curve_keys[k1]);
+ const float4 key0 = mesh->curve_keys[k0];
+ const float4 key1 = mesh->curve_keys[k1];
+ const float3 v0 = float4_to_float3(key0);
+ const float3 v1 = float4_to_float3(key1);
float v0p = v0[dim];
float v1p = v1[dim];
diff --git a/intern/cycles/bvh/bvh_split.h b/intern/cycles/bvh/bvh_split.h
index 1f4befbe8e2..5b739311e5f 100644
--- a/intern/cycles/bvh/bvh_split.h
+++ b/intern/cycles/bvh/bvh_split.h
@@ -77,7 +77,7 @@ public:
/* find split candidates. */
float area = range.bounds().safe_area();
- leafSAH = area * builder->params.triangle_cost(range.size());
+ leafSAH = area * builder->params.primitive_cost(range.size());
nodeSAH = area * builder->params.node_cost(2);
object = BVHObjectSplit(builder, range, nodeSAH);
@@ -92,7 +92,7 @@ public:
/* leaf SAH is the lowest => create leaf. */
minSAH = min(min(leafSAH, object.sah), spatial.sah);
- no_split = (minSAH == leafSAH && range.size() <= builder->params.max_leaf_size);
+ no_split = (minSAH == leafSAH && builder->range_within_max_leaf_size(range));
}
__forceinline void split(BVHBuild *builder, BVHRange& left, BVHRange& right, const BVHRange& range)
diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h
index cbabcb1e20e..bcddd4f73e2 100644
--- a/intern/cycles/device/device.h
+++ b/intern/cycles/device/device.h
@@ -54,6 +54,7 @@ public:
bool display_device;
bool advanced_shading;
bool pack_images;
+ bool extended_images; /* flag for GPU and Multi device */
vector<DeviceInfo> multi_devices;
DeviceInfo()
@@ -64,6 +65,7 @@ public:
display_device = false;
advanced_shading = true;
pack_images = false;
+ extended_images = false;
}
};
diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp
index e14e403d82b..c9cc7592028 100644
--- a/intern/cycles/device/device_cpu.cpp
+++ b/intern/cycles/device/device_cpu.cpp
@@ -395,7 +395,7 @@ public:
for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) {
kernel_cpu_avx_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x);
- if(task_pool.canceled())
+ if(task.get_cancel() || task_pool.canceled())
break;
}
}
@@ -406,7 +406,7 @@ public:
for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) {
kernel_cpu_sse41_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x);
- if(task_pool.canceled())
+ if(task.get_cancel() || task_pool.canceled())
break;
}
}
@@ -417,7 +417,7 @@ public:
for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) {
kernel_cpu_sse3_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x);
- if(task_pool.canceled())
+ if(task.get_cancel() || task_pool.canceled())
break;
}
}
@@ -428,7 +428,7 @@ public:
for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) {
kernel_cpu_sse2_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x);
- if(task_pool.canceled())
+ if(task.get_cancel() || task_pool.canceled())
break;
}
}
@@ -438,7 +438,7 @@ public:
for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) {
kernel_cpu_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x);
- if(task_pool.canceled())
+ if(task.get_cancel() || task_pool.canceled())
break;
}
}
diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp
index a5e4ec63699..68955211146 100644
--- a/intern/cycles/device/device_cuda.cpp
+++ b/intern/cycles/device/device_cuda.cpp
@@ -139,7 +139,7 @@ public:
/*cuda_abort();*/ \
cuda_error_documentation(); \
} \
- }
+ } (void)0
bool cuda_error_(CUresult result, const string& stmt)
{
@@ -166,7 +166,7 @@ public:
void cuda_push_context()
{
- cuda_assert(cuCtxSetCurrent(cuContext))
+ cuda_assert(cuCtxSetCurrent(cuContext));
}
void cuda_pop_context()
@@ -174,7 +174,7 @@ public:
cuda_assert(cuCtxSetCurrent(NULL));
}
- CUDADevice(DeviceInfo& info, Stats &stats, bool background_)
+ CUDADevice(DeviceInfo& info, Stats &stats, bool background_)
: Device(info, stats, background_)
{
first_error = true;
@@ -212,8 +212,8 @@ public:
if(cuda_error_(result, "cuCtxCreate"))
return;
- cuda_assert(cuStreamCreate(&cuStream, 0))
- cuda_assert(cuEventCreate(&tileDone, 0x1))
+ cuda_assert(cuStreamCreate(&cuStream, 0));
+ cuda_assert(cuEventCreate(&tileDone, 0x1));
int major, minor;
cuDeviceComputeCapability(&major, &minor, cuDevId);
@@ -222,7 +222,7 @@ public:
/* In order to use full 6GB of memory on Titan cards, use arrays instead
* of textures. On earlier cards this seems slower, but on Titan it is
* actually slightly faster in tests. */
- use_texture_storage = (cuDevArchitecture < 350);
+ use_texture_storage = (cuDevArchitecture < 300);
cuda_pop_context();
}
@@ -231,9 +231,9 @@ public:
{
task_pool.stop();
- cuda_assert(cuEventDestroy(tileDone))
- cuda_assert(cuStreamDestroy(cuStream))
- cuda_assert(cuCtxDestroy(cuContext))
+ cuda_assert(cuEventDestroy(tileDone));
+ cuda_assert(cuStreamDestroy(cuStream));
+ cuda_assert(cuCtxDestroy(cuContext));
}
bool support_device(bool experimental, bool branched)
@@ -247,13 +247,6 @@ public:
return false;
}
- /* Currently no Branched Path on sm_30 */
- if(branched) {
- cuda_error_message(string_printf("CUDA device: Branched Path is currently disabled, due to compile errors."));
- return false;
- }
-
-
return true;
}
@@ -304,28 +297,16 @@ public:
return "";
}
if(cuda_version < 50) {
- printf("Unsupported CUDA version %d.%d detected, you need CUDA 5.0.\n", cuda_version/10, cuda_version%10);
+ printf("Unsupported CUDA version %d.%d detected, you need CUDA 6.0.\n", cuda_version/10, cuda_version%10);
return "";
}
-
- else if(cuda_version > 50)
- printf("CUDA version %d.%d detected, build may succeed but only CUDA 5.0 is officially supported.\n", cuda_version/10, cuda_version%10);
+ else if(cuda_version != 60)
+ printf("CUDA version %d.%d detected, build may succeed but only CUDA 6.0 is officially supported.\n", cuda_version/10, cuda_version%10);
/* compile */
string kernel = path_join(kernel_path, "kernel.cu");
string include = kernel_path;
const int machine = system_cpu_bits();
- string arch_flags;
-
- /* CUDA 5.x build flags for different archs */
- if(major == 2) {
- /* sm_2x */
- arch_flags = "--maxrregcount=32 --use_fast_math";
- }
- else if(major == 3) {
- /* sm_3x */
- arch_flags = "--maxrregcount=32 --use_fast_math";
- }
double starttime = time_dt();
printf("Compiling CUDA kernel ...\n");
@@ -333,8 +314,8 @@ public:
path_create_directories(cubin);
string command = string_printf("\"%s\" -arch=sm_%d%d -m%d --cubin \"%s\" "
- "-o \"%s\" --ptxas-options=\"-v\" %s -I\"%s\" -DNVCC -D__KERNEL_CUDA_VERSION__=%d",
- nvcc.c_str(), major, minor, machine, kernel.c_str(), cubin.c_str(), arch_flags.c_str(), include.c_str(), cuda_version);
+ "-o \"%s\" --ptxas-options=\"-v\" -I\"%s\" -DNVCC -D__KERNEL_CUDA_VERSION__=%d",
+ nvcc.c_str(), major, minor, machine, kernel.c_str(), cubin.c_str(), include.c_str(), cuda_version);
printf("%s\n", command.c_str());
@@ -394,7 +375,7 @@ public:
cuda_push_context();
CUdeviceptr device_pointer;
size_t size = mem.memory_size();
- cuda_assert(cuMemAlloc(&device_pointer, size))
+ cuda_assert(cuMemAlloc(&device_pointer, size));
mem.device_pointer = (device_ptr)device_pointer;
stats.mem_alloc(size);
cuda_pop_context();
@@ -404,7 +385,7 @@ public:
{
cuda_push_context();
if(mem.device_pointer)
- cuda_assert(cuMemcpyHtoD(cuda_device_ptr(mem.device_pointer), (void*)mem.data_pointer, mem.memory_size()))
+ cuda_assert(cuMemcpyHtoD(cuda_device_ptr(mem.device_pointer), (void*)mem.data_pointer, mem.memory_size()));
cuda_pop_context();
}
@@ -416,7 +397,7 @@ public:
cuda_push_context();
if(mem.device_pointer) {
cuda_assert(cuMemcpyDtoH((uchar*)mem.data_pointer + offset,
- (CUdeviceptr)((uchar*)mem.device_pointer + offset), size))
+ (CUdeviceptr)((uchar*)mem.device_pointer + offset), size));
}
else {
memset((char*)mem.data_pointer + offset, 0, size);
@@ -430,7 +411,7 @@ public:
cuda_push_context();
if(mem.device_pointer)
- cuda_assert(cuMemsetD8(cuda_device_ptr(mem.device_pointer), 0, mem.memory_size()))
+ cuda_assert(cuMemsetD8(cuda_device_ptr(mem.device_pointer), 0, mem.memory_size()));
cuda_pop_context();
}
@@ -438,7 +419,7 @@ public:
{
if(mem.device_pointer) {
cuda_push_context();
- cuda_assert(cuMemFree(cuda_device_ptr(mem.device_pointer)))
+ cuda_assert(cuMemFree(cuda_device_ptr(mem.device_pointer)));
cuda_pop_context();
mem.device_pointer = 0;
@@ -453,9 +434,9 @@ public:
size_t bytes;
cuda_push_context();
- cuda_assert(cuModuleGetGlobal(&mem, &bytes, cuModule, name))
+ cuda_assert(cuModuleGetGlobal(&mem, &bytes, cuModule, name));
//assert(bytes == size);
- cuda_assert(cuMemcpyHtoD(mem, host, size))
+ cuda_assert(cuMemcpyHtoD(mem, host, size));
cuda_pop_context();
}
@@ -482,7 +463,7 @@ public:
CUtexref texref = NULL;
cuda_push_context();
- cuda_assert(cuModuleGetTexRef(&texref, cuModule, name))
+ cuda_assert(cuModuleGetTexRef(&texref, cuModule, name));
if(!texref) {
cuda_pop_context();
@@ -498,7 +479,7 @@ public:
desc.Format = format;
desc.NumChannels = mem.data_elements;
- cuda_assert(cuArrayCreate(&handle, &desc))
+ cuda_assert(cuArrayCreate(&handle, &desc));
if(!handle) {
cuda_pop_context();
@@ -516,23 +497,23 @@ public:
param.WidthInBytes = param.srcPitch;
param.Height = mem.data_height;
- cuda_assert(cuMemcpy2D(&param))
+ cuda_assert(cuMemcpy2D(&param));
}
else
- cuda_assert(cuMemcpyHtoA(handle, 0, (void*)mem.data_pointer, size))
+ cuda_assert(cuMemcpyHtoA(handle, 0, (void*)mem.data_pointer, size));
- cuda_assert(cuTexRefSetArray(texref, handle, CU_TRSA_OVERRIDE_FORMAT))
+ cuda_assert(cuTexRefSetArray(texref, handle, CU_TRSA_OVERRIDE_FORMAT));
if(interpolation == INTERPOLATION_CLOSEST) {
- cuda_assert(cuTexRefSetFilterMode(texref, CU_TR_FILTER_MODE_POINT))
+ cuda_assert(cuTexRefSetFilterMode(texref, CU_TR_FILTER_MODE_POINT));
}
- else if (interpolation == INTERPOLATION_LINEAR){
- cuda_assert(cuTexRefSetFilterMode(texref, CU_TR_FILTER_MODE_LINEAR))
+ else if (interpolation == INTERPOLATION_LINEAR) {
+ cuda_assert(cuTexRefSetFilterMode(texref, CU_TR_FILTER_MODE_LINEAR));
}
else {/* CUBIC and SMART are unsupported for CUDA */
- cuda_assert(cuTexRefSetFilterMode(texref, CU_TR_FILTER_MODE_LINEAR))
+ cuda_assert(cuTexRefSetFilterMode(texref, CU_TR_FILTER_MODE_LINEAR));
}
- cuda_assert(cuTexRefSetFlags(texref, CU_TRSF_NORMALIZED_COORDINATES))
+ cuda_assert(cuTexRefSetFlags(texref, CU_TRSF_NORMALIZED_COORDINATES));
mem.device_pointer = (device_ptr)handle;
@@ -546,20 +527,20 @@ public:
cuda_push_context();
- cuda_assert(cuTexRefSetAddress(NULL, texref, cuda_device_ptr(mem.device_pointer), size))
- cuda_assert(cuTexRefSetFilterMode(texref, CU_TR_FILTER_MODE_POINT))
- cuda_assert(cuTexRefSetFlags(texref, CU_TRSF_READ_AS_INTEGER))
+ cuda_assert(cuTexRefSetAddress(NULL, texref, cuda_device_ptr(mem.device_pointer), size));
+ cuda_assert(cuTexRefSetFilterMode(texref, CU_TR_FILTER_MODE_POINT));
+ cuda_assert(cuTexRefSetFlags(texref, CU_TRSF_READ_AS_INTEGER));
}
if(periodic) {
- cuda_assert(cuTexRefSetAddressMode(texref, 0, CU_TR_ADDRESS_MODE_WRAP))
- cuda_assert(cuTexRefSetAddressMode(texref, 1, CU_TR_ADDRESS_MODE_WRAP))
+ cuda_assert(cuTexRefSetAddressMode(texref, 0, CU_TR_ADDRESS_MODE_WRAP));
+ cuda_assert(cuTexRefSetAddressMode(texref, 1, CU_TR_ADDRESS_MODE_WRAP));
}
else {
- cuda_assert(cuTexRefSetAddressMode(texref, 0, CU_TR_ADDRESS_MODE_CLAMP))
- cuda_assert(cuTexRefSetAddressMode(texref, 1, CU_TR_ADDRESS_MODE_CLAMP))
+ cuda_assert(cuTexRefSetAddressMode(texref, 0, CU_TR_ADDRESS_MODE_CLAMP));
+ cuda_assert(cuTexRefSetAddressMode(texref, 1, CU_TR_ADDRESS_MODE_CLAMP));
}
- cuda_assert(cuTexRefSetFormat(texref, format, mem.data_elements))
+ cuda_assert(cuTexRefSetFormat(texref, format, mem.data_elements));
cuda_pop_context();
}
@@ -572,17 +553,17 @@ public:
CUdeviceptr cumem;
size_t cubytes;
- cuda_assert(cuModuleGetGlobal(&cumem, &cubytes, cuModule, name))
+ cuda_assert(cuModuleGetGlobal(&cumem, &cubytes, cuModule, name));
if(cubytes == 8) {
/* 64 bit device pointer */
uint64_t ptr = mem.device_pointer;
- cuda_assert(cuMemcpyHtoD(cumem, (void*)&ptr, cubytes))
+ cuda_assert(cuMemcpyHtoD(cumem, (void*)&ptr, cubytes));
}
else {
/* 32 bit device pointer */
uint32_t ptr = (uint32_t)mem.device_pointer;
- cuda_assert(cuMemcpyHtoD(cumem, (void*)&ptr, cubytes))
+ cuda_assert(cuMemcpyHtoD(cumem, (void*)&ptr, cubytes));
}
cuda_pop_context();
@@ -623,10 +604,12 @@ public:
CUdeviceptr d_rng_state = cuda_device_ptr(rtile.rng_state);
/* get kernel function */
- if(branched && support_device(true, branched))
- cuda_assert(cuModuleGetFunction(&cuPathTrace, cuModule, "kernel_cuda_branched_path_trace"))
- else
- cuda_assert(cuModuleGetFunction(&cuPathTrace, cuModule, "kernel_cuda_path_trace"))
+ if(branched && support_device(true, branched)) {
+ cuda_assert(cuModuleGetFunction(&cuPathTrace, cuModule, "kernel_cuda_branched_path_trace"));
+ }
+ else {
+ cuda_assert(cuModuleGetFunction(&cuPathTrace, cuModule, "kernel_cuda_path_trace"));
+ }
if(have_error())
return;
@@ -634,46 +617,63 @@ public:
/* pass in parameters */
int offset = 0;
- cuda_assert(cuParamSetv(cuPathTrace, offset, &d_buffer, sizeof(d_buffer)))
+ cuda_assert(cuParamSetv(cuPathTrace, offset, &d_buffer, sizeof(d_buffer)));
offset += sizeof(d_buffer);
- cuda_assert(cuParamSetv(cuPathTrace, offset, &d_rng_state, sizeof(d_rng_state)))
+ cuda_assert(cuParamSetv(cuPathTrace, offset, &d_rng_state, sizeof(d_rng_state)));
offset += sizeof(d_rng_state);
offset = align_up(offset, __alignof(sample));
- cuda_assert(cuParamSeti(cuPathTrace, offset, sample))
+ cuda_assert(cuParamSeti(cuPathTrace, offset, sample));
offset += sizeof(sample);
- cuda_assert(cuParamSeti(cuPathTrace, offset, rtile.x))
+ cuda_assert(cuParamSeti(cuPathTrace, offset, rtile.x));
offset += sizeof(rtile.x);
- cuda_assert(cuParamSeti(cuPathTrace, offset, rtile.y))
+ cuda_assert(cuParamSeti(cuPathTrace, offset, rtile.y));
offset += sizeof(rtile.y);
- cuda_assert(cuParamSeti(cuPathTrace, offset, rtile.w))
+ cuda_assert(cuParamSeti(cuPathTrace, offset, rtile.w));
offset += sizeof(rtile.w);
- cuda_assert(cuParamSeti(cuPathTrace, offset, rtile.h))
+ cuda_assert(cuParamSeti(cuPathTrace, offset, rtile.h));
offset += sizeof(rtile.h);
- cuda_assert(cuParamSeti(cuPathTrace, offset, rtile.offset))
+ cuda_assert(cuParamSeti(cuPathTrace, offset, rtile.offset));
offset += sizeof(rtile.offset);
- cuda_assert(cuParamSeti(cuPathTrace, offset, rtile.stride))
+ cuda_assert(cuParamSeti(cuPathTrace, offset, rtile.stride));
offset += sizeof(rtile.stride);
- cuda_assert(cuParamSetSize(cuPathTrace, offset))
+ cuda_assert(cuParamSetSize(cuPathTrace, offset));
+
+ /* launch kernel */
+ int threads_per_block;
+ cuda_assert(cuFuncGetAttribute(&threads_per_block, CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK, cuPathTrace));
+
+ /*int num_registers;
+ cuda_assert(cuFuncGetAttribute(&num_registers, CU_FUNC_ATTRIBUTE_NUM_REGS, cuPathTrace));
- /* launch kernel: todo find optimal size, cache config for fermi */
- int xthreads = 16;
- int ythreads = 16;
+ printf("threads_per_block %d\n", threads_per_block);
+ printf("num_registers %d\n", num_registers);*/
+
+ int xthreads = (int)sqrt((float)threads_per_block);
+ int ythreads = (int)sqrt((float)threads_per_block);
int xblocks = (rtile.w + xthreads - 1)/xthreads;
int yblocks = (rtile.h + ythreads - 1)/ythreads;
- cuda_assert(cuFuncSetCacheConfig(cuPathTrace, CU_FUNC_CACHE_PREFER_L1))
- cuda_assert(cuFuncSetBlockShape(cuPathTrace, xthreads, ythreads, 1))
- cuda_assert(cuLaunchGridAsync(cuPathTrace, xblocks, yblocks, cuStream))
+ cuda_assert(cuFuncSetCacheConfig(cuPathTrace, CU_FUNC_CACHE_PREFER_L1));
+ cuda_assert(cuFuncSetBlockShape(cuPathTrace, xthreads, ythreads, 1));
+
+ if(info.display_device) {
+ /* don't use async for device used for display, locks up UI too much */
+ cuda_assert(cuLaunchGrid(cuPathTrace, xblocks, yblocks));
+ cuda_assert(cuCtxSynchronize());
+ }
+ else {
+ cuda_assert(cuLaunchGridAsync(cuPathTrace, xblocks, yblocks, cuStream));
+ }
cuda_pop_context();
}
@@ -690,55 +690,60 @@ public:
CUdeviceptr d_buffer = cuda_device_ptr(buffer);
/* get kernel function */
- if(rgba_half)
- cuda_assert(cuModuleGetFunction(&cuFilmConvert, cuModule, "kernel_cuda_convert_to_half_float"))
- else
- cuda_assert(cuModuleGetFunction(&cuFilmConvert, cuModule, "kernel_cuda_convert_to_byte"))
+ if(rgba_half) {
+ cuda_assert(cuModuleGetFunction(&cuFilmConvert, cuModule, "kernel_cuda_convert_to_half_float"));
+ }
+ else {
+ cuda_assert(cuModuleGetFunction(&cuFilmConvert, cuModule, "kernel_cuda_convert_to_byte"));
+ }
/* pass in parameters */
int offset = 0;
- cuda_assert(cuParamSetv(cuFilmConvert, offset, &d_rgba, sizeof(d_rgba)))
+ cuda_assert(cuParamSetv(cuFilmConvert, offset, &d_rgba, sizeof(d_rgba)));
offset += sizeof(d_rgba);
- cuda_assert(cuParamSetv(cuFilmConvert, offset, &d_buffer, sizeof(d_buffer)))
+ cuda_assert(cuParamSetv(cuFilmConvert, offset, &d_buffer, sizeof(d_buffer)));
offset += sizeof(d_buffer);
float sample_scale = 1.0f/(task.sample + 1);
offset = align_up(offset, __alignof(sample_scale));
- cuda_assert(cuParamSetf(cuFilmConvert, offset, sample_scale))
+ cuda_assert(cuParamSetf(cuFilmConvert, offset, sample_scale));
offset += sizeof(sample_scale);
- cuda_assert(cuParamSeti(cuFilmConvert, offset, task.x))
+ cuda_assert(cuParamSeti(cuFilmConvert, offset, task.x));
offset += sizeof(task.x);
- cuda_assert(cuParamSeti(cuFilmConvert, offset, task.y))
+ cuda_assert(cuParamSeti(cuFilmConvert, offset, task.y));
offset += sizeof(task.y);
- cuda_assert(cuParamSeti(cuFilmConvert, offset, task.w))
+ cuda_assert(cuParamSeti(cuFilmConvert, offset, task.w));
offset += sizeof(task.w);
- cuda_assert(cuParamSeti(cuFilmConvert, offset, task.h))
+ cuda_assert(cuParamSeti(cuFilmConvert, offset, task.h));
offset += sizeof(task.h);
- cuda_assert(cuParamSeti(cuFilmConvert, offset, task.offset))
+ cuda_assert(cuParamSeti(cuFilmConvert, offset, task.offset));
offset += sizeof(task.offset);
- cuda_assert(cuParamSeti(cuFilmConvert, offset, task.stride))
+ cuda_assert(cuParamSeti(cuFilmConvert, offset, task.stride));
offset += sizeof(task.stride);
- cuda_assert(cuParamSetSize(cuFilmConvert, offset))
+ cuda_assert(cuParamSetSize(cuFilmConvert, offset));
- /* launch kernel: todo find optimal size, cache config for fermi */
- int xthreads = 16;
- int ythreads = 16;
+ /* launch kernel */
+ int threads_per_block;
+ cuda_assert(cuFuncGetAttribute(&threads_per_block, CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK, cuFilmConvert));
+
+ int xthreads = (int)sqrt((float)threads_per_block);
+ int ythreads = (int)sqrt((float)threads_per_block);
int xblocks = (task.w + xthreads - 1)/xthreads;
int yblocks = (task.h + ythreads - 1)/ythreads;
- cuda_assert(cuFuncSetCacheConfig(cuFilmConvert, CU_FUNC_CACHE_PREFER_L1))
- cuda_assert(cuFuncSetBlockShape(cuFilmConvert, xthreads, ythreads, 1))
- cuda_assert(cuLaunchGrid(cuFilmConvert, xblocks, yblocks))
+ cuda_assert(cuFuncSetCacheConfig(cuFilmConvert, CU_FUNC_CACHE_PREFER_L1));
+ cuda_assert(cuFuncSetBlockShape(cuFilmConvert, xthreads, ythreads, 1));
+ cuda_assert(cuLaunchGrid(cuFilmConvert, xblocks, yblocks));
unmap_pixels((rgba_byte)? rgba_byte: rgba_half);
@@ -752,40 +757,55 @@ public:
cuda_push_context();
- CUfunction cuDisplace;
+ CUfunction cuShader;
CUdeviceptr d_input = cuda_device_ptr(task.shader_input);
CUdeviceptr d_output = cuda_device_ptr(task.shader_output);
/* get kernel function */
- cuda_assert(cuModuleGetFunction(&cuDisplace, cuModule, "kernel_cuda_shader"))
-
- /* pass in parameters */
- int offset = 0;
-
- cuda_assert(cuParamSetv(cuDisplace, offset, &d_input, sizeof(d_input)))
- offset += sizeof(d_input);
+ cuda_assert(cuModuleGetFunction(&cuShader, cuModule, "kernel_cuda_shader"));
+
+ /* do tasks in smaller chunks, so we can cancel it */
+ const int shader_chunk_size = 65536;
+ const int start = task.shader_x;
+ const int end = task.shader_x + task.shader_w;
+
+ for(int shader_x = start; shader_x < end; shader_x += shader_chunk_size) {
+ if(task.get_cancel())
+ break;
+
+ /* pass in parameters */
+ int offset = 0;
+
+ cuda_assert(cuParamSetv(cuShader, offset, &d_input, sizeof(d_input)));
+ offset += sizeof(d_input);
- cuda_assert(cuParamSetv(cuDisplace, offset, &d_output, sizeof(d_output)))
- offset += sizeof(d_output);
+ cuda_assert(cuParamSetv(cuShader, offset, &d_output, sizeof(d_output)));
+ offset += sizeof(d_output);
- int shader_eval_type = task.shader_eval_type;
- offset = align_up(offset, __alignof(shader_eval_type));
+ int shader_eval_type = task.shader_eval_type;
+ offset = align_up(offset, __alignof(shader_eval_type));
- cuda_assert(cuParamSeti(cuDisplace, offset, task.shader_eval_type))
- offset += sizeof(task.shader_eval_type);
+ cuda_assert(cuParamSeti(cuShader, offset, task.shader_eval_type));
+ offset += sizeof(task.shader_eval_type);
- cuda_assert(cuParamSeti(cuDisplace, offset, task.shader_x))
- offset += sizeof(task.shader_x);
+ cuda_assert(cuParamSeti(cuShader, offset, shader_x));
+ offset += sizeof(shader_x);
- cuda_assert(cuParamSetSize(cuDisplace, offset))
+ cuda_assert(cuParamSetSize(cuShader, offset));
- /* launch kernel: todo find optimal size, cache config for fermi */
- int xthreads = 16;
- int xblocks = (task.shader_w + xthreads - 1)/xthreads;
+ /* launch kernel */
+ int threads_per_block;
+ cuda_assert(cuFuncGetAttribute(&threads_per_block, CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK, cuShader));
- cuda_assert(cuFuncSetCacheConfig(cuDisplace, CU_FUNC_CACHE_PREFER_L1))
- cuda_assert(cuFuncSetBlockShape(cuDisplace, xthreads, 1, 1))
- cuda_assert(cuLaunchGrid(cuDisplace, xblocks, 1))
+ int shader_w = min(shader_chunk_size, end - shader_x);
+ int xblocks = (shader_w + threads_per_block - 1)/threads_per_block;
+
+ cuda_assert(cuFuncSetCacheConfig(cuShader, CU_FUNC_CACHE_PREFER_L1));
+ cuda_assert(cuFuncSetBlockShape(cuShader, threads_per_block, 1, 1));
+ cuda_assert(cuLaunchGrid(cuShader, xblocks, 1));
+
+ cuda_assert(cuCtxSynchronize());
+ }
cuda_pop_context();
}
@@ -797,8 +817,8 @@ public:
CUdeviceptr buffer;
size_t bytes;
- cuda_assert(cuGraphicsMapResources(1, &pmem.cuPBOresource, 0))
- cuda_assert(cuGraphicsResourceGetMappedPointer(&buffer, &bytes, pmem.cuPBOresource))
+ cuda_assert(cuGraphicsMapResources(1, &pmem.cuPBOresource, 0));
+ cuda_assert(cuGraphicsResourceGetMappedPointer(&buffer, &bytes, pmem.cuPBOresource));
return buffer;
}
@@ -811,7 +831,7 @@ public:
if(!background) {
PixelMem pmem = pixel_mem_map[mem];
- cuda_assert(cuGraphicsUnmapResources(1, &pmem.cuPBOresource, 0))
+ cuda_assert(cuGraphicsUnmapResources(1, &pmem.cuPBOresource, 0));
}
}
@@ -900,7 +920,7 @@ public:
cuda_push_context();
- cuda_assert(cuGraphicsUnregisterResource(pmem.cuPBOresource))
+ cuda_assert(cuGraphicsUnregisterResource(pmem.cuPBOresource));
glDeleteBuffers(1, &pmem.cuPBO);
glDeleteTextures(1, &pmem.cuTexId);
@@ -999,7 +1019,6 @@ public:
bool branched = task->integrator_branched;
-
/* keep rendering tiles until done */
while(task->acquire_tile(this, tile)) {
int start_sample = tile.start_sample;
@@ -1020,10 +1039,10 @@ public:
tile.sample = sample + 1;
task->update_progress(tile);
- if(sample == sync_sample){
+ if(!info.display_device && sample == sync_sample) {
cuda_push_context();
- cuda_assert(cuEventRecord(tileDone, cuStream ))
- cuda_assert(cuEventSynchronize(tileDone))
+ cuda_assert(cuEventRecord(tileDone, cuStream));
+ cuda_assert(cuEventSynchronize(tileDone));
/* Do some time keeping to find out if we need to sync less */
boost::posix_time::ptime current_time(boost::posix_time::microsec_clock::local_time());
@@ -1033,7 +1052,7 @@ public:
float scaling_factor = (float)target_update_frequency / (float)msec;
/* sync at earliest next sample and probably later */
- sync_sample = (sample + 1) + sync_sample * ceil(scaling_factor);
+ sync_sample = (sample + 1) + sync_sample * (int)ceil(scaling_factor);
sync_sample = min(end_sample - 1, sync_sample); // make sure we sync the last sample always
@@ -1049,7 +1068,7 @@ public:
shader(*task);
cuda_push_context();
- cuda_assert(cuCtxSynchronize())
+ cuda_assert(cuCtxSynchronize());
cuda_pop_context();
}
}
@@ -1070,7 +1089,7 @@ public:
film_convert(task, task.buffer, task.rgba_byte, task.rgba_half);
cuda_push_context();
- cuda_assert(cuCtxSynchronize())
+ cuda_assert(cuCtxSynchronize());
cuda_pop_context();
}
else {
@@ -1131,6 +1150,7 @@ void device_cuda_info(vector<DeviceInfo>& devices)
int major, minor;
cuDeviceComputeCapability(&major, &minor, num);
info.advanced_shading = (major >= 2);
+ info.extended_images = (major >= 3);
info.pack_images = false;
/* if device has a kernel timeout, assume it is used for display */
diff --git a/intern/cycles/device/device_multi.cpp b/intern/cycles/device/device_multi.cpp
index 59bbf3b9d5a..c866ebaaea2 100644
--- a/intern/cycles/device/device_multi.cpp
+++ b/intern/cycles/device/device_multi.cpp
@@ -328,6 +328,7 @@ static bool device_multi_add(vector<DeviceInfo>& devices, DeviceType type, bool
info.advanced_shading = with_advanced_shading;
info.pack_images = false;
+ info.extended_images = true;
foreach(DeviceInfo& subinfo, devices) {
if(subinfo.type == type) {
@@ -351,6 +352,7 @@ static bool device_multi_add(vector<DeviceInfo>& devices, DeviceType type, bool
if(subinfo.display_device)
info.display_device = true;
info.pack_images = info.pack_images || subinfo.pack_images;
+ info.extended_images = info.extended_images && subinfo.extended_images;
num_added++;
}
}
diff --git a/intern/cycles/device/device_network.cpp b/intern/cycles/device/device_network.cpp
index 8f00324c3e1..af051076009 100644
--- a/intern/cycles/device/device_network.cpp
+++ b/intern/cycles/device/device_network.cpp
@@ -326,7 +326,7 @@ class DeviceServer {
public:
thread_mutex rpc_lock;
- void network_error(const string &message){
+ void network_error(const string &message) {
error_func.network_error(message);
}
@@ -366,7 +366,7 @@ protected:
{
/* create a new DataVector and insert it into mem_data */
pair<DataMap::iterator,bool> data_ins = mem_data.insert(
- DataMap::value_type(client_pointer, DataVector()));
+ DataMap::value_type(client_pointer, DataVector()));
/* make sure it was a unique insertion */
assert(data_ins.second);
diff --git a/intern/cycles/device/device_network.h b/intern/cycles/device/device_network.h
index 8596b61b179..893841d1da7 100644
--- a/intern/cycles/device/device_network.h
+++ b/intern/cycles/device/device_network.h
@@ -209,7 +209,7 @@ public:
boost::system::error_code error;
size_t len = boost::asio::read(socket, boost::asio::buffer(header), error);
- if(error.value()){
+ if(error.value()) {
error_func->network_error(error.message());
}
@@ -276,7 +276,7 @@ public:
boost::system::error_code error;
size_t len = boost::asio::read(socket, boost::asio::buffer(buffer, size), error);
- if(error.value()){
+ if(error.value()) {
error_func->network_error(error.message());
}
@@ -391,7 +391,7 @@ private:
/* add address if it's not already in the list */
bool found = std::find(servers.begin(), servers.end(),
- address) != servers.end();
+ address) != servers.end();
if(!found)
servers.push_back(address);
diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp
index 33170e1230d..694ec9db036 100644
--- a/intern/cycles/device/device_opencl.cpp
+++ b/intern/cycles/device/device_opencl.cpp
@@ -101,9 +101,6 @@ static string opencl_kernel_build_options(const string& platform, const string *
if(opencl_kernel_use_debug())
build_options += "-D__KERNEL_OPENCL_DEBUG__ ";
-
- if(opencl_kernel_use_advanced_shading(platform))
- build_options += "-D__KERNEL_OPENCL_NEED_ADVANCED_SHADING__ ";
return build_options;
}
@@ -409,10 +406,22 @@ public:
fprintf(stderr, "%s\n", message.c_str());
}
- void opencl_assert(cl_int err)
+#define opencl_assert(stmt) \
+ { \
+ cl_int err = stmt; \
+ \
+ if(err != CL_SUCCESS) { \
+ string message = string_printf("OpenCL error: %s in %s", opencl_error_string(err), #stmt); \
+ if(error_msg == "") \
+ error_msg = message; \
+ fprintf(stderr, "%s\n", message.c_str()); \
+ } \
+ } (void)0
+
+ void opencl_assert_err(cl_int err, const char* where)
{
if(err != CL_SUCCESS) {
- string message = string_printf("OpenCL error (%d): %s", err, opencl_error_string(err));
+ string message = string_printf("OpenCL error (%d): %s in %s", err, opencl_error_string(err), where);
if(error_msg == "")
error_msg = message;
fprintf(stderr, "%s\n", message.c_str());
@@ -452,8 +461,10 @@ public:
vector<cl_platform_id> platforms(num_platforms, NULL);
ciErr = clGetPlatformIDs(num_platforms, &platforms[0], NULL);
- if(opencl_error(ciErr))
+ if(opencl_error(ciErr)) {
+ fprintf(stderr, "clGetPlatformIDs failed \n");
return;
+ }
int num_base = 0;
int total_devices = 0;
@@ -478,8 +489,10 @@ public:
/* get devices */
vector<cl_device_id> device_ids(num_devices, NULL);
- if(opencl_error(clGetDeviceIDs(cpPlatform, opencl_device_type(), num_devices, &device_ids[0], NULL)))
+ if(opencl_error(clGetDeviceIDs(cpPlatform, opencl_device_type(), num_devices, &device_ids[0], NULL))) {
+ fprintf(stderr, "clGetDeviceIDs failed \n");
return;
+ }
cdDevice = device_ids[info.num - num_base];
@@ -515,8 +528,10 @@ public:
cxContext = clCreateContext(context_props, 1, &cdDevice,
context_notify_callback, cdDevice, &ciErr);
- if(opencl_error(ciErr))
+ if(opencl_error(ciErr)) {
+ opencl_error("OpenCL: clCreateContext failed");
return;
+ }
/* cache it */
OpenCLCache::store_context(cpPlatform, cdDevice, cxContext, cache_locker);
@@ -531,6 +546,7 @@ public:
if(opencl_error(ciErr))
return;
+ fprintf(stderr,"Device init succes\n");
device_initialized = true;
}
@@ -821,7 +837,7 @@ public:
mem.device_pointer = (device_ptr)clCreateBuffer(cxContext, mem_flag, size, mem_ptr, &ciErr);
- opencl_assert(ciErr);
+ opencl_assert_err(ciErr, "clCreateBuffer");
stats.mem_alloc(size);
}
@@ -830,8 +846,7 @@ public:
{
/* this is blocking */
size_t size = mem.memory_size();
- ciErr = clEnqueueWriteBuffer(cqCommandQueue, CL_MEM_PTR(mem.device_pointer), CL_TRUE, 0, size, (void*)mem.data_pointer, 0, NULL, NULL);
- opencl_assert(ciErr);
+ opencl_assert(clEnqueueWriteBuffer(cqCommandQueue, CL_MEM_PTR(mem.device_pointer), CL_TRUE, 0, size, (void*)mem.data_pointer, 0, NULL, NULL));
}
void mem_copy_from(device_memory& mem, int y, int w, int h, int elem)
@@ -839,8 +854,7 @@ public:
size_t offset = elem*y*w;
size_t size = elem*w*h;
- ciErr = clEnqueueReadBuffer(cqCommandQueue, CL_MEM_PTR(mem.device_pointer), CL_TRUE, offset, size, (uchar*)mem.data_pointer + offset, 0, NULL, NULL);
- opencl_assert(ciErr);
+ opencl_assert(clEnqueueReadBuffer(cqCommandQueue, CL_MEM_PTR(mem.device_pointer), CL_TRUE, offset, size, (uchar*)mem.data_pointer + offset, 0, NULL, NULL));
}
void mem_zero(device_memory& mem)
@@ -854,9 +868,8 @@ public:
void mem_free(device_memory& mem)
{
if(mem.device_pointer) {
- ciErr = clReleaseMemObject(CL_MEM_PTR(mem.device_pointer));
+ opencl_assert(clReleaseMemObject(CL_MEM_PTR(mem.device_pointer)));
mem.device_pointer = 0;
- opencl_assert(ciErr);
stats.mem_free(mem.memory_size());
}
@@ -919,7 +932,7 @@ public:
CL_DEVICE_MAX_WORK_ITEM_SIZES, sizeof(size_t)*3, max_work_items, NULL);
/* try to divide evenly over 2 dimensions */
- size_t sqrt_workgroup_size = max(sqrt((double)workgroup_size), 1.0);
+ size_t sqrt_workgroup_size = max((size_t)sqrt((double)workgroup_size), 1);
size_t local_size[2] = {sqrt_workgroup_size, sqrt_workgroup_size};
/* some implementations have max size 1 on 2nd dimension */
@@ -931,8 +944,7 @@ public:
size_t global_size[2] = {global_size_round_up(local_size[0], w), global_size_round_up(local_size[1], h)};
/* run kernel */
- ciErr = clEnqueueNDRangeKernel(cqCommandQueue, kernel, 2, NULL, global_size, NULL, 0, NULL, NULL);
- opencl_assert(ciErr);
+ opencl_assert(clEnqueueNDRangeKernel(cqCommandQueue, kernel, 2, NULL, global_size, NULL, 0, NULL, NULL));
opencl_assert(clFlush(cqCommandQueue));
}
@@ -952,33 +964,29 @@ public:
/* sample arguments */
cl_uint narg = 0;
- ciErr = 0;
- ciErr |= clSetKernelArg(ckPathTraceKernel, narg++, sizeof(d_data), (void*)&d_data);
- ciErr |= clSetKernelArg(ckPathTraceKernel, narg++, sizeof(d_buffer), (void*)&d_buffer);
- ciErr |= clSetKernelArg(ckPathTraceKernel, narg++, sizeof(d_rng_state), (void*)&d_rng_state);
+ opencl_assert(clSetKernelArg(ckPathTraceKernel, narg++, sizeof(d_data), (void*)&d_data));
+ opencl_assert(clSetKernelArg(ckPathTraceKernel, narg++, sizeof(d_buffer), (void*)&d_buffer));
+ opencl_assert(clSetKernelArg(ckPathTraceKernel, narg++, sizeof(d_rng_state), (void*)&d_rng_state));
#define KERNEL_TEX(type, ttype, name) \
- ciErr |= set_kernel_arg_mem(ckPathTraceKernel, &narg, #name);
+ set_kernel_arg_mem(ckPathTraceKernel, &narg, #name);
#include "kernel_textures.h"
- ciErr |= clSetKernelArg(ckPathTraceKernel, narg++, sizeof(d_sample), (void*)&d_sample);
- ciErr |= clSetKernelArg(ckPathTraceKernel, narg++, sizeof(d_x), (void*)&d_x);
- ciErr |= clSetKernelArg(ckPathTraceKernel, narg++, sizeof(d_y), (void*)&d_y);
- ciErr |= clSetKernelArg(ckPathTraceKernel, narg++, sizeof(d_w), (void*)&d_w);
- ciErr |= clSetKernelArg(ckPathTraceKernel, narg++, sizeof(d_h), (void*)&d_h);
- ciErr |= clSetKernelArg(ckPathTraceKernel, narg++, sizeof(d_offset), (void*)&d_offset);
- ciErr |= clSetKernelArg(ckPathTraceKernel, narg++, sizeof(d_stride), (void*)&d_stride);
-
- opencl_assert(ciErr);
+ opencl_assert(clSetKernelArg(ckPathTraceKernel, narg++, sizeof(d_sample), (void*)&d_sample));
+ opencl_assert(clSetKernelArg(ckPathTraceKernel, narg++, sizeof(d_x), (void*)&d_x));
+ opencl_assert(clSetKernelArg(ckPathTraceKernel, narg++, sizeof(d_y), (void*)&d_y));
+ opencl_assert(clSetKernelArg(ckPathTraceKernel, narg++, sizeof(d_w), (void*)&d_w));
+ opencl_assert(clSetKernelArg(ckPathTraceKernel, narg++, sizeof(d_h), (void*)&d_h));
+ opencl_assert(clSetKernelArg(ckPathTraceKernel, narg++, sizeof(d_offset), (void*)&d_offset));
+ opencl_assert(clSetKernelArg(ckPathTraceKernel, narg++, sizeof(d_stride), (void*)&d_stride));
enqueue_kernel(ckPathTraceKernel, d_w, d_h);
}
- cl_int set_kernel_arg_mem(cl_kernel kernel, cl_uint *narg, const char *name)
+ void set_kernel_arg_mem(cl_kernel kernel, cl_uint *narg, const char *name)
{
cl_mem ptr;
- cl_int err = 0;
MemMap::iterator i = mem_map.find(name);
if(i != mem_map.end()) {
@@ -989,10 +997,7 @@ public:
ptr = CL_MEM_PTR(null_mem);
}
- err |= clSetKernelArg(kernel, (*narg)++, sizeof(ptr), (void*)&ptr);
- opencl_assert(err);
-
- return err;
+ opencl_assert(clSetKernelArg(kernel, (*narg)++, sizeof(ptr), (void*)&ptr));
}
void film_convert(DeviceTask& task, device_ptr buffer, device_ptr rgba_byte, device_ptr rgba_half)
@@ -1011,27 +1016,27 @@ public:
/* sample arguments */
cl_uint narg = 0;
- ciErr = 0;
+
cl_kernel ckFilmConvertKernel = (rgba_byte)? ckFilmConvertByteKernel: ckFilmConvertHalfFloatKernel;
- ciErr |= clSetKernelArg(ckFilmConvertKernel, narg++, sizeof(d_data), (void*)&d_data);
- ciErr |= clSetKernelArg(ckFilmConvertKernel, narg++, sizeof(d_rgba), (void*)&d_rgba);
- ciErr |= clSetKernelArg(ckFilmConvertKernel, narg++, sizeof(d_buffer), (void*)&d_buffer);
+ opencl_assert(clSetKernelArg(ckFilmConvertKernel, narg++, sizeof(d_data), (void*)&d_data));
+ opencl_assert(clSetKernelArg(ckFilmConvertKernel, narg++, sizeof(d_rgba), (void*)&d_rgba));
+ opencl_assert(clSetKernelArg(ckFilmConvertKernel, narg++, sizeof(d_buffer), (void*)&d_buffer));
#define KERNEL_TEX(type, ttype, name) \
- ciErr |= set_kernel_arg_mem(ckFilmConvertKernel, &narg, #name);
+ set_kernel_arg_mem(ckFilmConvertKernel, &narg, #name);
#include "kernel_textures.h"
- ciErr |= clSetKernelArg(ckFilmConvertKernel, narg++, sizeof(d_sample_scale), (void*)&d_sample_scale);
- ciErr |= clSetKernelArg(ckFilmConvertKernel, narg++, sizeof(d_x), (void*)&d_x);
- ciErr |= clSetKernelArg(ckFilmConvertKernel, narg++, sizeof(d_y), (void*)&d_y);
- ciErr |= clSetKernelArg(ckFilmConvertKernel, narg++, sizeof(d_w), (void*)&d_w);
- ciErr |= clSetKernelArg(ckFilmConvertKernel, narg++, sizeof(d_h), (void*)&d_h);
- ciErr |= clSetKernelArg(ckFilmConvertKernel, narg++, sizeof(d_offset), (void*)&d_offset);
- ciErr |= clSetKernelArg(ckFilmConvertKernel, narg++, sizeof(d_stride), (void*)&d_stride);
+ opencl_assert(clSetKernelArg(ckFilmConvertKernel, narg++, sizeof(d_sample_scale), (void*)&d_sample_scale));
+ opencl_assert(clSetKernelArg(ckFilmConvertKernel, narg++, sizeof(d_x), (void*)&d_x));
+ opencl_assert(clSetKernelArg(ckFilmConvertKernel, narg++, sizeof(d_y), (void*)&d_y));
+ opencl_assert(clSetKernelArg(ckFilmConvertKernel, narg++, sizeof(d_w), (void*)&d_w));
+ opencl_assert(clSetKernelArg(ckFilmConvertKernel, narg++, sizeof(d_h), (void*)&d_h));
+ opencl_assert(clSetKernelArg(ckFilmConvertKernel, narg++, sizeof(d_offset), (void*)&d_offset));
+ opencl_assert(clSetKernelArg(ckFilmConvertKernel, narg++, sizeof(d_stride), (void*)&d_stride));
+
- opencl_assert(ciErr);
enqueue_kernel(ckFilmConvertKernel, d_w, d_h);
}
@@ -1048,21 +1053,18 @@ public:
/* sample arguments */
cl_uint narg = 0;
- ciErr = 0;
- ciErr |= clSetKernelArg(ckShaderKernel, narg++, sizeof(d_data), (void*)&d_data);
- ciErr |= clSetKernelArg(ckShaderKernel, narg++, sizeof(d_input), (void*)&d_input);
- ciErr |= clSetKernelArg(ckShaderKernel, narg++, sizeof(d_output), (void*)&d_output);
+ opencl_assert(clSetKernelArg(ckShaderKernel, narg++, sizeof(d_data), (void*)&d_data));
+ opencl_assert(clSetKernelArg(ckShaderKernel, narg++, sizeof(d_input), (void*)&d_input));
+ opencl_assert(clSetKernelArg(ckShaderKernel, narg++, sizeof(d_output), (void*)&d_output));
#define KERNEL_TEX(type, ttype, name) \
- ciErr |= set_kernel_arg_mem(ckShaderKernel, &narg, #name);
+ set_kernel_arg_mem(ckShaderKernel, &narg, #name);
#include "kernel_textures.h"
- ciErr |= clSetKernelArg(ckShaderKernel, narg++, sizeof(d_shader_eval_type), (void*)&d_shader_eval_type);
- ciErr |= clSetKernelArg(ckShaderKernel, narg++, sizeof(d_shader_x), (void*)&d_shader_x);
- ciErr |= clSetKernelArg(ckShaderKernel, narg++, sizeof(d_shader_w), (void*)&d_shader_w);
-
- opencl_assert(ciErr);
+ opencl_assert(clSetKernelArg(ckShaderKernel, narg++, sizeof(d_shader_eval_type), (void*)&d_shader_eval_type));
+ opencl_assert(clSetKernelArg(ckShaderKernel, narg++, sizeof(d_shader_x), (void*)&d_shader_x));
+ opencl_assert(clSetKernelArg(ckShaderKernel, narg++, sizeof(d_shader_w), (void*)&d_shader_w));
enqueue_kernel(ckShaderKernel, task.shader_w, 1);
}
diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt
index 45b4c81610e..d18f4fa2998 100644
--- a/intern/cycles/kernel/CMakeLists.txt
+++ b/intern/cycles/kernel/CMakeLists.txt
@@ -146,11 +146,11 @@ if(WITH_CYCLES_CUDA_BINARIES)
set(CUDA_VERSION "${CUDA_VERSION_MAJOR}${CUDA_VERSION_MINOR}")
# warn for other versions
- if(CUDA_VERSION MATCHES "50")
+ if(CUDA_VERSION MATCHES "60")
else()
message(WARNING
"CUDA version ${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR} detected, "
- "build may succeed but only CUDA 5.0 is officially supported")
+ "build may succeed but only CUDA 6.0 is officially supported")
endif()
# build for each arch
@@ -161,19 +161,11 @@ if(WITH_CYCLES_CUDA_BINARIES)
set(cuda_cubin kernel_${arch}.cubin)
set(cuda_version_flags "-D__KERNEL_CUDA_VERSION__=${CUDA_VERSION}")
-
- # CUDA 5.x build flags for different archs
- if(${arch} MATCHES "sm_2[0-9]")
- # sm_2x
- set(cuda_arch_flags "--maxrregcount=32")
- elseif(${arch} MATCHES "sm_3[0-9]")
- # sm_3x
- set(cuda_arch_flags "--maxrregcount=32")
- endif()
-
set(cuda_math_flags "--use_fast_math")
-
- if(CUDA_VERSION LESS 50 AND ${arch} MATCHES "sm_35")
+
+ if(CUDA_VERSION LESS 60 AND ${arch} MATCHES "sm_50")
+ message(WARNING "Can't build kernel for CUDA sm_50 architecture, skipping")
+ elseif(CUDA_VERSION LESS 50 AND ${arch} MATCHES "sm_35")
message(WARNING "Can't build kernel for CUDA sm_35 architecture, skipping")
else()
add_custom_command(
diff --git a/intern/cycles/kernel/SConscript b/intern/cycles/kernel/SConscript
index 82aaccb62d6..04e1bad7538 100644
--- a/intern/cycles/kernel/SConscript
+++ b/intern/cycles/kernel/SConscript
@@ -69,8 +69,8 @@ if env['WITH_BF_CYCLES_CUDA_BINARIES']:
cuda_major_minor = re.findall(r'release (\d+).(\d+)', output)[0]
cuda_version = int(cuda_major_minor[0])*10 + int(cuda_major_minor[1])
- if cuda_version != 50:
- print("CUDA version %d.%d detected, build may succeed but only CUDA 5.0 is officially supported." % (cuda_version/10, cuda_version%10))
+ if cuda_version != 60:
+ print("CUDA version %d.%d detected, build may succeed but only CUDA 6.0 is officially supported." % (cuda_version/10, cuda_version%10))
# nvcc flags
nvcc_flags = "-m%s" % (bits)
@@ -85,21 +85,17 @@ if env['WITH_BF_CYCLES_CUDA_BINARIES']:
# add command for each cuda architecture
for arch in cuda_archs:
- cubin_file = os.path.join(build_dir, "kernel_%s.cubin" % arch)
+ if cuda_version < 60 and arch == "sm_50":
+ print("Can't build kernel for CUDA sm_50 architecture, skipping")
+ continue
- # CUDA 5.x build flags for different archs
- if arch.startswith("sm_2"):
- # sm_2x
- cuda_arch_flags = "--maxrregcount=32 --use_fast_math"
- elif arch.startswith("sm_3"):
- # sm_3x
- cuda_arch_flags = "--maxrregcount=32 --use_fast_math"
+ cubin_file = os.path.join(build_dir, "kernel_%s.cubin" % arch)
if env['BF_CYCLES_CUDA_ENV']:
MS_SDK = "C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Bin\\SetEnv.cmd"
- command = "\"%s\" & \"%s\" -arch=%s %s %s \"%s\" -o \"%s\"" % (MS_SDK, nvcc, arch, nvcc_flags, cuda_arch_flags, kernel_file, cubin_file)
+ command = "\"%s\" & \"%s\" -arch=%s %s \"%s\" -o \"%s\"" % (MS_SDK, nvcc, arch, nvcc_flags, kernel_file, cubin_file)
else:
- command = "\"%s\" -arch=%s %s %s \"%s\" -o \"%s\"" % (nvcc, arch, nvcc_flags, cuda_arch_flags, kernel_file, cubin_file)
+ command = "\"%s\" -arch=%s %s \"%s\" -o \"%s\"" % (nvcc, arch, nvcc_flags, kernel_file, cubin_file)
kernel.Command(cubin_file, 'kernel.cu', command)
kernel.Depends(cubin_file, dependencies)
diff --git a/intern/cycles/kernel/closure/bsdf_hair.h b/intern/cycles/kernel/closure/bsdf_hair.h
index 163e7cc5ee2..19cdb773255 100644
--- a/intern/cycles/kernel/closure/bsdf_hair.h
+++ b/intern/cycles/kernel/closure/bsdf_hair.h
@@ -84,7 +84,7 @@ ccl_device float3 bsdf_hair_reflection_eval_reflect(const ShaderClosure *sc, con
float theta_i = M_PI_2_F - safe_acosf(omega_in_z);
float cosphi_i = dot(omega_in_y, locy);
- if(M_PI_2_F - fabsf(theta_i) < 0.001f || cosphi_i < 0.0f){
+ if(M_PI_2_F - fabsf(theta_i) < 0.001f || cosphi_i < 0.0f) {
*pdf = 0.0f;
return make_float3(*pdf, *pdf, *pdf);
}
@@ -99,7 +99,7 @@ ccl_device float3 bsdf_hair_reflection_eval_reflect(const ShaderClosure *sc, con
float theta_h = (theta_i + theta_r) * 0.5f;
float t = theta_h - offset;
- float phi_pdf = cos(phi_i * 0.5f) * 0.25f / roughness2;
+ float phi_pdf = cosf(phi_i * 0.5f) * 0.25f / roughness2;
float theta_pdf = roughness1 / (2 * (t*t + roughness1*roughness1) * (a_R - b_R)* costheta_i);
*pdf = phi_pdf * theta_pdf;
@@ -140,7 +140,7 @@ ccl_device float3 bsdf_hair_transmission_eval_transmit(const ShaderClosure *sc,
float theta_i = M_PI_2_F - safe_acosf(omega_in_z);
float phi_i = safe_acosf(dot(omega_in_y, locy));
- if(M_PI_2_F - fabsf(theta_i) < 0.001f){
+ if(M_PI_2_F - fabsf(theta_i) < 0.001f) {
*pdf = 0.0f;
return make_float3(*pdf, *pdf, *pdf);
}
@@ -191,7 +191,7 @@ ccl_device int bsdf_hair_reflection_sample(const ShaderClosure *sc, float3 Ng, f
float phi = 2 * safe_asinf(1 - 2 * randv) * roughness2;
- float phi_pdf = cos(phi * 0.5f) * 0.25f / roughness2;
+ float phi_pdf = cosf(phi * 0.5f) * 0.25f / roughness2;
float theta_pdf = roughness1 / (2 * (t*t + roughness1*roughness1) * (a_R - b_R)*costheta_i);
@@ -251,8 +251,8 @@ ccl_device int bsdf_hair_transmission_sample(const ShaderClosure *sc, float3 Ng,
float phi_pdf = roughness2 / (c_TT * (p * p + roughness2 * roughness2));
*omega_in =(cosf(phi) * costheta_i) * locy -
- (sinf(phi) * costheta_i) * locx +
- ( sintheta_i) * Tg;
+ (sinf(phi) * costheta_i) * locx +
+ ( sintheta_i) * Tg;
//differentials - TODO: find a better approximation for the transmission bounce
#ifdef __RAY_DIFFERENTIALS__
@@ -261,7 +261,7 @@ ccl_device int bsdf_hair_transmission_sample(const ShaderClosure *sc, float3 Ng,
#endif
*pdf = fabsf(phi_pdf * theta_pdf);
- if(M_PI_2_F - fabsf(theta_i) < 0.001f){
+ if(M_PI_2_F - fabsf(theta_i) < 0.001f) {
*pdf = 0.0f;
}
diff --git a/intern/cycles/kernel/closure/bsdf_microfacet.h b/intern/cycles/kernel/closure/bsdf_microfacet.h
index dfa8886c113..1ec35e444fe 100644
--- a/intern/cycles/kernel/closure/bsdf_microfacet.h
+++ b/intern/cycles/kernel/closure/bsdf_microfacet.h
@@ -154,8 +154,8 @@ ccl_device int bsdf_microfacet_ggx_sample(const ShaderClosure *sc, float3 Ng, fl
float sinThetaM = cosThetaM * safe_sqrtf(tanThetaM2);
float phiM = M_2PI_F * randv;
float3 m = (cosf(phiM) * sinThetaM) * X +
- (sinf(phiM) * sinThetaM) * Y +
- cosThetaM * Z;
+ (sinf(phiM) * sinThetaM) * Y +
+ ( cosThetaM) * Z;
if(!m_refractive) {
float cosMO = dot(m, I);
if(cosMO > 0) {
@@ -383,8 +383,8 @@ ccl_device int bsdf_microfacet_beckmann_sample(const ShaderClosure *sc, float3 N
float sinThetaM = cosThetaM * tanThetaM;
float phiM = M_2PI_F * randv;
float3 m = (cosf(phiM) * sinThetaM) * X +
- (sinf(phiM) * sinThetaM) * Y +
- cosThetaM * Z;
+ (sinf(phiM) * sinThetaM) * Y +
+ ( cosThetaM) * Z;
if(!m_refractive) {
float cosMO = dot(m, I);
diff --git a/intern/cycles/kernel/closure/bsdf_phong_ramp.h b/intern/cycles/kernel/closure/bsdf_phong_ramp.h
index 219c5aea159..2b4e1c68640 100644
--- a/intern/cycles/kernel/closure/bsdf_phong_ramp.h
+++ b/intern/cycles/kernel/closure/bsdf_phong_ramp.h
@@ -109,8 +109,8 @@ ccl_device int bsdf_phong_ramp_sample(const ShaderClosure *sc, const float3 colo
float sinTheta2 = 1 - cosTheta * cosTheta;
float sinTheta = sinTheta2 > 0 ? sqrtf(sinTheta2) : 0;
*omega_in = (cosf(phi) * sinTheta) * T +
- (sinf(phi) * sinTheta) * B +
- ( cosTheta) * R;
+ (sinf(phi) * sinTheta) * B +
+ ( cosTheta) * R;
if (dot(Ng, *omega_in) > 0.0f)
{
// common terms for pdf and eval
diff --git a/intern/cycles/kernel/closure/bsdf_util.h b/intern/cycles/kernel/closure/bsdf_util.h
index f6dceb3ca82..b3dcb9dcc38 100644
--- a/intern/cycles/kernel/closure/bsdf_util.h
+++ b/intern/cycles/kernel/closure/bsdf_util.h
@@ -35,14 +35,15 @@
CCL_NAMESPACE_BEGIN
-ccl_device float fresnel_dielectric(float eta, const float3 N,
- const float3 I, float3 *R, float3 *T,
+ccl_device float fresnel_dielectric(
+ float eta, const float3 N,
+ const float3 I, float3 *R, float3 *T,
#ifdef __RAY_DIFFERENTIALS__
- const float3 dIdx, const float3 dIdy,
- float3 *dRdx, float3 *dRdy,
- float3 *dTdx, float3 *dTdy,
+ const float3 dIdx, const float3 dIdy,
+ float3 *dRdx, float3 *dRdy,
+ float3 *dTdx, float3 *dTdy,
#endif
- bool *is_inside)
+ bool *is_inside)
{
float cos = dot(N, I), neta;
float3 Nn;
diff --git a/intern/cycles/kernel/closure/bsdf_westin.h b/intern/cycles/kernel/closure/bsdf_westin.h
index ca4c05e91fe..9dc1c00bb3d 100644
--- a/intern/cycles/kernel/closure/bsdf_westin.h
+++ b/intern/cycles/kernel/closure/bsdf_westin.h
@@ -96,10 +96,9 @@ ccl_device int bsdf_westin_backscatter_sample(const ShaderClosure *sc, float3 Ng
float sinTheta2 = 1 - cosTheta * cosTheta;
float sinTheta = sinTheta2 > 0 ? sqrtf(sinTheta2) : 0;
*omega_in = (cosf(phi) * sinTheta) * T +
- (sinf(phi) * sinTheta) * B +
- (cosTheta) * I;
- if(dot(Ng, *omega_in) > 0)
- {
+ (sinf(phi) * sinTheta) * B +
+ (cosTheta) * I;
+ if(dot(Ng, *omega_in) > 0) {
// common terms for pdf and eval
float cosNI = dot(N, *omega_in);
// make sure the direction we chose is still in the right hemisphere
diff --git a/intern/cycles/kernel/geom/geom_bvh.h b/intern/cycles/kernel/geom/geom_bvh.h
index 12ebc646c14..dd7c25d581d 100644
--- a/intern/cycles/kernel/geom/geom_bvh.h
+++ b/intern/cycles/kernel/geom/geom_bvh.h
@@ -93,6 +93,36 @@ CCL_NAMESPACE_BEGIN
#include "geom_bvh_subsurface.h"
#endif
+#if defined(__SHADOW_RECORD_ALL__)
+#define BVH_FUNCTION_NAME bvh_intersect_shadow_all
+#define BVH_FUNCTION_FEATURES 0
+#include "geom_bvh_shadow.h"
+#endif
+
+#if defined(__SUBSURFACE__) && defined(__INSTANCING__)
+#define BVH_FUNCTION_NAME bvh_intersect_shadow_all_instancing
+#define BVH_FUNCTION_FEATURES BVH_INSTANCING
+#include "geom_bvh_shadow.h"
+#endif
+
+#if defined(__SUBSURFACE__) && defined(__HAIR__)
+#define BVH_FUNCTION_NAME bvh_intersect_shadow_all_hair
+#define BVH_FUNCTION_FEATURES BVH_INSTANCING|BVH_HAIR
+#include "geom_bvh_shadow.h"
+#endif
+
+#if defined(__SUBSURFACE__) && defined(__OBJECT_MOTION__)
+#define BVH_FUNCTION_NAME bvh_intersect_shadow_all_motion
+#define BVH_FUNCTION_FEATURES BVH_INSTANCING|BVH_MOTION
+#include "geom_bvh_shadow.h"
+#endif
+
+#if defined(__SUBSURFACE__) && defined(__HAIR__) && defined(__OBJECT_MOTION__)
+#define BVH_FUNCTION_NAME bvh_intersect_shadow_all_hair_motion
+#define BVH_FUNCTION_FEATURES BVH_INSTANCING|BVH_HAIR|BVH_MOTION
+#include "geom_bvh_shadow.h"
+#endif
+
/* to work around titan bug when using arrays instead of textures */
#if !defined(__KERNEL_CUDA__) || defined(__KERNEL_CUDA_TEX_STORAGE__)
ccl_device_inline
@@ -185,6 +215,52 @@ uint scene_intersect_subsurface(KernelGlobals *kg, const Ray *ray, Intersection
}
#endif
+/* to work around titan bug when using arrays instead of textures */
+#ifdef __SHADOW_RECORD_ALL__
+#if !defined(__KERNEL_CUDA__) || defined(__KERNEL_CUDA_TEX_STORAGE__)
+ccl_device_inline
+#else
+ccl_device_noinline
+#endif
+uint scene_intersect_shadow_all(KernelGlobals *kg, const Ray *ray, Intersection *isect, uint max_hits, uint *num_hits)
+{
+#ifdef __OBJECT_MOTION__
+ if(kernel_data.bvh.have_motion) {
+#ifdef __HAIR__
+ if(kernel_data.bvh.have_curves)
+ return bvh_intersect_shadow_all_hair_motion(kg, ray, isect, max_hits, num_hits);
+#endif /* __HAIR__ */
+
+ return bvh_intersect_shadow_all_motion(kg, ray, isect, max_hits, num_hits);
+ }
+#endif /* __OBJECT_MOTION__ */
+
+#ifdef __HAIR__
+ if(kernel_data.bvh.have_curves)
+ return bvh_intersect_shadow_all_hair(kg, ray, isect, max_hits, num_hits);
+#endif /* __HAIR__ */
+
+#ifdef __KERNEL_CPU__
+
+#ifdef __INSTANCING__
+ if(kernel_data.bvh.have_instancing)
+ return bvh_intersect_shadow_all_instancing(kg, ray, isect, max_hits, num_hits);
+#endif /* __INSTANCING__ */
+
+ return bvh_intersect_shadow_all(kg, ray, isect, max_hits, num_hits);
+#else /* __KERNEL_CPU__ */
+
+#ifdef __INSTANCING__
+ return bvh_intersect_shadow_all_instancing(kg, ray, isect, max_hits, num_hits);
+#else
+ return bvh_intersect_shadow_all(kg, ray, isect, max_hits, num_hits);
+#endif /* __INSTANCING__ */
+
+#endif /* __KERNEL_CPU__ */
+}
+#endif
+
+
/* Ray offset to avoid self intersection.
*
* This function should be used to compute a modified ray start position for
diff --git a/intern/cycles/kernel/geom/geom_bvh_shadow.h b/intern/cycles/kernel/geom/geom_bvh_shadow.h
new file mode 100644
index 00000000000..98bf82b3b2d
--- /dev/null
+++ b/intern/cycles/kernel/geom/geom_bvh_shadow.h
@@ -0,0 +1,375 @@
+/*
+ * Adapted from code Copyright 2009-2010 NVIDIA Corporation,
+ * and code copyright 2009-2012 Intel Corporation
+ *
+ * Modifications Copyright 2011-2013, Blender Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* This is a template BVH traversal function, where various features can be
+ * enabled/disabled. This way we can compile optimized versions for each case
+ * without new features slowing things down.
+ *
+ * BVH_INSTANCING: object instancing
+ * BVH_HAIR: hair curve rendering
+ * BVH_MOTION: motion blur rendering
+ *
+ */
+
+#define FEATURE(f) (((BVH_FUNCTION_FEATURES) & (f)) != 0)
+
+ccl_device bool BVH_FUNCTION_NAME
+(KernelGlobals *kg, const Ray *ray, Intersection *isect_array, const uint max_hits, uint *num_hits)
+{
+ /* todo:
+ * - likely and unlikely for if() statements
+ * - test restrict attribute for pointers
+ */
+
+ /* traversal stack in CUDA thread-local memory */
+ int traversalStack[BVH_STACK_SIZE];
+ traversalStack[0] = ENTRYPOINT_SENTINEL;
+
+ /* traversal variables in registers */
+ int stackPtr = 0;
+ int nodeAddr = kernel_data.bvh.root;
+
+ /* ray parameters in registers */
+ const float tmax = ray->t;
+ float3 P = ray->P;
+ float3 dir = bvh_clamp_direction(ray->D);
+ float3 idir = bvh_inverse_direction(dir);
+ int object = OBJECT_NONE;
+ float isect_t = tmax;
+
+#if FEATURE(BVH_MOTION)
+ Transform ob_tfm;
+#endif
+
+#if FEATURE(BVH_INSTANCING)
+ int num_hits_in_instance = 0;
+#endif
+
+ *num_hits = 0;
+ isect_array->t = tmax;
+
+#if defined(__KERNEL_SSE2__)
+ const shuffle_swap_t shuf_identity = shuffle_swap_identity();
+ const shuffle_swap_t shuf_swap = shuffle_swap_swap();
+
+ const __m128 pn = _mm_castsi128_ps(_mm_set_epi32(0x80000000, 0x80000000, 0, 0));
+ __m128 Psplat[3], idirsplat[3];
+ shuffle_swap_t shufflexyz[3];
+
+ Psplat[0] = _mm_set_ps1(P.x);
+ Psplat[1] = _mm_set_ps1(P.y);
+ Psplat[2] = _mm_set_ps1(P.z);
+
+ __m128 tsplat = _mm_set_ps(-isect_t, -isect_t, 0.0f, 0.0f);
+
+ gen_idirsplat_swap(pn, shuf_identity, shuf_swap, idir, idirsplat, shufflexyz);
+#endif
+
+ /* traversal loop */
+ do {
+ do {
+ /* traverse internal nodes */
+ while(nodeAddr >= 0 && nodeAddr != ENTRYPOINT_SENTINEL) {
+ bool traverseChild0, traverseChild1;
+ int nodeAddrChild1;
+
+#if !defined(__KERNEL_SSE2__)
+ /* Intersect two child bounding boxes, non-SSE version */
+ float t = isect_t;
+
+ /* fetch node data */
+ float4 node0 = kernel_tex_fetch(__bvh_nodes, nodeAddr*BVH_NODE_SIZE+0);
+ float4 node1 = kernel_tex_fetch(__bvh_nodes, nodeAddr*BVH_NODE_SIZE+1);
+ float4 node2 = kernel_tex_fetch(__bvh_nodes, nodeAddr*BVH_NODE_SIZE+2);
+ float4 cnodes = kernel_tex_fetch(__bvh_nodes, nodeAddr*BVH_NODE_SIZE+3);
+
+ /* intersect ray against child nodes */
+ NO_EXTENDED_PRECISION float c0lox = (node0.x - P.x) * idir.x;
+ NO_EXTENDED_PRECISION float c0hix = (node0.z - P.x) * idir.x;
+ NO_EXTENDED_PRECISION float c0loy = (node1.x - P.y) * idir.y;
+ NO_EXTENDED_PRECISION float c0hiy = (node1.z - P.y) * idir.y;
+ NO_EXTENDED_PRECISION float c0loz = (node2.x - P.z) * idir.z;
+ NO_EXTENDED_PRECISION float c0hiz = (node2.z - P.z) * idir.z;
+ NO_EXTENDED_PRECISION float c0min = max4(min(c0lox, c0hix), min(c0loy, c0hiy), min(c0loz, c0hiz), 0.0f);
+ NO_EXTENDED_PRECISION float c0max = min4(max(c0lox, c0hix), max(c0loy, c0hiy), max(c0loz, c0hiz), t);
+
+ NO_EXTENDED_PRECISION float c1lox = (node0.y - P.x) * idir.x;
+ NO_EXTENDED_PRECISION float c1hix = (node0.w - P.x) * idir.x;
+ NO_EXTENDED_PRECISION float c1loy = (node1.y - P.y) * idir.y;
+ NO_EXTENDED_PRECISION float c1hiy = (node1.w - P.y) * idir.y;
+ NO_EXTENDED_PRECISION float c1loz = (node2.y - P.z) * idir.z;
+ NO_EXTENDED_PRECISION float c1hiz = (node2.w - P.z) * idir.z;
+ NO_EXTENDED_PRECISION float c1min = max4(min(c1lox, c1hix), min(c1loy, c1hiy), min(c1loz, c1hiz), 0.0f);
+ NO_EXTENDED_PRECISION float c1max = min4(max(c1lox, c1hix), max(c1loy, c1hiy), max(c1loz, c1hiz), t);
+
+ /* decide which nodes to traverse next */
+#ifdef __VISIBILITY_FLAG__
+ /* this visibility test gives a 5% performance hit, how to solve? */
+ traverseChild0 = (c0max >= c0min) && (__float_as_uint(cnodes.z) & PATH_RAY_SHADOW);
+ traverseChild1 = (c1max >= c1min) && (__float_as_uint(cnodes.w) & PATH_RAY_SHADOW);
+#else
+ traverseChild0 = (c0max >= c0min);
+ traverseChild1 = (c1max >= c1min);
+#endif
+
+#else // __KERNEL_SSE2__
+ /* Intersect two child bounding boxes, SSE3 version adapted from Embree */
+
+ /* fetch node data */
+ const __m128 *bvh_nodes = (__m128*)kg->__bvh_nodes.data + nodeAddr*BVH_NODE_SIZE;
+ const float4 cnodes = ((float4*)bvh_nodes)[3];
+
+ /* intersect ray against child nodes */
+ const __m128 tminmaxx = _mm_mul_ps(_mm_sub_ps(shuffle_swap(bvh_nodes[0], shufflexyz[0]), Psplat[0]), idirsplat[0]);
+ const __m128 tminmaxy = _mm_mul_ps(_mm_sub_ps(shuffle_swap(bvh_nodes[1], shufflexyz[1]), Psplat[1]), idirsplat[1]);
+ const __m128 tminmaxz = _mm_mul_ps(_mm_sub_ps(shuffle_swap(bvh_nodes[2], shufflexyz[2]), Psplat[2]), idirsplat[2]);
+
+ /* calculate { c0min, c1min, -c0max, -c1max} */
+ __m128 minmax = _mm_max_ps(_mm_max_ps(tminmaxx, tminmaxy), _mm_max_ps(tminmaxz, tsplat));
+ const __m128 tminmax = _mm_xor_ps(minmax, pn);
+ const __m128 lrhit = _mm_cmple_ps(tminmax, shuffle<2, 3, 0, 1>(tminmax));
+
+ /* decide which nodes to traverse next */
+#ifdef __VISIBILITY_FLAG__
+ /* this visibility test gives a 5% performance hit, how to solve? */
+ traverseChild0 = (_mm_movemask_ps(lrhit) & 1) && (__float_as_uint(cnodes.z) & PATH_RAY_SHADOW);
+ traverseChild1 = (_mm_movemask_ps(lrhit) & 2) && (__float_as_uint(cnodes.w) & PATH_RAY_SHADOW);
+#else
+ traverseChild0 = (_mm_movemask_ps(lrhit) & 1);
+ traverseChild1 = (_mm_movemask_ps(lrhit) & 2);
+#endif
+#endif // __KERNEL_SSE2__
+
+ nodeAddr = __float_as_int(cnodes.x);
+ nodeAddrChild1 = __float_as_int(cnodes.y);
+
+ if(traverseChild0 && traverseChild1) {
+ /* both children were intersected, push the farther one */
+#if !defined(__KERNEL_SSE2__)
+ bool closestChild1 = (c1min < c0min);
+#else
+ union { __m128 m128; float v[4]; } uminmax;
+ uminmax.m128 = tminmax;
+ bool closestChild1 = uminmax.v[1] < uminmax.v[0];
+#endif
+
+ if(closestChild1) {
+ int tmp = nodeAddr;
+ nodeAddr = nodeAddrChild1;
+ nodeAddrChild1 = tmp;
+ }
+
+ ++stackPtr;
+ traversalStack[stackPtr] = nodeAddrChild1;
+ }
+ else {
+ /* one child was intersected */
+ if(traverseChild1) {
+ nodeAddr = nodeAddrChild1;
+ }
+ else if(!traverseChild0) {
+ /* neither child was intersected */
+ nodeAddr = traversalStack[stackPtr];
+ --stackPtr;
+ }
+ }
+ }
+
+ /* if node is leaf, fetch triangle list */
+ if(nodeAddr < 0) {
+ float4 leaf = kernel_tex_fetch(__bvh_nodes, (-nodeAddr-1)*BVH_NODE_SIZE+(BVH_NODE_SIZE-1));
+ int primAddr = __float_as_int(leaf.x);
+
+#if FEATURE(BVH_INSTANCING)
+ if(primAddr >= 0) {
+#endif
+ int primAddr2 = __float_as_int(leaf.y);
+
+ /* pop */
+ nodeAddr = traversalStack[stackPtr];
+ --stackPtr;
+
+ /* primitive intersection */
+ while(primAddr < primAddr2) {
+ bool hit;
+ uint type = kernel_tex_fetch(__prim_type, primAddr);
+
+ /* todo: specialized intersect functions which don't fill in
+ * isect unless needed and check SD_HAS_TRANSPARENT_SHADOW?
+ * might give a few % performance improvement */
+
+ switch(type & PRIMITIVE_ALL) {
+ case PRIMITIVE_TRIANGLE: {
+ hit = triangle_intersect(kg, isect_array, P, dir, PATH_RAY_SHADOW, object, primAddr);
+ break;
+ }
+#if FEATURE(BVH_MOTION)
+ case PRIMITIVE_MOTION_TRIANGLE: {
+ hit = motion_triangle_intersect(kg, isect_array, P, dir, ray->time, PATH_RAY_SHADOW, object, primAddr);
+ break;
+ }
+#endif
+#if FEATURE(BVH_HAIR)
+ case PRIMITIVE_CURVE:
+ case PRIMITIVE_MOTION_CURVE: {
+ if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE)
+ hit = bvh_cardinal_curve_intersect(kg, isect_array, P, dir, PATH_RAY_SHADOW, object, primAddr, ray->time, type, NULL, 0, 0);
+ else
+ hit = bvh_curve_intersect(kg, isect_array, P, dir, PATH_RAY_SHADOW, object, primAddr, ray->time, type, NULL, 0, 0);
+ break;
+ }
+#endif
+ default: {
+ hit = false;
+ break;
+ }
+ }
+
+ /* shadow ray early termination */
+ if(hit) {
+ /* detect if this surface has a shader with transparent shadows */
+
+ /* todo: optimize so primitive visibility flag indicates if
+ * the primitive has a transparent shadow shader? */
+ int prim = kernel_tex_fetch(__prim_index, isect_array->prim);
+ int shader = 0;
+
+#ifdef __HAIR__
+ if(kernel_tex_fetch(__prim_type, isect_array->prim) & PRIMITIVE_ALL_TRIANGLE)
+#endif
+ {
+ float4 Ns = kernel_tex_fetch(__tri_normal, prim);
+ shader = __float_as_int(Ns.w);
+ }
+#ifdef __HAIR__
+ else {
+ float4 str = kernel_tex_fetch(__curves, prim);
+ shader = __float_as_int(str.z);
+ }
+#endif
+ int flag = kernel_tex_fetch(__shader_flag, (shader & SHADER_MASK)*2);
+
+ /* if no transparent shadows, all light is blocked */
+ if(!(flag & SD_HAS_TRANSPARENT_SHADOW)) {
+ return true;
+ }
+ /* if maximum number of hits reached, block all light */
+ else if(*num_hits == max_hits) {
+ return true;
+ }
+
+ /* move on to next entry in intersections array */
+ isect_array++;
+ (*num_hits)++;
+#if FEATURE(BVH_INSTANCING)
+ num_hits_in_instance++;
+#endif
+
+ isect_array->t = isect_t;
+ }
+
+ primAddr++;
+ }
+ }
+#if FEATURE(BVH_INSTANCING)
+ else {
+ /* instance push */
+ object = kernel_tex_fetch(__prim_object, -primAddr-1);
+
+#if FEATURE(BVH_MOTION)
+ bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect_t, &ob_tfm);
+#else
+ bvh_instance_push(kg, object, ray, &P, &dir, &idir, &isect_t);
+#endif
+
+ num_hits_in_instance = 0;
+
+#if defined(__KERNEL_SSE2__)
+ Psplat[0] = _mm_set_ps1(P.x);
+ Psplat[1] = _mm_set_ps1(P.y);
+ Psplat[2] = _mm_set_ps1(P.z);
+
+ isect_array->t = isect_t;
+ tsplat = _mm_set_ps(-isect_t, -isect_t, 0.0f, 0.0f);
+
+ gen_idirsplat_swap(pn, shuf_identity, shuf_swap, idir, idirsplat, shufflexyz);
+#endif
+
+ ++stackPtr;
+ traversalStack[stackPtr] = ENTRYPOINT_SENTINEL;
+
+ nodeAddr = kernel_tex_fetch(__object_node, object);
+ }
+ }
+#endif
+ } while(nodeAddr != ENTRYPOINT_SENTINEL);
+
+#if FEATURE(BVH_INSTANCING)
+ if(stackPtr >= 0) {
+ kernel_assert(object != OBJECT_NONE);
+
+ if(num_hits_in_instance) {
+ float t_fac;
+
+#if FEATURE(BVH_MOTION)
+ bvh_instance_motion_pop_factor(kg, object, ray, &P, &dir, &idir, &t_fac, &ob_tfm);
+#else
+ bvh_instance_pop_factor(kg, object, ray, &P, &dir, &idir, &t_fac);
+#endif
+
+ /* scale isect->t to adjust for instancing */
+ for(int i = 0; i < num_hits_in_instance; i++)
+ (isect_array-i-1)->t *= t_fac;
+ }
+ else {
+ float ignore_t = FLT_MAX;
+
+#if FEATURE(BVH_MOTION)
+ bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, &ignore_t, &ob_tfm);
+#else
+ bvh_instance_pop(kg, object, ray, &P, &dir, &idir, &ignore_t);
+#endif
+ }
+
+#if defined(__KERNEL_SSE2__)
+ Psplat[0] = _mm_set_ps1(P.x);
+ Psplat[1] = _mm_set_ps1(P.y);
+ Psplat[2] = _mm_set_ps1(P.z);
+
+ isect_t = tmax;
+ isect_array->t = isect_t;
+ tsplat = _mm_set_ps(-isect_t, -isect_t, 0.0f, 0.0f);
+
+ gen_idirsplat_swap(pn, shuf_identity, shuf_swap, idir, idirsplat, shufflexyz);
+#endif
+
+ object = OBJECT_NONE;
+ nodeAddr = traversalStack[stackPtr];
+ --stackPtr;
+ }
+#endif
+ } while(nodeAddr != ENTRYPOINT_SENTINEL);
+
+ return false;
+}
+
+#undef FEATURE
+#undef BVH_FUNCTION_NAME
+#undef BVH_FUNCTION_FEATURES
+
diff --git a/intern/cycles/kernel/geom/geom_bvh_subsurface.h b/intern/cycles/kernel/geom/geom_bvh_subsurface.h
index 6b71ffc24ba..a19f05dd371 100644
--- a/intern/cycles/kernel/geom/geom_bvh_subsurface.h
+++ b/intern/cycles/kernel/geom/geom_bvh_subsurface.h
@@ -48,12 +48,11 @@ ccl_device uint BVH_FUNCTION_NAME(KernelGlobals *kg, const Ray *ray, Intersectio
int nodeAddr = kernel_data.bvh.root;
/* ray parameters in registers */
- const float tmax = ray->t;
float3 P = ray->P;
float3 dir = bvh_clamp_direction(ray->D);
float3 idir = bvh_inverse_direction(dir);
int object = OBJECT_NONE;
- float isect_t = tmax;
+ float isect_t = ray->t;
const uint visibility = PATH_RAY_ALL_VISIBILITY;
uint num_hits = 0;
@@ -219,10 +218,12 @@ ccl_device uint BVH_FUNCTION_NAME(KernelGlobals *kg, const Ray *ray, Intersectio
triangle_intersect_subsurface(kg, isect_array, P, dir, object, primAddr, isect_t, &num_hits, lcg_state, max_hits);
break;
}
+#if FEATURE(BVH_MOTION)
case PRIMITIVE_MOTION_TRIANGLE: {
motion_triangle_intersect_subsurface(kg, isect_array, P, dir, ray->time, object, primAddr, isect_t, &num_hits, lcg_state, max_hits);
break;
}
+#endif
default: {
break;
}
@@ -236,9 +237,9 @@ ccl_device uint BVH_FUNCTION_NAME(KernelGlobals *kg, const Ray *ray, Intersectio
object = subsurface_object;
#if FEATURE(BVH_MOTION)
- bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect_t, &ob_tfm, tmax);
+ bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect_t, &ob_tfm);
#else
- bvh_instance_push(kg, object, ray, &P, &dir, &idir, &isect_t, tmax);
+ bvh_instance_push(kg, object, ray, &P, &dir, &idir, &isect_t);
#endif
#if defined(__KERNEL_SSE2__)
@@ -272,9 +273,9 @@ ccl_device uint BVH_FUNCTION_NAME(KernelGlobals *kg, const Ray *ray, Intersectio
/* instance pop */
#if FEATURE(BVH_MOTION)
- bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, &isect_t, &ob_tfm, tmax);
+ bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, &isect_t, &ob_tfm);
#else
- bvh_instance_pop(kg, object, ray, &P, &dir, &idir, &isect_t, tmax);
+ bvh_instance_pop(kg, object, ray, &P, &dir, &idir, &isect_t);
#endif
#if defined(__KERNEL_SSE2__)
diff --git a/intern/cycles/kernel/geom/geom_bvh_traversal.h b/intern/cycles/kernel/geom/geom_bvh_traversal.h
index 566aa421474..9fd40f91471 100644
--- a/intern/cycles/kernel/geom/geom_bvh_traversal.h
+++ b/intern/cycles/kernel/geom/geom_bvh_traversal.h
@@ -53,7 +53,6 @@ ccl_device bool BVH_FUNCTION_NAME
int nodeAddr = kernel_data.bvh.root;
/* ray parameters in registers */
- const float tmax = ray->t;
float3 P = ray->P;
float3 dir = bvh_clamp_direction(ray->D);
float3 idir = bvh_inverse_direction(dir);
@@ -63,7 +62,7 @@ ccl_device bool BVH_FUNCTION_NAME
Transform ob_tfm;
#endif
- isect->t = tmax;
+ isect->t = ray->t;
isect->object = OBJECT_NONE;
isect->prim = PRIM_NONE;
isect->u = 0.0f;
@@ -88,11 +87,9 @@ ccl_device bool BVH_FUNCTION_NAME
/* traversal loop */
do {
- do
- {
+ do {
/* traverse internal nodes */
- while(nodeAddr >= 0 && nodeAddr != ENTRYPOINT_SENTINEL)
- {
+ while(nodeAddr >= 0 && nodeAddr != ENTRYPOINT_SENTINEL) {
bool traverseChild0, traverseChild1;
int nodeAddrChild1;
@@ -257,25 +254,19 @@ ccl_device bool BVH_FUNCTION_NAME
hit = triangle_intersect(kg, isect, P, dir, visibility, object, primAddr);
break;
}
+#if FEATURE(BVH_MOTION)
case PRIMITIVE_MOTION_TRIANGLE: {
hit = motion_triangle_intersect(kg, isect, P, dir, ray->time, visibility, object, primAddr);
break;
}
+#endif
#if FEATURE(BVH_HAIR)
case PRIMITIVE_CURVE:
case PRIMITIVE_MOTION_CURVE: {
-#if FEATURE(BVH_HAIR_MINIMUM_WIDTH)
if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE)
hit = bvh_cardinal_curve_intersect(kg, isect, P, dir, visibility, object, primAddr, ray->time, type, lcg_state, difl, extmax);
else
hit = bvh_curve_intersect(kg, isect, P, dir, visibility, object, primAddr, ray->time, type, lcg_state, difl, extmax);
-#else
- if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE)
- hit = bvh_cardinal_curve_intersect(kg, isect, P, dir, visibility, object, primAddr, ray->time, type);
- else
- hit = bvh_curve_intersect(kg, isect, P, dir, visibility, object, primAddr, ray->time, type);
-#endif
-
break;
}
#endif
@@ -307,9 +298,9 @@ ccl_device bool BVH_FUNCTION_NAME
object = kernel_tex_fetch(__prim_object, -primAddr-1);
#if FEATURE(BVH_MOTION)
- bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect->t, &ob_tfm, tmax);
+ bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect->t, &ob_tfm);
#else
- bvh_instance_push(kg, object, ray, &P, &dir, &idir, &isect->t, tmax);
+ bvh_instance_push(kg, object, ray, &P, &dir, &idir, &isect->t);
#endif
#if defined(__KERNEL_SSE2__)
@@ -337,9 +328,9 @@ ccl_device bool BVH_FUNCTION_NAME
/* instance pop */
#if FEATURE(BVH_MOTION)
- bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, &isect->t, &ob_tfm, tmax);
+ bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, &isect->t, &ob_tfm);
#else
- bvh_instance_pop(kg, object, ray, &P, &dir, &idir, &isect->t, tmax);
+ bvh_instance_pop(kg, object, ray, &P, &dir, &idir, &isect->t);
#endif
#if defined(__KERNEL_SSE2__)
diff --git a/intern/cycles/kernel/geom/geom_curve.h b/intern/cycles/kernel/geom/geom_curve.h
index e57bcd894a6..e1d225436a6 100644
--- a/intern/cycles/kernel/geom/geom_curve.h
+++ b/intern/cycles/kernel/geom/geom_curve.h
@@ -125,6 +125,23 @@ ccl_device float curve_thickness(KernelGlobals *kg, ShaderData *sd)
return r*2.0f;
}
+/* Curve location for motion pass, linear interpolation between keys and
+ * ignoring radius because we do the same for the motion keys */
+
+ccl_device float3 curve_motion_center_location(KernelGlobals *kg, ShaderData *sd)
+{
+ float4 curvedata = kernel_tex_fetch(__curves, sd->prim);
+ int k0 = __float_as_int(curvedata.x) + PRIMITIVE_UNPACK_SEGMENT(sd->type);
+ int k1 = k0 + 1;
+
+ float4 P_curve[2];
+
+ P_curve[0]= kernel_tex_fetch(__curve_keys, k0);
+ P_curve[1]= kernel_tex_fetch(__curve_keys, k1);
+
+ return float4_to_float3(P_curve[1]) * sd->u + float4_to_float3(P_curve[0]) * (1.0f - sd->u);
+}
+
/* Curve tangent normal */
ccl_device float3 curve_tangent_normal(KernelGlobals *kg, ShaderData *sd)
@@ -152,48 +169,47 @@ ccl_device_inline void curvebounds(float *lower, float *upper, float *extremta,
float halfdiscroot = (p2 * p2 - 3 * p3 * p1);
float ta = -1.0f;
float tb = -1.0f;
+
*extremta = -1.0f;
*extremtb = -1.0f;
*upper = p0;
- *lower = p0 + p1 + p2 + p3;
+ *lower = (p0 + p1) + (p2 + p3);
*extrema = *upper;
*extremb = *lower;
+
if(*lower >= *upper) {
*upper = *lower;
*lower = p0;
}
if(halfdiscroot >= 0) {
- halfdiscroot = sqrt(halfdiscroot);
- ta = (-p2 - halfdiscroot) / (3 * p3);
- tb = (-p2 + halfdiscroot) / (3 * p3);
+ float inv3p3 = (1.0f/3.0f)/p3;
+ halfdiscroot = sqrtf(halfdiscroot);
+ ta = (-p2 - halfdiscroot) * inv3p3;
+ tb = (-p2 + halfdiscroot) * inv3p3;
}
float t2;
float t3;
+
if(ta > 0.0f && ta < 1.0f) {
t2 = ta * ta;
t3 = t2 * ta;
*extremta = ta;
*extrema = p3 * t3 + p2 * t2 + p1 * ta + p0;
- if(*extrema > *upper) {
- *upper = *extrema;
- }
- if(*extrema < *lower) {
- *lower = *extrema;
- }
+
+ *upper = fmaxf(*extrema, *upper);
+ *lower = fminf(*extrema, *lower);
}
+
if(tb > 0.0f && tb < 1.0f) {
t2 = tb * tb;
t3 = t2 * tb;
*extremtb = tb;
*extremb = p3 * t3 + p2 * t2 + p1 * tb + p0;
- if(*extremb >= *upper) {
- *upper = *extremb;
- }
- if(*extremb <= *lower) {
- *lower = *extremb;
- }
+
+ *upper = fmaxf(*extremb, *upper);
+ *lower = fminf(*extremb, *lower);
}
}
@@ -438,6 +454,8 @@ ccl_device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersect
* dP* is reversed if necessary.*/
float t = isect->t;
float u = 0.0f;
+ float gd = 0.0f;
+
if(flags & CURVE_KN_RIBBONS) {
float3 tg = (p_en - p_st);
float w = tg.x * tg.x + tg.y * tg.y;
@@ -481,10 +499,11 @@ ccl_device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersect
float d = sqrtf(p_curr.x * p_curr.x + p_curr.y * p_curr.y);
float d0 = d - r_curr;
float d1 = d + r_curr;
+ float inv_mw_extension = 1.0f/mw_extension;
if (d0 >= 0)
- coverage = (min(d1 / mw_extension, 1.0f) - min(d0 / mw_extension, 1.0f)) * 0.5f;
+ coverage = (min(d1 * inv_mw_extension, 1.0f) - min(d0 * inv_mw_extension, 1.0f)) * 0.5f;
else // inside
- coverage = (min(d1 / mw_extension, 1.0f) + min(-d0 / mw_extension, 1.0f)) * 0.5f;
+ coverage = (min(d1 * inv_mw_extension, 1.0f) + min(-d0 * inv_mw_extension, 1.0f)) * 0.5f;
}
if (p_curr.x * p_curr.x + p_curr.y * p_curr.y >= r_ext * r_ext || p_curr.z <= epsilon || isect->t < p_curr.z) {
@@ -494,12 +513,19 @@ ccl_device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersect
}
t = p_curr.z;
+
+ /* stochastic fade from minimum width */
+ if(difl != 0.0f && lcg_state) {
+ if(coverage != 1.0f && (lcg_step_float(lcg_state) > coverage))
+ return hit;
+ }
}
else {
float l = len(p_en - p_st);
/* minimum width extension */
float or1 = r1;
float or2 = r2;
+
if(difl != 0.0f) {
mw_extension = min(len(p_st - P) * difl, extmax);
or1 = r1 < mw_extension ? mw_extension : r1;
@@ -507,12 +533,14 @@ ccl_device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersect
or2 = r2 < mw_extension ? mw_extension : r2;
}
/* --- */
- float3 tg = (p_en - p_st) / l;
- float gd = (or2 - or1) / l;
+ float invl = 1.0f/l;
+ float3 tg = (p_en - p_st) * invl;
+ gd = (or2 - or1) * invl;
float difz = -dot(p_st,tg);
float cyla = 1.0f - (tg.z * tg.z * (1 + gd*gd));
+ float invcyla = 1.0f/cyla;
float halfb = (-p_st.z - tg.z*(difz + gd*(difz*gd + or1)));
- float tcentre = -halfb/cyla;
+ float tcentre = -halfb*invcyla;
float zcentre = difz + (tg.z * tcentre);
float3 tdif = - p_st;
tdif.z += tcentre;
@@ -527,7 +555,7 @@ ccl_device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersect
}
float rootd = sqrtf(td);
- float correction = ((-tb - rootd)/(2*cyla));
+ float correction = (-tb - rootd) * 0.5f * invcyla;
t = tcentre + correction;
float3 dp_st = (3 * curve_coef[3] * i_st + 2 * curve_coef[2]) * i_st + curve_coef[1];
@@ -538,7 +566,7 @@ ccl_device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersect
dp_en *= -1;
if(flags & CURVE_KN_BACKFACING && (dot(dp_st, -p_st) + t * dp_st.z < 0 || dot(dp_en, p_en) - t * dp_en.z < 0 || isect->t < t || t <= 0.0f)) {
- correction = ((-tb + rootd)/(2*cyla));
+ correction = (-tb + rootd) * 0.5f * invcyla;
t = tcentre + correction;
}
@@ -548,22 +576,22 @@ ccl_device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersect
continue;
}
- float w = (zcentre + (tg.z * correction))/l;
+ float w = (zcentre + (tg.z * correction)) * invl;
w = clamp((float)w, 0.0f, 1.0f);
/* compute u on the curve segment */
u = i_st * (1 - w) + i_en * w;
- r_curr = r1 + (r2 - r1) * w;
- r_ext = or1 + (or2 - or1) * w;
- coverage = r_curr/r_ext;
- }
- /* we found a new intersection */
+ /* stochastic fade from minimum width */
+ if(difl != 0.0f && lcg_state) {
+ r_curr = r1 + (r2 - r1) * w;
+ r_ext = or1 + (or2 - or1) * w;
+ coverage = r_curr/r_ext;
- /* stochastic fade from minimum width */
- if(lcg_state && coverage != 1.0f) {
- if(lcg_step_float(lcg_state) > coverage)
- return hit;
+ if(coverage != 1.0f && (lcg_step_float(lcg_state) > coverage))
+ return hit;
+ }
}
+ /* we found a new intersection */
#ifdef __VISIBILITY_FLAG__
/* visibility flag test. we do it here under the assumption
@@ -576,8 +604,8 @@ ccl_device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersect
isect->object = object;
isect->type = type;
isect->u = u;
- isect->v = 0.0f;
- /*isect->v = 1.0f - coverage; */
+ isect->v = gd;
+ /*isect->transparency = 1.0f - coverage; */
isect->t = t;
hit = true;
}
@@ -771,10 +799,10 @@ ccl_device_inline bool bvh_curve_intersect(KernelGlobals *kg, Intersection *isec
}
float z = zcentre + (dirz * correction);
- bool backface = false;
+ // bool backface = false;
if(flags & CURVE_KN_BACKFACING && (t < 0.0f || z < 0 || z > l)) {
- backface = true;
+ // backface = true;
correction = ((-tb + rootd)/(2*a));
t = tcentre + correction;
z = zcentre + (dirz * correction);
@@ -812,13 +840,10 @@ ccl_device_inline bool bvh_curve_intersect(KernelGlobals *kg, Intersection *isec
isect->object = object;
isect->type = type;
isect->u = z*invl;
- isect->v = td/(4*a*a);
- /*isect->v = 1.0f - adjradius;*/
+ isect->v = gd;
+ /*isect->transparency = 1.0f - adjradius;*/
isect->t = t;
- if(backface)
- isect->u = -isect->u;
-
return true;
}
}
@@ -901,35 +926,41 @@ ccl_device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, con
motion_cardinal_curve_keys(kg, sd->object, sd->prim, sd->time, ka, k0, k1, kb, P_curve);
}
- float l = 1.0f;
- tg = normalize_len(float4_to_float3(P_curve[2] - P_curve[1]), &l);
- float r1 = P_curve[1].w;
- float r2 = P_curve[2].w;
- float gd = ((r2 - r1)/l);
-
- P = P + D*t;
-
float3 p[4];
p[0] = float4_to_float3(P_curve[0]);
p[1] = float4_to_float3(P_curve[1]);
p[2] = float4_to_float3(P_curve[2]);
p[3] = float4_to_float3(P_curve[3]);
+ P = P + D*t;
+
#ifdef __UV__
sd->u = isect->u;
sd->v = 0.0f;
#endif
- tg = normalize(curvetangent(isect->u, p[0], p[1], p[2], p[3]));
-
- if(kernel_data.curve.curveflags & CURVE_KN_RIBBONS)
+ if(kernel_data.curve.curveflags & CURVE_KN_RIBBONS) {
+ tg = normalize(curvetangent(isect->u, p[0], p[1], p[2], p[3]));
sd->Ng = normalize(-(D - tg * (dot(tg, D))));
+ }
else {
+ /* direction from inside to surface of curve */
float3 p_curr = curvepoint(isect->u, p[0], p[1], p[2], p[3]);
sd->Ng = normalize(P - p_curr);
- sd->Ng = sd->Ng - gd * tg;
- sd->Ng = normalize(sd->Ng);
+
+ /* adjustment for changing radius */
+ float gd = isect->v;
+
+ if(gd != 0.0f) {
+ tg = normalize(curvetangent(isect->u, p[0], p[1], p[2], p[3]));
+ sd->Ng = sd->Ng - gd * tg;
+ sd->Ng = normalize(sd->Ng);
+ }
}
+
+ /* todo: sometimes the normal is still so that this is detected as
+ * backfacing even if cull backfaces is enabled */
+
sd->N = sd->Ng;
}
else {
@@ -945,9 +976,6 @@ ccl_device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, con
float l = 1.0f;
tg = normalize_len(float4_to_float3(P_curve[1] - P_curve[0]), &l);
- float r1 = P_curve[0].w;
- float r2 = P_curve[1].w;
- float gd = ((r2 - r1)/l);
P = P + D*t;
@@ -963,9 +991,14 @@ ccl_device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, con
sd->Ng = normalize(sd->Ng);
}
else {
+ float gd = isect->v;
+
+ /* direction from inside to surface of curve */
sd->Ng = (dif - tg * sd->u * l) / (P_curve[0].w + sd->u * l * gd);
+
+ /* adjustment for changing radius */
if (gd != 0.0f) {
- sd->Ng = sd->Ng - gd * tg ;
+ sd->Ng = sd->Ng - gd * tg;
sd->Ng = normalize(sd->Ng);
}
}
@@ -980,7 +1013,7 @@ ccl_device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, con
#endif
/*add fading parameter for minimum pixel width with transparency bsdf*/
- /*sd->curve_transparency = isect->v;*/
+ /*sd->curve_transparency = isect->transparency;*/
/*sd->curve_radius = sd->u * gd * l + r1;*/
if(isect->object != OBJECT_NONE) {
diff --git a/intern/cycles/kernel/geom/geom_object.h b/intern/cycles/kernel/geom/geom_object.h
index 71ad4a55088..91edd5863ac 100644
--- a/intern/cycles/kernel/geom/geom_object.h
+++ b/intern/cycles/kernel/geom/geom_object.h
@@ -240,7 +240,7 @@ ccl_device_inline float object_random_number(KernelGlobals *kg, int object)
/* Particle ID from which this object was generated */
-ccl_device_inline uint object_particle_id(KernelGlobals *kg, int object)
+ccl_device_inline int object_particle_id(KernelGlobals *kg, int object)
{
if(object == OBJECT_NONE)
return 0.0f;
@@ -364,10 +364,10 @@ ccl_device float3 particle_angular_velocity(KernelGlobals *kg, int particle)
ccl_device_inline float3 bvh_clamp_direction(float3 dir)
{
/* clamp absolute values by exp2f(-80.0f) to avoid division by zero when calculating inverse direction */
- float ooeps = 8.271806E-25;
+ float ooeps = 8.271806E-25f;
return make_float3((fabsf(dir.x) > ooeps)? dir.x: copysignf(ooeps, dir.x),
- (fabsf(dir.y) > ooeps)? dir.y: copysignf(ooeps, dir.y),
- (fabsf(dir.z) > ooeps)? dir.z: copysignf(ooeps, dir.z));
+ (fabsf(dir.y) > ooeps)? dir.y: copysignf(ooeps, dir.y),
+ (fabsf(dir.z) > ooeps)? dir.z: copysignf(ooeps, dir.z));
}
ccl_device_inline float3 bvh_inverse_direction(float3 dir)
@@ -377,7 +377,7 @@ ccl_device_inline float3 bvh_inverse_direction(float3 dir)
/* Transform ray into object space to enter static object in BVH */
-ccl_device_inline void bvh_instance_push(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *dir, float3 *idir, float *t, const float tmax)
+ccl_device_inline void bvh_instance_push(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *dir, float3 *idir, float *t)
{
Transform tfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM);
@@ -393,7 +393,7 @@ ccl_device_inline void bvh_instance_push(KernelGlobals *kg, int object, const Ra
/* Transorm ray to exit static object in BVH */
-ccl_device_inline void bvh_instance_pop(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *dir, float3 *idir, float *t, const float tmax)
+ccl_device_inline void bvh_instance_pop(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *dir, float3 *idir, float *t)
{
if(*t != FLT_MAX) {
Transform tfm = object_fetch_transform(kg, object, OBJECT_TRANSFORM);
@@ -405,10 +405,23 @@ ccl_device_inline void bvh_instance_pop(KernelGlobals *kg, int object, const Ray
*idir = bvh_inverse_direction(*dir);
}
+/* Same as above, but returns scale factor to apply to multiple intersection distances */
+
+ccl_device_inline void bvh_instance_pop_factor(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *dir, float3 *idir, float *t_fac)
+{
+ Transform tfm = object_fetch_transform(kg, object, OBJECT_TRANSFORM);
+ *t_fac = len(transform_direction(&tfm, 1.0f/(*idir)));
+
+ *P = ray->P;
+ *dir = bvh_clamp_direction(ray->D);
+ *idir = bvh_inverse_direction(*dir);
+}
+
+
#ifdef __OBJECT_MOTION__
/* Transform ray into object space to enter motion blurred object in BVH */
-ccl_device_inline void bvh_instance_motion_push(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *dir, float3 *idir, float *t, Transform *tfm, const float tmax)
+ccl_device_inline void bvh_instance_motion_push(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *dir, float3 *idir, float *t, Transform *tfm)
{
Transform itfm;
*tfm = object_fetch_transform_motion_test(kg, object, ray->time, &itfm);
@@ -425,7 +438,7 @@ ccl_device_inline void bvh_instance_motion_push(KernelGlobals *kg, int object, c
/* Transorm ray to exit motion blurred object in BVH */
-ccl_device_inline void bvh_instance_motion_pop(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *dir, float3 *idir, float *t, Transform *tfm, const float tmax)
+ccl_device_inline void bvh_instance_motion_pop(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *dir, float3 *idir, float *t, Transform *tfm)
{
if(*t != FLT_MAX)
*t *= len(transform_direction(tfm, 1.0f/(*idir)));
@@ -434,6 +447,18 @@ ccl_device_inline void bvh_instance_motion_pop(KernelGlobals *kg, int object, co
*dir = bvh_clamp_direction(ray->D);
*idir = bvh_inverse_direction(*dir);
}
+
+/* Same as above, but returns scale factor to apply to multiple intersection distances */
+
+ccl_device_inline void bvh_instance_motion_pop_factor(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *dir, float3 *idir, float *t_fac, Transform *tfm)
+{
+ *t_fac = len(transform_direction(tfm, 1.0f/(*idir)));
+
+ *P = ray->P;
+ *dir = bvh_clamp_direction(ray->D);
+ *idir = bvh_inverse_direction(*dir);
+}
+
#endif
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/geom/geom_primitive.h b/intern/cycles/kernel/geom/geom_primitive.h
index f821e696a07..533973621d7 100644
--- a/intern/cycles/kernel/geom/geom_primitive.h
+++ b/intern/cycles/kernel/geom/geom_primitive.h
@@ -140,7 +140,19 @@ ccl_device float3 primitive_tangent(KernelGlobals *kg, ShaderData *sd)
ccl_device float4 primitive_motion_vector(KernelGlobals *kg, ShaderData *sd)
{
- float3 motion_pre = sd->P, motion_post = sd->P;
+ /* center position */
+ float3 center;
+
+ if(sd->type & PRIMITIVE_ALL_CURVE) {
+ center = curve_motion_center_location(kg, sd);
+
+ if(!(sd->flag & SD_TRANSFORM_APPLIED))
+ object_position_transform(kg, sd, &center);
+ }
+ else
+ center = sd->P;
+
+ float3 motion_pre = center, motion_post = center;
/* deformation motion */
AttributeElement elem;
@@ -168,13 +180,13 @@ ccl_device float4 primitive_motion_vector(KernelGlobals *kg, ShaderData *sd)
tfm = object_fetch_vector_transform(kg, sd->object, OBJECT_VECTOR_MOTION_POST);
motion_post = transform_point(&tfm, motion_post);
- float3 P;
+ float3 motion_center;
/* camera motion, for perspective/orthographic motion.pre/post will be a
* world-to-raster matrix, for panorama it's world-to-camera */
if (kernel_data.cam.type != CAMERA_PANORAMA) {
tfm = kernel_data.cam.worldtoraster;
- P = transform_perspective(&tfm, sd->P);
+ motion_center = transform_perspective(&tfm, center);
tfm = kernel_data.cam.motion.pre;
motion_pre = transform_perspective(&tfm, motion_pre);
@@ -184,10 +196,10 @@ ccl_device float4 primitive_motion_vector(KernelGlobals *kg, ShaderData *sd)
}
else {
tfm = kernel_data.cam.worldtocamera;
- P = normalize(transform_point(&tfm, sd->P));
- P = float2_to_float3(direction_to_panorama(kg, P));
- P.x *= kernel_data.cam.width;
- P.y *= kernel_data.cam.height;
+ motion_center = normalize(transform_point(&tfm, center));
+ motion_center = float2_to_float3(direction_to_panorama(kg, motion_center));
+ motion_center.x *= kernel_data.cam.width;
+ motion_center.y *= kernel_data.cam.height;
tfm = kernel_data.cam.motion.pre;
motion_pre = normalize(transform_point(&tfm, motion_pre));
@@ -202,8 +214,8 @@ ccl_device float4 primitive_motion_vector(KernelGlobals *kg, ShaderData *sd)
motion_post.y *= kernel_data.cam.height;
}
- motion_pre = motion_pre - P;
- motion_post = P - motion_post;
+ motion_pre = motion_pre - motion_center;
+ motion_post = motion_center - motion_post;
return make_float4(motion_pre.x, motion_pre.y, motion_post.x, motion_post.y);
}
diff --git a/intern/cycles/kernel/kernel.cpp b/intern/cycles/kernel/kernel.cpp
index 41cf7a6b66c..173028d50c8 100644
--- a/intern/cycles/kernel/kernel.cpp
+++ b/intern/cycles/kernel/kernel.cpp
@@ -61,9 +61,7 @@ void kernel_tex_copy(KernelGlobals *kg, const char *name, device_ptr mem, size_t
if(tex) {
tex->data = (float4*)mem;
- tex->width = width;
- tex->height = height;
- tex->depth = depth;
+ tex->dimensions_set(width, height, depth);
tex->interpolation = interpolation;
}
}
@@ -78,9 +76,7 @@ void kernel_tex_copy(KernelGlobals *kg, const char *name, device_ptr mem, size_t
if(tex) {
tex->data = (uchar4*)mem;
- tex->width = width;
- tex->height = height;
- tex->depth = depth;
+ tex->dimensions_set(width, height, depth);
tex->interpolation = interpolation;
}
}
diff --git a/intern/cycles/kernel/kernel.cu b/intern/cycles/kernel/kernel.cu
index 5e6748c66fc..636e48b5456 100644
--- a/intern/cycles/kernel/kernel.cu
+++ b/intern/cycles/kernel/kernel.cu
@@ -24,7 +24,83 @@
#include "kernel_path.h"
#include "kernel_displace.h"
-extern "C" __global__ void kernel_cuda_path_trace(float *buffer, uint *rng_state, int sample, int sx, int sy, int sw, int sh, int offset, int stride)
+/* device data taken from CUDA occupancy calculator */
+
+#ifdef __CUDA_ARCH__
+
+/* 2.0 and 2.1 */
+#if __CUDA_ARCH__ == 200 || __CUDA_ARCH__ == 210
+#define CUDA_MULTIPRESSOR_MAX_REGISTERS 32768
+#define CUDA_MULTIPROCESSOR_MAX_BLOCKS 8
+#define CUDA_BLOCK_MAX_THREADS 1024
+#define CUDA_THREAD_MAX_REGISTERS 63
+
+/* tunable parameters */
+#define CUDA_THREADS_BLOCK_WIDTH 16
+#define CUDA_KERNEL_MAX_REGISTERS 32
+#define CUDA_KERNEL_BRANCHED_MAX_REGISTERS 40
+
+/* 3.0 and 3.5 */
+#elif __CUDA_ARCH__ == 300 || __CUDA_ARCH__ == 350
+#define CUDA_MULTIPRESSOR_MAX_REGISTERS 65536
+#define CUDA_MULTIPROCESSOR_MAX_BLOCKS 16
+#define CUDA_BLOCK_MAX_THREADS 1024
+#define CUDA_THREAD_MAX_REGISTERS 63
+
+/* tunable parameters */
+#define CUDA_THREADS_BLOCK_WIDTH 16
+#define CUDA_KERNEL_MAX_REGISTERS 63
+#define CUDA_KERNEL_BRANCHED_MAX_REGISTERS 63
+
+/* 5.0 */
+#elif __CUDA_ARCH__ == 500
+#define CUDA_MULTIPRESSOR_MAX_REGISTERS 65536
+#define CUDA_MULTIPROCESSOR_MAX_BLOCKS 32
+#define CUDA_BLOCK_MAX_THREADS 1024
+#define CUDA_THREAD_MAX_REGISTERS 255
+
+/* tunable parameters */
+#define CUDA_THREADS_BLOCK_WIDTH 16
+#define CUDA_KERNEL_MAX_REGISTERS 63
+#define CUDA_KERNEL_BRANCHED_MAX_REGISTERS 63
+
+/* unknown architecture */
+#else
+#error "Unknown or unuspported CUDA architecture, can't determine launch bounds"
+#endif
+
+/* compute number of threads per block and minimum blocks per multiprocessor
+ * given the maximum number of registers per thread */
+
+#define CUDA_LAUNCH_BOUNDS(threads_block_width, thread_num_registers) \
+ __launch_bounds__( \
+ threads_block_width*threads_block_width, \
+ CUDA_MULTIPRESSOR_MAX_REGISTERS/(threads_block_width*threads_block_width*thread_num_registers) \
+ )
+
+/* sanity checks */
+
+#if CUDA_THREADS_BLOCK_WIDTH*CUDA_THREADS_BLOCK_WIDTH > CUDA_BLOCK_MAX_THREADS
+#error "Maximum number of threads per block exceeded"
+#endif
+
+#if CUDA_MULTIPRESSOR_MAX_REGISTERS/(CUDA_THREADS_BLOCK_WIDTH*CUDA_THREADS_BLOCK_WIDTH*CUDA_KERNEL_MAX_REGISTERS) > CUDA_MULTIPROCESSOR_MAX_BLOCKS
+#error "Maximum number of blocks per multiprocessor exceeded"
+#endif
+
+#if CUDA_KERNEL_MAX_REGISTERS > CUDA_THREAD_MAX_REGISTERS
+#error "Maximum number of registers per thread exceeded"
+#endif
+
+#if CUDA_KERNEL_BRANCHED_MAX_REGISTERS > CUDA_THREAD_MAX_REGISTERS
+#error "Maximum number of registers per thread exceeded"
+#endif
+
+/* kernels */
+
+extern "C" __global__ void
+CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_MAX_REGISTERS)
+kernel_cuda_path_trace(float *buffer, uint *rng_state, int sample, int sx, int sy, int sw, int sh, int offset, int stride)
{
int x = sx + blockDim.x*blockIdx.x + threadIdx.x;
int y = sy + blockDim.y*blockIdx.y + threadIdx.y;
@@ -34,7 +110,9 @@ extern "C" __global__ void kernel_cuda_path_trace(float *buffer, uint *rng_state
}
#ifdef __BRANCHED_PATH__
-extern "C" __global__ void kernel_cuda_branched_path_trace(float *buffer, uint *rng_state, int sample, int sx, int sy, int sw, int sh, int offset, int stride)
+extern "C" __global__ void
+CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_BRANCHED_MAX_REGISTERS)
+kernel_cuda_branched_path_trace(float *buffer, uint *rng_state, int sample, int sx, int sy, int sw, int sh, int offset, int stride)
{
int x = sx + blockDim.x*blockIdx.x + threadIdx.x;
int y = sy + blockDim.y*blockIdx.y + threadIdx.y;
@@ -44,7 +122,9 @@ extern "C" __global__ void kernel_cuda_branched_path_trace(float *buffer, uint *
}
#endif
-extern "C" __global__ void kernel_cuda_convert_to_byte(uchar4 *rgba, float *buffer, float sample_scale, int sx, int sy, int sw, int sh, int offset, int stride)
+extern "C" __global__ void
+CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_MAX_REGISTERS)
+kernel_cuda_convert_to_byte(uchar4 *rgba, float *buffer, float sample_scale, int sx, int sy, int sw, int sh, int offset, int stride)
{
int x = sx + blockDim.x*blockIdx.x + threadIdx.x;
int y = sy + blockDim.y*blockIdx.y + threadIdx.y;
@@ -53,7 +133,9 @@ extern "C" __global__ void kernel_cuda_convert_to_byte(uchar4 *rgba, float *buff
kernel_film_convert_to_byte(NULL, rgba, buffer, sample_scale, x, y, offset, stride);
}
-extern "C" __global__ void kernel_cuda_convert_to_half_float(uchar4 *rgba, float *buffer, float sample_scale, int sx, int sy, int sw, int sh, int offset, int stride)
+extern "C" __global__ void
+CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_MAX_REGISTERS)
+kernel_cuda_convert_to_half_float(uchar4 *rgba, float *buffer, float sample_scale, int sx, int sy, int sw, int sh, int offset, int stride)
{
int x = sx + blockDim.x*blockIdx.x + threadIdx.x;
int y = sy + blockDim.y*blockIdx.y + threadIdx.y;
@@ -62,10 +144,14 @@ extern "C" __global__ void kernel_cuda_convert_to_half_float(uchar4 *rgba, float
kernel_film_convert_to_half_float(NULL, rgba, buffer, sample_scale, x, y, offset, stride);
}
-extern "C" __global__ void kernel_cuda_shader(uint4 *input, float4 *output, int type, int sx)
+extern "C" __global__ void
+CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_MAX_REGISTERS)
+kernel_cuda_shader(uint4 *input, float4 *output, int type, int sx)
{
int x = sx + blockDim.x*blockIdx.x + threadIdx.x;
kernel_shader_evaluate(NULL, input, output, (ShaderEvalType)type, x);
}
+#endif
+
diff --git a/intern/cycles/kernel/kernel_accumulate.h b/intern/cycles/kernel/kernel_accumulate.h
index 582a220ab3c..b4f6dcdace9 100644
--- a/intern/cycles/kernel/kernel_accumulate.h
+++ b/intern/cycles/kernel/kernel_accumulate.h
@@ -407,5 +407,30 @@ ccl_device_inline float3 path_radiance_clamp_and_sum(KernelGlobals *kg, PathRadi
return L_sum;
}
+ccl_device_inline void path_radiance_accum_sample(PathRadiance *L, PathRadiance *L_sample, int num_samples)
+{
+ float fac = 1.0f/num_samples;
+
+#ifdef __PASSES__
+ L->direct_diffuse += L_sample->direct_diffuse*fac;
+ L->direct_glossy += L_sample->direct_glossy*fac;
+ L->direct_transmission += L_sample->direct_transmission*fac;
+ L->direct_subsurface += L_sample->direct_subsurface*fac;
+
+ L->indirect_diffuse += L_sample->indirect_diffuse*fac;
+ L->indirect_glossy += L_sample->indirect_glossy*fac;
+ L->indirect_transmission += L_sample->indirect_transmission*fac;
+ L->indirect_subsurface += L_sample->indirect_subsurface*fac;
+
+ L->emission += L_sample->emission*fac;
+ L->background += L_sample->background*fac;
+ L->ao += L_sample->ao*fac;
+ L->shadow += L_sample->shadow*fac;
+ L->mist += L_sample->mist*fac;
+#else
+ *L += *L_sample * fac;
+#endif
+}
+
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/kernel_avx.cpp b/intern/cycles/kernel/kernel_avx.cpp
index d2a7142c551..354214c406e 100644
--- a/intern/cycles/kernel/kernel_avx.cpp
+++ b/intern/cycles/kernel/kernel_avx.cpp
@@ -77,6 +77,6 @@ CCL_NAMESPACE_END
/* needed for some linkers in combination with scons making empty compilation unit in a library */
void __dummy_function_cycles_avx(void);
-void __dummy_function_cycles_avx(void){}
+void __dummy_function_cycles_avx(void) {}
#endif
diff --git a/intern/cycles/kernel/kernel_compat_cpu.h b/intern/cycles/kernel/kernel_compat_cpu.h
index feaff503212..d027bb62ebe 100644
--- a/intern/cycles/kernel/kernel_compat_cpu.h
+++ b/intern/cycles/kernel/kernel_compat_cpu.h
@@ -95,14 +95,14 @@ template<typename T> struct texture_image {
ccl_always_inline float4 interp(float x, float y, bool periodic = true)
{
- if(!data)
+ if(UNLIKELY(!data))
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
int ix, iy, nix, niy;
if(interpolation == INTERPOLATION_CLOSEST) {
- frac(x*width, &ix);
- frac(y*height, &iy);
+ frac(x*(float)width, &ix);
+ frac(y*(float)height, &iy);
if(periodic) {
ix = wrap_periodic(ix, width);
iy = wrap_periodic(iy, height);
@@ -115,8 +115,8 @@ template<typename T> struct texture_image {
return read(data[ix + iy*width]);
}
else {
- float tx = frac(x*width - 0.5f, &ix);
- float ty = frac(y*height - 0.5f, &iy);
+ float tx = frac(x*(float)width - 0.5f, &ix);
+ float ty = frac(y*(float)height - 0.5f, &iy);
if(periodic) {
ix = wrap_periodic(ix, width);
@@ -144,15 +144,15 @@ template<typename T> struct texture_image {
ccl_always_inline float4 interp_3d(float x, float y, float z, bool periodic = false)
{
- if(!data)
+ if(UNLIKELY(!data))
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
int ix, iy, iz, nix, niy, niz;
if(interpolation == INTERPOLATION_CLOSEST) {
- frac(x*width, &ix);
- frac(y*height, &iy);
- frac(z*depth, &iz);
+ frac(x*(float)width, &ix);
+ frac(y*(float)height, &iy);
+ frac(z*(float)depth, &iz);
if(periodic) {
ix = wrap_periodic(ix, width);
@@ -168,9 +168,9 @@ template<typename T> struct texture_image {
return read(data[ix + iy*width + iz*width*height]);
}
else {
- float tx = frac(x*width - 0.5f, &ix);
- float ty = frac(y*height - 0.5f, &iy);
- float tz = frac(z*depth - 0.5f, &iz);
+ float tx = frac(x*(float)width - 0.5f, &ix);
+ float ty = frac(y*(float)height - 0.5f, &iy);
+ float tz = frac(z*(float)depth - 0.5f, &iz);
if(periodic) {
ix = wrap_periodic(ix, width);
@@ -207,6 +207,13 @@ template<typename T> struct texture_image {
}
}
+ ccl_always_inline void dimensions_set(int width_, int height_, int depth_)
+ {
+ width = width_;
+ height = height_;
+ depth = depth_;
+ }
+
T *data;
int interpolation;
int width, height, depth;
diff --git a/intern/cycles/kernel/kernel_compat_cuda.h b/intern/cycles/kernel/kernel_compat_cuda.h
index 15e7353ec38..e4c20d26ff1 100644
--- a/intern/cycles/kernel/kernel_compat_cuda.h
+++ b/intern/cycles/kernel/kernel_compat_cuda.h
@@ -60,7 +60,7 @@ typedef texture<uchar4, 2, cudaReadModeNormalizedFloat> texture_image_uchar4;
/* In order to use full 6GB of memory on Titan cards, use arrays instead
* of textures. On earlier cards this seems slower, but on Titan it is
* actually slightly faster in tests. */
-#if __CUDA_ARCH__ < 350
+#if __CUDA_ARCH__ < 300
#define __KERNEL_CUDA_TEX_STORAGE__
#endif
diff --git a/intern/cycles/kernel/kernel_compat_opencl.h b/intern/cycles/kernel/kernel_compat_opencl.h
index 4f4414cc298..8346b09619e 100644
--- a/intern/cycles/kernel/kernel_compat_opencl.h
+++ b/intern/cycles/kernel/kernel_compat_opencl.h
@@ -85,27 +85,36 @@
#define __float_as_uint(x) as_uint(x)
#define __int_as_float(x) as_float(x)
#define __float_as_int(x) as_int(x)
-#define sqrtf(x) sqrt(((float)x))
-#define cosf(x) cos(((float)x))
-#define sinf(x) sin(((float)x))
#define powf(x, y) pow(((float)x), ((float)y))
#define fabsf(x) fabs(((float)x))
#define copysignf(x, y) copysign(((float)x), ((float)y))
-#define cosf(x) cos(((float)x))
#define asinf(x) asin(((float)x))
#define acosf(x) acos(((float)x))
#define atanf(x) atan(((float)x))
-#define tanf(x) tan(((float)x))
-#define logf(x) log(((float)x))
#define floorf(x) floor(((float)x))
#define ceilf(x) ceil(((float)x))
-#define expf(x) exp(((float)x))
#define hypotf(x, y) hypot(((float)x), ((float)y))
#define atan2f(x, y) atan2(((float)x), ((float)y))
#define fmaxf(x, y) fmax(((float)x), ((float)y))
#define fminf(x, y) fmin(((float)x), ((float)y))
#define fmodf(x, y) fmod((float)x, (float)y)
+#ifndef __CL_USE_NATIVE__
+#define sinf(x) native_sin(((float)x))
+#define cosf(x) native_cos(((float)x))
+#define tanf(x) native_tan(((float)x))
+#define expf(x) native_exp(((float)x))
+#define sqrtf(x) native_sqrt(((float)x))
+#define logf(x) native_log(((float)x))
+#else
+#define sinf(x) sin(((float)x))
+#define cosf(x) cos(((float)x))
+#define tanf(x) tan(((float)x))
+#define expf(x) exp(((float)x))
+#define sqrtf(x) sqrt(((float)x))
+#define logf(x) log(((float)x))
+#endif
+
/* data lookup defines */
#define kernel_data (*kg->data)
#define kernel_tex_fetch(t, index) kg->t[index]
diff --git a/intern/cycles/kernel/kernel_displace.h b/intern/cycles/kernel/kernel_displace.h
index c50e2166660..b8c64af658f 100644
--- a/intern/cycles/kernel/kernel_displace.h
+++ b/intern/cycles/kernel/kernel_displace.h
@@ -16,8 +16,308 @@
CCL_NAMESPACE_BEGIN
+ccl_device void compute_light_pass(KernelGlobals *kg, ShaderData *sd, PathRadiance *L, RNG rng,
+ bool is_combined, bool is_ao, bool is_sss)
+{
+ int samples = kernel_data.integrator.aa_samples;
+
+ /* initialize master radiance accumulator */
+ kernel_assert(kernel_data.film.use_light_pass);
+ path_radiance_init(L, kernel_data.film.use_light_pass);
+
+ /* take multiple samples */
+ for(int sample = 0; sample < samples; sample++) {
+ PathRadiance L_sample;
+ PathState state;
+ Ray ray;
+ float3 throughput = make_float3(1.0f, 1.0f, 1.0f);
+
+ /* init radiance */
+ path_radiance_init(&L_sample, kernel_data.film.use_light_pass);
+
+ /* init path state */
+ path_state_init(kg, &state, &rng, sample);
+ state.num_samples = samples;
+
+ /* evaluate surface shader */
+ float rbsdf = path_state_rng_1D(kg, &rng, &state, PRNG_BSDF);
+ shader_eval_surface(kg, sd, rbsdf, state.flag, SHADER_CONTEXT_MAIN);
+
+ /* TODO, disable the closures we won't need */
+
+ /* sample ambient occlusion */
+ if(is_combined || is_ao) {
+ kernel_path_ao(kg, sd, &L_sample, &state, &rng, throughput);
+ }
+
+ /* sample subsurface scattering */
+ if((is_combined || is_sss) && (sd->flag & SD_BSSRDF)) {
+#ifdef __SUBSURFACE__
+ /* when mixing BSSRDF and BSDF closures we should skip BSDF lighting if scattering was successful */
+ if (kernel_path_subsurface_scatter(kg, sd, &L_sample, &state, &rng, &ray, &throughput))
+ is_sss = true;
+#endif
+ }
+
+ /* sample light and BSDF */
+ if((!is_sss) && (!is_ao)) {
+ if(kernel_path_integrate_lighting(kg, &rng, sd, &throughput, &state, &L_sample, &ray)) {
+#ifdef __LAMP_MIS__
+ state.ray_t = 0.0f;
+#endif
+ /* compute indirect light */
+ kernel_path_indirect(kg, &rng, ray, throughput, state.num_samples, state, &L_sample);
+
+ /* sum and reset indirect light pass variables for the next samples */
+ path_radiance_sum_indirect(&L_sample);
+ path_radiance_reset_indirect(&L_sample);
+ }
+ }
+
+ /* accumulate into master L */
+ path_radiance_accum_sample(L, &L_sample, samples);
+ }
+}
+
+ccl_device bool is_light_pass(ShaderEvalType type)
+{
+ switch (type) {
+ case SHADER_EVAL_AO:
+ case SHADER_EVAL_COMBINED:
+ case SHADER_EVAL_SHADOW:
+ case SHADER_EVAL_DIFFUSE_DIRECT:
+ case SHADER_EVAL_GLOSSY_DIRECT:
+ case SHADER_EVAL_TRANSMISSION_DIRECT:
+ case SHADER_EVAL_SUBSURFACE_DIRECT:
+ case SHADER_EVAL_DIFFUSE_INDIRECT:
+ case SHADER_EVAL_GLOSSY_INDIRECT:
+ case SHADER_EVAL_TRANSMISSION_INDIRECT:
+ case SHADER_EVAL_SUBSURFACE_INDIRECT:
+ return true;
+ default:
+ return false;
+ }
+}
+
+ccl_device void kernel_bake_evaluate(KernelGlobals *kg, ccl_global uint4 *input, ccl_global float4 *output, ShaderEvalType type, int i)
+{
+ ShaderData sd;
+ uint4 in = input[i * 2];
+ uint4 diff = input[i * 2 + 1];
+
+ float3 out;
+
+ int object = in.x;
+ int prim = in.y;
+
+ if(prim == -1)
+ return;
+
+ float u = __uint_as_float(in.z);
+ float v = __uint_as_float(in.w);
+
+ float dudx = __uint_as_float(diff.x);
+ float dudy = __uint_as_float(diff.y);
+ float dvdx = __uint_as_float(diff.z);
+ float dvdy = __uint_as_float(diff.w);
+
+ int shader;
+ float3 P, Ng;
+
+ triangle_point_normal(kg, prim, u, v, &P, &Ng, &shader);
+
+ /* dummy initilizations copied from SHADER_EVAL_DISPLACE */
+ float3 I = Ng;
+ float t = 0.0f;
+ float time = TIME_INVALID;
+ int bounce = 0;
+ int transparent_bounce = 0;
+
+ /* light passes */
+ PathRadiance L;
+
+ shader_setup_from_sample(kg, &sd, P, Ng, I, shader, object, prim, u, v, t, time, bounce, transparent_bounce);
+ sd.I = sd.N;
+
+ /* update differentials */
+ sd.dP.dx = sd.dPdu * dudx + sd.dPdv * dvdx;
+ sd.dP.dy = sd.dPdu * dudy + sd.dPdv * dvdy;
+ sd.du.dx = dudx;
+ sd.du.dy = dudy;
+ sd.dv.dx = dvdx;
+ sd.dv.dy = dvdy;
+
+ if(is_light_pass(type)) {
+ RNG rng = cmj_hash(i, 0);
+ compute_light_pass(kg, &sd, &L, rng, (type == SHADER_EVAL_COMBINED),
+ (type == SHADER_EVAL_AO),
+ (type == SHADER_EVAL_SUBSURFACE_DIRECT ||
+ type == SHADER_EVAL_SUBSURFACE_INDIRECT));
+ }
+
+ switch (type) {
+ /* data passes */
+ case SHADER_EVAL_NORMAL:
+ {
+ /* compression: normal = (2 * color) - 1 */
+ out = sd.N * 0.5f + make_float3(0.5f, 0.5f, 0.5f);
+ break;
+ }
+ case SHADER_EVAL_UV:
+ {
+ out = primitive_uv(kg, &sd);
+ break;
+ }
+ case SHADER_EVAL_DIFFUSE_COLOR:
+ {
+ shader_eval_surface(kg, &sd, 0.f, 0, SHADER_CONTEXT_MAIN);
+ out = shader_bsdf_diffuse(kg, &sd);
+ break;
+ }
+ case SHADER_EVAL_GLOSSY_COLOR:
+ {
+ shader_eval_surface(kg, &sd, 0.f, 0, SHADER_CONTEXT_MAIN);
+ out = shader_bsdf_glossy(kg, &sd);
+ break;
+ }
+ case SHADER_EVAL_TRANSMISSION_COLOR:
+ {
+ shader_eval_surface(kg, &sd, 0.f, 0, SHADER_CONTEXT_MAIN);
+ out = shader_bsdf_transmission(kg, &sd);
+ break;
+ }
+ case SHADER_EVAL_SUBSURFACE_COLOR:
+ {
+#ifdef __SUBSURFACE__
+ shader_eval_surface(kg, &sd, 0.f, 0, SHADER_CONTEXT_MAIN);
+ out = shader_bsdf_subsurface(kg, &sd);
+#endif
+ break;
+ }
+ case SHADER_EVAL_EMISSION:
+ {
+ shader_eval_surface(kg, &sd, 0.f, 0, SHADER_CONTEXT_EMISSION);
+ out = shader_emissive_eval(kg, &sd);
+ break;
+ }
+
+#ifdef __PASSES__
+ /* light passes */
+ case SHADER_EVAL_AO:
+ {
+ out = L.ao;
+ break;
+ }
+ case SHADER_EVAL_COMBINED:
+ {
+ out = path_radiance_clamp_and_sum(kg, &L);
+ break;
+ }
+ case SHADER_EVAL_SHADOW:
+ {
+ out = make_float3(L.shadow.x, L.shadow.y, L.shadow.z);
+ break;
+ }
+ case SHADER_EVAL_DIFFUSE_DIRECT:
+ {
+ shader_eval_surface(kg, &sd, 0.f, 0, SHADER_CONTEXT_MAIN);
+ out = safe_divide_color(L.direct_diffuse, shader_bsdf_diffuse(kg, &sd));
+ break;
+ }
+ case SHADER_EVAL_GLOSSY_DIRECT:
+ {
+ shader_eval_surface(kg, &sd, 0.f, 0, SHADER_CONTEXT_MAIN);
+ out = safe_divide_color(L.direct_glossy, shader_bsdf_glossy(kg, &sd));
+ break;
+ }
+ case SHADER_EVAL_TRANSMISSION_DIRECT:
+ {
+ shader_eval_surface(kg, &sd, 0.f, 0, SHADER_CONTEXT_MAIN);
+ out = safe_divide_color(L.direct_transmission, shader_bsdf_transmission(kg, &sd));
+ break;
+ }
+ case SHADER_EVAL_SUBSURFACE_DIRECT:
+ {
+#ifdef __SUBSURFACE__
+ shader_eval_surface(kg, &sd, 0.f, 0, SHADER_CONTEXT_MAIN);
+ out = safe_divide_color(L.direct_subsurface, shader_bsdf_subsurface(kg, &sd));
+#endif
+ break;
+ }
+ case SHADER_EVAL_DIFFUSE_INDIRECT:
+ {
+ shader_eval_surface(kg, &sd, 0.f, 0, SHADER_CONTEXT_MAIN);
+ out = safe_divide_color(L.indirect_diffuse, shader_bsdf_diffuse(kg, &sd));
+ break;
+ }
+ case SHADER_EVAL_GLOSSY_INDIRECT:
+ {
+ shader_eval_surface(kg, &sd, 0.f, 0, SHADER_CONTEXT_MAIN);
+ out = safe_divide_color(L.indirect_glossy, shader_bsdf_glossy(kg, &sd));
+ break;
+ }
+ case SHADER_EVAL_TRANSMISSION_INDIRECT:
+ {
+ shader_eval_surface(kg, &sd, 0.f, 0, SHADER_CONTEXT_MAIN);
+ out = safe_divide_color(L.indirect_transmission, shader_bsdf_transmission(kg, &sd));
+ break;
+ }
+ case SHADER_EVAL_SUBSURFACE_INDIRECT:
+ {
+#ifdef __SUBSURFACE__
+ shader_eval_surface(kg, &sd, 0.f, 0, SHADER_CONTEXT_MAIN);
+ out = safe_divide_color(L.indirect_subsurface, shader_bsdf_subsurface(kg, &sd));
+#endif
+ break;
+ }
+#endif
+
+ /* extra */
+ case SHADER_EVAL_ENVIRONMENT:
+ {
+ /* setup ray */
+ Ray ray;
+
+ ray.P = make_float3(0.0f, 0.0f, 0.0f);
+ ray.D = normalize(P);
+ ray.t = 0.0f;
+#ifdef __CAMERA_MOTION__
+ ray.time = 0.5f;
+#endif
+
+#ifdef __RAY_DIFFERENTIALS__
+ ray.dD = differential3_zero();
+ ray.dP = differential3_zero();
+#endif
+
+ /* setup shader data */
+ shader_setup_from_background(kg, &sd, &ray, 0, 0);
+
+ /* evaluate */
+ int flag = 0; /* we can't know which type of BSDF this is for */
+ out = shader_eval_background(kg, &sd, flag, SHADER_CONTEXT_MAIN);
+ break;
+ }
+ default:
+ {
+ /* no real shader, returning the position of the verts for debugging */
+ out = normalize(P);
+ break;
+ }
+ }
+
+ /* write output */
+ output[i] = make_float4(out.x, out.y, out.z, 1.0f);
+ return;
+}
+
ccl_device void kernel_shader_evaluate(KernelGlobals *kg, ccl_global uint4 *input, ccl_global float4 *output, ShaderEvalType type, int i)
{
+ if(type >= SHADER_EVAL_BAKE) {
+ kernel_bake_evaluate(kg, input, output, type, i);
+ return;
+ }
+
ShaderData sd;
uint4 in = input[i];
float3 out;
@@ -55,7 +355,7 @@ ccl_device void kernel_shader_evaluate(KernelGlobals *kg, ccl_global uint4 *inpu
#endif
/* setup shader data */
- shader_setup_from_background(kg, &sd, &ray, 0);
+ shader_setup_from_background(kg, &sd, &ray, 0, 0);
/* evaluate */
int flag = 0; /* we can't know which type of BSDF this is for */
diff --git a/intern/cycles/kernel/kernel_emission.h b/intern/cycles/kernel/kernel_emission.h
index bb61b2111fe..deffa7f2ba2 100644
--- a/intern/cycles/kernel/kernel_emission.h
+++ b/intern/cycles/kernel/kernel_emission.h
@@ -18,8 +18,8 @@ CCL_NAMESPACE_BEGIN
/* Direction Emission */
-ccl_device_noinline float3 direct_emissive_eval(KernelGlobals *kg, float rando,
- LightSample *ls, float3 I, differential3 dI, float t, float time, int bounce)
+ccl_device_noinline float3 direct_emissive_eval(KernelGlobals *kg,
+ LightSample *ls, float3 I, differential3 dI, float t, float time, int bounce, int transparent_bounce)
{
/* setup shading at emitter */
ShaderData sd;
@@ -37,19 +37,19 @@ ccl_device_noinline float3 direct_emissive_eval(KernelGlobals *kg, float rando,
ray.dP = differential3_zero();
ray.dD = dI;
- shader_setup_from_background(kg, &sd, &ray, bounce+1);
+ shader_setup_from_background(kg, &sd, &ray, bounce+1, transparent_bounce);
eval = shader_eval_background(kg, &sd, 0, SHADER_CONTEXT_EMISSION);
}
else
#endif
{
- shader_setup_from_sample(kg, &sd, ls->P, ls->Ng, I, ls->shader, ls->object, ls->prim, ls->u, ls->v, t, time, bounce+1);
+ shader_setup_from_sample(kg, &sd, ls->P, ls->Ng, I, ls->shader, ls->object, ls->prim, ls->u, ls->v, t, time, bounce+1, transparent_bounce);
ls->Ng = sd.Ng;
/* no path flag, we're evaluating this for all closures. that's weak but
* we'd have to do multiple evaluations otherwise */
- shader_eval_surface(kg, &sd, rando, 0, SHADER_CONTEXT_EMISSION);
+ shader_eval_surface(kg, &sd, 0.0f, 0, SHADER_CONTEXT_EMISSION);
/* evaluate emissive closure */
if(sd.flag & SD_EMISSION)
@@ -64,8 +64,8 @@ ccl_device_noinline float3 direct_emissive_eval(KernelGlobals *kg, float rando,
}
ccl_device_noinline bool direct_emission(KernelGlobals *kg, ShaderData *sd, int lindex,
- float randt, float rando, float randu, float randv, Ray *ray, BsdfEval *eval,
- bool *is_lamp, int bounce)
+ float randt, float randu, float randv, Ray *ray, BsdfEval *eval,
+ bool *is_lamp, int bounce, int transparent_bounce)
{
LightSample ls;
@@ -88,7 +88,7 @@ ccl_device_noinline bool direct_emission(KernelGlobals *kg, ShaderData *sd, int
differential3 dD = differential3_zero();
/* evaluate closure */
- float3 light_eval = direct_emissive_eval(kg, rando, &ls, -ls.D, dD, ls.t, sd->time, bounce);
+ float3 light_eval = direct_emissive_eval(kg, &ls, -ls.D, dD, ls.t, sd->time, bounce, transparent_bounce);
if(is_zero(light_eval))
return false;
@@ -166,10 +166,11 @@ ccl_device_noinline float3 indirect_primitive_emission(KernelGlobals *kg, Shader
float3 L = shader_emissive_eval(kg, sd);
#ifdef __HAIR__
- if(!(path_flag & PATH_RAY_MIS_SKIP) && (sd->flag & SD_USE_MIS) && (sd->type & PRIMITIVE_ALL_TRIANGLE)) {
+ if(!(path_flag & PATH_RAY_MIS_SKIP) && (sd->flag & SD_USE_MIS) && (sd->type & PRIMITIVE_ALL_TRIANGLE))
#else
- if(!(path_flag & PATH_RAY_MIS_SKIP) && (sd->flag & SD_USE_MIS)) {
+ if(!(path_flag & PATH_RAY_MIS_SKIP) && (sd->flag & SD_USE_MIS))
#endif
+ {
/* multiple importance sampling, get triangle light pdf,
* and compute weight with respect to BSDF pdf */
float pdf = triangle_light_pdf(kg, sd->Ng, sd->I, t);
@@ -183,71 +184,75 @@ ccl_device_noinline float3 indirect_primitive_emission(KernelGlobals *kg, Shader
/* Indirect Lamp Emission */
-ccl_device_noinline bool indirect_lamp_emission(KernelGlobals *kg, Ray *ray, int path_flag, float bsdf_pdf, float randt, float3 *emission, int bounce)
+ccl_device_noinline bool indirect_lamp_emission(KernelGlobals *kg, PathState *state, Ray *ray, float3 *emission)
{
- LightSample ls;
- int lamp = lamp_light_eval_sample(kg, randt);
+ bool hit_lamp = false;
- if(lamp == LAMP_NONE)
- return false;
+ *emission = make_float3(0.0f, 0.0f, 0.0f);
- if(!lamp_light_eval(kg, lamp, ray->P, ray->D, ray->t, &ls))
- return false;
+ for(int lamp = 0; lamp < kernel_data.integrator.num_all_lights; lamp++) {
+ LightSample ls;
+
+ if(!lamp_light_eval(kg, lamp, ray->P, ray->D, ray->t, &ls))
+ continue;
#ifdef __PASSES__
- /* use visibility flag to skip lights */
- if(ls.shader & SHADER_EXCLUDE_ANY) {
- if(((ls.shader & SHADER_EXCLUDE_DIFFUSE) && (path_flag & PATH_RAY_DIFFUSE)) ||
- ((ls.shader & SHADER_EXCLUDE_GLOSSY) && (path_flag & PATH_RAY_GLOSSY)) ||
- ((ls.shader & SHADER_EXCLUDE_TRANSMIT) && (path_flag & PATH_RAY_TRANSMIT)))
- return false;
- }
+ /* use visibility flag to skip lights */
+ if(ls.shader & SHADER_EXCLUDE_ANY) {
+ if(((ls.shader & SHADER_EXCLUDE_DIFFUSE) && (state->flag & PATH_RAY_DIFFUSE)) ||
+ ((ls.shader & SHADER_EXCLUDE_GLOSSY) && (state->flag & PATH_RAY_GLOSSY)) ||
+ ((ls.shader & SHADER_EXCLUDE_TRANSMIT) && (state->flag & PATH_RAY_TRANSMIT)))
+ continue;
+ }
#endif
- float3 L = direct_emissive_eval(kg, 0.0f, &ls, -ray->D, ray->dD, ls.t, ray->time, bounce);
+ float3 L = direct_emissive_eval(kg, &ls, -ray->D, ray->dD, ls.t, ray->time, state->bounce, state->transparent_bounce);
- if(!(path_flag & PATH_RAY_MIS_SKIP)) {
- /* multiple importance sampling, get regular light pdf,
- * and compute weight with respect to BSDF pdf */
- float mis_weight = power_heuristic(bsdf_pdf, ls.pdf);
- L *= mis_weight;
+ if(!(state->flag & PATH_RAY_MIS_SKIP)) {
+ /* multiple importance sampling, get regular light pdf,
+ * and compute weight with respect to BSDF pdf */
+ float mis_weight = power_heuristic(state->ray_pdf, ls.pdf);
+ L *= mis_weight;
+ }
+
+ *emission += L;
+ hit_lamp = true;
}
- *emission = L;
- return true;
+ return hit_lamp;
}
/* Indirect Background */
-ccl_device_noinline float3 indirect_background(KernelGlobals *kg, Ray *ray, int path_flag, float bsdf_pdf, int bounce)
+ccl_device_noinline float3 indirect_background(KernelGlobals *kg, PathState *state, Ray *ray)
{
#ifdef __BACKGROUND__
int shader = kernel_data.background.surface_shader;
/* use visibility flag to skip lights */
if(shader & SHADER_EXCLUDE_ANY) {
- if(((shader & SHADER_EXCLUDE_DIFFUSE) && (path_flag & PATH_RAY_DIFFUSE)) ||
- ((shader & SHADER_EXCLUDE_GLOSSY) && (path_flag & PATH_RAY_GLOSSY)) ||
- ((shader & SHADER_EXCLUDE_TRANSMIT) && (path_flag & PATH_RAY_TRANSMIT)) ||
- ((shader & SHADER_EXCLUDE_CAMERA) && (path_flag & PATH_RAY_CAMERA)))
+ if(((shader & SHADER_EXCLUDE_DIFFUSE) && (state->flag & PATH_RAY_DIFFUSE)) ||
+ ((shader & SHADER_EXCLUDE_GLOSSY) && (state->flag & PATH_RAY_GLOSSY)) ||
+ ((shader & SHADER_EXCLUDE_TRANSMIT) && (state->flag & PATH_RAY_TRANSMIT)) ||
+ ((shader & SHADER_EXCLUDE_CAMERA) && (state->flag & PATH_RAY_CAMERA)))
return make_float3(0.0f, 0.0f, 0.0f);
}
/* evaluate background closure */
ShaderData sd;
- shader_setup_from_background(kg, &sd, ray, bounce+1);
+ shader_setup_from_background(kg, &sd, ray, state->bounce+1, state->transparent_bounce);
- float3 L = shader_eval_background(kg, &sd, path_flag, SHADER_CONTEXT_EMISSION);
+ float3 L = shader_eval_background(kg, &sd, state->flag, SHADER_CONTEXT_EMISSION);
#ifdef __BACKGROUND_MIS__
/* check if background light exists or if we should skip pdf */
int res = kernel_data.integrator.pdf_background_res;
- if(!(path_flag & PATH_RAY_MIS_SKIP) && res) {
+ if(!(state->flag & PATH_RAY_MIS_SKIP) && res) {
/* multiple importance sampling, get background light pdf for ray
* direction, and compute weight with respect to BSDF pdf */
float pdf = background_light_pdf(kg, ray->D);
- float mis_weight = power_heuristic(bsdf_pdf, pdf);
+ float mis_weight = power_heuristic(state->ray_pdf, pdf);
return L*mis_weight;
}
diff --git a/intern/cycles/kernel/kernel_light.h b/intern/cycles/kernel/kernel_light.h
index ffda44fee57..ac432d3fe04 100644
--- a/intern/cycles/kernel/kernel_light.h
+++ b/intern/cycles/kernel/kernel_light.h
@@ -421,7 +421,6 @@ ccl_device bool lamp_light_eval(KernelGlobals *kg, int lamp, float3 P, float3 D,
/* compute pdf */
if(ls->t != FLT_MAX)
ls->pdf *= lamp_light_pdf(kg, ls->Ng, -ls->D, ls->t);
- ls->eval_fac *= kernel_data.integrator.inv_pdf_lights;
return true;
}
diff --git a/intern/cycles/kernel/kernel_passes.h b/intern/cycles/kernel/kernel_passes.h
index 9cdcb8c5229..b3b6fc02894 100644
--- a/intern/cycles/kernel/kernel_passes.h
+++ b/intern/cycles/kernel/kernel_passes.h
@@ -51,7 +51,8 @@ ccl_device_inline void kernel_write_data_passes(KernelGlobals *kg, ccl_global fl
if(!(path_flag & PATH_RAY_SINGLE_PASS_DONE)) {
if(!(sd->flag & SD_TRANSPARENT) ||
kernel_data.film.pass_alpha_threshold == 0.0f ||
- average(shader_bsdf_alpha(kg, sd)) >= kernel_data.film.pass_alpha_threshold) {
+ average(shader_bsdf_alpha(kg, sd)) >= kernel_data.film.pass_alpha_threshold)
+ {
if(sample == 0) {
if(flag & PASS_DEPTH) {
diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h
index 2764d0e0f19..a80a0033712 100644
--- a/intern/cycles/kernel/kernel_path.h
+++ b/intern/cycles/kernel/kernel_path.h
@@ -56,11 +56,6 @@ ccl_device_inline bool kernel_path_integrate_scatter_lighting(KernelGlobals *kg,
/* sample illumination from lights to find path contribution */
if(sd->flag & SD_BSDF_HAS_EVAL) {
float light_t = path_state_rng_1D(kg, rng, state, PRNG_LIGHT);
-#ifdef __MULTI_CLOSURE__
- float light_o = 0.0f;
-#else
- float light_o = path_state_rng_1D(kg, rng, state, PRNG_LIGHT_F);
-#endif
float light_u, light_v;
path_state_rng_2D(kg, rng, state, PRNG_LIGHT_U, &light_u, &light_v);
@@ -72,7 +67,7 @@ ccl_device_inline bool kernel_path_integrate_scatter_lighting(KernelGlobals *kg,
light_ray.time = sd->time;
#endif
- if(direct_emission(kg, sd, LAMP_NONE, light_t, light_o, light_u, light_v, &light_ray, &L_light, &is_lamp, state->bounce)) {
+ if(direct_emission(kg, sd, LAMP_NONE, light_t, light_u, light_v, &light_ray, &L_light, &is_lamp, state->bounce, state->transparent_bounce)) {
/* trace shadow ray */
float3 shadow;
@@ -157,7 +152,7 @@ ccl_device void kernel_branched_path_integrate_direct_lighting(KernelGlobals *kg
float light_u, light_v;
path_branched_rng_2D(kg, &lamp_rng, state, j, num_samples, PRNG_LIGHT_U, &light_u, &light_v);
- if(direct_emission(kg, sd, i, 0.0f, 0.0f, light_u, light_v, &light_ray, &L_light, &is_lamp, state->bounce)) {
+ if(direct_emission(kg, sd, i, 0.0f, light_u, light_v, &light_ray, &L_light, &is_lamp, state->bounce, state->transparent_bounce)) {
/* trace shadow ray */
float3 shadow;
@@ -186,7 +181,7 @@ ccl_device void kernel_branched_path_integrate_direct_lighting(KernelGlobals *kg
if(kernel_data.integrator.num_all_lights)
light_t = 0.5f*light_t;
- if(direct_emission(kg, sd, LAMP_NONE, light_t, 0.0f, light_u, light_v, &light_ray, &L_light, &is_lamp, state->bounce)) {
+ if(direct_emission(kg, sd, LAMP_NONE, light_t, light_u, light_v, &light_ray, &L_light, &is_lamp, state->bounce, state->transparent_bounce)) {
/* trace shadow ray */
float3 shadow;
@@ -204,7 +199,7 @@ ccl_device void kernel_branched_path_integrate_direct_lighting(KernelGlobals *kg
path_state_rng_2D(kg, rng, state, PRNG_LIGHT_U, &light_u, &light_v);
/* sample random light */
- if(direct_emission(kg, sd, LAMP_NONE, light_t, 0.0f, light_u, light_v, &light_ray, &L_light, &is_lamp, state->bounce)) {
+ if(direct_emission(kg, sd, LAMP_NONE, light_t, light_u, light_v, &light_ray, &L_light, &is_lamp, state->bounce, state->transparent_bounce)) {
/* trace shadow ray */
float3 shadow;
@@ -217,7 +212,9 @@ ccl_device void kernel_branched_path_integrate_direct_lighting(KernelGlobals *kg
}
}
-ccl_device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, Ray ray, ccl_global float *buffer,
+#endif
+
+ccl_device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, Ray ray,
float3 throughput, int num_samples, PathState state, PathRadiance *L)
{
/* path iteration */
@@ -245,10 +242,9 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, Ray ray, ccl_g
light_ray.dP = ray.dP;
/* intersect with lamp */
- float light_t = path_state_rng_1D(kg, rng, &state, PRNG_LIGHT);
float3 emission;
- if(indirect_lamp_emission(kg, &light_ray, state.flag, state.ray_pdf, light_t, &emission, state.bounce))
+ if(indirect_lamp_emission(kg, &state, &light_ray, &emission))
path_radiance_accum_emission(L, throughput, emission, state.bounce);
}
#endif
@@ -275,7 +271,7 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, Ray ray, ccl_g
if(!hit) {
#ifdef __BACKGROUND__
/* sample background shader */
- float3 L_background = indirect_background(kg, &ray, state.flag, state.ray_pdf, state.bounce);
+ float3 L_background = indirect_background(kg, &state, &ray);
path_radiance_accum_background(L, throughput, L_background, state.bounce);
#endif
@@ -284,7 +280,7 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, Ray ray, ccl_g
/* setup shading */
ShaderData sd;
- shader_setup_from_ray(kg, &sd, &isect, &ray, state.bounce);
+ shader_setup_from_ray(kg, &sd, &isect, &ray, state.bounce, state.transparent_bounce);
float rbsdf = path_state_rng_1D(kg, rng, &state, PRNG_BSDF);
shader_eval_surface(kg, &sd, rbsdf, state.flag, SHADER_CONTEXT_INDIRECT);
#ifdef __BRANCHED_PATH__
@@ -384,7 +380,7 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, Ray ray, ccl_g
}
#endif
-#ifdef __EMISSION__
+#if defined(__EMISSION__) && defined(__BRANCHED_PATH__)
if(kernel_data.integrator.use_direct_light) {
bool all = kernel_data.integrator.sample_all_lights_indirect;
kernel_branched_path_integrate_direct_lighting(kg, rng, &sd, &state, throughput, 1.0f, L, all);
@@ -462,10 +458,6 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, Ray ray, ccl_g
}
}
-#endif
-
-#ifdef __SUBSURFACE__
-
ccl_device_inline bool kernel_path_integrate_lighting(KernelGlobals *kg, RNG *rng,
ShaderData *sd, float3 *throughput, PathState *state, PathRadiance *L, Ray *ray)
{
@@ -474,11 +466,6 @@ ccl_device_inline bool kernel_path_integrate_lighting(KernelGlobals *kg, RNG *rn
/* sample illumination from lights to find path contribution */
if(sd->flag & SD_BSDF_HAS_EVAL) {
float light_t = path_state_rng_1D(kg, rng, state, PRNG_LIGHT);
-#ifdef __MULTI_CLOSURE__
- float light_o = 0.0f;
-#else
- float light_o = path_state_rng_1D(kg, rng, state, PRNG_LIGHT_F);
-#endif
float light_u, light_v;
path_state_rng_2D(kg, rng, state, PRNG_LIGHT_U, &light_u, &light_v);
@@ -490,7 +477,7 @@ ccl_device_inline bool kernel_path_integrate_lighting(KernelGlobals *kg, RNG *rn
light_ray.time = sd->time;
#endif
- if(direct_emission(kg, sd, LAMP_NONE, light_t, light_o, light_u, light_v, &light_ray, &L_light, &is_lamp, state->bounce)) {
+ if(direct_emission(kg, sd, LAMP_NONE, light_t, light_u, light_v, &light_ray, &L_light, &is_lamp, state->bounce, state->transparent_bounce)) {
/* trace shadow ray */
float3 shadow;
@@ -580,6 +567,84 @@ ccl_device_inline bool kernel_path_integrate_lighting(KernelGlobals *kg, RNG *rn
}
}
+ccl_device void kernel_path_ao(KernelGlobals *kg, ShaderData *sd, PathRadiance *L, PathState *state, RNG *rng, float3 throughput)
+{
+ /* todo: solve correlation */
+ float bsdf_u, bsdf_v;
+
+ path_state_rng_2D(kg, rng, state, PRNG_BSDF_U, &bsdf_u, &bsdf_v);
+
+ float ao_factor = kernel_data.background.ao_factor;
+ float3 ao_N;
+ float3 ao_bsdf = shader_bsdf_ao(kg, sd, ao_factor, &ao_N);
+ float3 ao_D;
+ float ao_pdf;
+ float3 ao_alpha = shader_bsdf_alpha(kg, sd);
+
+ sample_cos_hemisphere(ao_N, bsdf_u, bsdf_v, &ao_D, &ao_pdf);
+
+ if(dot(sd->Ng, ao_D) > 0.0f && ao_pdf != 0.0f) {
+ Ray light_ray;
+ float3 ao_shadow;
+
+ light_ray.P = ray_offset(sd->P, sd->Ng);
+ light_ray.D = ao_D;
+ light_ray.t = kernel_data.background.ao_distance;
+#ifdef __OBJECT_MOTION__
+ light_ray.time = sd->time;
+#endif
+ light_ray.dP = sd->dP;
+ light_ray.dD = differential3_zero();
+
+ if(!shadow_blocked(kg, state, &light_ray, &ao_shadow))
+ path_radiance_accum_ao(L, throughput, ao_alpha, ao_bsdf, ao_shadow, state->bounce);
+ }
+}
+
+#ifdef __SUBSURFACE__
+ccl_device bool kernel_path_subsurface_scatter(KernelGlobals *kg, ShaderData *sd, PathRadiance *L, PathState *state, RNG *rng, Ray *ray, float3 *throughput)
+{
+ float bssrdf_probability;
+ ShaderClosure *sc = subsurface_scatter_pick_closure(kg, sd, &bssrdf_probability);
+
+ /* modify throughput for picking bssrdf or bsdf */
+ *throughput *= bssrdf_probability;
+
+ /* do bssrdf scatter step if we picked a bssrdf closure */
+ if(sc) {
+ uint lcg_state = lcg_state_init(rng, state, 0x68bc21eb);
+
+ ShaderData bssrdf_sd[BSSRDF_MAX_HITS];
+ float bssrdf_u, bssrdf_v;
+ path_state_rng_2D(kg, rng, state, PRNG_BSDF_U, &bssrdf_u, &bssrdf_v);
+ int num_hits = subsurface_scatter_multi_step(kg, sd, bssrdf_sd, state->flag, sc, &lcg_state, bssrdf_u, bssrdf_v, false);
+
+ /* compute lighting with the BSDF closure */
+ for(int hit = 0; hit < num_hits; hit++) {
+ float3 tp = *throughput;
+ PathState hit_state = *state;
+ Ray hit_ray = *ray;
+
+ hit_state.flag |= PATH_RAY_BSSRDF_ANCESTOR;
+ hit_state.rng_offset += PRNG_BOUNCE_NUM;
+
+ if(kernel_path_integrate_lighting(kg, rng, &bssrdf_sd[hit], &tp, &hit_state, L, &hit_ray)) {
+#ifdef __LAMP_MIS__
+ hit_state.ray_t = 0.0f;
+#endif
+
+ kernel_path_indirect(kg, rng, hit_ray, tp, state->num_samples, hit_state, L);
+
+ /* for render passes, sum and reset indirect light pass variables
+ * for the next samples */
+ path_radiance_sum_indirect(L);
+ path_radiance_reset_indirect(L);
+ }
+ }
+ return true;
+ }
+ return false;
+}
#endif
ccl_device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, Ray ray, ccl_global float *buffer)
@@ -634,10 +699,9 @@ ccl_device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample,
light_ray.dP = ray.dP;
/* intersect with lamp */
- float light_t = path_state_rng_1D(kg, rng, &state, PRNG_LIGHT);
float3 emission;
- if(indirect_lamp_emission(kg, &light_ray, state.flag, state.ray_pdf, light_t, &emission, state.bounce))
+ if(indirect_lamp_emission(kg, &state, &light_ray, &emission))
path_radiance_accum_emission(&L, throughput, emission, state.bounce);
}
#endif
@@ -674,7 +738,7 @@ ccl_device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample,
#ifdef __BACKGROUND__
/* sample background shader */
- float3 L_background = indirect_background(kg, &ray, state.flag, state.ray_pdf, state.bounce);
+ float3 L_background = indirect_background(kg, &state, &ray);
path_radiance_accum_background(&L, throughput, L_background, state.bounce);
#endif
@@ -683,7 +747,7 @@ ccl_device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample,
/* setup shading */
ShaderData sd;
- shader_setup_from_ray(kg, &sd, &isect, &ray, state.bounce);
+ shader_setup_from_ray(kg, &sd, &isect, &ray, state.bounce, state.transparent_bounce);
float rbsdf = path_state_rng_1D(kg, rng, &state, PRNG_BSDF);
shader_eval_surface(kg, &sd, rbsdf, state.flag, SHADER_CONTEXT_MAIN);
@@ -750,35 +814,7 @@ ccl_device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample,
#ifdef __AO__
/* ambient occlusion */
if(kernel_data.integrator.use_ambient_occlusion || (sd.flag & SD_AO)) {
- /* todo: solve correlation */
- float bsdf_u, bsdf_v;
- path_state_rng_2D(kg, rng, &state, PRNG_BSDF_U, &bsdf_u, &bsdf_v);
-
- float ao_factor = kernel_data.background.ao_factor;
- float3 ao_N;
- float3 ao_bsdf = shader_bsdf_ao(kg, &sd, ao_factor, &ao_N);
- float3 ao_D;
- float ao_pdf;
- float3 ao_alpha = shader_bsdf_alpha(kg, &sd);
-
- sample_cos_hemisphere(ao_N, bsdf_u, bsdf_v, &ao_D, &ao_pdf);
-
- if(dot(sd.Ng, ao_D) > 0.0f && ao_pdf != 0.0f) {
- Ray light_ray;
- float3 ao_shadow;
-
- light_ray.P = ray_offset(sd.P, sd.Ng);
- light_ray.D = ao_D;
- light_ray.t = kernel_data.background.ao_distance;
-#ifdef __OBJECT_MOTION__
- light_ray.time = sd.time;
-#endif
- light_ray.dP = sd.dP;
- light_ray.dD = differential3_zero();
-
- if(!shadow_blocked(kg, &state, &light_ray, &ao_shadow))
- path_radiance_accum_ao(&L, throughput, ao_alpha, ao_bsdf, ao_shadow, state.bounce);
- }
+ kernel_path_ao(kg, &sd, &L, &state, rng, throughput);
}
#endif
@@ -786,60 +822,18 @@ ccl_device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample,
/* bssrdf scatter to a different location on the same object, replacing
* the closures with a diffuse BSDF */
if(sd.flag & SD_BSSRDF) {
- float bssrdf_probability;
- ShaderClosure *sc = subsurface_scatter_pick_closure(kg, &sd, &bssrdf_probability);
-
- /* modify throughput for picking bssrdf or bsdf */
- throughput *= bssrdf_probability;
-
- /* do bssrdf scatter step if we picked a bssrdf closure */
- if(sc) {
- uint lcg_state = lcg_state_init(rng, &state, 0x68bc21eb);
-
- ShaderData bssrdf_sd[BSSRDF_MAX_HITS];
- float bssrdf_u, bssrdf_v;
- path_state_rng_2D(kg, rng, &state, PRNG_BSDF_U, &bssrdf_u, &bssrdf_v);
- int num_hits = subsurface_scatter_multi_step(kg, &sd, bssrdf_sd, state.flag, sc, &lcg_state, bssrdf_u, bssrdf_v, false);
-
- /* compute lighting with the BSDF closure */
- for(int hit = 0; hit < num_hits; hit++) {
- float3 tp = throughput;
- PathState hit_state = state;
- Ray hit_ray = ray;
-
- hit_state.flag |= PATH_RAY_BSSRDF_ANCESTOR;
- hit_state.rng_offset += PRNG_BOUNCE_NUM;
-
- if(kernel_path_integrate_lighting(kg, rng, &bssrdf_sd[hit], &tp, &hit_state, &L, &hit_ray)) {
-#ifdef __LAMP_MIS__
- hit_state.ray_t = 0.0f;
-#endif
-
- kernel_path_indirect(kg, rng, hit_ray, buffer, tp, state.num_samples, hit_state, &L);
-
- /* for render passes, sum and reset indirect light pass variables
- * for the next samples */
- path_radiance_sum_indirect(&L);
- path_radiance_reset_indirect(&L);
- }
- }
+ if(kernel_path_subsurface_scatter(kg, &sd, &L, &state, rng, &ray, &throughput))
break;
- }
}
#endif
- /* The following code is the same as in kernel_path_integrate_lighting(),
+ /* Same as kernel_path_integrate_lighting(kg, rng, &sd, &throughput, &state, &L, &ray),
but for CUDA the function call is slower. */
#ifdef __EMISSION__
if(kernel_data.integrator.use_direct_light) {
/* sample illumination from lights to find path contribution */
if(sd.flag & SD_BSDF_HAS_EVAL) {
float light_t = path_state_rng_1D(kg, rng, &state, PRNG_LIGHT);
-#ifdef __MULTI_CLOSURE__
- float light_o = 0.0f;
-#else
- float light_o = path_state_rng_1D(kg, rng, &state, PRNG_LIGHT_F);
-#endif
float light_u, light_v;
path_state_rng_2D(kg, rng, &state, PRNG_LIGHT_U, &light_u, &light_v);
@@ -851,7 +845,7 @@ ccl_device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample,
light_ray.time = sd.time;
#endif
- if(direct_emission(kg, &sd, LAMP_NONE, light_t, light_o, light_u, light_v, &light_ray, &L_light, &is_lamp, state.bounce)) {
+ if(direct_emission(kg, &sd, LAMP_NONE, light_t, light_u, light_v, &light_ray, &L_light, &is_lamp, state.bounce, state.transparent_bounce)) {
/* trace shadow ray */
float3 shadow;
@@ -1039,7 +1033,7 @@ ccl_device_noinline void kernel_branched_path_integrate_lighting(KernelGlobals *
ps.ray_t = 0.0f;
#endif
- kernel_path_indirect(kg, rng, bsdf_ray, buffer, tp*num_samples_inv, num_samples, ps, L);
+ kernel_path_indirect(kg, rng, bsdf_ray, tp*num_samples_inv, num_samples, ps, L);
/* for render passes, sum and reset indirect light pass variables
* for the next samples */
@@ -1100,7 +1094,7 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
VolumeSegment volume_segment;
ShaderData volume_sd;
- shader_setup_from_volume(kg, &volume_sd, &volume_ray, state.bounce);
+ shader_setup_from_volume(kg, &volume_sd, &volume_ray, state.bounce, state.transparent_bounce);
kernel_volume_decoupled_record(kg, &state,
&volume_ray, &volume_sd, &volume_segment, heterogeneous);
@@ -1127,7 +1121,7 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
if(result == VOLUME_PATH_SCATTERED) {
/* todo: use all-light sampling */
if(kernel_path_integrate_scatter_lighting(kg, rng, &volume_sd, &tp, &ps, &L, &pray, num_samples_inv)) {
- kernel_path_indirect(kg, rng, pray, buffer, tp*num_samples_inv, num_samples, ps, &L);
+ kernel_path_indirect(kg, rng, pray, tp*num_samples_inv, num_samples, ps, &L);
/* for render passes, sum and reset indirect light pass variables
* for the next samples */
@@ -1167,7 +1161,7 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
if(result == VOLUME_PATH_SCATTERED) {
/* todo: use all-light sampling */
if(kernel_path_integrate_scatter_lighting(kg, rng, &volume_sd, &tp, &ps, &L, &pray, num_samples_inv)) {
- kernel_path_indirect(kg, rng, pray, buffer, tp*num_samples_inv, num_samples, ps, &L);
+ kernel_path_indirect(kg, rng, pray, tp*num_samples_inv, num_samples, ps, &L);
/* for render passes, sum and reset indirect light pass variables
* for the next samples */
@@ -1196,7 +1190,7 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
#ifdef __BACKGROUND__
/* sample background shader */
- float3 L_background = indirect_background(kg, &ray, state.flag, state.ray_pdf, state.bounce);
+ float3 L_background = indirect_background(kg, &state, &ray);
path_radiance_accum_background(&L, throughput, L_background, state.bounce);
#endif
@@ -1205,7 +1199,7 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
/* setup shading */
ShaderData sd;
- shader_setup_from_ray(kg, &sd, &isect, &ray, state.bounce);
+ shader_setup_from_ray(kg, &sd, &isect, &ray, state.bounce, state.transparent_bounce);
shader_eval_surface(kg, &sd, 0.0f, state.flag, SHADER_CONTEXT_MAIN);
shader_merge_closures(&sd);
@@ -1319,21 +1313,21 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
/* do subsurface scatter step with copy of shader data, this will
* replace the BSSRDF with a diffuse BSDF closure */
for(int j = 0; j < num_samples; j++) {
- ShaderData bssrdf_sd[BSSRDF_MAX_HITS];
- float bssrdf_u, bssrdf_v;
- path_branched_rng_2D(kg, &bssrdf_rng, &state, j, num_samples, PRNG_BSDF_U, &bssrdf_u, &bssrdf_v);
- int num_hits = subsurface_scatter_multi_step(kg, &sd, bssrdf_sd, state.flag, sc, &lcg_state, bssrdf_u, bssrdf_v, true);
+ ShaderData bssrdf_sd[BSSRDF_MAX_HITS];
+ float bssrdf_u, bssrdf_v;
+ path_branched_rng_2D(kg, &bssrdf_rng, &state, j, num_samples, PRNG_BSDF_U, &bssrdf_u, &bssrdf_v);
+ int num_hits = subsurface_scatter_multi_step(kg, &sd, bssrdf_sd, state.flag, sc, &lcg_state, bssrdf_u, bssrdf_v, true);
- /* compute lighting with the BSDF closure */
- for(int hit = 0; hit < num_hits; hit++) {
- PathState hit_state = state;
+ /* compute lighting with the BSDF closure */
+ for(int hit = 0; hit < num_hits; hit++) {
+ PathState hit_state = state;
- path_state_branch(&hit_state, j, num_samples);
+ path_state_branch(&hit_state, j, num_samples);
- kernel_branched_path_integrate_lighting(kg, rng,
- &bssrdf_sd[hit], throughput, num_samples_inv,
- &hit_state, &L, buffer);
- }
+ kernel_branched_path_integrate_lighting(kg, rng,
+ &bssrdf_sd[hit], throughput, num_samples_inv,
+ &hit_state, &L, buffer);
+ }
}
state.flag &= ~PATH_RAY_BSSRDF_ANCESTOR;
diff --git a/intern/cycles/kernel/kernel_projection.h b/intern/cycles/kernel/kernel_projection.h
index e2108604bc8..6744471d659 100644
--- a/intern/cycles/kernel/kernel_projection.h
+++ b/intern/cycles/kernel/kernel_projection.h
@@ -39,7 +39,7 @@ CCL_NAMESPACE_BEGIN
ccl_device float2 direction_to_spherical(float3 dir)
{
- float theta = acosf(dir.z);
+ float theta = safe_acosf(dir.z);
float phi = atan2f(dir.x, dir.y);
return make_float2(theta, phi);
@@ -97,7 +97,7 @@ ccl_device float3 fisheye_to_direction(float u, float v, float fov)
if(r > 1.0f)
return make_float3(0.0f, 0.0f, 0.0f);
- float phi = acosf((r != 0.0f)? u/r: 0.0f);
+ float phi = safe_acosf((r != 0.0f)? u/r: 0.0f);
float theta = r * fov * 0.5f;
if(v < 0.0f) phi = -phi;
@@ -111,7 +111,7 @@ ccl_device float3 fisheye_to_direction(float u, float v, float fov)
ccl_device float2 direction_to_fisheye_equisolid(float3 dir, float lens, float width, float height)
{
- float theta = acosf(dir.x);
+ float theta = safe_acosf(dir.x);
float r = 2.0f * lens * sinf(theta * 0.5f);
float phi = atan2f(dir.z, dir.y);
@@ -132,7 +132,7 @@ ccl_device float3 fisheye_equisolid_to_direction(float u, float v, float lens, f
if(r > rmax)
return make_float3(0.0f, 0.0f, 0.0f);
- float phi = acosf((r != 0.0f)? u/r: 0.0f);
+ float phi = safe_acosf((r != 0.0f)? u/r: 0.0f);
float theta = 2.0f * asinf(r/(2.0f * lens));
if(v < 0.0f) phi = -phi;
diff --git a/intern/cycles/kernel/kernel_shader.h b/intern/cycles/kernel/kernel_shader.h
index 7aa9cfbcccc..58cec090410 100644
--- a/intern/cycles/kernel/kernel_shader.h
+++ b/intern/cycles/kernel/kernel_shader.h
@@ -39,7 +39,7 @@ ccl_device void shader_setup_object_transforms(KernelGlobals *kg, ShaderData *sd
{
if(sd->flag & SD_OBJECT_MOTION) {
sd->ob_tfm = object_fetch_transform_motion(kg, sd->object, time);
- sd->ob_itfm= transform_quick_inverse(sd->ob_tfm);
+ sd->ob_itfm = transform_quick_inverse(sd->ob_tfm);
}
else {
sd->ob_tfm = object_fetch_transform(kg, sd->object, OBJECT_TRANSFORM);
@@ -49,7 +49,7 @@ ccl_device void shader_setup_object_transforms(KernelGlobals *kg, ShaderData *sd
#endif
ccl_device void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd,
- const Intersection *isect, const Ray *ray, int bounce)
+ const Intersection *isect, const Ray *ray, int bounce, int transparent_bounce)
{
#ifdef __INSTANCING__
sd->object = (isect->object == PRIM_NONE)? kernel_tex_fetch(__prim_object, isect->prim): isect->object;
@@ -67,6 +67,7 @@ ccl_device void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd,
sd->prim = kernel_tex_fetch(__prim_index, isect->prim);
sd->ray_length = isect->t;
sd->ray_depth = bounce;
+ sd->transparent_depth = transparent_bounce;
#ifdef __UV__
sd->u = isect->u;
@@ -228,7 +229,7 @@ ccl_device_inline void shader_setup_from_subsurface(KernelGlobals *kg, ShaderDat
ccl_device void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd,
const float3 P, const float3 Ng, const float3 I,
- int shader, int object, int prim, float u, float v, float t, float time, int bounce)
+ int shader, int object, int prim, float u, float v, float t, float time, int bounce, int transparent_bounce)
{
/* vectors */
sd->P = P;
@@ -250,6 +251,7 @@ ccl_device void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd,
#endif
sd->ray_length = t;
sd->ray_depth = bounce;
+ sd->transparent_depth = transparent_bounce;
/* detect instancing, for non-instanced the object index is -object-1 */
#ifdef __INSTANCING__
@@ -347,12 +349,12 @@ ccl_device void shader_setup_from_displace(KernelGlobals *kg, ShaderData *sd,
/* watch out: no instance transform currently */
- shader_setup_from_sample(kg, sd, P, Ng, I, shader, object, prim, u, v, 0.0f, TIME_INVALID, 0);
+ shader_setup_from_sample(kg, sd, P, Ng, I, shader, object, prim, u, v, 0.0f, TIME_INVALID, 0, 0);
}
/* ShaderData setup from ray into background */
-ccl_device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderData *sd, const Ray *ray, int bounce)
+ccl_device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderData *sd, const Ray *ray, int bounce, int transparent_bounce)
{
/* vectors */
sd->P = ray->D;
@@ -366,6 +368,7 @@ ccl_device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderDat
#endif
sd->ray_length = 0.0f;
sd->ray_depth = bounce;
+ sd->transparent_depth = transparent_bounce;
#ifdef __INSTANCING__
sd->object = PRIM_NONE;
@@ -395,7 +398,7 @@ ccl_device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderDat
/* ShaderData setup from point inside volume */
-ccl_device_inline void shader_setup_from_volume(KernelGlobals *kg, ShaderData *sd, const Ray *ray, int bounce)
+ccl_device_inline void shader_setup_from_volume(KernelGlobals *kg, ShaderData *sd, const Ray *ray, int bounce, int transparent_bounce)
{
/* vectors */
sd->P = ray->P;
@@ -409,6 +412,7 @@ ccl_device_inline void shader_setup_from_volume(KernelGlobals *kg, ShaderData *s
#endif
sd->ray_length = 0.0f; /* todo: can we set this to some useful value? */
sd->ray_depth = bounce;
+ sd->transparent_depth = transparent_bounce;
#ifdef __INSTANCING__
sd->object = PRIM_NONE; /* todo: fill this for texture coordinates */
@@ -486,8 +490,6 @@ ccl_device void shader_merge_closures(ShaderData *sd)
/* BSDF */
-#ifdef __MULTI_CLOSURE__
-
ccl_device_inline void _shader_bsdf_multi_eval(KernelGlobals *kg, const ShaderData *sd, const float3 omega_in, float *pdf,
int skip_bsdf, BsdfEval *result_eval, float sum_pdf, float sum_sample_weight)
{
@@ -515,28 +517,18 @@ ccl_device_inline void _shader_bsdf_multi_eval(KernelGlobals *kg, const ShaderDa
*pdf = (sum_sample_weight > 0.0f)? sum_pdf/sum_sample_weight: 0.0f;
}
-#endif
-
ccl_device void shader_bsdf_eval(KernelGlobals *kg, const ShaderData *sd,
const float3 omega_in, BsdfEval *eval, float *pdf)
{
-#ifdef __MULTI_CLOSURE__
bsdf_eval_init(eval, NBUILTIN_CLOSURES, make_float3(0.0f, 0.0f, 0.0f), kernel_data.film.use_light_pass);
_shader_bsdf_multi_eval(kg, sd, omega_in, pdf, -1, eval, 0.0f, 0.0f);
-#else
- const ShaderClosure *sc = &sd->closure;
-
- *pdf = 0.0f;
- *eval = bsdf_eval(kg, sd, sc, omega_in, pdf)*sc->weight;
-#endif
}
ccl_device int shader_bsdf_sample(KernelGlobals *kg, const ShaderData *sd,
float randu, float randv, BsdfEval *bsdf_eval,
float3 *omega_in, differential3 *domega_in, float *pdf)
{
-#ifdef __MULTI_CLOSURE__
int sampled = 0;
if(sd->num_closure > 1) {
@@ -587,13 +579,6 @@ ccl_device int shader_bsdf_sample(KernelGlobals *kg, const ShaderData *sd,
}
return label;
-#else
- /* sample the single closure that we picked */
- *pdf = 0.0f;
- int label = bsdf_sample(kg, sd, &sd->closure, randu, randv, bsdf_eval, omega_in, domega_in, pdf);
- *bsdf_eval *= sd->closure.weight;
- return label;
-#endif
}
ccl_device int shader_bsdf_sample_closure(KernelGlobals *kg, const ShaderData *sd,
@@ -614,21 +599,16 @@ ccl_device int shader_bsdf_sample_closure(KernelGlobals *kg, const ShaderData *s
ccl_device void shader_bsdf_blur(KernelGlobals *kg, ShaderData *sd, float roughness)
{
-#ifdef __MULTI_CLOSURE__
for(int i = 0; i< sd->num_closure; i++) {
ShaderClosure *sc = &sd->closure[i];
if(CLOSURE_IS_BSDF(sc->type))
bsdf_blur(kg, sc, roughness);
}
-#else
- bsdf_blur(kg, &sd->closure, roughness);
-#endif
}
ccl_device float3 shader_bsdf_transparency(KernelGlobals *kg, ShaderData *sd)
{
-#ifdef __MULTI_CLOSURE__
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
for(int i = 0; i< sd->num_closure; i++) {
@@ -639,12 +619,6 @@ ccl_device float3 shader_bsdf_transparency(KernelGlobals *kg, ShaderData *sd)
}
return eval;
-#else
- if(sd->closure.type == CLOSURE_BSDF_TRANSPARENT_ID)
- return sd->closure.weight;
- else
- return make_float3(0.0f, 0.0f, 0.0f);
-#endif
}
ccl_device float3 shader_bsdf_alpha(KernelGlobals *kg, ShaderData *sd)
@@ -659,7 +633,6 @@ ccl_device float3 shader_bsdf_alpha(KernelGlobals *kg, ShaderData *sd)
ccl_device float3 shader_bsdf_diffuse(KernelGlobals *kg, ShaderData *sd)
{
-#ifdef __MULTI_CLOSURE__
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
for(int i = 0; i< sd->num_closure; i++) {
@@ -670,17 +643,10 @@ ccl_device float3 shader_bsdf_diffuse(KernelGlobals *kg, ShaderData *sd)
}
return eval;
-#else
- if(CLOSURE_IS_BSDF_DIFFUSE(sd->closure.type))
- return sd->closure.weight;
- else
- return make_float3(0.0f, 0.0f, 0.0f);
-#endif
}
ccl_device float3 shader_bsdf_glossy(KernelGlobals *kg, ShaderData *sd)
{
-#ifdef __MULTI_CLOSURE__
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
for(int i = 0; i< sd->num_closure; i++) {
@@ -691,17 +657,10 @@ ccl_device float3 shader_bsdf_glossy(KernelGlobals *kg, ShaderData *sd)
}
return eval;
-#else
- if(CLOSURE_IS_BSDF_GLOSSY(sd->closure.type))
- return sd->closure.weight;
- else
- return make_float3(0.0f, 0.0f, 0.0f);
-#endif
}
ccl_device float3 shader_bsdf_transmission(KernelGlobals *kg, ShaderData *sd)
{
-#ifdef __MULTI_CLOSURE__
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
for(int i = 0; i< sd->num_closure; i++) {
@@ -712,17 +671,10 @@ ccl_device float3 shader_bsdf_transmission(KernelGlobals *kg, ShaderData *sd)
}
return eval;
-#else
- if(CLOSURE_IS_BSDF_TRANSMISSION(sd->closure.type))
- return sd->closure.weight;
- else
- return make_float3(0.0f, 0.0f, 0.0f);
-#endif
}
ccl_device float3 shader_bsdf_subsurface(KernelGlobals *kg, ShaderData *sd)
{
-#ifdef __MULTI_CLOSURE__
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
for(int i = 0; i< sd->num_closure; i++) {
@@ -733,17 +685,10 @@ ccl_device float3 shader_bsdf_subsurface(KernelGlobals *kg, ShaderData *sd)
}
return eval;
-#else
- if(CLOSURE_IS_BSSRDF(sd->closure.type))
- return sd->closure.weight;
- else
- return make_float3(0.0f, 0.0f, 0.0f);
-#endif
}
ccl_device float3 shader_bsdf_ao(KernelGlobals *kg, ShaderData *sd, float ao_factor, float3 *N_)
{
-#ifdef __MULTI_CLOSURE__
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
float3 N = make_float3(0.0f, 0.0f, 0.0f);
@@ -767,21 +712,10 @@ ccl_device float3 shader_bsdf_ao(KernelGlobals *kg, ShaderData *sd, float ao_fac
*N_ = N;
return eval;
-#else
- *N_ = sd->N;
-
- if(CLOSURE_IS_BSDF_DIFFUSE(sd->closure.type))
- return sd->closure.weight*ao_factor;
- else if(CLOSURE_IS_AMBIENT_OCCLUSION(sd->closure.type))
- return sd->closure.weight;
- else
- return make_float3(0.0f, 0.0f, 0.0f);
-#endif
}
ccl_device float3 shader_bssrdf_sum(ShaderData *sd, float3 *N_, float *texture_blur_)
{
-#ifdef __MULTI_CLOSURE__
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
float3 N = make_float3(0.0f, 0.0f, 0.0f);
float texture_blur = 0.0f, weight_sum = 0.0f;
@@ -806,20 +740,6 @@ ccl_device float3 shader_bssrdf_sum(ShaderData *sd, float3 *N_, float *texture_b
*texture_blur_ = texture_blur/weight_sum;
return eval;
-#else
- if(CLOSURE_IS_BSSRDF(sd->closure.type)) {
- if(N_) *N_ = sd->closure.N;
- if(texture_blur_) *texture_blur_ = sd->closure.data1;
-
- return sd->closure.weight;
- }
- else {
- if(N_) *N_ = sd->N;
- if(texture_blur_) *texture_blur_ = 0.0f;
-
- return make_float3(0.0f, 0.0f, 0.0f);
- }
-#endif
}
/* Emission */
@@ -832,7 +752,6 @@ ccl_device float3 emissive_eval(KernelGlobals *kg, ShaderData *sd, ShaderClosure
ccl_device float3 shader_emissive_eval(KernelGlobals *kg, ShaderData *sd)
{
float3 eval;
-#ifdef __MULTI_CLOSURE__
eval = make_float3(0.0f, 0.0f, 0.0f);
for(int i = 0; i < sd->num_closure; i++) {
@@ -841,9 +760,6 @@ ccl_device float3 shader_emissive_eval(KernelGlobals *kg, ShaderData *sd)
if(CLOSURE_IS_EMISSION(sc->type))
eval += emissive_eval(kg, sd, sc)*sc->weight;
}
-#else
- eval = emissive_eval(kg, sd, &sd->closure)*sd->closure.weight;
-#endif
return eval;
}
@@ -852,7 +768,6 @@ ccl_device float3 shader_emissive_eval(KernelGlobals *kg, ShaderData *sd)
ccl_device float3 shader_holdout_eval(KernelGlobals *kg, ShaderData *sd)
{
-#ifdef __MULTI_CLOSURE__
float3 weight = make_float3(0.0f, 0.0f, 0.0f);
for(int i = 0; i < sd->num_closure; i++) {
@@ -863,12 +778,6 @@ ccl_device float3 shader_holdout_eval(KernelGlobals *kg, ShaderData *sd)
}
return weight;
-#else
- if(sd->closure.type == CLOSURE_HOLDOUT_ID)
- return make_float3(1.0f, 1.0f, 1.0f);
-
- return make_float3(0.0f, 0.0f, 0.0f);
-#endif
}
/* Surface Evaluation */
@@ -876,12 +785,8 @@ ccl_device float3 shader_holdout_eval(KernelGlobals *kg, ShaderData *sd)
ccl_device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd,
float randb, int path_flag, ShaderContext ctx)
{
-#ifdef __MULTI_CLOSURE__
sd->num_closure = 0;
sd->randb_closure = randb;
-#else
- sd->closure.type = NBUILTIN_CLOSURES;
-#endif
#ifdef __OSL__
if(kg->osl)
@@ -890,7 +795,7 @@ ccl_device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd,
#endif
{
#ifdef __SVM__
- svm_eval_nodes(kg, sd, SHADER_TYPE_SURFACE, randb, path_flag);
+ svm_eval_nodes(kg, sd, SHADER_TYPE_SURFACE, path_flag);
#else
sd->closure.weight = make_float3(0.8f, 0.8f, 0.8f);
sd->closure.N = sd->N;
@@ -903,12 +808,8 @@ ccl_device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd,
ccl_device float3 shader_eval_background(KernelGlobals *kg, ShaderData *sd, int path_flag, ShaderContext ctx)
{
-#ifdef __MULTI_CLOSURE__
sd->num_closure = 0;
sd->randb_closure = 0.0f;
-#else
- sd->closure.type = NBUILTIN_CLOSURES;
-#endif
#ifdef __OSL__
if(kg->osl) {
@@ -919,9 +820,8 @@ ccl_device float3 shader_eval_background(KernelGlobals *kg, ShaderData *sd, int
{
#ifdef __SVM__
- svm_eval_nodes(kg, sd, SHADER_TYPE_SURFACE, 0.0f, path_flag);
+ svm_eval_nodes(kg, sd, SHADER_TYPE_SURFACE, path_flag);
-#ifdef __MULTI_CLOSURE__
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
for(int i = 0; i< sd->num_closure; i++) {
@@ -933,13 +833,6 @@ ccl_device float3 shader_eval_background(KernelGlobals *kg, ShaderData *sd, int
return eval;
#else
- if(sd->closure.type == CLOSURE_BACKGROUND_ID)
- return sd->closure.weight;
- else
- return make_float3(0.0f, 0.0f, 0.0f);
-#endif
-
-#else
return make_float3(0.8f, 0.8f, 0.8f);
#endif
}
@@ -1058,11 +951,7 @@ ccl_device void shader_eval_volume(KernelGlobals *kg, ShaderData *sd,
{
/* reset closures once at the start, we will be accumulating the closures
* for all volumes in the stack into a single array of closures */
-#ifdef __MULTI_CLOSURE__
sd->num_closure = 0;
-#else
- sd->closure.type = NBUILTIN_CLOSURES;
-#endif
sd->flag = 0;
for(int i = 0; stack[i].shader != SHADER_NONE; i++) {
@@ -1093,7 +982,7 @@ ccl_device void shader_eval_volume(KernelGlobals *kg, ShaderData *sd,
else
#endif
{
- svm_eval_nodes(kg, sd, SHADER_TYPE_VOLUME, 0.0f, path_flag);
+ svm_eval_nodes(kg, sd, SHADER_TYPE_VOLUME, path_flag);
}
#endif
@@ -1109,12 +998,8 @@ ccl_device void shader_eval_volume(KernelGlobals *kg, ShaderData *sd,
ccl_device void shader_eval_displacement(KernelGlobals *kg, ShaderData *sd, ShaderContext ctx)
{
-#ifdef __MULTI_CLOSURE__
sd->num_closure = 0;
sd->randb_closure = 0.0f;
-#else
- sd->closure.type = NBUILTIN_CLOSURES;
-#endif
/* this will modify sd->P */
#ifdef __SVM__
@@ -1124,7 +1009,7 @@ ccl_device void shader_eval_displacement(KernelGlobals *kg, ShaderData *sd, Shad
else
#endif
{
- svm_eval_nodes(kg, sd, SHADER_TYPE_DISPLACEMENT, 0.0f, 0);
+ svm_eval_nodes(kg, sd, SHADER_TYPE_DISPLACEMENT, 0);
}
#endif
}
diff --git a/intern/cycles/kernel/kernel_shadow.h b/intern/cycles/kernel/kernel_shadow.h
index 971dca38fc5..ab7524c411a 100644
--- a/intern/cycles/kernel/kernel_shadow.h
+++ b/intern/cycles/kernel/kernel_shadow.h
@@ -16,6 +16,178 @@
CCL_NAMESPACE_BEGIN
+#ifdef __SHADOW_RECORD_ALL__
+
+/* Shadow function to compute how much light is blocked, CPU variation.
+ *
+ * We trace a single ray. If it hits any opaque surface, or more than a given
+ * number of transparent surfaces is hit, then we consider the geometry to be
+ * entirely blocked. If not, all transparent surfaces will be recorded and we
+ * will shade them one by one to determine how much light is blocked. This all
+ * happens in one scene intersection function.
+ *
+ * Recording all hits works well in some cases but may be slower in others. If
+ * we have many semi-transparent hairs, one intersection may be faster because
+ * you'd be reinteresecting the same hairs a lot with each step otherwise. If
+ * however there is mostly binary transparency then we may be recording many
+ * unnecessary intersections when one of the first surfaces blocks all light.
+ *
+ * From tests in real scenes it seems the performance loss is either minimal,
+ * or there is a performance increase anyway due to avoiding the need to send
+ * two rays with transparent shadows.
+ *
+ * This is CPU only because of qsort, and malloc or high stack space usage to
+ * record all these intersections. */
+
+ccl_device_noinline int shadow_intersections_compare(const void *a, const void *b)
+{
+ const Intersection *isect_a = (const Intersection*)a;
+ const Intersection *isect_b = (const Intersection*)b;
+
+ if(isect_a->t < isect_b->t)
+ return -1;
+ else if(isect_a->t > isect_b->t)
+ return 1;
+ else
+ return 0;
+}
+
+#define STACK_MAX_HITS 64
+
+ccl_device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *ray, float3 *shadow)
+{
+ *shadow = make_float3(1.0f, 1.0f, 1.0f);
+
+ if(ray->t == 0.0f)
+ return false;
+
+ bool blocked;
+
+ if(kernel_data.integrator.transparent_shadows) {
+ /* intersect to find an opaque surface, or record all transparent surface hits */
+ Intersection hits_stack[STACK_MAX_HITS];
+ Intersection *hits;
+ uint max_hits = kernel_data.integrator.transparent_max_bounce - state->transparent_bounce - 1;
+
+ /* prefer to use stack but use dynamic allocation if too deep max hits
+ * we need max_hits + 1 storage space due to the logic in
+ * scene_intersect_shadow_all which will first store and then check if
+ * the limit is exceeded */
+ if(max_hits + 1 <= STACK_MAX_HITS)
+ hits = hits_stack;
+ else
+ hits = (Intersection*)malloc(sizeof(Intersection)*(max_hits + 1));
+
+ uint num_hits;
+ blocked = scene_intersect_shadow_all(kg, ray, hits, max_hits, &num_hits);
+
+ /* if no opaque surface found but we did find transparent hits, shade them */
+ if(!blocked && num_hits > 0) {
+ float3 throughput = make_float3(1.0f, 1.0f, 1.0f);
+ float3 Pend = ray->P + ray->D*ray->t;
+ float last_t = 0.0f;
+ int bounce = state->transparent_bounce;
+ Intersection *isect = hits;
+#ifdef __VOLUME__
+ PathState ps = *state;
+#endif
+
+ qsort(hits, num_hits, sizeof(Intersection), shadow_intersections_compare);
+
+ for(int hit = 0; hit < num_hits; hit++, isect++) {
+ /* adjust intersection distance for moving ray forward */
+ float new_t = isect->t;
+ isect->t -= last_t;
+
+ /* skip hit if we did not move forward, step by step raytracing
+ * would have skipped it as well then */
+ if(last_t == new_t)
+ continue;
+
+ last_t = new_t;
+
+#ifdef __VOLUME__
+ /* attenuation between last surface and next surface */
+ if(ps.volume_stack[0].shader != SHADER_NONE) {
+ Ray segment_ray = *ray;
+ segment_ray.t = isect->t;
+ kernel_volume_shadow(kg, &ps, &segment_ray, &throughput);
+ }
+#endif
+
+ /* setup shader data at surface */
+ ShaderData sd;
+ shader_setup_from_ray(kg, &sd, isect, ray, state->bounce+1, bounce);
+
+ /* attenuation from transparent surface */
+ if(!(sd.flag & SD_HAS_ONLY_VOLUME)) {
+ shader_eval_surface(kg, &sd, 0.0f, PATH_RAY_SHADOW, SHADER_CONTEXT_SHADOW);
+ throughput *= shader_bsdf_transparency(kg, &sd);
+ }
+
+ /* stop if all light is blocked */
+ if(is_zero(throughput)) {
+ /* free dynamic storage */
+ if(hits != hits_stack)
+ free(hits);
+ return true;
+ }
+
+ /* move ray forward */
+ ray->P = sd.P;
+ if(ray->t != FLT_MAX)
+ ray->D = normalize_len(Pend - ray->P, &ray->t);
+
+#ifdef __VOLUME__
+ /* exit/enter volume */
+ kernel_volume_stack_enter_exit(kg, &sd, ps.volume_stack);
+#endif
+
+ bounce++;
+ }
+
+#ifdef __VOLUME__
+ /* attenuation for last line segment towards light */
+ if(ps.volume_stack[0].shader != SHADER_NONE)
+ kernel_volume_shadow(kg, &ps, ray, &throughput);
+#endif
+
+ *shadow *= throughput;
+ }
+
+ /* free dynamic storage */
+ if(hits != hits_stack)
+ free(hits);
+ }
+ else {
+ Intersection isect;
+#ifdef __HAIR__
+ blocked = scene_intersect(kg, ray, PATH_RAY_SHADOW_OPAQUE, &isect, NULL, 0.0f, 0.0f);
+#else
+ blocked = scene_intersect(kg, ray, PATH_RAY_SHADOW_OPAQUE, &isect);
+#endif
+ }
+
+#ifdef __VOLUME__
+ if(!blocked && state->volume_stack[0].shader != SHADER_NONE) {
+ /* apply attenuation from current volume shader */
+ kernel_volume_shadow(kg, state, ray, shadow);
+ }
+#endif
+
+ return blocked;
+}
+
+#else
+
+/* Shadow function to compute how much light is blocked, GPU variation.
+ *
+ * Here we raytrace from one transparent surface to the next step by step.
+ * To minimize overhead in cases where we don't need transparent shadows, we
+ * first trace a regular shadow ray. We check if the hit primitive was
+ * potentially transparent, and only in that case start marching. this gives
+ * one extra ray cast for the cases were we do want transparency. */
+
ccl_device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *ray, float3 *shadow)
{
*shadow = make_float3(1.0f, 1.0f, 1.0f);
@@ -25,21 +197,13 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *
Intersection isect;
#ifdef __HAIR__
- bool result = scene_intersect(kg, ray, PATH_RAY_SHADOW_OPAQUE, &isect, NULL, 0.0f, 0.0f);
+ bool blocked = scene_intersect(kg, ray, PATH_RAY_SHADOW_OPAQUE, &isect, NULL, 0.0f, 0.0f);
#else
- bool result = scene_intersect(kg, ray, PATH_RAY_SHADOW_OPAQUE, &isect);
+ bool blocked = scene_intersect(kg, ray, PATH_RAY_SHADOW_OPAQUE, &isect);
#endif
#ifdef __TRANSPARENT_SHADOWS__
- if(result && kernel_data.integrator.transparent_shadows) {
- /* transparent shadows work in such a way to try to minimize overhead
- * in cases where we don't need them. after a regular shadow ray is
- * cast we check if the hit primitive was potentially transparent, and
- * only in that case start marching. this gives on extra ray cast for
- * the cases were we do want transparency.
- *
- * also note that for this to work correct, multi close sampling must
- * be used, since we don't pass a random number to shader_eval_surface */
+ if(blocked && kernel_data.integrator.transparent_shadows) {
if(shader_transparent_shadow(kg, &isect)) {
float3 throughput = make_float3(1.0f, 1.0f, 1.0f);
float3 Pend = ray->P + ray->D*ray->t;
@@ -49,27 +213,15 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *
#endif
for(;;) {
- if(bounce >= kernel_data.integrator.transparent_max_bounce) {
+ if(bounce >= kernel_data.integrator.transparent_max_bounce)
return true;
- }
- else if(bounce >= kernel_data.integrator.transparent_min_bounce) {
- /* todo: get random number somewhere for probabilistic terminate */
-#if 0
- float probability = average(throughput);
- float terminate = 0.0f;
-
- if(terminate >= probability)
- return true;
-
- throughput /= probability;
-#endif
- }
#ifdef __HAIR__
- if(!scene_intersect(kg, ray, PATH_RAY_SHADOW_TRANSPARENT, &isect, NULL, 0.0f, 0.0f)) {
+ if(!scene_intersect(kg, ray, PATH_RAY_SHADOW_TRANSPARENT, &isect, NULL, 0.0f, 0.0f))
#else
- if(!scene_intersect(kg, ray, PATH_RAY_SHADOW_TRANSPARENT, &isect)) {
+ if(!scene_intersect(kg, ray, PATH_RAY_SHADOW_TRANSPARENT, &isect))
#endif
+ {
#ifdef __VOLUME__
/* attenuation for last line segment towards light */
@@ -78,6 +230,7 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *
#endif
*shadow *= throughput;
+
return false;
}
@@ -95,7 +248,7 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *
/* setup shader data at surface */
ShaderData sd;
- shader_setup_from_ray(kg, &sd, &isect, ray, state->bounce+1);
+ shader_setup_from_ray(kg, &sd, &isect, ray, state->bounce+1, bounce);
/* attenuation from transparent surface */
if(!(sd.flag & SD_HAS_ONLY_VOLUME)) {
@@ -103,6 +256,9 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *
throughput *= shader_bsdf_transparency(kg, &sd);
}
+ if(is_zero(throughput))
+ return true;
+
/* move ray forward */
ray->P = ray_offset(sd.P, -sd.Ng);
if(ray->t != FLT_MAX)
@@ -118,15 +274,17 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *
}
}
#ifdef __VOLUME__
- else if(!result && state->volume_stack[0].shader != SHADER_NONE) {
+ else if(!blocked && state->volume_stack[0].shader != SHADER_NONE) {
/* apply attenuation from current volume shader */
kernel_volume_shadow(kg, state, ray, shadow);
}
#endif
#endif
- return result;
+ return blocked;
}
+#endif
+
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/kernel_sse2.cpp b/intern/cycles/kernel/kernel_sse2.cpp
index 6a2a7804146..2d5f6091908 100644
--- a/intern/cycles/kernel/kernel_sse2.cpp
+++ b/intern/cycles/kernel/kernel_sse2.cpp
@@ -75,6 +75,6 @@ CCL_NAMESPACE_END
/* needed for some linkers in combination with scons making empty compilation unit in a library */
void __dummy_function_cycles_sse2(void);
-void __dummy_function_cycles_sse2(void){}
+void __dummy_function_cycles_sse2(void) {}
#endif
diff --git a/intern/cycles/kernel/kernel_sse3.cpp b/intern/cycles/kernel/kernel_sse3.cpp
index 9d0abb93cc6..1062fd0c990 100644
--- a/intern/cycles/kernel/kernel_sse3.cpp
+++ b/intern/cycles/kernel/kernel_sse3.cpp
@@ -76,6 +76,6 @@ CCL_NAMESPACE_END
/* needed for some linkers in combination with scons making empty compilation unit in a library */
void __dummy_function_cycles_sse3(void);
-void __dummy_function_cycles_sse3(void){}
+void __dummy_function_cycles_sse3(void) {}
#endif
diff --git a/intern/cycles/kernel/kernel_sse41.cpp b/intern/cycles/kernel/kernel_sse41.cpp
index bc20de0ec20..ba3b4887650 100644
--- a/intern/cycles/kernel/kernel_sse41.cpp
+++ b/intern/cycles/kernel/kernel_sse41.cpp
@@ -77,6 +77,6 @@ CCL_NAMESPACE_END
/* needed for some linkers in combination with scons making empty compilation unit in a library */
void __dummy_function_cycles_sse41(void);
-void __dummy_function_cycles_sse41(void){}
+void __dummy_function_cycles_sse41(void) {}
#endif
diff --git a/intern/cycles/kernel/kernel_textures.h b/intern/cycles/kernel/kernel_textures.h
index c8734d67c3b..b07075c6c95 100644
--- a/intern/cycles/kernel/kernel_textures.h
+++ b/intern/cycles/kernel/kernel_textures.h
@@ -174,6 +174,61 @@ KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_097)
KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_098)
KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_099)
+/* Kepler and above */
+#if defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 300)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_100)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_101)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_102)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_103)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_104)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_105)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_106)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_107)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_108)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_109)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_110)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_111)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_112)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_113)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_114)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_115)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_116)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_117)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_118)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_119)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_120)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_121)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_122)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_123)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_124)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_125)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_126)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_127)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_128)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_129)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_130)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_131)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_132)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_133)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_134)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_135)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_136)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_137)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_138)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_139)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_140)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_141)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_142)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_143)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_144)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_145)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_146)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_147)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_148)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_149)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_150)
+#endif
+
/* packed image (opencl) */
KERNEL_TEX(uchar4, texture_uchar4, __tex_image_packed)
KERNEL_TEX(uint4, texture_uint4, __tex_image_packed_info)
diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h
index 1045b0add73..11445aa1c93 100644
--- a/intern/cycles/kernel/kernel_types.h
+++ b/intern/cycles/kernel/kernel_types.h
@@ -64,13 +64,13 @@ CCL_NAMESPACE_BEGIN
#define __SUBSURFACE__
#define __CMJ__
#define __VOLUME__
+#define __SHADOW_RECORD_ALL__
#endif
#ifdef __KERNEL_CUDA__
#define __KERNEL_SHADING__
#define __KERNEL_ADV_SHADING__
-/* Disabled for now, compile errors */
-//#define __BRANCHED_PATH__
+#define __BRANCHED_PATH__
/* Experimental on GPU */
//#define __VOLUME__
@@ -92,26 +92,24 @@ CCL_NAMESPACE_BEGIN
#endif
#ifdef __KERNEL_OPENCL_AMD__
-#define __SVM__
-#define __EMISSION__
-#define __IMAGE_TEXTURES__
-#define __PROCEDURAL_TEXTURES__
-#define __EXTRA_NODES__
-#define __HOLDOUT__
-#define __NORMAL_MAP__
-//#define __BACKGROUND_MIS__
-//#define __LAMP_MIS__
-//#define __AO__
-//#define __ANISOTROPIC__
+#define __CL_USE_NATIVE__
+#define __KERNEL_SHADING__
+//__KERNEL_ADV_SHADING__
+#define __MULTI_CLOSURE__
+#define __TRANSPARENT_SHADOWS__
+#define __PASSES__
+#define __BACKGROUND_MIS__
+#define __LAMP_MIS__
+#define __AO__
+#define __ANISOTROPIC__
//#define __CAMERA_MOTION__
//#define __OBJECT_MOTION__
//#define __HAIR__
-//#define __MULTI_CLOSURE__
-//#define __TRANSPARENT_SHADOWS__
-//#define __PASSES__
+//end __KERNEL_ADV_SHADING__
#endif
#ifdef __KERNEL_OPENCL_INTEL_CPU__
+#define __CL_USE_NATIVE__
#define __KERNEL_SHADING__
#define __KERNEL_ADV_SHADING__
#endif
@@ -154,12 +152,6 @@ CCL_NAMESPACE_BEGIN
#define __HAIR__
#endif
-/* Sanity check */
-
-#if defined(__KERNEL_OPENCL_NEED_ADVANCED_SHADING__) && !defined(__MULTI_CLOSURE__)
-#error "OpenCL: mismatch between advanced shading flags in device_opencl.cpp and kernel_types.h"
-#endif
-
/* Random Numbers */
typedef uint RNG;
@@ -168,7 +160,35 @@ typedef uint RNG;
typedef enum ShaderEvalType {
SHADER_EVAL_DISPLACE,
- SHADER_EVAL_BACKGROUND
+ SHADER_EVAL_BACKGROUND,
+ /* bake types */
+ SHADER_EVAL_BAKE, /* no real shade, it's used in the code to
+ * differentiate the type of shader eval from the above
+ */
+ /* data passes */
+ SHADER_EVAL_NORMAL,
+ SHADER_EVAL_UV,
+ SHADER_EVAL_DIFFUSE_COLOR,
+ SHADER_EVAL_GLOSSY_COLOR,
+ SHADER_EVAL_TRANSMISSION_COLOR,
+ SHADER_EVAL_SUBSURFACE_COLOR,
+ SHADER_EVAL_EMISSION,
+
+ /* light passes */
+ SHADER_EVAL_AO,
+ SHADER_EVAL_COMBINED,
+ SHADER_EVAL_SHADOW,
+ SHADER_EVAL_DIFFUSE_DIRECT,
+ SHADER_EVAL_GLOSSY_DIRECT,
+ SHADER_EVAL_TRANSMISSION_DIRECT,
+ SHADER_EVAL_SUBSURFACE_DIRECT,
+ SHADER_EVAL_DIFFUSE_INDIRECT,
+ SHADER_EVAL_GLOSSY_INDIRECT,
+ SHADER_EVAL_TRANSMISSION_INDIRECT,
+ SHADER_EVAL_SUBSURFACE_INDIRECT,
+
+ /* extra */
+ SHADER_EVAL_ENVIRONMENT,
} ShaderEvalType;
/* Path Tracing
@@ -184,10 +204,8 @@ enum PathTraceDimension {
PRNG_UNUSED_0 = 5,
PRNG_UNUSED_1 = 6, /* for some reason (6, 7) is a bad sobol pattern */
PRNG_UNUSED_2 = 7, /* with a low number of samples (< 64) */
- PRNG_BASE_NUM = 8,
-#else
- PRNG_BASE_NUM = 4,
#endif
+ PRNG_BASE_NUM = 8,
PRNG_BSDF_U = 0,
PRNG_BSDF_V = 1,
@@ -195,7 +213,7 @@ enum PathTraceDimension {
PRNG_LIGHT = 3,
PRNG_LIGHT_U = 4,
PRNG_LIGHT_V = 5,
- PRNG_LIGHT_F = 6,
+ PRNG_UNUSED_3 = 6,
PRNG_TERMINATE = 7,
#ifdef __VOLUME__
@@ -289,7 +307,8 @@ typedef enum PassType {
PASS_MIST = 2097152,
PASS_SUBSURFACE_DIRECT = 4194304,
PASS_SUBSURFACE_INDIRECT = 8388608,
- PASS_SUBSURFACE_COLOR = 16777216
+ PASS_SUBSURFACE_COLOR = 16777216,
+ PASS_LIGHT = 33554432, /* no real pass, used to force use_light_pass */
} PassType;
#define PASS_ALL (~0)
@@ -494,15 +513,17 @@ typedef enum AttributeStandard {
/* Closure data */
+#ifdef __MULTI_CLOSURE__
#define MAX_CLOSURE 64
+#else
+#define MAX_CLOSURE 1
+#endif
typedef struct ShaderClosure {
ClosureType type;
float3 weight;
-#ifdef __MULTI_CLOSURE__
float sample_weight;
-#endif
float data0;
float data1;
@@ -612,6 +633,9 @@ typedef struct ShaderData {
/* ray bounce depth */
int ray_depth;
+ /* ray transparent depth */
+ int transparent_depth;
+
#ifdef __RAY_DIFFERENTIALS__
/* differential of P. these are orthogonal to Ng, not N */
differential3 dP;
@@ -634,15 +658,10 @@ typedef struct ShaderData {
Transform ob_itfm;
#endif
-#ifdef __MULTI_CLOSURE__
/* Closure data, we store a fixed array of closures */
ShaderClosure closure[MAX_CLOSURE];
int num_closure;
float randb_closure;
-#else
- /* Closure data, with a single sampled closure for low memory usage */
- ShaderClosure closure;
-#endif
/* ray start position, only set for backgrounds */
float3 ray_P;
diff --git a/intern/cycles/kernel/kernel_volume.h b/intern/cycles/kernel/kernel_volume.h
index 7928bdc4ff1..faaa68e3309 100644
--- a/intern/cycles/kernel/kernel_volume.h
+++ b/intern/cycles/kernel/kernel_volume.h
@@ -184,7 +184,7 @@ ccl_device void kernel_volume_shadow_heterogeneous(KernelGlobals *kg, PathState
ccl_device_noinline void kernel_volume_shadow(KernelGlobals *kg, PathState *state, Ray *ray, float3 *throughput)
{
ShaderData sd;
- shader_setup_from_volume(kg, &sd, ray, state->bounce);
+ shader_setup_from_volume(kg, &sd, ray, state->bounce, state->transparent_bounce);
if(volume_stack_is_heterogeneous(kg, state->volume_stack))
kernel_volume_shadow_heterogeneous(kg, state, ray, &sd, throughput);
@@ -203,7 +203,7 @@ ccl_device float kernel_volume_equiangular_sample(Ray *ray, float3 light_P, floa
float D = sqrtf(len_squared(light_P - ray->P) - delta * delta);
float theta_a = -atan2f(delta, D);
float theta_b = atan2f(t - delta, D);
- float t_ = D * tan((xi * theta_b) + (1 - xi) * theta_a);
+ float t_ = D * tanf((xi * theta_b) + (1 - xi) * theta_a);
*pdf = D / ((theta_b - theta_a) * (D * D + t_ * t_));
@@ -828,7 +828,7 @@ ccl_device_noinline VolumeIntegrateResult kernel_volume_integrate(KernelGlobals
/* debugging code to compare decoupled ray marching */
VolumeSegment segment;
- shader_setup_from_volume(kg, sd, ray, state->bounce);
+ shader_setup_from_volume(kg, sd, ray, state->bounce, state->transparent_bounce);
kernel_volume_decoupled_record(kg, state, ray, sd, &segment, heterogeneous);
VolumeIntegrateResult result = kernel_volume_decoupled_scatter(kg, state, ray, sd, throughput, &tmp_rng, &segment);
@@ -837,7 +837,7 @@ ccl_device_noinline VolumeIntegrateResult kernel_volume_integrate(KernelGlobals
return result;
#else
- shader_setup_from_volume(kg, sd, ray, state->bounce);
+ shader_setup_from_volume(kg, sd, ray, state->bounce, state->transparent_bounce);
if(heterogeneous)
return kernel_volume_integrate_heterogeneous(kg, state, ray, sd, L, throughput, &tmp_rng);
diff --git a/intern/cycles/kernel/osl/osl_services.cpp b/intern/cycles/kernel/osl/osl_services.cpp
index d5edd04d8a5..54894ea19eb 100644
--- a/intern/cycles/kernel/osl/osl_services.cpp
+++ b/intern/cycles/kernel/osl/osl_services.cpp
@@ -50,11 +50,16 @@ CCL_NAMESPACE_BEGIN
/* RenderServices implementation */
-#define COPY_MATRIX44(m1, m2) memcpy(m1, m2, sizeof(*m2))
+#define COPY_MATRIX44(m1, m2) { \
+ CHECK_TYPE(m1, OSL::Matrix44*); \
+ CHECK_TYPE(m2, Transform*); \
+ memcpy(m1, m2, sizeof(*m2)); \
+} (void)0
/* static ustrings */
ustring OSLRenderServices::u_distance("distance");
ustring OSLRenderServices::u_index("index");
+ustring OSLRenderServices::u_world("world");
ustring OSLRenderServices::u_camera("camera");
ustring OSLRenderServices::u_screen("screen");
ustring OSLRenderServices::u_raster("raster");
@@ -85,6 +90,7 @@ ustring OSLRenderServices::u_curve_tangent_normal("geom:curve_tangent_normal");
#endif
ustring OSLRenderServices::u_path_ray_length("path:ray_length");
ustring OSLRenderServices::u_path_ray_depth("path:ray_depth");
+ustring OSLRenderServices::u_path_transparent_depth("path:transparent_depth");
ustring OSLRenderServices::u_trace("trace");
ustring OSLRenderServices::u_hit("hit");
ustring OSLRenderServices::u_hitdist("hitdist");
@@ -204,6 +210,10 @@ bool OSLRenderServices::get_matrix(OSL::Matrix44 &result, ustring from, float ti
COPY_MATRIX44(&result, &tfm);
return true;
}
+ else if (from == u_world) {
+ result.makeIdentity();
+ return true;
+ }
return false;
}
@@ -232,6 +242,10 @@ bool OSLRenderServices::get_inverse_matrix(OSL::Matrix44 &result, ustring to, fl
COPY_MATRIX44(&result, &tfm);
return true;
}
+ else if (to == u_world) {
+ result.makeIdentity();
+ return true;
+ }
return false;
}
@@ -523,7 +537,8 @@ static bool get_mesh_element_attribute(KernelGlobals *kg, const ShaderData *sd,
const TypeDesc& type, bool derivatives, void *val)
{
if (attr.type == TypeDesc::TypePoint || attr.type == TypeDesc::TypeVector ||
- attr.type == TypeDesc::TypeNormal || attr.type == TypeDesc::TypeColor) {
+ attr.type == TypeDesc::TypeNormal || attr.type == TypeDesc::TypeColor)
+ {
float3 fval[3];
fval[0] = primitive_attribute_float3(kg, sd, attr.elem, attr.offset,
(derivatives) ? &fval[1] : NULL, (derivatives) ? &fval[2] : NULL);
@@ -594,44 +609,44 @@ bool OSLRenderServices::get_object_standard_attribute(KernelGlobals *kg, ShaderD
/* Particle Attributes */
else if (name == u_particle_index) {
- uint particle_id = object_particle_id(kg, sd->object);
+ int particle_id = object_particle_id(kg, sd->object);
float f = particle_index(kg, particle_id);
return set_attribute_float(f, type, derivatives, val);
}
else if (name == u_particle_age) {
- uint particle_id = object_particle_id(kg, sd->object);
+ int particle_id = object_particle_id(kg, sd->object);
float f = particle_age(kg, particle_id);
return set_attribute_float(f, type, derivatives, val);
}
else if (name == u_particle_lifetime) {
- uint particle_id = object_particle_id(kg, sd->object);
- float f= particle_lifetime(kg, particle_id);
+ int particle_id = object_particle_id(kg, sd->object);
+ float f = particle_lifetime(kg, particle_id);
return set_attribute_float(f, type, derivatives, val);
}
else if (name == u_particle_location) {
- uint particle_id = object_particle_id(kg, sd->object);
+ int particle_id = object_particle_id(kg, sd->object);
float3 f = particle_location(kg, particle_id);
return set_attribute_float3(f, type, derivatives, val);
}
#if 0 /* unsupported */
else if (name == u_particle_rotation) {
- uint particle_id = object_particle_id(kg, sd->object);
+ int particle_id = object_particle_id(kg, sd->object);
float4 f = particle_rotation(kg, particle_id);
return set_attribute_float4(f, type, derivatives, val);
}
#endif
else if (name == u_particle_size) {
- uint particle_id = object_particle_id(kg, sd->object);
+ int particle_id = object_particle_id(kg, sd->object);
float f = particle_size(kg, particle_id);
return set_attribute_float(f, type, derivatives, val);
}
else if (name == u_particle_velocity) {
- uint particle_id = object_particle_id(kg, sd->object);
+ int particle_id = object_particle_id(kg, sd->object);
float3 f = particle_velocity(kg, particle_id);
return set_attribute_float3(f, type, derivatives, val);
}
else if (name == u_particle_angular_velocity) {
- uint particle_id = object_particle_id(kg, sd->object);
+ int particle_id = object_particle_id(kg, sd->object);
float3 f = particle_angular_velocity(kg, particle_id);
return set_attribute_float3(f, type, derivatives, val);
}
@@ -642,10 +657,11 @@ bool OSLRenderServices::get_object_standard_attribute(KernelGlobals *kg, ShaderD
}
else if ((name == u_geom_trianglevertices || name == u_geom_polyvertices)
#ifdef __HAIR__
- && sd->type & PRIMITIVE_ALL_TRIANGLE) {
+ && sd->type & PRIMITIVE_ALL_TRIANGLE)
#else
- ) {
+ )
#endif
+ {
float3 P[3];
if(sd->type & PRIMITIVE_TRIANGLE)
@@ -701,6 +717,11 @@ bool OSLRenderServices::get_background_attribute(KernelGlobals *kg, ShaderData *
int f = sd->ray_depth;
return set_attribute_int(f, type, derivatives, val);
}
+ else if (name == u_path_transparent_depth) {
+ /* Ray Depth */
+ int f = sd->transparent_depth;
+ return set_attribute_int(f, type, derivatives, val);
+ }
else if (name == u_ndc) {
/* NDC coordinates with special exception for otho */
OSLThreadData *tdata = kg->osl_tdata;
@@ -736,7 +757,8 @@ bool OSLRenderServices::get_attribute(void *renderstate, bool derivatives, ustri
ShaderData *sd = (ShaderData *)renderstate;
KernelGlobals *kg = sd->osl_globals;
bool is_curve;
- int object, prim;
+ int object;
+ // int prim;
/* lookup of attribute on another object */
if (object_name != u_empty) {
@@ -746,12 +768,12 @@ bool OSLRenderServices::get_attribute(void *renderstate, bool derivatives, ustri
return false;
object = it->second;
- prim = PRIM_NONE;
+ // prim = PRIM_NONE;
is_curve = false;
}
else {
object = sd->object;
- prim = sd->prim;
+ // prim = sd->prim;
is_curve = (sd->type & PRIMITIVE_ALL_CURVE) != 0;
if (object == OBJECT_NONE)
@@ -768,7 +790,9 @@ bool OSLRenderServices::get_attribute(void *renderstate, bool derivatives, ustri
if (attr.elem != ATTR_ELEMENT_OBJECT) {
/* triangle and vertex attributes */
- if(!get_mesh_element_attribute(kg, sd, attr, type, derivatives, val))
+ if(get_mesh_element_attribute(kg, sd, attr, type, derivatives, val))
+ return true;
+ else
return get_mesh_attribute(kg, sd, attr, type, derivatives, val);
}
else {
@@ -1031,8 +1055,9 @@ bool OSLRenderServices::getmessage(OSL::ShaderGlobals *sg, ustring source, ustri
/* lazy shader data setup */
ShaderData *original_sd = (ShaderData *)(sg->renderstate);
int bounce = original_sd->ray_depth + 1;
+ int transparent_bounce = original_sd->transparent_depth;
- shader_setup_from_ray(kg, sd, &tracedata->isect, &tracedata->ray, bounce);
+ shader_setup_from_ray(kg, sd, &tracedata->isect, &tracedata->ray, bounce, transparent_bounce);
tracedata->setup = true;
}
diff --git a/intern/cycles/kernel/osl/osl_services.h b/intern/cycles/kernel/osl/osl_services.h
index 479b6da1afb..069722d81b6 100644
--- a/intern/cycles/kernel/osl/osl_services.h
+++ b/intern/cycles/kernel/osl/osl_services.h
@@ -110,12 +110,13 @@ public:
ustring dataname, TypeDesc datatype, void *data);
static bool get_background_attribute(KernelGlobals *kg, ShaderData *sd, ustring name,
- TypeDesc type, bool derivatives, void *val);
+ TypeDesc type, bool derivatives, void *val);
static bool get_object_standard_attribute(KernelGlobals *kg, ShaderData *sd, ustring name,
- TypeDesc type, bool derivatives, void *val);
+ TypeDesc type, bool derivatives, void *val);
static ustring u_distance;
static ustring u_index;
+ static ustring u_world;
static ustring u_camera;
static ustring u_screen;
static ustring u_raster;
@@ -144,6 +145,7 @@ public:
static ustring u_curve_tangent_normal;
static ustring u_path_ray_length;
static ustring u_path_ray_depth;
+ static ustring u_path_transparent_depth;
static ustring u_trace;
static ustring u_hit;
static ustring u_hitdist;
diff --git a/intern/cycles/kernel/osl/osl_shader.cpp b/intern/cycles/kernel/osl/osl_shader.cpp
index 64c734dec64..843dcdd0985 100644
--- a/intern/cycles/kernel/osl/osl_shader.cpp
+++ b/intern/cycles/kernel/osl/osl_shader.cpp
@@ -409,8 +409,9 @@ static void flatten_volume_closure_tree(ShaderData *sd,
sc.data1 = volume->sc.data1;
/* add */
- if(sc.sample_weight > CLOSURE_WEIGHT_CUTOFF &&
- sd->num_closure < MAX_CLOSURE) {
+ if((sc.sample_weight > CLOSURE_WEIGHT_CUTOFF) &&
+ (sd->num_closure < MAX_CLOSURE))
+ {
sd->closure[sd->num_closure++] = sc;
sd->flag |= volume->shaderdata_flag();
}
diff --git a/intern/cycles/kernel/shaders/node_absorption_volume.osl b/intern/cycles/kernel/shaders/node_absorption_volume.osl
index 69c4c0ef7af..6bac83ba4f5 100644
--- a/intern/cycles/kernel/shaders/node_absorption_volume.osl
+++ b/intern/cycles/kernel/shaders/node_absorption_volume.osl
@@ -21,6 +21,6 @@ shader node_absorption_volume(
float Density = 1.0,
output closure color Volume = 0)
{
- Volume = ((color(1.0, 1.0, 1.0) - Color) * Density) * absorption();
+ Volume = ((color(1.0, 1.0, 1.0) - Color) * max(Density, 0.0)) * absorption();
}
diff --git a/intern/cycles/kernel/shaders/node_fresnel.osl b/intern/cycles/kernel/shaders/node_fresnel.osl
index 8c59d5bb512..7ef553c0f39 100644
--- a/intern/cycles/kernel/shaders/node_fresnel.osl
+++ b/intern/cycles/kernel/shaders/node_fresnel.osl
@@ -23,7 +23,7 @@ shader node_fresnel(
output float Fac = 0.0)
{
float f = max(IOR, 1e-5);
- float eta = backfacing() ? 1.0 / f: f;
+ float eta = backfacing() ? 1.0 / f : f;
float cosi = dot(I, Normal);
Fac = fresnel_dielectric_cos(cosi, eta);
}
diff --git a/intern/cycles/kernel/shaders/node_glass_bsdf.osl b/intern/cycles/kernel/shaders/node_glass_bsdf.osl
index 96934199621..b3d6133553b 100644
--- a/intern/cycles/kernel/shaders/node_glass_bsdf.osl
+++ b/intern/cycles/kernel/shaders/node_glass_bsdf.osl
@@ -26,7 +26,7 @@ shader node_glass_bsdf(
output closure color BSDF = 0)
{
float f = max(IOR, 1e-5);
- float eta = backfacing() ? 1.0 / f: f;
+ float eta = backfacing() ? 1.0 / f : f;
float cosi = dot(I, Normal);
float Fr = fresnel_dielectric_cos(cosi, eta);
diff --git a/intern/cycles/kernel/shaders/node_light_path.osl b/intern/cycles/kernel/shaders/node_light_path.osl
index 599c7f5a262..95fbcabf917 100644
--- a/intern/cycles/kernel/shaders/node_light_path.osl
+++ b/intern/cycles/kernel/shaders/node_light_path.osl
@@ -26,7 +26,8 @@ shader node_light_path(
output float IsTransmissionRay = 0.0,
output float IsVolumeScatterRay = 0.0,
output float RayLength = 0.0,
- output float RayDepth = 0.0)
+ output float RayDepth = 0.0,
+ output float TransparentDepth = 0.0)
{
IsCameraRay = raytype("camera");
IsShadowRay = raytype("shadow");
@@ -42,5 +43,9 @@ shader node_light_path(
int ray_depth;
getattribute("path:ray_depth", ray_depth);
RayDepth = (float)ray_depth;
+
+ int transparent_depth;
+ getattribute("path:transparent_depth", transparent_depth);
+ TransparentDepth = (float)transparent_depth;
}
diff --git a/intern/cycles/kernel/shaders/node_math.osl b/intern/cycles/kernel/shaders/node_math.osl
index 066e5f8dbe1..abb6a359e75 100644
--- a/intern/cycles/kernel/shaders/node_math.osl
+++ b/intern/cycles/kernel/shaders/node_math.osl
@@ -93,6 +93,8 @@ shader node_math(
Value = Value1 > Value2;
else if (type == "Modulo")
Value = safe_modulo(Value1, Value2);
+ else if (type == "Absolute")
+ Value = fabs(Value1);
if (Clamp)
Value = clamp(Value, 0.0, 1.0);
diff --git a/intern/cycles/kernel/shaders/node_mix.osl b/intern/cycles/kernel/shaders/node_mix.osl
index c2c397c6446..dd54fd814de 100644
--- a/intern/cycles/kernel/shaders/node_mix.osl
+++ b/intern/cycles/kernel/shaders/node_mix.osl
@@ -88,7 +88,7 @@ color node_mix_diff(float t, color col1, color col2)
color node_mix_dark(float t, color col1, color col2)
{
- return min(col1, col2 * t);
+ return min(col1, col2) * t + col1 * (1.0 - t);
}
color node_mix_light(float t, color col1, color col2)
diff --git a/intern/cycles/kernel/shaders/node_refraction_bsdf.osl b/intern/cycles/kernel/shaders/node_refraction_bsdf.osl
index f87b3a5dd86..4a32415b482 100644
--- a/intern/cycles/kernel/shaders/node_refraction_bsdf.osl
+++ b/intern/cycles/kernel/shaders/node_refraction_bsdf.osl
@@ -25,7 +25,7 @@ shader node_refraction_bsdf(
output closure color BSDF = 0)
{
float f = max(IOR, 1e-5);
- float eta = backfacing() ? 1.0 / f: f;
+ float eta = backfacing() ? 1.0 / f : f;
if (distribution == "Sharp")
BSDF = Color * refraction(Normal, eta);
diff --git a/intern/cycles/kernel/shaders/node_scatter_volume.osl b/intern/cycles/kernel/shaders/node_scatter_volume.osl
index bf23abbf933..77c157bd92b 100644
--- a/intern/cycles/kernel/shaders/node_scatter_volume.osl
+++ b/intern/cycles/kernel/shaders/node_scatter_volume.osl
@@ -22,6 +22,6 @@ shader node_scatter_volume(
float Anisotropy = 0.0,
output closure color Volume = 0)
{
- Volume = (Color * Density) * henyey_greenstein(Anisotropy);
+ Volume = (Color * max(Density, 0.0)) * henyey_greenstein(Anisotropy);
}
diff --git a/intern/cycles/kernel/shaders/node_uv_map.osl b/intern/cycles/kernel/shaders/node_uv_map.osl
index fd039beaee8..01c984aff4c 100644
--- a/intern/cycles/kernel/shaders/node_uv_map.osl
+++ b/intern/cycles/kernel/shaders/node_uv_map.osl
@@ -17,18 +17,29 @@
#include "stdosl.h"
shader node_uv_map(
- string name = "",
int from_dupli = 0,
+ string name = "",
+ string bump_offset = "center",
output point UV = point(0.0, 0.0, 0.0))
-
{
if (from_dupli) {
getattribute("geom:dupli_uv", UV);
}
else {
- if (name == "")
- getattribute("geom:uv", UV);
- else
- getattribute(name, UV);
+ if (name == "")
+ getattribute("geom:uv", UV);
+ else
+ getattribute(name, UV);
+ }
+
+ if (bump_offset == "dx") {
+ if (!from_dupli) {
+ UV += Dx(UV);
+ }
+ }
+ else if (bump_offset == "dy") {
+ if (!from_dupli) {
+ UV += Dy(UV);
+ }
}
}
diff --git a/intern/cycles/kernel/svm/svm.h b/intern/cycles/kernel/svm/svm.h
index 96c7cefbcb2..dbf59c60cb0 100644
--- a/intern/cycles/kernel/svm/svm.h
+++ b/intern/cycles/kernel/svm/svm.h
@@ -182,10 +182,9 @@ CCL_NAMESPACE_BEGIN
/* Main Interpreter Loop */
-ccl_device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderType type, float randb, int path_flag)
+ccl_device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderType type, int path_flag)
{
float stack[SVM_STACK_SIZE];
- float closure_weight = 1.0f;
int offset = sd->shader & SHADER_MASK;
while(1) {
@@ -200,7 +199,7 @@ ccl_device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, Shade
break;
}
case NODE_CLOSURE_BSDF:
- svm_node_closure_bsdf(kg, sd, stack, node, randb, path_flag, &offset);
+ svm_node_closure_bsdf(kg, sd, stack, node, path_flag, &offset);
break;
case NODE_CLOSURE_EMISSION:
svm_node_closure_emission(sd, stack, node);
@@ -227,13 +226,15 @@ ccl_device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, Shade
svm_node_emission_weight(kg, sd, stack, node);
break;
case NODE_MIX_CLOSURE:
- svm_node_mix_closure(sd, stack, node, &offset, &randb);
+ svm_node_mix_closure(sd, stack, node);
break;
- case NODE_ADD_CLOSURE:
- svm_node_add_closure(sd, stack, node.y, node.z, &offset, &randb, &closure_weight);
+ case NODE_JUMP_IF_ZERO:
+ if(stack_load_float(stack, node.z) == 0.0f)
+ offset += node.y;
break;
- case NODE_JUMP:
- offset = node.y;
+ case NODE_JUMP_IF_ONE:
+ if(stack_load_float(stack, node.z) == 1.0f)
+ offset += node.y;
break;
#ifdef __IMAGE_TEXTURES__
case NODE_TEX_IMAGE:
@@ -437,9 +438,6 @@ ccl_device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, Shade
#endif
case NODE_END:
default:
-#ifndef __MULTI_CLOSURE__
- sd->closure.weight *= closure_weight;
-#endif
return;
}
}
diff --git a/intern/cycles/kernel/svm/svm_closure.h b/intern/cycles/kernel/svm/svm_closure.h
index fb1a981adda..a3770877544 100644
--- a/intern/cycles/kernel/svm/svm_closure.h
+++ b/intern/cycles/kernel/svm/svm_closure.h
@@ -51,7 +51,6 @@ ccl_device void svm_node_glass_setup(ShaderData *sd, ShaderClosure *sc, int type
ccl_device_inline ShaderClosure *svm_node_closure_get_non_bsdf(ShaderData *sd, ClosureType type, float mix_weight)
{
-#ifdef __MULTI_CLOSURE__
ShaderClosure *sc = &sd->closure[sd->num_closure];
if(sd->num_closure < MAX_CLOSURE) {
@@ -65,14 +64,10 @@ ccl_device_inline ShaderClosure *svm_node_closure_get_non_bsdf(ShaderData *sd, C
}
return NULL;
-#else
- return &sd->closure;
-#endif
}
ccl_device_inline ShaderClosure *svm_node_closure_get_bsdf(ShaderData *sd, float mix_weight)
{
-#ifdef __MULTI_CLOSURE__
ShaderClosure *sc = &sd->closure[sd->num_closure];
float3 weight = sc->weight * mix_weight;
float sample_weight = fabsf(average(weight));
@@ -88,14 +83,10 @@ ccl_device_inline ShaderClosure *svm_node_closure_get_bsdf(ShaderData *sd, float
}
return NULL;
-#else
- return &sd->closure;
-#endif
}
ccl_device_inline ShaderClosure *svm_node_closure_get_absorption(ShaderData *sd, float mix_weight)
{
-#ifdef __MULTI_CLOSURE__
ShaderClosure *sc = &sd->closure[sd->num_closure];
float3 weight = (make_float3(1.0f, 1.0f, 1.0f) - sc->weight) * mix_weight;
float sample_weight = fabsf(average(weight));
@@ -111,16 +102,12 @@ ccl_device_inline ShaderClosure *svm_node_closure_get_absorption(ShaderData *sd,
}
return NULL;
-#else
- return &sd->closure;
-#endif
}
-ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, float randb, int path_flag, int *offset)
+ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int path_flag, int *offset)
{
uint type, param1_offset, param2_offset;
-#ifdef __MULTI_CLOSURE__
uint mix_weight_offset;
decode_node_uchar4(node.y, &type, &param1_offset, &param2_offset, &mix_weight_offset);
float mix_weight = (stack_valid(mix_weight_offset)? stack_load_float(stack, mix_weight_offset): 1.0f);
@@ -132,13 +119,6 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
return;
float3 N = stack_valid(data_node.x)? stack_load_float3(stack, data_node.x): sd->N;
-#else
- decode_node_uchar4(node.y, &type, &param1_offset, &param2_offset, NULL);
- float mix_weight = 1.0f;
-
- uint4 data_node = read_node(kg, offset);
- float3 N = stack_valid(data_node.x)? stack_load_float3(stack, data_node.x): sd->N;
-#endif
float param1 = (stack_valid(param1_offset))? stack_load_float(stack, param1_offset): __uint_as_float(node.z);
float param2 = (stack_valid(param2_offset))? stack_load_float(stack, param2_offset): __uint_as_float(node.w);
@@ -255,7 +235,6 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
float fresnel = fresnel_dielectric_cos(cosNO, eta);
float roughness = param1;
-#ifdef __MULTI_CLOSURE__
/* reflection */
ShaderClosure *sc = &sd->closure[sd->num_closure];
float3 weight = sc->weight;
@@ -279,15 +258,6 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
sc->N = N;
svm_node_glass_setup(sd, sc, type, eta, roughness, true);
}
-#else
- ShaderClosure *sc = svm_node_closure_get_bsdf(sd, mix_weight);
-
- if(sc) {
- sc->N = N;
- bool refract = (randb > fresnel);
- svm_node_glass_setup(sd, sc, type, eta, roughness, refract);
- }
-#endif
break;
}
@@ -366,8 +336,14 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
if(sd->flag & SD_BACKFACING && sd->type & PRIMITIVE_ALL_CURVE) {
ShaderClosure *sc = svm_node_closure_get_bsdf(sd, mix_weight);
+
if(sc) {
- sc->weight = make_float3(1.0f,1.0f,1.0f);
+ /* todo: giving a fixed weight here will cause issues when
+ * mixing multiple BSDFS. energey will not be conserved and
+ * the throughput can blow up after multiple bounces. we
+ * better figure out a way to skip backfaces from rays
+ * spawned by transmission from the front */
+ sc->weight = make_float3(1.0f, 1.0f, 1.0f);
sc->N = N;
sd->flag |= bsdf_transparent_setup(sc);
}
@@ -381,12 +357,14 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
sc->data0 = param1;
sc->data1 = param2;
sc->offset = -stack_load_float(stack, data_node.z);
- if(sd->type & PRIMITIVE_ALL_CURVE) {
+
+ if(!(sd->type & PRIMITIVE_ALL_CURVE)) {
sc->T = normalize(sd->dPdv);
sc->offset = 0.0f;
}
else
sc->T = sd->dPdu;
+
if(type == CLOSURE_BSDF_HAIR_REFLECTION_ID) {
sd->flag |= bsdf_hair_reflection_setup(sc);
}
@@ -484,21 +462,16 @@ ccl_device void svm_node_closure_volume(KernelGlobals *kg, ShaderData *sd, float
#ifdef __VOLUME__
uint type, param1_offset, param2_offset;
-#ifdef __MULTI_CLOSURE__
uint mix_weight_offset;
decode_node_uchar4(node.y, &type, &param1_offset, &param2_offset, &mix_weight_offset);
float mix_weight = (stack_valid(mix_weight_offset)? stack_load_float(stack, mix_weight_offset): 1.0f);
if(mix_weight == 0.0f)
return;
-#else
- decode_node_uchar4(node.y, &type, &param1_offset, &param2_offset, NULL);
- float mix_weight = 1.0f;
-#endif
float param1 = (stack_valid(param1_offset))? stack_load_float(stack, param1_offset): __uint_as_float(node.z);
float param2 = (stack_valid(param2_offset))? stack_load_float(stack, param2_offset): __uint_as_float(node.w);
- float density = param1;
+ float density = fmaxf(param1, 0.0f);
switch(type) {
case CLOSURE_VOLUME_ABSORPTION_ID: {
@@ -527,7 +500,6 @@ ccl_device void svm_node_closure_volume(KernelGlobals *kg, ShaderData *sd, float
ccl_device void svm_node_closure_emission(ShaderData *sd, float *stack, uint4 node)
{
-#ifdef __MULTI_CLOSURE__
uint mix_weight_offset = node.y;
if(stack_valid(mix_weight_offset)) {
@@ -540,17 +512,12 @@ ccl_device void svm_node_closure_emission(ShaderData *sd, float *stack, uint4 no
}
else
svm_node_closure_get_non_bsdf(sd, CLOSURE_EMISSION_ID, 1.0f);
-#else
- ShaderClosure *sc = &sd->closure;
- sc->type = CLOSURE_EMISSION_ID;
-#endif
sd->flag |= SD_EMISSION;
}
ccl_device void svm_node_closure_background(ShaderData *sd, float *stack, uint4 node)
{
-#ifdef __MULTI_CLOSURE__
uint mix_weight_offset = node.y;
if(stack_valid(mix_weight_offset)) {
@@ -563,15 +530,10 @@ ccl_device void svm_node_closure_background(ShaderData *sd, float *stack, uint4
}
else
svm_node_closure_get_non_bsdf(sd, CLOSURE_BACKGROUND_ID, 1.0f);
-#else
- ShaderClosure *sc = &sd->closure;
- sc->type = CLOSURE_BACKGROUND_ID;
-#endif
}
ccl_device void svm_node_closure_holdout(ShaderData *sd, float *stack, uint4 node)
{
-#ifdef __MULTI_CLOSURE__
uint mix_weight_offset = node.y;
if(stack_valid(mix_weight_offset)) {
@@ -584,17 +546,12 @@ ccl_device void svm_node_closure_holdout(ShaderData *sd, float *stack, uint4 nod
}
else
svm_node_closure_get_non_bsdf(sd, CLOSURE_HOLDOUT_ID, 1.0f);
-#else
- ShaderClosure *sc = &sd->closure;
- sc->type = CLOSURE_HOLDOUT_ID;
-#endif
sd->flag |= SD_HOLDOUT;
}
ccl_device void svm_node_closure_ambient_occlusion(ShaderData *sd, float *stack, uint4 node)
{
-#ifdef __MULTI_CLOSURE__
uint mix_weight_offset = node.y;
if(stack_valid(mix_weight_offset)) {
@@ -607,10 +564,6 @@ ccl_device void svm_node_closure_ambient_occlusion(ShaderData *sd, float *stack,
}
else
svm_node_closure_get_non_bsdf(sd, CLOSURE_AMBIENT_OCCLUSION_ID, 1.0f);
-#else
- ShaderClosure *sc = &sd->closure;
- sc->type = CLOSURE_AMBIENT_OCCLUSION_ID;
-#endif
sd->flag |= SD_AO;
}
@@ -619,12 +572,8 @@ ccl_device void svm_node_closure_ambient_occlusion(ShaderData *sd, float *stack,
ccl_device_inline void svm_node_closure_store_weight(ShaderData *sd, float3 weight)
{
-#ifdef __MULTI_CLOSURE__
if(sd->num_closure < MAX_CLOSURE)
sd->closure[sd->num_closure].weight = weight;
-#else
- sd->closure.weight = weight;
-#endif
}
ccl_device void svm_node_closure_set_weight(ShaderData *sd, uint r, uint g, uint b)
@@ -665,10 +614,8 @@ ccl_device void svm_node_emission_weight(KernelGlobals *kg, ShaderData *sd, floa
svm_node_closure_store_weight(sd, weight);
}
-ccl_device void svm_node_mix_closure(ShaderData *sd, float *stack,
- uint4 node, int *offset, float *randb)
+ccl_device void svm_node_mix_closure(ShaderData *sd, float *stack, uint4 node)
{
-#ifdef __MULTI_CLOSURE__
/* fetch weight from blend input, previous mix closures,
* and write to stack to be used by closure nodes later */
uint weight_offset, in_weight_offset, weight1_offset, weight2_offset;
@@ -683,44 +630,6 @@ ccl_device void svm_node_mix_closure(ShaderData *sd, float *stack,
stack_store_float(stack, weight1_offset, in_weight*(1.0f - weight));
if(stack_valid(weight2_offset))
stack_store_float(stack, weight2_offset, in_weight*weight);
-#else
- /* pick a closure and make the random number uniform over 0..1 again.
- * closure 1 starts on the next node, for closure 2 the start is at an
- * offset from the current node, so we jump */
- uint weight_offset = node.y;
- uint node_jump = node.z;
- float weight = stack_load_float(stack, weight_offset);
- weight = clamp(weight, 0.0f, 1.0f);
-
- if(*randb < weight) {
- *offset += node_jump;
- *randb = *randb/weight;
- }
- else
- *randb = (*randb - weight)/(1.0f - weight);
-#endif
-}
-
-ccl_device void svm_node_add_closure(ShaderData *sd, float *stack, uint unused,
- uint node_jump, int *offset, float *randb, float *closure_weight)
-{
-#ifdef __MULTI_CLOSURE__
- /* nothing to do, handled in compiler */
-#else
- /* pick one of the two closures with probability 0.5. sampling quality
- * is not going to be great, for that we'd need to evaluate the weights
- * of the two closures being added */
- float weight = 0.5f;
-
- if(*randb < weight) {
- *offset += node_jump;
- *randb = *randb/weight;
- }
- else
- *randb = (*randb - weight)/(1.0f - weight);
-
- *closure_weight *= 2.0f;
-#endif
}
/* (Bump) normal */
diff --git a/intern/cycles/kernel/svm/svm_geometry.h b/intern/cycles/kernel/svm/svm_geometry.h
index 1ed6a4b1916..fe681ec92af 100644
--- a/intern/cycles/kernel/svm/svm_geometry.h
+++ b/intern/cycles/kernel/svm/svm_geometry.h
@@ -98,44 +98,44 @@ ccl_device void svm_node_particle_info(KernelGlobals *kg, ShaderData *sd, float
{
switch(type) {
case NODE_INFO_PAR_INDEX: {
- uint particle_id = object_particle_id(kg, sd->object);
+ int particle_id = object_particle_id(kg, sd->object);
stack_store_float(stack, out_offset, particle_index(kg, particle_id));
break;
}
case NODE_INFO_PAR_AGE: {
- uint particle_id = object_particle_id(kg, sd->object);
+ int particle_id = object_particle_id(kg, sd->object);
stack_store_float(stack, out_offset, particle_age(kg, particle_id));
break;
}
case NODE_INFO_PAR_LIFETIME: {
- uint particle_id = object_particle_id(kg, sd->object);
+ int particle_id = object_particle_id(kg, sd->object);
stack_store_float(stack, out_offset, particle_lifetime(kg, particle_id));
break;
}
case NODE_INFO_PAR_LOCATION: {
- uint particle_id = object_particle_id(kg, sd->object);
+ int particle_id = object_particle_id(kg, sd->object);
stack_store_float3(stack, out_offset, particle_location(kg, particle_id));
break;
}
- #if 0 /* XXX float4 currently not supported in SVM stack */
+#if 0 /* XXX float4 currently not supported in SVM stack */
case NODE_INFO_PAR_ROTATION: {
- uint particle_id = object_particle_id(kg, sd->object);
+ int particle_id = object_particle_id(kg, sd->object);
stack_store_float4(stack, out_offset, particle_rotation(kg, particle_id));
break;
}
- #endif
+#endif
case NODE_INFO_PAR_SIZE: {
- uint particle_id = object_particle_id(kg, sd->object);
+ int particle_id = object_particle_id(kg, sd->object);
stack_store_float(stack, out_offset, particle_size(kg, particle_id));
break;
}
case NODE_INFO_PAR_VELOCITY: {
- uint particle_id = object_particle_id(kg, sd->object);
+ int particle_id = object_particle_id(kg, sd->object);
stack_store_float3(stack, out_offset, particle_velocity(kg, particle_id));
break;
}
case NODE_INFO_PAR_ANGULAR_VELOCITY: {
- uint particle_id = object_particle_id(kg, sd->object);
+ int particle_id = object_particle_id(kg, sd->object);
stack_store_float3(stack, out_offset, particle_angular_velocity(kg, particle_id));
break;
}
diff --git a/intern/cycles/kernel/svm/svm_image.h b/intern/cycles/kernel/svm/svm_image.h
index ce2893e1893..daf7c6652d2 100644
--- a/intern/cycles/kernel/svm/svm_image.h
+++ b/intern/cycles/kernel/svm/svm_image.h
@@ -65,7 +65,7 @@ ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y,
float4 r;
int ix, iy, nix, niy;
- if (interpolation == INTERPOLATION_CLOSEST){
+ if (interpolation == INTERPOLATION_CLOSEST) {
svm_image_texture_frac(x*width, &ix);
svm_image_texture_frac(y*height, &iy);
@@ -149,8 +149,8 @@ ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y,
* - group by size and use a 3d texture, performance impact
* - group into larger texture with some padding for correct lerp
*
- * also note that cuda has 128 textures limit, we use 100 now, since
- * we still need some for other storage */
+ * also note that cuda has a textures limit (128 for Fermi, 256 for Kepler),
+ * and we cannot use all since we still need some for other storage */
switch(id) {
case 0: r = kernel_tex_image_interp(__tex_image_float_000, x, y); break;
@@ -253,7 +253,62 @@ ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y,
case 97: r = kernel_tex_image_interp(__tex_image_097, x, y); break;
case 98: r = kernel_tex_image_interp(__tex_image_098, x, y); break;
case 99: r = kernel_tex_image_interp(__tex_image_099, x, y); break;
- default:
+
+#if defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 300)
+ case 100: r = kernel_tex_image_interp(__tex_image_100, x, y); break;
+ case 101: r = kernel_tex_image_interp(__tex_image_101, x, y); break;
+ case 102: r = kernel_tex_image_interp(__tex_image_102, x, y); break;
+ case 103: r = kernel_tex_image_interp(__tex_image_103, x, y); break;
+ case 104: r = kernel_tex_image_interp(__tex_image_104, x, y); break;
+ case 105: r = kernel_tex_image_interp(__tex_image_105, x, y); break;
+ case 106: r = kernel_tex_image_interp(__tex_image_106, x, y); break;
+ case 107: r = kernel_tex_image_interp(__tex_image_107, x, y); break;
+ case 108: r = kernel_tex_image_interp(__tex_image_108, x, y); break;
+ case 109: r = kernel_tex_image_interp(__tex_image_109, x, y); break;
+ case 110: r = kernel_tex_image_interp(__tex_image_110, x, y); break;
+ case 111: r = kernel_tex_image_interp(__tex_image_111, x, y); break;
+ case 112: r = kernel_tex_image_interp(__tex_image_112, x, y); break;
+ case 113: r = kernel_tex_image_interp(__tex_image_113, x, y); break;
+ case 114: r = kernel_tex_image_interp(__tex_image_114, x, y); break;
+ case 115: r = kernel_tex_image_interp(__tex_image_115, x, y); break;
+ case 116: r = kernel_tex_image_interp(__tex_image_116, x, y); break;
+ case 117: r = kernel_tex_image_interp(__tex_image_117, x, y); break;
+ case 118: r = kernel_tex_image_interp(__tex_image_118, x, y); break;
+ case 119: r = kernel_tex_image_interp(__tex_image_119, x, y); break;
+ case 120: r = kernel_tex_image_interp(__tex_image_120, x, y); break;
+ case 121: r = kernel_tex_image_interp(__tex_image_121, x, y); break;
+ case 122: r = kernel_tex_image_interp(__tex_image_122, x, y); break;
+ case 123: r = kernel_tex_image_interp(__tex_image_123, x, y); break;
+ case 124: r = kernel_tex_image_interp(__tex_image_124, x, y); break;
+ case 125: r = kernel_tex_image_interp(__tex_image_125, x, y); break;
+ case 126: r = kernel_tex_image_interp(__tex_image_126, x, y); break;
+ case 127: r = kernel_tex_image_interp(__tex_image_127, x, y); break;
+ case 128: r = kernel_tex_image_interp(__tex_image_128, x, y); break;
+ case 129: r = kernel_tex_image_interp(__tex_image_129, x, y); break;
+ case 130: r = kernel_tex_image_interp(__tex_image_130, x, y); break;
+ case 131: r = kernel_tex_image_interp(__tex_image_131, x, y); break;
+ case 132: r = kernel_tex_image_interp(__tex_image_132, x, y); break;
+ case 133: r = kernel_tex_image_interp(__tex_image_133, x, y); break;
+ case 134: r = kernel_tex_image_interp(__tex_image_134, x, y); break;
+ case 135: r = kernel_tex_image_interp(__tex_image_135, x, y); break;
+ case 136: r = kernel_tex_image_interp(__tex_image_136, x, y); break;
+ case 137: r = kernel_tex_image_interp(__tex_image_137, x, y); break;
+ case 138: r = kernel_tex_image_interp(__tex_image_138, x, y); break;
+ case 139: r = kernel_tex_image_interp(__tex_image_139, x, y); break;
+ case 140: r = kernel_tex_image_interp(__tex_image_140, x, y); break;
+ case 141: r = kernel_tex_image_interp(__tex_image_141, x, y); break;
+ case 142: r = kernel_tex_image_interp(__tex_image_142, x, y); break;
+ case 143: r = kernel_tex_image_interp(__tex_image_143, x, y); break;
+ case 144: r = kernel_tex_image_interp(__tex_image_144, x, y); break;
+ case 145: r = kernel_tex_image_interp(__tex_image_145, x, y); break;
+ case 146: r = kernel_tex_image_interp(__tex_image_146, x, y); break;
+ case 147: r = kernel_tex_image_interp(__tex_image_147, x, y); break;
+ case 148: r = kernel_tex_image_interp(__tex_image_148, x, y); break;
+ case 149: r = kernel_tex_image_interp(__tex_image_149, x, y); break;
+ case 150: r = kernel_tex_image_interp(__tex_image_150, x, y); break;
+#endif
+
+ default:
kernel_assert(0);
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
}
diff --git a/intern/cycles/kernel/svm/svm_light_path.h b/intern/cycles/kernel/svm/svm_light_path.h
index 8968146c5e2..da544c63ae0 100644
--- a/intern/cycles/kernel/svm/svm_light_path.h
+++ b/intern/cycles/kernel/svm/svm_light_path.h
@@ -34,6 +34,7 @@ ccl_device void svm_node_light_path(ShaderData *sd, float *stack, uint type, uin
case NODE_LP_backfacing: info = (sd->flag & SD_BACKFACING)? 1.0f: 0.0f; break;
case NODE_LP_ray_length: info = sd->ray_length; break;
case NODE_LP_ray_depth: info = (float)sd->ray_depth; break;
+ case NODE_LP_ray_transparent: info = sd->transparent_depth; break;
}
stack_store_float(stack, out_offset, info);
diff --git a/intern/cycles/kernel/svm/svm_math.h b/intern/cycles/kernel/svm/svm_math.h
index bb46d443a6b..1ce9386e40e 100644
--- a/intern/cycles/kernel/svm/svm_math.h
+++ b/intern/cycles/kernel/svm/svm_math.h
@@ -56,6 +56,8 @@ ccl_device float svm_math(NodeMath type, float Fac1, float Fac2)
Fac = Fac1 > Fac2;
else if(type == NODE_MATH_MODULO)
Fac = safe_modulo(Fac1, Fac2);
+ else if(type == NODE_MATH_ABSOLUTE)
+ Fac = fabsf(Fac1);
else if(type == NODE_MATH_CLAMP)
Fac = clamp(Fac1, 0.0f, 1.0f);
else
diff --git a/intern/cycles/kernel/svm/svm_mix.h b/intern/cycles/kernel/svm/svm_mix.h
index 4e834b7c500..edc3903865e 100644
--- a/intern/cycles/kernel/svm/svm_mix.h
+++ b/intern/cycles/kernel/svm/svm_mix.h
@@ -89,7 +89,7 @@ ccl_device float3 svm_mix_diff(float t, float3 col1, float3 col2)
ccl_device float3 svm_mix_dark(float t, float3 col1, float3 col2)
{
- return min(col1, col2*t);
+ return min(col1, col2)*t + col1*(1.0f - t);
}
ccl_device float3 svm_mix_light(float t, float3 col1, float3 col2)
diff --git a/intern/cycles/kernel/svm/svm_sepcomb_hsv.h b/intern/cycles/kernel/svm/svm_sepcomb_hsv.h
index 0f68ecbea03..111d5d47988 100644
--- a/intern/cycles/kernel/svm/svm_sepcomb_hsv.h
+++ b/intern/cycles/kernel/svm/svm_sepcomb_hsv.h
@@ -42,12 +42,12 @@ ccl_device void svm_node_separate_hsv(KernelGlobals *kg, ShaderData *sd, float *
/* Convert to HSV */
color = rgb_to_hsv(color);
- if (stack_valid(hue_out))
- stack_store_float(stack, hue_out, color.x);
- if (stack_valid(saturation_out))
- stack_store_float(stack, saturation_out, color.y);
- if (stack_valid(value_out))
- stack_store_float(stack, value_out, color.z);
+ if (stack_valid(hue_out))
+ stack_store_float(stack, hue_out, color.x);
+ if (stack_valid(saturation_out))
+ stack_store_float(stack, saturation_out, color.y);
+ if (stack_valid(value_out))
+ stack_store_float(stack, value_out, color.z);
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/svm/svm_sky.h b/intern/cycles/kernel/svm/svm_sky.h
index 1e3552647bd..500b5146931 100644
--- a/intern/cycles/kernel/svm/svm_sky.h
+++ b/intern/cycles/kernel/svm/svm_sky.h
@@ -74,7 +74,7 @@ ccl_device float sky_radiance_internal(float *configuration, float theta, float
float expM = expf(configuration[4] * gamma);
float rayM = cgamma * cgamma;
float mieM = (1.0f + rayM) / powf((1.0f + configuration[8]*configuration[8] - 2.0f*configuration[8]*cgamma), 1.5f);
- float zenith = sqrt(ctheta);
+ float zenith = sqrtf(ctheta);
return (1.0f + configuration[0] * expf(configuration[1] / (ctheta + 0.01f))) *
(configuration[2] + configuration[3] * expM + configuration[5] * rayM + configuration[6] * mieM + configuration[7] * zenith);
diff --git a/intern/cycles/kernel/svm/svm_types.h b/intern/cycles/kernel/svm/svm_types.h
index 4381bfe0996..80972ec82bc 100644
--- a/intern/cycles/kernel/svm/svm_types.h
+++ b/intern/cycles/kernel/svm/svm_types.h
@@ -36,7 +36,8 @@ typedef enum NodeType {
NODE_CLOSURE_SET_WEIGHT,
NODE_CLOSURE_WEIGHT,
NODE_MIX_CLOSURE,
- NODE_JUMP,
+ NODE_JUMP_IF_ZERO,
+ NODE_JUMP_IF_ONE,
NODE_TEX_IMAGE,
NODE_TEX_IMAGE_BOX,
NODE_TEX_SKY,
@@ -71,7 +72,6 @@ typedef enum NodeType {
NODE_TEX_COORD,
NODE_TEX_COORD_BUMP_DX,
NODE_TEX_COORD_BUMP_DY,
- NODE_ADD_CLOSURE,
NODE_EMISSION_SET_WEIGHT_TOTAL,
NODE_ATTR_BUMP_DX,
NODE_ATTR_BUMP_DY,
@@ -159,7 +159,8 @@ typedef enum NodeLightPath {
NODE_LP_volume_scatter,
NODE_LP_backfacing,
NODE_LP_ray_length,
- NODE_LP_ray_depth
+ NODE_LP_ray_depth,
+ NODE_LP_ray_transparent
} NodeLightPath;
typedef enum NodeLightFalloff {
@@ -220,6 +221,7 @@ typedef enum NodeMath {
NODE_MATH_LESS_THAN,
NODE_MATH_GREATER_THAN,
NODE_MATH_MODULO,
+ NODE_MATH_ABSOLUTE,
NODE_MATH_CLAMP /* used for the clamp UI option */
} NodeMath;
diff --git a/intern/cycles/kernel/svm/svm_vector_transform.h b/intern/cycles/kernel/svm/svm_vector_transform.h
index 890a9ddda69..61d33aeb8cf 100644
--- a/intern/cycles/kernel/svm/svm_vector_transform.h
+++ b/intern/cycles/kernel/svm/svm_vector_transform.h
@@ -91,9 +91,9 @@ ccl_device void svm_node_vector_transform(KernelGlobals *kg, ShaderData *sd, flo
if(type == NODE_VECTOR_TRANSFORM_TYPE_NORMAL)
in = normalize(in);
- /* Output */
+ /* Output */
if(stack_valid(vector_out)) {
- stack_store_float3(stack, vector_out, in);
+ stack_store_float3(stack, vector_out, in);
}
}
diff --git a/intern/cycles/kernel/svm/svm_wavelength.h b/intern/cycles/kernel/svm/svm_wavelength.h
index dca4003b89a..9e57c470c0f 100644
--- a/intern/cycles/kernel/svm/svm_wavelength.h
+++ b/intern/cycles/kernel/svm/svm_wavelength.h
@@ -43,33 +43,33 @@ ccl_device void svm_node_wavelength(ShaderData *sd, float *stack, uint wavelengt
// cie_colour_match[(lambda - 380) / 5][1] = yBar
// cie_colour_match[(lambda - 380) / 5][2] = zBar
const float cie_colour_match[81][3] = {
- {0.0014,0.0000,0.0065}, {0.0022,0.0001,0.0105}, {0.0042,0.0001,0.0201},
- {0.0076,0.0002,0.0362}, {0.0143,0.0004,0.0679}, {0.0232,0.0006,0.1102},
- {0.0435,0.0012,0.2074}, {0.0776,0.0022,0.3713}, {0.1344,0.0040,0.6456},
- {0.2148,0.0073,1.0391}, {0.2839,0.0116,1.3856}, {0.3285,0.0168,1.6230},
- {0.3483,0.0230,1.7471}, {0.3481,0.0298,1.7826}, {0.3362,0.0380,1.7721},
- {0.3187,0.0480,1.7441}, {0.2908,0.0600,1.6692}, {0.2511,0.0739,1.5281},
- {0.1954,0.0910,1.2876}, {0.1421,0.1126,1.0419}, {0.0956,0.1390,0.8130},
- {0.0580,0.1693,0.6162}, {0.0320,0.2080,0.4652}, {0.0147,0.2586,0.3533},
- {0.0049,0.3230,0.2720}, {0.0024,0.4073,0.2123}, {0.0093,0.5030,0.1582},
- {0.0291,0.6082,0.1117}, {0.0633,0.7100,0.0782}, {0.1096,0.7932,0.0573},
- {0.1655,0.8620,0.0422}, {0.2257,0.9149,0.0298}, {0.2904,0.9540,0.0203},
- {0.3597,0.9803,0.0134}, {0.4334,0.9950,0.0087}, {0.5121,1.0000,0.0057},
- {0.5945,0.9950,0.0039}, {0.6784,0.9786,0.0027}, {0.7621,0.9520,0.0021},
- {0.8425,0.9154,0.0018}, {0.9163,0.8700,0.0017}, {0.9786,0.8163,0.0014},
- {1.0263,0.7570,0.0011}, {1.0567,0.6949,0.0010}, {1.0622,0.6310,0.0008},
- {1.0456,0.5668,0.0006}, {1.0026,0.5030,0.0003}, {0.9384,0.4412,0.0002},
- {0.8544,0.3810,0.0002}, {0.7514,0.3210,0.0001}, {0.6424,0.2650,0.0000},
- {0.5419,0.2170,0.0000}, {0.4479,0.1750,0.0000}, {0.3608,0.1382,0.0000},
- {0.2835,0.1070,0.0000}, {0.2187,0.0816,0.0000}, {0.1649,0.0610,0.0000},
- {0.1212,0.0446,0.0000}, {0.0874,0.0320,0.0000}, {0.0636,0.0232,0.0000},
- {0.0468,0.0170,0.0000}, {0.0329,0.0119,0.0000}, {0.0227,0.0082,0.0000},
- {0.0158,0.0057,0.0000}, {0.0114,0.0041,0.0000}, {0.0081,0.0029,0.0000},
- {0.0058,0.0021,0.0000}, {0.0041,0.0015,0.0000}, {0.0029,0.0010,0.0000},
- {0.0020,0.0007,0.0000}, {0.0014,0.0005,0.0000}, {0.0010,0.0004,0.0000},
- {0.0007,0.0002,0.0000}, {0.0005,0.0002,0.0000}, {0.0003,0.0001,0.0000},
- {0.0002,0.0001,0.0000}, {0.0002,0.0001,0.0000}, {0.0001,0.0000,0.0000},
- {0.0001,0.0000,0.0000}, {0.0001,0.0000,0.0000}, {0.0000,0.0000,0.0000}
+ {0.0014f,0.0000f,0.0065f}, {0.0022f,0.0001f,0.0105f}, {0.0042f,0.0001f,0.0201f},
+ {0.0076f,0.0002f,0.0362f}, {0.0143f,0.0004f,0.0679f}, {0.0232f,0.0006f,0.1102f},
+ {0.0435f,0.0012f,0.2074f}, {0.0776f,0.0022f,0.3713f}, {0.1344f,0.0040f,0.6456f},
+ {0.2148f,0.0073f,1.0391f}, {0.2839f,0.0116f,1.3856f}, {0.3285f,0.0168f,1.6230f},
+ {0.3483f,0.0230f,1.7471f}, {0.3481f,0.0298f,1.7826f}, {0.3362f,0.0380f,1.7721f},
+ {0.3187f,0.0480f,1.7441f}, {0.2908f,0.0600f,1.6692f}, {0.2511f,0.0739f,1.5281f},
+ {0.1954f,0.0910f,1.2876f}, {0.1421f,0.1126f,1.0419f}, {0.0956f,0.1390f,0.8130f},
+ {0.0580f,0.1693f,0.6162f}, {0.0320f,0.2080f,0.4652f}, {0.0147f,0.2586f,0.3533f},
+ {0.0049f,0.3230f,0.2720f}, {0.0024f,0.4073f,0.2123f}, {0.0093f,0.5030f,0.1582f},
+ {0.0291f,0.6082f,0.1117f}, {0.0633f,0.7100f,0.0782f}, {0.1096f,0.7932f,0.0573f},
+ {0.1655f,0.8620f,0.0422f}, {0.2257f,0.9149f,0.0298f}, {0.2904f,0.9540f,0.0203f},
+ {0.3597f,0.9803f,0.0134f}, {0.4334f,0.9950f,0.0087f}, {0.5121f,1.0000f,0.0057f},
+ {0.5945f,0.9950f,0.0039f}, {0.6784f,0.9786f,0.0027f}, {0.7621f,0.9520f,0.0021f},
+ {0.8425f,0.9154f,0.0018f}, {0.9163f,0.8700f,0.0017f}, {0.9786f,0.8163f,0.0014f},
+ {1.0263f,0.7570f,0.0011f}, {1.0567f,0.6949f,0.0010f}, {1.0622f,0.6310f,0.0008f},
+ {1.0456f,0.5668f,0.0006f}, {1.0026f,0.5030f,0.0003f}, {0.9384f,0.4412f,0.0002f},
+ {0.8544f,0.3810f,0.0002f}, {0.7514f,0.3210f,0.0001f}, {0.6424f,0.2650f,0.0000f},
+ {0.5419f,0.2170f,0.0000f}, {0.4479f,0.1750f,0.0000f}, {0.3608f,0.1382f,0.0000f},
+ {0.2835f,0.1070f,0.0000f}, {0.2187f,0.0816f,0.0000f}, {0.1649f,0.0610f,0.0000f},
+ {0.1212f,0.0446f,0.0000f}, {0.0874f,0.0320f,0.0000f}, {0.0636f,0.0232f,0.0000f},
+ {0.0468f,0.0170f,0.0000f}, {0.0329f,0.0119f,0.0000f}, {0.0227f,0.0082f,0.0000f},
+ {0.0158f,0.0057f,0.0000f}, {0.0114f,0.0041f,0.0000f}, {0.0081f,0.0029f,0.0000f},
+ {0.0058f,0.0021f,0.0000f}, {0.0041f,0.0015f,0.0000f}, {0.0029f,0.0010f,0.0000f},
+ {0.0020f,0.0007f,0.0000f}, {0.0014f,0.0005f,0.0000f}, {0.0010f,0.0004f,0.0000f},
+ {0.0007f,0.0002f,0.0000f}, {0.0005f,0.0002f,0.0000f}, {0.0003f,0.0001f,0.0000f},
+ {0.0002f,0.0001f,0.0000f}, {0.0002f,0.0001f,0.0000f}, {0.0001f,0.0000f,0.0000f},
+ {0.0001f,0.0000f,0.0000f}, {0.0001f,0.0000f,0.0000f}, {0.0000f,0.0000f,0.0000f}
};
float lambda_nm = stack_load_float(stack, wavelength);
diff --git a/intern/cycles/kernel/svm/svm_wireframe.h b/intern/cycles/kernel/svm/svm_wireframe.h
index 5802b9d7188..660e6e2ca47 100644
--- a/intern/cycles/kernel/svm/svm_wireframe.h
+++ b/intern/cycles/kernel/svm/svm_wireframe.h
@@ -45,15 +45,16 @@ ccl_device void svm_node_wireframe(KernelGlobals *kg, ShaderData *sd, float *sta
/* Calculate wireframe */
#ifdef __HAIR__
- if (sd->prim != PRIM_NONE && sd->type & PRIMITIVE_ALL_TRIANGLE) {
+ if (sd->prim != PRIM_NONE && sd->type & PRIMITIVE_ALL_TRIANGLE)
#else
- if (sd->prim != PRIM_NONE) {
+ if (sd->prim != PRIM_NONE)
#endif
+ {
float3 Co[3];
float pixelwidth = 1.0f;
/* Triangles */
- float np = 3;
+ int np = 3;
if(sd->type & PRIMITIVE_TRIANGLE)
triangle_vertices(kg, sd->prim, Co);
diff --git a/intern/cycles/render/CMakeLists.txt b/intern/cycles/render/CMakeLists.txt
index 7d00ed92164..449c1391980 100644
--- a/intern/cycles/render/CMakeLists.txt
+++ b/intern/cycles/render/CMakeLists.txt
@@ -16,6 +16,7 @@ set(INC_SYS
set(SRC
attribute.cpp
background.cpp
+ bake.cpp
blackbody.cpp
buffers.cpp
camera.cpp
@@ -43,6 +44,7 @@ set(SRC
set(SRC_HEADERS
attribute.h
+ bake.h
background.h
blackbody.h
buffers.h
diff --git a/intern/cycles/render/attribute.cpp b/intern/cycles/render/attribute.cpp
index ce232e90ffc..14805b6f11a 100644
--- a/intern/cycles/render/attribute.cpp
+++ b/intern/cycles/render/attribute.cpp
@@ -96,6 +96,14 @@ void Attribute::add(const VoxelAttribute& f)
buffer.push_back(data[i]);
}
+void Attribute::add(const char *data)
+{
+ size_t size = data_sizeof();
+
+ for(size_t i = 0; i < size; i++)
+ buffer.push_back(data[i]);
+}
+
size_t Attribute::data_sizeof() const
{
if(element == ATTR_ELEMENT_VOXEL)
diff --git a/intern/cycles/render/attribute.h b/intern/cycles/render/attribute.h
index 3dc7b7f7401..9fc32db8444 100644
--- a/intern/cycles/render/attribute.h
+++ b/intern/cycles/render/attribute.h
@@ -82,6 +82,7 @@ public:
void add(const float3& f);
void add(const Transform& f);
void add(const VoxelAttribute& f);
+ void add(const char *data);
static bool same_storage(TypeDesc a, TypeDesc b);
static const char *standard_name(AttributeStandard std);
diff --git a/intern/cycles/render/bake.cpp b/intern/cycles/render/bake.cpp
new file mode 100644
index 00000000000..aa317ab672f
--- /dev/null
+++ b/intern/cycles/render/bake.cpp
@@ -0,0 +1,206 @@
+/*
+ * Copyright 2011-2014 Blender Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+#include "bake.h"
+
+CCL_NAMESPACE_BEGIN
+
+BakeData::BakeData(const int object, const int tri_offset, const int num_pixels):
+m_object(object),
+m_tri_offset(tri_offset),
+m_num_pixels(num_pixels)
+{
+ m_primitive.resize(num_pixels);
+ m_u.resize(num_pixels);
+ m_v.resize(num_pixels);
+ m_dudx.resize(num_pixels);
+ m_dudy.resize(num_pixels);
+ m_dvdx.resize(num_pixels);
+ m_dvdy.resize(num_pixels);
+}
+
+BakeData::~BakeData()
+{
+ m_primitive.clear();
+ m_u.clear();
+ m_v.clear();
+ m_dudx.clear();
+ m_dudy.clear();
+ m_dvdx.clear();
+ m_dvdy.clear();
+}
+
+void BakeData::set(int i, int prim, float uv[2], float dudx, float dudy, float dvdx, float dvdy)
+{
+ m_primitive[i] = (prim == -1 ? -1 : m_tri_offset + prim);
+ m_u[i] = uv[0];
+ m_v[i] = uv[1];
+ m_dudx[i] = dudx;
+ m_dudy[i] = dudy;
+ m_dvdx[i] = dvdx;
+ m_dvdy[i] = dvdy;
+}
+
+int BakeData::object()
+{
+ return m_object;
+}
+
+int BakeData::size()
+{
+ return m_num_pixels;
+}
+
+bool BakeData::is_valid(int i)
+{
+ return m_primitive[i] != -1;
+}
+
+uint4 BakeData::data(int i)
+{
+ return make_uint4(
+ m_object,
+ m_primitive[i],
+ __float_as_int(m_u[i]),
+ __float_as_int(m_v[i])
+ );
+}
+
+uint4 BakeData::differentials(int i)
+{
+ return make_uint4(
+ __float_as_int(m_dudx[i]),
+ __float_as_int(m_dudy[i]),
+ __float_as_int(m_dvdx[i]),
+ __float_as_int(m_dvdy[i])
+ );
+}
+
+BakeManager::BakeManager()
+{
+ m_bake_data = NULL;
+ m_is_baking = false;
+ need_update = true;
+}
+
+BakeManager::~BakeManager()
+{
+ if(m_bake_data)
+ delete m_bake_data;
+}
+
+bool BakeManager::get_baking()
+{
+ return m_is_baking;
+}
+
+void BakeManager::set_baking(const bool value)
+{
+ m_is_baking = value;
+}
+
+BakeData *BakeManager::init(const int object, const int tri_offset, const int num_pixels)
+{
+ m_bake_data = new BakeData(object, tri_offset, num_pixels);
+ return m_bake_data;
+}
+
+bool BakeManager::bake(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress, ShaderEvalType shader_type, BakeData *bake_data, float result[])
+{
+ size_t limit = bake_data->size();
+
+ /* setup input for device task */
+ device_vector<uint4> d_input;
+ uint4 *d_input_data = d_input.resize(limit * 2);
+ size_t d_input_size = 0;
+
+ for(size_t i = 0; i < limit; i++) {
+ d_input_data[d_input_size++] = bake_data->data(i);
+ d_input_data[d_input_size++] = bake_data->differentials(i);
+ }
+
+ if(d_input_size == 0)
+ return false;
+
+ /* run device task */
+ device_vector<float4> d_output;
+ d_output.resize(limit);
+
+ /* needs to be up to data for attribute access */
+ device->const_copy_to("__data", &dscene->data, sizeof(dscene->data));
+
+ device->mem_alloc(d_input, MEM_READ_ONLY);
+ device->mem_copy_to(d_input);
+ device->mem_alloc(d_output, MEM_WRITE_ONLY);
+
+ DeviceTask task(DeviceTask::SHADER);
+ task.shader_input = d_input.device_pointer;
+ task.shader_output = d_output.device_pointer;
+ task.shader_eval_type = shader_type;
+ task.shader_x = 0;
+ task.shader_w = d_output.size();
+ task.get_cancel = function_bind(&Progress::get_cancel, &progress);
+
+ device->task_add(task);
+ device->task_wait();
+
+ if(progress.get_cancel()) {
+ device->mem_free(d_input);
+ device->mem_free(d_output);
+ m_is_baking = false;
+ return false;
+ }
+
+ device->mem_copy_from(d_output, 0, 1, d_output.size(), sizeof(float4));
+ device->mem_free(d_input);
+ device->mem_free(d_output);
+
+ /* read result */
+ int k = 0;
+
+ float4 *offset = (float4*)d_output.data_pointer;
+
+ size_t depth = 4;
+ for(size_t i = 0; i < limit; i++) {
+ size_t index = i * depth;
+ float4 out = offset[k++];
+
+ if(bake_data->is_valid(i)) {
+ for(size_t j=0; j < 4; j++) {
+ result[index + j] = out[j];
+ }
+ }
+ }
+
+ m_is_baking = false;
+ return true;
+}
+
+void BakeManager::device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
+{
+ if(!need_update)
+ return;
+
+ if(progress.get_cancel()) return;
+
+ need_update = false;
+}
+
+void BakeManager::device_free(Device *device, DeviceScene *dscene)
+{
+}
+
+CCL_NAMESPACE_END
diff --git a/intern/cycles/render/bake.h b/intern/cycles/render/bake.h
new file mode 100644
index 00000000000..ea403f7d39a
--- /dev/null
+++ b/intern/cycles/render/bake.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2011-2014 Blender Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+#ifndef __BAKE_H__
+#define __BAKE_H__
+
+#include "util_vector.h"
+#include "device.h"
+#include "scene.h"
+#include "session.h"
+
+CCL_NAMESPACE_BEGIN
+
+class BakeData {
+public:
+ BakeData(const int object, const int tri_offset, const int num_pixels);
+ ~BakeData();
+
+ void set(int i, int prim, float uv[2], float dudx, float dudy, float dvdx, float dvdy);
+ int object();
+ int size();
+ uint4 data(int i);
+ uint4 differentials(int i);
+ bool is_valid(int i);
+
+private:
+ int m_object;
+ int m_tri_offset;
+ int m_num_pixels;
+ vector<int>m_primitive;
+ vector<float>m_u;
+ vector<float>m_v;
+ vector<float>m_dudx;
+ vector<float>m_dudy;
+ vector<float>m_dvdx;
+ vector<float>m_dvdy;
+};
+
+class BakeManager {
+public:
+ BakeManager();
+ ~BakeManager();
+
+ bool get_baking();
+ void set_baking(const bool value);
+
+ BakeData *init(const int object, const int tri_offset, const int num_pixels);
+
+ bool bake(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress, ShaderEvalType shader_type, BakeData *bake_data, float result[]);
+
+ void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
+ void device_free(Device *device, DeviceScene *dscene);
+
+ bool need_update;
+
+private:
+ BakeData *m_bake_data;
+ bool m_is_baking;
+};
+
+CCL_NAMESPACE_END
+
+#endif /* __BAKE_H__ */
+
diff --git a/intern/cycles/render/blackbody.cpp b/intern/cycles/render/blackbody.cpp
index ab61886e262..89af714e8ec 100644
--- a/intern/cycles/render/blackbody.cpp
+++ b/intern/cycles/render/blackbody.cpp
@@ -59,33 +59,33 @@ vector<float> blackbody_table()
*/
const float cie_colour_match[81][3] = {
- {0.0014,0.0000,0.0065}, {0.0022,0.0001,0.0105}, {0.0042,0.0001,0.0201},
- {0.0076,0.0002,0.0362}, {0.0143,0.0004,0.0679}, {0.0232,0.0006,0.1102},
- {0.0435,0.0012,0.2074}, {0.0776,0.0022,0.3713}, {0.1344,0.0040,0.6456},
- {0.2148,0.0073,1.0391}, {0.2839,0.0116,1.3856}, {0.3285,0.0168,1.6230},
- {0.3483,0.0230,1.7471}, {0.3481,0.0298,1.7826}, {0.3362,0.0380,1.7721},
- {0.3187,0.0480,1.7441}, {0.2908,0.0600,1.6692}, {0.2511,0.0739,1.5281},
- {0.1954,0.0910,1.2876}, {0.1421,0.1126,1.0419}, {0.0956,0.1390,0.8130},
- {0.0580,0.1693,0.6162}, {0.0320,0.2080,0.4652}, {0.0147,0.2586,0.3533},
- {0.0049,0.3230,0.2720}, {0.0024,0.4073,0.2123}, {0.0093,0.5030,0.1582},
- {0.0291,0.6082,0.1117}, {0.0633,0.7100,0.0782}, {0.1096,0.7932,0.0573},
- {0.1655,0.8620,0.0422}, {0.2257,0.9149,0.0298}, {0.2904,0.9540,0.0203},
- {0.3597,0.9803,0.0134}, {0.4334,0.9950,0.0087}, {0.5121,1.0000,0.0057},
- {0.5945,0.9950,0.0039}, {0.6784,0.9786,0.0027}, {0.7621,0.9520,0.0021},
- {0.8425,0.9154,0.0018}, {0.9163,0.8700,0.0017}, {0.9786,0.8163,0.0014},
- {1.0263,0.7570,0.0011}, {1.0567,0.6949,0.0010}, {1.0622,0.6310,0.0008},
- {1.0456,0.5668,0.0006}, {1.0026,0.5030,0.0003}, {0.9384,0.4412,0.0002},
- {0.8544,0.3810,0.0002}, {0.7514,0.3210,0.0001}, {0.6424,0.2650,0.0000},
- {0.5419,0.2170,0.0000}, {0.4479,0.1750,0.0000}, {0.3608,0.1382,0.0000},
- {0.2835,0.1070,0.0000}, {0.2187,0.0816,0.0000}, {0.1649,0.0610,0.0000},
- {0.1212,0.0446,0.0000}, {0.0874,0.0320,0.0000}, {0.0636,0.0232,0.0000},
- {0.0468,0.0170,0.0000}, {0.0329,0.0119,0.0000}, {0.0227,0.0082,0.0000},
- {0.0158,0.0057,0.0000}, {0.0114,0.0041,0.0000}, {0.0081,0.0029,0.0000},
- {0.0058,0.0021,0.0000}, {0.0041,0.0015,0.0000}, {0.0029,0.0010,0.0000},
- {0.0020,0.0007,0.0000}, {0.0014,0.0005,0.0000}, {0.0010,0.0004,0.0000},
- {0.0007,0.0002,0.0000}, {0.0005,0.0002,0.0000}, {0.0003,0.0001,0.0000},
- {0.0002,0.0001,0.0000}, {0.0002,0.0001,0.0000}, {0.0001,0.0000,0.0000},
- {0.0001,0.0000,0.0000}, {0.0001,0.0000,0.0000}, {0.0000,0.0000,0.0000}
+ {0.0014f,0.0000f,0.0065f}, {0.0022f,0.0001f,0.0105f}, {0.0042f,0.0001f,0.0201f},
+ {0.0076f,0.0002f,0.0362f}, {0.0143f,0.0004f,0.0679f}, {0.0232f,0.0006f,0.1102f},
+ {0.0435f,0.0012f,0.2074f}, {0.0776f,0.0022f,0.3713f}, {0.1344f,0.0040f,0.6456f},
+ {0.2148f,0.0073f,1.0391f}, {0.2839f,0.0116f,1.3856f}, {0.3285f,0.0168f,1.6230f},
+ {0.3483f,0.0230f,1.7471f}, {0.3481f,0.0298f,1.7826f}, {0.3362f,0.0380f,1.7721f},
+ {0.3187f,0.0480f,1.7441f}, {0.2908f,0.0600f,1.6692f}, {0.2511f,0.0739f,1.5281f},
+ {0.1954f,0.0910f,1.2876f}, {0.1421f,0.1126f,1.0419f}, {0.0956f,0.1390f,0.8130f},
+ {0.0580f,0.1693f,0.6162f}, {0.0320f,0.2080f,0.4652f}, {0.0147f,0.2586f,0.3533f},
+ {0.0049f,0.3230f,0.2720f}, {0.0024f,0.4073f,0.2123f}, {0.0093f,0.5030f,0.1582f},
+ {0.0291f,0.6082f,0.1117f}, {0.0633f,0.7100f,0.0782f}, {0.1096f,0.7932f,0.0573f},
+ {0.1655f,0.8620f,0.0422f}, {0.2257f,0.9149f,0.0298f}, {0.2904f,0.9540f,0.0203f},
+ {0.3597f,0.9803f,0.0134f}, {0.4334f,0.9950f,0.0087f}, {0.5121f,1.0000f,0.0057f},
+ {0.5945f,0.9950f,0.0039f}, {0.6784f,0.9786f,0.0027f}, {0.7621f,0.9520f,0.0021f},
+ {0.8425f,0.9154f,0.0018f}, {0.9163f,0.8700f,0.0017f}, {0.9786f,0.8163f,0.0014f},
+ {1.0263f,0.7570f,0.0011f}, {1.0567f,0.6949f,0.0010f}, {1.0622f,0.6310f,0.0008f},
+ {1.0456f,0.5668f,0.0006f}, {1.0026f,0.5030f,0.0003f}, {0.9384f,0.4412f,0.0002f},
+ {0.8544f,0.3810f,0.0002f}, {0.7514f,0.3210f,0.0001f}, {0.6424f,0.2650f,0.0000f},
+ {0.5419f,0.2170f,0.0000f}, {0.4479f,0.1750f,0.0000f}, {0.3608f,0.1382f,0.0000f},
+ {0.2835f,0.1070f,0.0000f}, {0.2187f,0.0816f,0.0000f}, {0.1649f,0.0610f,0.0000f},
+ {0.1212f,0.0446f,0.0000f}, {0.0874f,0.0320f,0.0000f}, {0.0636f,0.0232f,0.0000f},
+ {0.0468f,0.0170f,0.0000f}, {0.0329f,0.0119f,0.0000f}, {0.0227f,0.0082f,0.0000f},
+ {0.0158f,0.0057f,0.0000f}, {0.0114f,0.0041f,0.0000f}, {0.0081f,0.0029f,0.0000f},
+ {0.0058f,0.0021f,0.0000f}, {0.0041f,0.0015f,0.0000f}, {0.0029f,0.0010f,0.0000f},
+ {0.0020f,0.0007f,0.0000f}, {0.0014f,0.0005f,0.0000f}, {0.0010f,0.0004f,0.0000f},
+ {0.0007f,0.0002f,0.0000f}, {0.0005f,0.0002f,0.0000f}, {0.0003f,0.0001f,0.0000f},
+ {0.0002f,0.0001f,0.0000f}, {0.0002f,0.0001f,0.0000f}, {0.0001f,0.0000f,0.0000f},
+ {0.0001f,0.0000f,0.0000f}, {0.0001f,0.0000f,0.0000f}, {0.0000f,0.0000f,0.0000f}
};
const double c1 = 3.74183e-16; // 2*pi*h*c^2, W*m^2
diff --git a/intern/cycles/render/camera.cpp b/intern/cycles/render/camera.cpp
index d2e2a220861..8659fe4f7a3 100644
--- a/intern/cycles/render/camera.cpp
+++ b/intern/cycles/render/camera.cpp
@@ -44,8 +44,8 @@ Camera::Camera()
fisheye_lens = 10.5f;
fov = M_PI_4_F;
- sensorwidth = 0.036;
- sensorheight = 0.024;
+ sensorwidth = 0.036f;
+ sensorheight = 0.024f;
nearclip = 1e-5f;
farclip = 1e5f;
diff --git a/intern/cycles/render/curves.cpp b/intern/cycles/render/curves.cpp
index 6e6b11ca92f..2c96ffa655e 100644
--- a/intern/cycles/render/curves.cpp
+++ b/intern/cycles/render/curves.cpp
@@ -110,7 +110,7 @@ void CurveSystemManager::device_update(Device *device, DeviceScene *dscene, Scen
progress.set_status("Updating Hair settings", "Copying Hair settings to device");
- KernelCurves *kcurve= &dscene->data.curve;
+ KernelCurves *kcurve = &dscene->data.curve;
kcurve->curveflags = 0;
diff --git a/intern/cycles/render/film.cpp b/intern/cycles/render/film.cpp
index 30ad86a8d4c..c1aefbcfbbc 100644
--- a/intern/cycles/render/film.cpp
+++ b/intern/cycles/render/film.cpp
@@ -155,6 +155,9 @@ void Pass::add(PassType type, vector<Pass>& passes)
pass.components = 4;
pass.exposure = false;
break;
+ case PASS_LIGHT:
+ /* ignores */
+ break;
}
passes.push_back(pass);
@@ -393,6 +396,10 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
kfilm->pass_shadow = kfilm->pass_stride;
kfilm->use_light_pass = 1;
break;
+
+ case PASS_LIGHT:
+ kfilm->use_light_pass = 1;
+ break;
case PASS_NONE:
break;
}
diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp
index 9142eb5308c..0ff904d06e7 100644
--- a/intern/cycles/render/graph.cpp
+++ b/intern/cycles/render/graph.cpp
@@ -227,7 +227,7 @@ void ShaderGraph::disconnect(ShaderInput *to)
from->links.erase(remove(from->links.begin(), from->links.end(), to), from->links.end());
}
-void ShaderGraph::finalize(bool do_bump, bool do_osl, bool do_multi_transform)
+void ShaderGraph::finalize(bool do_bump, bool do_osl)
{
/* before compiling, the shader graph may undergo a number of modifications.
* currently we set default geometry shader inputs, and create automatic bump
@@ -242,17 +242,15 @@ void ShaderGraph::finalize(bool do_bump, bool do_osl, bool do_multi_transform)
if(do_bump)
bump_from_displacement();
- if(do_multi_transform) {
- ShaderInput *surface_in = output()->input("Surface");
- ShaderInput *volume_in = output()->input("Volume");
+ ShaderInput *surface_in = output()->input("Surface");
+ ShaderInput *volume_in = output()->input("Volume");
- /* todo: make this work when surface and volume closures are tangled up */
+ /* todo: make this work when surface and volume closures are tangled up */
- if(surface_in->link)
- transform_multi_closure(surface_in->link->parent, NULL, false);
- if(volume_in->link)
- transform_multi_closure(volume_in->link->parent, NULL, true);
- }
+ if(surface_in->link)
+ transform_multi_closure(surface_in->link->parent, NULL, false);
+ if(volume_in->link)
+ transform_multi_closure(volume_in->link->parent, NULL, true);
finalized = true;
}
diff --git a/intern/cycles/render/graph.h b/intern/cycles/render/graph.h
index 263ce59156a..89a066195d6 100644
--- a/intern/cycles/render/graph.h
+++ b/intern/cycles/render/graph.h
@@ -247,7 +247,7 @@ public:
void disconnect(ShaderInput *to);
void remove_unneeded_nodes();
- void finalize(bool do_bump = false, bool do_osl = false, bool do_multi_closure = false);
+ void finalize(bool do_bump = false, bool do_osl = false);
protected:
typedef pair<ShaderNode* const, ShaderNode*> NodePair;
diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp
index 6348c9e6706..86755badc42 100644
--- a/intern/cycles/render/image.cpp
+++ b/intern/cycles/render/image.cpp
@@ -59,11 +59,16 @@ void ImageManager::set_osl_texture_system(void *texture_system)
osl_texture_system = texture_system;
}
-void ImageManager::set_extended_image_limits(void)
+void ImageManager::set_extended_image_limits(const DeviceInfo& info)
{
- tex_num_images = TEX_EXTENDED_NUM_IMAGES;
- tex_num_float_images = TEX_EXTENDED_NUM_FLOAT_IMAGES;
- tex_image_byte_start = TEX_EXTENDED_IMAGE_BYTE_START;
+ if(info.type == DEVICE_CPU) {
+ tex_num_images = TEX_EXTENDED_NUM_IMAGES_CPU;
+ tex_num_float_images = TEX_EXTENDED_NUM_FLOAT_IMAGES;
+ tex_image_byte_start = TEX_EXTENDED_IMAGE_BYTE_START;
+ }
+ else if((info.type == DEVICE_CUDA || info.type == DEVICE_MULTI) && info.extended_images) {
+ tex_num_images = TEX_EXTENDED_NUM_IMAGES_GPU;
+ }
}
bool ImageManager::set_animation_frame_update(int frame)
@@ -152,7 +157,7 @@ static bool image_equals(ImageManager::Image *image, const string& filename, voi
image->interpolation == interpolation;
}
-int ImageManager::add_image(const string& filename, void *builtin_data, bool animated, bool& is_float, bool& is_linear, InterpolationType interpolation)
+int ImageManager::add_image(const string& filename, void *builtin_data, bool animated, bool& is_float, bool& is_linear, InterpolationType interpolation, bool use_alpha)
{
Image *img;
size_t slot;
@@ -194,6 +199,7 @@ int ImageManager::add_image(const string& filename, void *builtin_data, bool ani
img->animated = animated;
img->interpolation = interpolation;
img->users = 1;
+ img->use_alpha = use_alpha;
float_images[slot] = img;
}
@@ -230,6 +236,7 @@ int ImageManager::add_image(const string& filename, void *builtin_data, bool ani
img->animated = animated;
img->interpolation = interpolation;
img->users = 1;
+ img->use_alpha = use_alpha;
images[slot] = img;
@@ -307,9 +314,13 @@ bool ImageManager::file_load_image(Image *img, device_vector<uchar4>& tex_img)
if(!in)
return false;
- ImageSpec spec;
+ ImageSpec spec = ImageSpec();
+ ImageSpec config = ImageSpec();
+
+ if(img->use_alpha == false)
+ config.attribute("oiio:UnassociatedAlpha", 1);
- if(!in->open(img->filename, spec)) {
+ if(!in->open(img->filename, spec, config)) {
delete in;
return false;
}
@@ -387,6 +398,12 @@ bool ImageManager::file_load_image(Image *img, device_vector<uchar4>& tex_img)
}
}
+ if(img->use_alpha == false) {
+ for(int i = width*height*depth-1; i >= 0; i--) {
+ pixels[i*4+3] = 255;
+ }
+ }
+
return true;
}
@@ -405,9 +422,13 @@ bool ImageManager::file_load_float_image(Image *img, device_vector<float4>& tex_
if(!in)
return false;
- ImageSpec spec;
+ ImageSpec spec = ImageSpec();
+ ImageSpec config = ImageSpec();
- if(!in->open(img->filename, spec)) {
+ if(img->use_alpha == false)
+ config.attribute("oiio:UnassociatedAlpha",1);
+
+ if(!in->open(img->filename, spec, config)) {
delete in;
return false;
}
@@ -484,6 +505,12 @@ bool ImageManager::file_load_float_image(Image *img, device_vector<float4>& tex_
}
}
+ if(img->use_alpha == false) {
+ for(int i = width*height*depth-1; i >= 0; i--) {
+ pixels[i*4+3] = 1.0f;
+ }
+ }
+
return true;
}
diff --git a/intern/cycles/render/image.h b/intern/cycles/render/image.h
index a52ab2853b9..561550fe0d2 100644
--- a/intern/cycles/render/image.h
+++ b/intern/cycles/render/image.h
@@ -17,6 +17,7 @@
#ifndef __IMAGE_H__
#define __IMAGE_H__
+#include "device.h"
#include "device_memory.h"
#include "util_string.h"
@@ -27,11 +28,16 @@
CCL_NAMESPACE_BEGIN
+/* generic */
#define TEX_NUM_IMAGES 95
#define TEX_IMAGE_BYTE_START TEX_NUM_FLOAT_IMAGES
+/* extended gpu */
+#define TEX_EXTENDED_NUM_IMAGES_GPU 145
+
+/* extended cpu */
#define TEX_EXTENDED_NUM_FLOAT_IMAGES 1024
-#define TEX_EXTENDED_NUM_IMAGES 1024
+#define TEX_EXTENDED_NUM_IMAGES_CPU 1024
#define TEX_EXTENDED_IMAGE_BYTE_START TEX_EXTENDED_NUM_FLOAT_IMAGES
/* color to use when textures are not found */
@@ -49,7 +55,7 @@ public:
ImageManager();
~ImageManager();
- int add_image(const string& filename, void *builtin_data, bool animated, bool& is_float, bool& is_linear, InterpolationType interpolation);
+ int add_image(const string& filename, void *builtin_data, bool animated, bool& is_float, bool& is_linear, InterpolationType interpolation, bool use_alpha);
void remove_image(int slot);
void remove_image(const string& filename, void *builtin_data, InterpolationType interpolation);
bool is_float_image(const string& filename, void *builtin_data, bool& is_linear);
@@ -59,7 +65,7 @@ public:
void set_osl_texture_system(void *texture_system);
void set_pack_images(bool pack_images_);
- void set_extended_image_limits(void);
+ void set_extended_image_limits(const DeviceInfo& info);
bool set_animation_frame_update(int frame);
bool need_update;
@@ -72,6 +78,7 @@ public:
string filename;
void *builtin_data;
+ bool use_alpha;
bool need_load;
bool animated;
InterpolationType interpolation;
diff --git a/intern/cycles/render/integrator.cpp b/intern/cycles/render/integrator.cpp
index e079e7e5ff1..59a0de07e5a 100644
--- a/intern/cycles/render/integrator.cpp
+++ b/intern/cycles/render/integrator.cpp
@@ -34,16 +34,14 @@ Integrator::Integrator()
max_glossy_bounce = max_bounce;
max_transmission_bounce = max_bounce;
max_volume_bounce = max_bounce;
- probalistic_termination = true;
transparent_min_bounce = min_bounce;
transparent_max_bounce = max_bounce;
- transparent_probalistic = true;
transparent_shadows = false;
volume_homogeneous_sampling = 0;
volume_max_steps = 1024;
- volume_step_size = 0.1;
+ volume_step_size = 0.1f;
no_caustics = false;
filter_glossy = 0.0f;
@@ -83,10 +81,7 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene
/* integrator parameters */
kintegrator->max_bounce = max_bounce + 1;
- if(probalistic_termination)
- kintegrator->min_bounce = min_bounce + 1;
- else
- kintegrator->min_bounce = kintegrator->max_bounce;
+ kintegrator->min_bounce = min_bounce + 1;
kintegrator->max_diffuse_bounce = max_diffuse_bounce + 1;
kintegrator->max_glossy_bounce = max_glossy_bounce + 1;
@@ -98,10 +93,7 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene
kintegrator->max_volume_bounce = 1;
kintegrator->transparent_max_bounce = transparent_max_bounce + 1;
- if(transparent_probalistic)
- kintegrator->transparent_min_bounce = transparent_min_bounce + 1;
- else
- kintegrator->transparent_min_bounce = kintegrator->transparent_max_bounce;
+ kintegrator->transparent_min_bounce = transparent_min_bounce + 1;
kintegrator->transparent_shadows = transparent_shadows;
@@ -175,10 +167,8 @@ bool Integrator::modified(const Integrator& integrator)
max_glossy_bounce == integrator.max_glossy_bounce &&
max_transmission_bounce == integrator.max_transmission_bounce &&
max_volume_bounce == integrator.max_volume_bounce &&
- probalistic_termination == integrator.probalistic_termination &&
transparent_min_bounce == integrator.transparent_min_bounce &&
transparent_max_bounce == integrator.transparent_max_bounce &&
- transparent_probalistic == integrator.transparent_probalistic &&
transparent_shadows == integrator.transparent_shadows &&
volume_homogeneous_sampling == integrator.volume_homogeneous_sampling &&
volume_max_steps == integrator.volume_max_steps &&
diff --git a/intern/cycles/render/integrator.h b/intern/cycles/render/integrator.h
index 2570b13808c..380c1a65722 100644
--- a/intern/cycles/render/integrator.h
+++ b/intern/cycles/render/integrator.h
@@ -34,11 +34,9 @@ public:
int max_glossy_bounce;
int max_transmission_bounce;
int max_volume_bounce;
- bool probalistic_termination;
int transparent_min_bounce;
int transparent_max_bounce;
- bool transparent_probalistic;
bool transparent_shadows;
int volume_homogeneous_sampling;
diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp
index cfc4f55ed5e..7bdb1fbf8af 100644
--- a/intern/cycles/render/light.cpp
+++ b/intern/cycles/render/light.cpp
@@ -29,7 +29,7 @@
CCL_NAMESPACE_BEGIN
-static void shade_background_pixels(Device *device, DeviceScene *dscene, int res, vector<float3>& pixels)
+static void shade_background_pixels(Device *device, DeviceScene *dscene, int res, vector<float3>& pixels, Progress& progress)
{
/* create input */
int width = res;
@@ -66,6 +66,7 @@ static void shade_background_pixels(Device *device, DeviceScene *dscene, int res
main_task.shader_eval_type = SHADER_EVAL_BACKGROUND;
main_task.shader_x = 0;
main_task.shader_w = width*height;
+ main_task.get_cancel = function_bind(&Progress::get_cancel, &progress);
/* disabled splitting for now, there's an issue with multi-GPU mem_copy_from */
list<DeviceTask> split_tasks;
@@ -149,7 +150,6 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
size_t num_lights = scene->lights.size();
size_t num_background_lights = 0;
size_t num_triangles = 0;
- size_t num_curve_segments = 0;
foreach(Object *object, scene->objects) {
Mesh *mesh = object->mesh;
@@ -184,8 +184,7 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
}
}
- size_t num_distribution = num_triangles + num_curve_segments;
- num_distribution += num_lights;
+ size_t num_distribution = num_triangles + num_lights;
/* emission area */
float4 *distribution = dscene->light_distribution.resize(num_distribution + 1);
@@ -397,7 +396,7 @@ void LightManager::device_update_background(Device *device, DeviceScene *dscene,
assert(res > 0);
vector<float3> pixels;
- shade_background_pixels(device, dscene, res, pixels);
+ shade_background_pixels(device, dscene, res, pixels, progress);
if(progress.get_cancel())
return;
diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp
index 2ae15e09efb..9c5ddd55010 100644
--- a/intern/cycles/render/mesh.cpp
+++ b/intern/cycles/render/mesh.cpp
@@ -134,6 +134,22 @@ void Mesh::clear()
transform_normal = transform_identity();
}
+int Mesh::split_vertex(int vertex)
+{
+ /* copy vertex location and vertex attributes */
+ verts.push_back(verts[vertex]);
+
+ foreach(Attribute& attr, attributes.attributes) {
+ if(attr.element == ATTR_ELEMENT_VERTEX) {
+ vector<char> tmp(attr.data_sizeof());
+ memcpy(&tmp[0], attr.data() + tmp.size()*vertex, tmp.size());
+ attr.add(&tmp[0]);
+ }
+ }
+
+ return verts.size() - 1;
+}
+
void Mesh::set_triangle(int i, int v0, int v1, int v2, int shader_, bool smooth_)
{
Triangle tri;
@@ -330,7 +346,7 @@ void Mesh::add_vertex_normals()
Attribute *attr_mP = attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
Attribute *attr_mN = attributes.find(ATTR_STD_MOTION_VERTEX_NORMAL);
- if(has_motion_blur() && !attr_mN) {
+ if(has_motion_blur() && attr_mP && !attr_mN) {
/* create attribute */
attr_mN = attributes.add(ATTR_STD_MOTION_VERTEX_NORMAL);
@@ -538,7 +554,7 @@ bool Mesh::has_motion_blur() const
{
return (use_motion_blur &&
(attributes.find(ATTR_STD_MOTION_VERTEX_POSITION) ||
- curve_attributes.find(ATTR_STD_MOTION_VERTEX_POSITION)));
+ curve_attributes.find(ATTR_STD_MOTION_VERTEX_POSITION)));
}
/* Mesh Manager */
diff --git a/intern/cycles/render/mesh.h b/intern/cycles/render/mesh.h
index eec20acd3a9..247e3dd555e 100644
--- a/intern/cycles/render/mesh.h
+++ b/intern/cycles/render/mesh.h
@@ -114,6 +114,7 @@ public:
void add_triangle(int v0, int v1, int v2, int shader, bool smooth);
void add_curve_key(float3 loc, float radius);
void add_curve(int first_key, int num_keys, int shader);
+ int split_vertex(int vertex);
void compute_bounds();
void add_face_normals();
diff --git a/intern/cycles/render/mesh_displace.cpp b/intern/cycles/render/mesh_displace.cpp
index 09d3ce6a588..661fd9c66c1 100644
--- a/intern/cycles/render/mesh_displace.cpp
+++ b/intern/cycles/render/mesh_displace.cpp
@@ -119,17 +119,21 @@ bool MeshManager::displace(Device *device, DeviceScene *dscene, Scene *scene, Me
task.shader_eval_type = SHADER_EVAL_DISPLACE;
task.shader_x = 0;
task.shader_w = d_output.size();
+ task.get_cancel = function_bind(&Progress::get_cancel, &progress);
device->task_add(task);
device->task_wait();
+ if(progress.get_cancel()) {
+ device->mem_free(d_input);
+ device->mem_free(d_output);
+ return false;
+ }
+
device->mem_copy_from(d_output, 0, 1, d_output.size(), sizeof(float4));
device->mem_free(d_input);
device->mem_free(d_output);
- if(progress.get_cancel())
- return false;
-
/* read result */
done.clear();
done.resize(mesh->verts.size(), false);
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 908acb3e6aa..a53e0b39435 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -189,6 +189,7 @@ ImageTextureNode::ImageTextureNode()
slot = -1;
is_float = -1;
is_linear = false;
+ use_alpha = true;
filename = "";
builtin_data = NULL;
color_space = ustring("Color");
@@ -242,7 +243,7 @@ void ImageTextureNode::compile(SVMCompiler& compiler)
image_manager = compiler.image_manager;
if(is_float == -1) {
bool is_float_bool;
- slot = image_manager->add_image(filename, builtin_data, animated, is_float_bool, is_linear, interpolation);
+ slot = image_manager->add_image(filename, builtin_data, animated, is_float_bool, is_linear, interpolation, use_alpha);
is_float = (int)is_float_bool;
}
@@ -317,7 +318,7 @@ void ImageTextureNode::compile(OSLCompiler& compiler)
compiler.parameter("is_float", is_float);
compiler.parameter("use_alpha", !alpha_out->links.empty());
- switch (interpolation){
+ switch (interpolation) {
case INTERPOLATION_CLOSEST:
compiler.parameter("interpolation", "closest");
break;
@@ -357,6 +358,7 @@ EnvironmentTextureNode::EnvironmentTextureNode()
slot = -1;
is_float = -1;
is_linear = false;
+ use_alpha = true;
filename = "";
builtin_data = NULL;
color_space = ustring("Color");
@@ -406,7 +408,7 @@ void EnvironmentTextureNode::compile(SVMCompiler& compiler)
image_manager = compiler.image_manager;
if(slot == -1) {
bool is_float_bool;
- slot = image_manager->add_image(filename, builtin_data, animated, is_float_bool, is_linear, INTERPOLATION_LINEAR);
+ slot = image_manager->add_image(filename, builtin_data, animated, is_float_bool, is_linear, INTERPOLATION_LINEAR, use_alpha);
is_float = (int)is_float_bool;
}
@@ -582,13 +584,13 @@ static void sky_texture_precompute_new(SunSky *sunsky, float3 dir, float turbidi
/* Copy values from sky_state to SunSky */
for (int i = 0; i < 9; ++i) {
- sunsky->config_x[i] = sky_state->configs[0][i];
- sunsky->config_y[i] = sky_state->configs[1][i];
- sunsky->config_z[i] = sky_state->configs[2][i];
+ sunsky->config_x[i] = (float)sky_state->configs[0][i];
+ sunsky->config_y[i] = (float)sky_state->configs[1][i];
+ sunsky->config_z[i] = (float)sky_state->configs[2][i];
}
- sunsky->radiance_x = sky_state->radiances[0];
- sunsky->radiance_y = sky_state->radiances[1];
- sunsky->radiance_z = sky_state->radiances[2];
+ sunsky->radiance_x = (float)sky_state->radiances[0];
+ sunsky->radiance_y = (float)sky_state->radiances[1];
+ sunsky->radiance_z = (float)sky_state->radiances[2];
/* Free sky_state */
arhosekskymodelstate_free(sky_state);
@@ -629,6 +631,8 @@ void SkyTextureNode::compile(SVMCompiler& compiler)
sky_texture_precompute_old(&sunsky, sun_direction, turbidity);
else if(type_enum[type] == NODE_SKY_NEW)
sky_texture_precompute_new(&sunsky, sun_direction, turbidity, ground_albedo);
+ else
+ assert(false);
if(vector_in->link)
compiler.stack_assign(vector_in);
@@ -666,6 +670,8 @@ void SkyTextureNode::compile(OSLCompiler& compiler)
sky_texture_precompute_old(&sunsky, sun_direction, turbidity);
else if(type_enum[type] == NODE_SKY_NEW)
sky_texture_precompute_new(&sunsky, sun_direction, turbidity, ground_albedo);
+ else
+ assert(false);
compiler.parameter("sky_model", type);
compiler.parameter("theta", sunsky.theta);
@@ -2360,6 +2366,15 @@ void UVMapNode::compile(SVMCompiler& compiler)
NodeType attr_node = NODE_ATTR;
int attr;
+ if(bump == SHADER_BUMP_DX) {
+ texco_node = NODE_TEX_COORD_BUMP_DX;
+ attr_node = NODE_ATTR_BUMP_DX;
+ }
+ else if(bump == SHADER_BUMP_DY) {
+ texco_node = NODE_TEX_COORD_BUMP_DY;
+ attr_node = NODE_ATTR_BUMP_DY;
+ }
+
if(!out->links.empty()) {
if(from_dupli) {
compiler.stack_assign(out);
@@ -2379,6 +2394,13 @@ void UVMapNode::compile(SVMCompiler& compiler)
void UVMapNode::compile(OSLCompiler& compiler)
{
+ if(bump == SHADER_BUMP_DX)
+ compiler.parameter("bump_offset", "dx");
+ else if(bump == SHADER_BUMP_DY)
+ compiler.parameter("bump_offset", "dy");
+ else
+ compiler.parameter("bump_offset", "center");
+
compiler.parameter("from_dupli", from_dupli);
compiler.parameter("name", attribute.c_str());
compiler.add(this, "node_uv_map");
@@ -2399,6 +2421,7 @@ LightPathNode::LightPathNode()
add_output("Is Volume Scatter Ray", SHADER_SOCKET_FLOAT);
add_output("Ray Length", SHADER_SOCKET_FLOAT);
add_output("Ray Depth", SHADER_SOCKET_FLOAT);
+ add_output("Transparent Depth", SHADER_SOCKET_FLOAT);
}
void LightPathNode::compile(SVMCompiler& compiler)
@@ -2466,6 +2489,11 @@ void LightPathNode::compile(SVMCompiler& compiler)
compiler.add_node(NODE_LIGHT_PATH, NODE_LP_ray_depth, out->stack_offset);
}
+ out = output("Transparent Depth");
+ if(!out->links.empty()) {
+ compiler.stack_assign(out);
+ compiler.add_node(NODE_LIGHT_PATH, NODE_LP_ray_transparent, out->stack_offset);
+ }
}
void LightPathNode::compile(OSLCompiler& compiler)
@@ -3516,6 +3544,7 @@ static ShaderEnum math_type_init()
enm.insert("Less Than", NODE_MATH_LESS_THAN);
enm.insert("Greater Than", NODE_MATH_GREATER_THAN);
enm.insert("Modulo", NODE_MATH_MODULO);
+ enm.insert("Absolute", NODE_MATH_ABSOLUTE);
return enm;
}
diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h
index 054ae0f613c..d94d8ce6033 100644
--- a/intern/cycles/render/nodes.h
+++ b/intern/cycles/render/nodes.h
@@ -72,6 +72,7 @@ public:
int slot;
int is_float;
bool is_linear;
+ bool use_alpha;
string filename;
void *builtin_data;
ustring color_space;
@@ -95,6 +96,7 @@ public:
int slot;
int is_float;
bool is_linear;
+ bool use_alpha;
string filename;
void *builtin_data;
ustring color_space;
diff --git a/intern/cycles/render/object.cpp b/intern/cycles/render/object.cpp
index dab00eae2df..027bfd71931 100644
--- a/intern/cycles/render/object.cpp
+++ b/intern/cycles/render/object.cpp
@@ -79,7 +79,7 @@ void Object::compute_bounds(bool motion_blur)
bounds = mbounds.transformed(&tfm);
}
-void Object::apply_transform()
+void Object::apply_transform(bool apply_to_motion)
{
if(!mesh || tfm == transform_identity())
return;
@@ -94,25 +94,28 @@ void Object::apply_transform()
/* apply to mesh vertices */
for(size_t i = 0; i < mesh->verts.size(); i++)
mesh->verts[i] = transform_point(&tfm, mesh->verts[i]);
+
+ if(apply_to_motion) {
+ Attribute *attr = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
- Attribute *attr = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
- if (attr) {
- size_t steps_size = mesh->verts.size() * (mesh->motion_steps - 1);
- float3 *vert_steps = attr->data_float3();
+ if (attr) {
+ size_t steps_size = mesh->verts.size() * (mesh->motion_steps - 1);
+ float3 *vert_steps = attr->data_float3();
- for (size_t i = 0; i < steps_size; i++)
- vert_steps[i] = transform_point(&tfm, vert_steps[i]);
- }
+ for (size_t i = 0; i < steps_size; i++)
+ vert_steps[i] = transform_point(&tfm, vert_steps[i]);
+ }
- Attribute *attr_N = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_NORMAL);
+ Attribute *attr_N = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_NORMAL);
- if(attr_N) {
- Transform ntfm = mesh->transform_normal;
- size_t steps_size = mesh->verts.size() * (mesh->motion_steps - 1);
- float3 *normal_steps = attr_N->data_float3();
+ if(attr_N) {
+ Transform ntfm = mesh->transform_normal;
+ size_t steps_size = mesh->verts.size() * (mesh->motion_steps - 1);
+ float3 *normal_steps = attr_N->data_float3();
- for (size_t i = 0; i < steps_size; i++)
- normal_steps[i] = normalize(transform_direction(&ntfm, normal_steps[i]));
+ for (size_t i = 0; i < steps_size; i++)
+ normal_steps[i] = normalize(transform_direction(&ntfm, normal_steps[i]));
+ }
}
}
@@ -134,20 +137,22 @@ void Object::apply_transform()
mesh->curve_keys[i].w = radius;
}
- Attribute *curve_attr = mesh->curve_attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
+ if(apply_to_motion) {
+ Attribute *curve_attr = mesh->curve_attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
- if (curve_attr) {
- /* apply transform to motion curve keys */
- size_t steps_size = mesh->curve_keys.size() * (mesh->motion_steps - 1);
- float4 *key_steps = curve_attr->data_float4();
+ if (curve_attr) {
+ /* apply transform to motion curve keys */
+ size_t steps_size = mesh->curve_keys.size() * (mesh->motion_steps - 1);
+ float4 *key_steps = curve_attr->data_float4();
- for (size_t i = 0; i < steps_size; i++) {
- float3 co = transform_point(&tfm, float4_to_float3(key_steps[i]));
- float radius = key_steps[i].w * scalar;
+ for (size_t i = 0; i < steps_size; i++) {
+ float3 co = transform_point(&tfm, float4_to_float3(key_steps[i]));
+ float radius = key_steps[i].w * scalar;
- /* scale for curve radius is only correct for uniform scale */
- key_steps[i] = float3_to_float4(co);
- key_steps[i].w = radius;
+ /* scale for curve radius is only correct for uniform scale */
+ key_steps[i] = float3_to_float4(co);
+ key_steps[i].w = radius;
+ }
}
}
}
@@ -189,11 +194,12 @@ vector<float> Object::motion_times()
{
/* compute times at which we sample motion for this object */
vector<float> times;
- int motion_steps = mesh->motion_steps;
- if(!mesh || motion_steps == 1)
+ if(!mesh || mesh->motion_steps == 1)
return times;
+ int motion_steps = mesh->motion_steps;
+
for(int step = 0; step < motion_steps; step++) {
if(step != motion_steps / 2) {
float time = 2.0f * step / (motion_steps - 1) - 1.0f;
@@ -288,8 +294,11 @@ void ObjectManager::device_update_transforms(Device *device, DeviceScene *dscene
/* pack in texture */
int offset = i*OBJECT_SIZE;
+ /* OBJECT_TRANSFORM */
memcpy(&objects[offset], &tfm, sizeof(float4)*3);
+ /* OBJECT_INVERSE_TRANSFORM */
memcpy(&objects[offset+4], &itfm, sizeof(float4)*3);
+ /* OBJECT_PROPERTIES */
objects[offset+8] = make_float4(surface_area, pass_id, random_number, __int_as_float(particle_index));
if(need_motion == Scene::MOTION_PASS) {
@@ -321,6 +330,9 @@ void ObjectManager::device_update_transforms(Device *device, DeviceScene *dscene
}
#endif
+ if(mesh->use_motion_blur)
+ have_motion = true;
+
/* dupli object coords and motion info */
int totalsteps = mesh->motion_steps;
int numsteps = (totalsteps - 1)/2;
@@ -407,6 +419,7 @@ void ObjectManager::apply_static_transforms(DeviceScene *dscene, Scene *scene, u
#ifdef __OBJECT_MOTION__
Scene::MotionType need_motion = scene->need_motion();
bool motion_blur = need_motion == Scene::MOTION_BLUR;
+ bool apply_to_motion = need_motion != Scene::MOTION_PASS;
#else
bool motion_blur = false;
#endif
@@ -429,7 +442,7 @@ void ObjectManager::apply_static_transforms(DeviceScene *dscene, Scene *scene, u
if(mesh_users[object->mesh] == 1) {
if(!(motion_blur && object->use_motion)) {
if(!object->mesh->transform_applied) {
- object->apply_transform();
+ object->apply_transform(apply_to_motion);
object->mesh->transform_applied = true;
if(progress.get_cancel()) return;
diff --git a/intern/cycles/render/object.h b/intern/cycles/render/object.h
index f3a019f4d73..677526b715f 100644
--- a/intern/cycles/render/object.h
+++ b/intern/cycles/render/object.h
@@ -60,7 +60,7 @@ public:
void tag_update(Scene *scene);
void compute_bounds(bool motion_blur);
- void apply_transform();
+ void apply_transform(bool apply_to_motion);
vector<float> motion_times();
};
diff --git a/intern/cycles/render/scene.cpp b/intern/cycles/render/scene.cpp
index 2ed4efe7f2b..4f5ad439520 100644
--- a/intern/cycles/render/scene.cpp
+++ b/intern/cycles/render/scene.cpp
@@ -17,6 +17,7 @@
#include <stdlib.h>
#include "background.h"
+#include "bake.h"
#include "camera.h"
#include "curves.h"
#include "device.h"
@@ -54,6 +55,7 @@ Scene::Scene(const SceneParams& params_, const DeviceInfo& device_info_)
image_manager = new ImageManager();
particle_system_manager = new ParticleSystemManager();
curve_system_manager = new CurveSystemManager();
+ bake_manager = new BakeManager();
/* OSL only works on the CPU */
if(device_info_.type == DEVICE_CPU)
@@ -61,8 +63,8 @@ Scene::Scene(const SceneParams& params_, const DeviceInfo& device_info_)
else
shader_manager = ShaderManager::create(this, SceneParams::SVM);
- if (device_info_.type == DEVICE_CPU)
- image_manager->set_extended_image_limits();
+ /* Extended image limits for CPU and GPUs */
+ image_manager->set_extended_image_limits(device_info_);
}
Scene::~Scene()
@@ -103,6 +105,8 @@ void Scene::free_memory(bool final)
particle_system_manager->device_free(device, &dscene);
curve_system_manager->device_free(device, &dscene);
+ bake_manager->device_free(device, &dscene);
+
if(!params.persistent_data || final)
image_manager->device_free(device, &dscene);
@@ -122,6 +126,7 @@ void Scene::free_memory(bool final)
delete particle_system_manager;
delete curve_system_manager;
delete image_manager;
+ delete bake_manager;
}
}
@@ -208,6 +213,11 @@ void Scene::device_update(Device *device_, Progress& progress)
if(progress.get_cancel()) return;
+ progress.set_status("Updating Baking");
+ bake_manager->device_update(device, &dscene, this, progress);
+
+ if(progress.get_cancel()) return;
+
progress.set_status("Updating Device", "Writing constant memory");
device->const_copy_to("__data", &dscene.data, sizeof(dscene.data));
}
@@ -226,9 +236,9 @@ bool Scene::need_global_attribute(AttributeStandard std)
{
if(std == ATTR_STD_UV)
return Pass::contains(film->passes, PASS_UV);
- if(std == ATTR_STD_MOTION_VERTEX_POSITION)
+ else if(std == ATTR_STD_MOTION_VERTEX_POSITION)
return need_motion() != MOTION_NONE;
- if(std == ATTR_STD_MOTION_VERTEX_NORMAL)
+ else if(std == ATTR_STD_MOTION_VERTEX_NORMAL)
return need_motion() == MOTION_BLUR;
return false;
@@ -258,7 +268,8 @@ bool Scene::need_reset()
|| integrator->need_update
|| shader_manager->need_update
|| particle_system_manager->need_update
- || curve_system_manager->need_update);
+ || curve_system_manager->need_update
+ || bake_manager->need_update);
}
void Scene::reset()
diff --git a/intern/cycles/render/scene.h b/intern/cycles/render/scene.h
index b6a4d6c0436..0f0bb725823 100644
--- a/intern/cycles/render/scene.h
+++ b/intern/cycles/render/scene.h
@@ -51,6 +51,8 @@ class CurveSystemManager;
class Shader;
class ShaderManager;
class Progress;
+class BakeManager;
+class BakeData;
/* Scene Device Data */
@@ -103,8 +105,8 @@ public:
/* integrator */
device_vector<uint> sobol_directions;
- /* images */
- device_vector<uchar4> tex_image[TEX_EXTENDED_NUM_IMAGES];
+ /* cpu images */
+ device_vector<uchar4> tex_image[TEX_EXTENDED_NUM_IMAGES_CPU];
device_vector<float4> tex_float_image[TEX_EXTENDED_NUM_FLOAT_IMAGES];
/* opencl images */
@@ -174,6 +176,7 @@ public:
ObjectManager *object_manager;
ParticleSystemManager *particle_system_manager;
CurveSystemManager *curve_system_manager;
+ BakeManager *bake_manager;
/* default shaders */
int default_surface;
diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp
index 2b799972a97..28b44df6b36 100644
--- a/intern/cycles/render/session.cpp
+++ b/intern/cycles/render/session.cpp
@@ -23,6 +23,7 @@
#include "integrator.h"
#include "scene.h"
#include "session.h"
+#include "bake.h"
#include "util_foreach.h"
#include "util_function.h"
@@ -50,7 +51,7 @@ Session::Session(const SessionParams& params_)
device = Device::create(params.device, stats, params.background);
- if(params.background) {
+ if(params.background && params.output_path.empty()) {
buffers = NULL;
display = NULL;
}
@@ -81,6 +82,7 @@ Session::Session(const SessionParams& params_)
Session::~Session()
{
if(session_thread) {
+ /* wait for session thread to end */
progress.set_cancel("Exiting");
gpu_need_tonemap = false;
@@ -95,13 +97,19 @@ Session::~Session()
wait();
}
- if(display && !params.output_path.empty()) {
- tonemap();
+ if(!params.output_path.empty()) {
+ /* tonemap and write out image if requested */
+ delete display;
+
+ display = new DisplayBuffer(device, false);
+ display->reset(device, buffers->params);
+ tonemap(params.samples);
progress.set_status("Writing Image", params.output_path);
display->write(device, params.output_path);
}
+ /* clean up */
foreach(RenderBuffers *buffers, tile_buffers)
delete buffers;
@@ -165,7 +173,7 @@ bool Session::draw_gpu(BufferParams& buffer_params, DeviceDrawParams& draw_param
* only access GL buffers from the main thread */
if(gpu_need_tonemap) {
thread_scoped_lock buffers_lock(buffers_mutex);
- tonemap();
+ tonemap(tile_manager.state.sample);
gpu_need_tonemap = false;
gpu_need_tonemap_cond.notify_all();
}
@@ -367,7 +375,7 @@ bool Session::acquire_tile(Device *tile_device, RenderTile& rtile)
/* in case of a permanent buffer, return it, otherwise we will allocate
* a new temporary buffer */
- if(!params.background) {
+ if(!(params.background && params.output_path.empty())) {
tile_manager.state.buffer.get_offset_stride(rtile.offset, rtile.stride);
rtile.buffer = buffers->buffer.device_pointer;
@@ -567,8 +575,8 @@ void Session::run_cpu()
}
else if(need_tonemap) {
/* tonemap only if we do not reset, we don't we don't
- * want to show the result of an incomplete sample*/
- tonemap();
+ * want to show the result of an incomplete sample */
+ tonemap(tile_manager.state.sample);
}
if(!device->error_message().empty())
@@ -726,10 +734,14 @@ void Session::update_scene()
cam->tag_update();
}
- /* number of samples is needed by multi jittered sampling pattern */
+ /* number of samples is needed by multi jittered
+ * sampling pattern and by baking */
Integrator *integrator = scene->integrator;
+ BakeManager *bake_manager = scene->bake_manager;
- if(integrator->sampling_pattern == SAMPLING_PATTERN_CMJ) {
+ if(integrator->sampling_pattern == SAMPLING_PATTERN_CMJ ||
+ bake_manager->get_baking())
+ {
int aa_samples = tile_manager.num_samples;
if(aa_samples != integrator->aa_samples) {
@@ -834,7 +846,7 @@ void Session::path_trace()
device->task_add(task);
}
-void Session::tonemap()
+void Session::tonemap(int sample)
{
/* add tonemap task */
DeviceTask task(DeviceTask::FILM_CONVERT);
@@ -846,7 +858,7 @@ void Session::tonemap()
task.rgba_byte = display->rgba_byte.device_pointer;
task.rgba_half = display->rgba_half.device_pointer;
task.buffer = buffers->buffer.device_pointer;
- task.sample = tile_manager.state.sample;
+ task.sample = sample;
tile_manager.state.buffer.get_offset_stride(task.offset, task.stride);
if(task.w > 0 && task.h > 0) {
diff --git a/intern/cycles/render/session.h b/intern/cycles/render/session.h
index e2a7076f250..1e625158652 100644
--- a/intern/cycles/render/session.h
+++ b/intern/cycles/render/session.h
@@ -136,6 +136,7 @@ public:
void set_samples(int samples);
void set_pause(bool pause);
+ void update_scene();
void device_free();
protected:
struct DelayedReset {
@@ -147,10 +148,9 @@ protected:
void run();
- void update_scene();
void update_status_time(bool show_pause = false, bool show_done = false);
- void tonemap();
+ void tonemap(int sample);
void path_trace();
void reset_(BufferParams& params, int samples);
diff --git a/intern/cycles/render/sky_model.cpp b/intern/cycles/render/sky_model.cpp
index 6f250c06bc1..adb07d9e288 100644
--- a/intern/cycles/render/sky_model.cpp
+++ b/intern/cycles/render/sky_model.cpp
@@ -310,7 +310,7 @@ double arhosekskymodel_radiance(
double wavelength
)
{
- int low_wl = (wavelength - 320.0 ) / 40.0;
+ int low_wl = (int)((wavelength - 320.0) / 40.0);
if ( low_wl < 0 || low_wl >= 11 )
return 0.0f;
diff --git a/intern/cycles/render/svm.cpp b/intern/cycles/render/svm.cpp
index c004187a091..576c176759c 100644
--- a/intern/cycles/render/svm.cpp
+++ b/intern/cycles/render/svm.cpp
@@ -63,8 +63,6 @@ void SVMShaderManager::device_update(Device *device, DeviceScene *dscene, Scene
svm_nodes.push_back(make_int4(NODE_SHADER_JUMP, 0, 0, 0));
}
- bool use_multi_closure = device->info.advanced_shading;
-
for(i = 0; i < scene->shaders.size(); i++) {
Shader *shader = scene->shaders[i];
@@ -75,8 +73,7 @@ void SVMShaderManager::device_update(Device *device, DeviceScene *dscene, Scene
if(shader->use_mis && shader->has_surface_emission)
scene->light_manager->need_update = true;
- SVMCompiler compiler(scene->shader_manager, scene->image_manager,
- use_multi_closure);
+ SVMCompiler compiler(scene->shader_manager, scene->image_manager);
compiler.background = ((int)i == scene->default_background);
compiler.compile(shader, svm_nodes, i);
}
@@ -104,7 +101,7 @@ void SVMShaderManager::device_free(Device *device, DeviceScene *dscene, Scene *s
/* Graph Compiler */
-SVMCompiler::SVMCompiler(ShaderManager *shader_manager_, ImageManager *image_manager_, bool use_multi_closure_)
+SVMCompiler::SVMCompiler(ShaderManager *shader_manager_, ImageManager *image_manager_)
{
shader_manager = shader_manager_;
image_manager = image_manager_;
@@ -114,7 +111,6 @@ SVMCompiler::SVMCompiler(ShaderManager *shader_manager_, ImageManager *image_man
current_graph = NULL;
background = false;
mix_weight_offset = SVM_STACK_INVALID;
- use_multi_closure = use_multi_closure_;
compile_failed = false;
}
@@ -230,7 +226,8 @@ void SVMCompiler::stack_assign(ShaderInput *input)
else if(input->type == SHADER_SOCKET_VECTOR ||
input->type == SHADER_SOCKET_NORMAL ||
input->type == SHADER_SOCKET_POINT ||
- input->type == SHADER_SOCKET_COLOR) {
+ input->type == SHADER_SOCKET_COLOR)
+ {
add_node(NODE_VALUE_V, input->stack_offset);
add_node(NODE_VALUE_V, input->value);
@@ -389,6 +386,10 @@ void SVMCompiler::generate_node(ShaderNode *node, set<ShaderNode*>& done)
if(node->has_spatial_varying())
current_shader->has_heterogeneous_volume = true;
}
+
+ /* detect if we have a blackbody converter, to prepare lookup table */
+ if(node->has_converter_blackbody())
+ current_shader->has_converter_blackbody = true;
}
void SVMCompiler::generate_svm_nodes(const set<ShaderNode*>& nodes, set<ShaderNode*>& done)
@@ -408,10 +409,6 @@ void SVMCompiler::generate_svm_nodes(const set<ShaderNode*>& nodes, set<ShaderNo
inputs_done = false;
if(inputs_done) {
- /* Detect if we have a blackbody converter, to prepare lookup table */
- if(node->has_converter_blackbody())
- current_shader->has_converter_blackbody = true;
-
generate_node(node, done);
done.insert(node);
}
@@ -422,104 +419,61 @@ void SVMCompiler::generate_svm_nodes(const set<ShaderNode*>& nodes, set<ShaderNo
} while(!nodes_done);
}
-void SVMCompiler::generate_closure(ShaderNode *node, set<ShaderNode*>& done)
+void SVMCompiler::generate_closure_node(ShaderNode *node, set<ShaderNode*>& done)
{
- if(node->name == ustring("mix_closure") || node->name == ustring("add_closure")) {
- ShaderInput *fin = node->input("Fac");
- ShaderInput *cl1in = node->input("Closure1");
- ShaderInput *cl2in = node->input("Closure2");
-
- /* execute dependencies for mix weight */
- if(fin) {
+ /* execute dependencies for closure */
+ foreach(ShaderInput *in, node->inputs) {
+ if(!node_skip_input(node, in) && in->link) {
set<ShaderNode*> dependencies;
- find_dependencies(dependencies, done, fin);
+ find_dependencies(dependencies, done, in);
generate_svm_nodes(dependencies, done);
-
- /* add mix node */
- stack_assign(fin);
}
+ }
- int mix_offset = svm_nodes.size();
-
- if(fin)
- add_node(NODE_MIX_CLOSURE, fin->stack_offset, 0, 0);
- else
- add_node(NODE_ADD_CLOSURE, 0, 0, 0);
-
- /* generate code for closure 1
- * note we backup all compiler state and restore it afterwards, so one
- * closure choice doesn't influence the other*/
- if(cl1in->link) {
- StackBackup backup;
- stack_backup(backup, done);
-
- generate_closure(cl1in->link->parent, done);
- add_node(NODE_END, 0, 0, 0);
-
- stack_restore(backup, done);
- }
- else
- add_node(NODE_END, 0, 0, 0);
+ /* closure mix weight */
+ const char *weight_name = (current_type == SHADER_TYPE_VOLUME)? "VolumeMixWeight": "SurfaceMixWeight";
+ ShaderInput *weight_in = node->input(weight_name);
- /* generate code for closure 2 */
- int cl2_offset = svm_nodes.size();
+ if(weight_in && (weight_in->link || weight_in->value.x != 1.0f)) {
+ stack_assign(weight_in);
+ mix_weight_offset = weight_in->stack_offset;
+ }
+ else
+ mix_weight_offset = SVM_STACK_INVALID;
- if(cl2in->link) {
- StackBackup backup;
- stack_backup(backup, done);
+ /* compile closure itself */
+ generate_node(node, done);
- generate_closure(cl2in->link->parent, done);
- add_node(NODE_END, 0, 0, 0);
+ mix_weight_offset = SVM_STACK_INVALID;
- stack_restore(backup, done);
+ if(current_type == SHADER_TYPE_SURFACE) {
+ if(node->has_surface_emission())
+ current_shader->has_surface_emission = true;
+ if(node->has_surface_transparent())
+ current_shader->has_surface_transparent = true;
+ if(node->has_surface_bssrdf()) {
+ current_shader->has_surface_bssrdf = true;
+ if(node->has_bssrdf_bump())
+ current_shader->has_bssrdf_bump = true;
}
- else
- add_node(NODE_END, 0, 0, 0);
-
- /* set jump for mix node, -1 because offset is already
- * incremented when this jump is added to it */
- svm_nodes[mix_offset].z = cl2_offset - mix_offset - 1;
+ }
+}
- done.insert(node);
- stack_clear_users(node, done);
- stack_clear_temporary(node);
+void SVMCompiler::generated_shared_closure_nodes(ShaderNode *node, set<ShaderNode*>& done, set<ShaderNode*>& closure_done, const set<ShaderNode*>& shared)
+{
+ if(shared.find(node) != shared.end()) {
+ generate_multi_closure(node, done, closure_done);
}
else {
- /* execute dependencies for closure */
foreach(ShaderInput *in, node->inputs) {
- if(!node_skip_input(node, in) && in->link) {
- set<ShaderNode*> dependencies;
- find_dependencies(dependencies, done, in);
- generate_svm_nodes(dependencies, done);
- }
- }
-
- /* compile closure itself */
- generate_node(node, done);
-
- if(current_type == SHADER_TYPE_SURFACE) {
- if(node->has_surface_emission())
- current_shader->has_surface_emission = true;
- if(node->has_surface_transparent())
- current_shader->has_surface_transparent = true;
- if(node->has_surface_bssrdf()) {
- current_shader->has_surface_bssrdf = true;
- if(node->has_bssrdf_bump())
- current_shader->has_bssrdf_bump = true;
- }
+ if(in->type == SHADER_SOCKET_CLOSURE && in->link)
+ generated_shared_closure_nodes(in->link->parent, done, closure_done, shared);
}
-
- /* end node is added outside of this */
}
}
void SVMCompiler::generate_multi_closure(ShaderNode *node, set<ShaderNode*>& done, set<ShaderNode*>& closure_done)
{
- /* todo: the weak point here is that unlike the single closure sampling
- * we will evaluate all nodes even if they are used as input for closures
- * that are unused. it's not clear what would be the best way to skip such
- * nodes at runtime, especially if they are tangled up */
-
/* only generate once */
if(closure_done.find(node) != closure_done.end())
return;
@@ -530,49 +484,80 @@ void SVMCompiler::generate_multi_closure(ShaderNode *node, set<ShaderNode*>& don
/* weighting is already taken care of in ShaderGraph::transform_multi_closure */
ShaderInput *cl1in = node->input("Closure1");
ShaderInput *cl2in = node->input("Closure2");
+ ShaderInput *facin = node->input("Fac");
- if(cl1in->link)
- generate_multi_closure(cl1in->link->parent, done, closure_done);
- if(cl2in->link)
- generate_multi_closure(cl2in->link->parent, done, closure_done);
- }
- else {
- /* execute dependencies for closure */
- foreach(ShaderInput *in, node->inputs) {
- if(!node_skip_input(node, in) && in->link) {
- set<ShaderNode*> dependencies;
- find_dependencies(dependencies, done, in);
- generate_svm_nodes(dependencies, done);
+ /* skip empty mix/add closure nodes */
+ if(!cl1in->link && !cl2in->link)
+ return;
+
+ if(facin && facin->link) {
+ /* mix closure: generate instructions to compute mix weight */
+ set<ShaderNode*> dependencies;
+ find_dependencies(dependencies, done, facin);
+ generate_svm_nodes(dependencies, done);
+
+ stack_assign(facin);
+
+ /* execute shared dependencies. this is needed to allow skipping
+ * of zero weight closures and their dependencies later, so we
+ * ensure that they only skip dependencies that are unique to them */
+ set<ShaderNode*> cl1deps, cl2deps, shareddeps;
+
+ find_dependencies(cl1deps, done, cl1in);
+ find_dependencies(cl2deps, done, cl2in);
+
+ set_intersection(cl1deps.begin(), cl1deps.end(),
+ cl2deps.begin(), cl2deps.end(),
+ std::inserter(shareddeps, shareddeps.begin()));
+
+ if(!shareddeps.empty()) {
+ if(cl1in->link)
+ generated_shared_closure_nodes(cl1in->link->parent, done, closure_done, shareddeps);
+ if(cl2in->link)
+ generated_shared_closure_nodes(cl2in->link->parent, done, closure_done, shareddeps);
+
+ generate_svm_nodes(shareddeps, done);
}
- }
- /* closure mix weight */
- const char *weight_name = (current_type == SHADER_TYPE_VOLUME)? "VolumeMixWeight": "SurfaceMixWeight";
- ShaderInput *weight_in = node->input(weight_name);
+ /* generate instructions for input closure 1 */
+ if(cl1in->link) {
+ /* add instruction to skip closure and its dependencies if mix weight is zero */
+ svm_nodes.push_back(make_int4(NODE_JUMP_IF_ONE, 0, facin->stack_offset, 0));
+ int node_jump_skip_index = svm_nodes.size() - 1;
- if(weight_in && (weight_in->link || weight_in->value.x != 1.0f)) {
- stack_assign(weight_in);
- mix_weight_offset = weight_in->stack_offset;
- }
- else
- mix_weight_offset = SVM_STACK_INVALID;
+ generate_multi_closure(cl1in->link->parent, done, closure_done);
- /* compile closure itself */
- generate_node(node, done);
+ /* fill in jump instruction location to be after closure */
+ svm_nodes[node_jump_skip_index].y = svm_nodes.size() - node_jump_skip_index - 1;
+ }
- mix_weight_offset = SVM_STACK_INVALID;
+ /* generate instructions for input closure 2 */
+ if(cl2in->link) {
+ /* add instruction to skip closure and its dependencies if mix weight is zero */
+ svm_nodes.push_back(make_int4(NODE_JUMP_IF_ZERO, 0, facin->stack_offset, 0));
+ int node_jump_skip_index = svm_nodes.size() - 1;
- if(current_type == SHADER_TYPE_SURFACE) {
- if(node->has_surface_emission())
- current_shader->has_surface_emission = true;
- if(node->has_surface_transparent())
- current_shader->has_surface_transparent = true;
- if(node->has_surface_bssrdf()) {
- current_shader->has_surface_bssrdf = true;
- if(node->has_bssrdf_bump())
- current_shader->has_bssrdf_bump = true;
+ generate_multi_closure(cl2in->link->parent, done, closure_done);
+
+ /* fill in jump instruction location to be after closure */
+ svm_nodes[node_jump_skip_index].y = svm_nodes.size() - node_jump_skip_index - 1;
}
+
+ /* unassign */
+ facin->stack_offset = SVM_STACK_INVALID;
}
+ else {
+ /* execute closures and their dependencies, no runtime checks
+ * to skip closures here because was already optimized due to
+ * fixed weight or add closure that always needs both */
+ if(cl1in->link)
+ generate_multi_closure(cl1in->link->parent, done, closure_done);
+ if(cl2in->link)
+ generate_multi_closure(cl2in->link->parent, done, closure_done);
+ }
+ }
+ else {
+ generate_closure_node(node, done);
}
done.insert(node);
@@ -652,14 +637,8 @@ void SVMCompiler::compile_type(Shader *shader, ShaderGraph *graph, ShaderType ty
}
if(generate) {
- set<ShaderNode*> done;
-
- if(use_multi_closure) {
- set<ShaderNode*> closure_done;
- generate_multi_closure(clin->link->parent, done, closure_done);
- }
- else
- generate_closure(clin->link->parent, done);
+ set<ShaderNode*> done, closure_done;
+ generate_multi_closure(clin->link->parent, done, closure_done);
}
}
@@ -686,9 +665,9 @@ void SVMCompiler::compile(Shader *shader, vector<int4>& global_svm_nodes, int in
shader->graph_bump = shader->graph->copy();
/* finalize */
- shader->graph->finalize(false, false, use_multi_closure);
+ shader->graph->finalize(false, false);
if(shader->graph_bump)
- shader->graph_bump->finalize(true, false, use_multi_closure);
+ shader->graph_bump->finalize(true, false);
current_shader = shader;
diff --git a/intern/cycles/render/svm.h b/intern/cycles/render/svm.h
index 069ba5247a2..45aa4d26926 100644
--- a/intern/cycles/render/svm.h
+++ b/intern/cycles/render/svm.h
@@ -52,8 +52,7 @@ public:
class SVMCompiler {
public:
- SVMCompiler(ShaderManager *shader_manager, ImageManager *image_manager,
- bool use_multi_closure_);
+ SVMCompiler(ShaderManager *shader_manager, ImageManager *image_manager);
void compile(Shader *shader, vector<int4>& svm_nodes, int index);
void stack_assign(ShaderOutput *output);
@@ -123,10 +122,13 @@ protected:
bool node_skip_input(ShaderNode *node, ShaderInput *input);
/* single closure */
- void find_dependencies(set<ShaderNode*>& dependencies, const set<ShaderNode*>& done, ShaderInput *input);
+ void find_dependencies(set<ShaderNode*>& dependencies,
+ const set<ShaderNode*>& done, ShaderInput *input);
void generate_node(ShaderNode *node, set<ShaderNode*>& done);
+ void generate_closure_node(ShaderNode *node, set<ShaderNode*>& done);
+ void generated_shared_closure_nodes(ShaderNode *node, set<ShaderNode*>& done,
+ set<ShaderNode*>& closure_done, const set<ShaderNode*>& shared);
void generate_svm_nodes(const set<ShaderNode*>& nodes, set<ShaderNode*>& done);
- void generate_closure(ShaderNode *node, set<ShaderNode*>& done);
/* multi closure */
void generate_multi_closure(ShaderNode *node, set<ShaderNode*>& done, set<ShaderNode*>& closure_done);
@@ -141,7 +143,6 @@ protected:
Stack active_stack;
int max_stack_use;
uint mix_weight_offset;
- bool use_multi_closure;
bool compile_failed;
};
diff --git a/intern/cycles/subd/subd_split.cpp b/intern/cycles/subd/subd_split.cpp
index 417ecfffd49..6bbf4af3f85 100644
--- a/intern/cycles/subd/subd_split.cpp
+++ b/intern/cycles/subd/subd_split.cpp
@@ -94,7 +94,7 @@ void DiagSplit::partition_edge(Patch *patch, float2 *P, int *t0, int *t1, float2
*t1 = T(patch, *P, Pend);
}
else {
- int I = floor(t*0.5f);
+ int I = (int)floor((float)t*0.5f);
*P = interp(Pstart, Pend, (t == 0)? 0: I/(float)t); /* XXX is t faces or verts */
*t0 = I;
*t1 = t - I;
diff --git a/intern/cycles/util/util_color.h b/intern/cycles/util/util_color.h
index 0cfa4049d3e..b72cc6bc873 100644
--- a/intern/cycles/util/util_color.h
+++ b/intern/cycles/util/util_color.h
@@ -61,22 +61,22 @@ ccl_device float3 rgb_to_hsv(float3 rgb)
h = 0.0f;
}
- if(s == 0.0f) {
- h = 0.0f;
- }
- else {
+ if(s != 0.0f) {
float3 cmax3 = make_float3(cmax, cmax, cmax);
c = (cmax3 - rgb)/cdelta;
- if(rgb.x == cmax) h = c.z - c.y;
- else if(rgb.y == cmax) h = 2.0f + c.x - c.z;
- else h = 4.0f + c.y - c.x;
+ if (rgb.x == cmax) h = c.z - c.y;
+ else if(rgb.y == cmax) h = 2.0f + c.x - c.z;
+ else h = 4.0f + c.y - c.x;
h /= 6.0f;
if(h < 0.0f)
h += 1.0f;
}
+ else {
+ h = 0.0f;
+ }
return make_float3(h, s, v);
}
@@ -90,13 +90,10 @@ ccl_device float3 hsv_to_rgb(float3 hsv)
s = hsv.y;
v = hsv.z;
- if(s == 0.0f) {
- rgb = make_float3(v, v, v);
- }
- else {
+ if(s != 0.0f) {
if(h == 1.0f)
h = 0.0f;
-
+
h *= 6.0f;
i = floorf(h);
f = h - i;
@@ -104,13 +101,16 @@ ccl_device float3 hsv_to_rgb(float3 hsv)
p = v*(1.0f-s);
q = v*(1.0f-(s*f));
t = v*(1.0f-(s*(1.0f-f)));
-
- if(i == 0.0f) rgb = make_float3(v, t, p);
+
+ if (i == 0.0f) rgb = make_float3(v, t, p);
else if(i == 1.0f) rgb = make_float3(q, v, p);
else if(i == 2.0f) rgb = make_float3(p, v, t);
else if(i == 3.0f) rgb = make_float3(p, q, v);
else if(i == 4.0f) rgb = make_float3(t, p, v);
- else rgb = make_float3(v, p, q);
+ else rgb = make_float3(v, p, q);
+ }
+ else {
+ rgb = make_float3(v, v, v);
}
return rgb;
@@ -132,8 +132,8 @@ ccl_device float3 xyY_to_xyz(float x, float y, float Y)
ccl_device float3 xyz_to_rgb(float x, float y, float z)
{
return make_float3(3.240479f * x + -1.537150f * y + -0.498535f * z,
- -0.969256f * x + 1.875991f * y + 0.041556f * z,
- 0.055648f * x + -0.204043f * y + 1.057311f * z);
+ -0.969256f * x + 1.875991f * y + 0.041556f * z,
+ 0.055648f * x + -0.204043f * y + 1.057311f * z);
}
#ifndef __KERNEL_OPENCL__
diff --git a/intern/cycles/util/util_hash.h b/intern/cycles/util/util_hash.h
index ded25c92b90..edd2448efa4 100644
--- a/intern/cycles/util/util_hash.h
+++ b/intern/cycles/util/util_hash.h
@@ -23,7 +23,7 @@ CCL_NAMESPACE_BEGIN
static inline uint hash_int_2d(uint kx, uint ky)
{
- #define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
+#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
uint a, b, c;
@@ -41,7 +41,7 @@ static inline uint hash_int_2d(uint kx, uint ky)
return c;
- #undef rot
+#undef rot
}
static inline uint hash_int(uint k)
diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h
index 53ed6817258..ded75762cd2 100644
--- a/intern/cycles/util/util_math.h
+++ b/intern/cycles/util/util_math.h
@@ -1237,7 +1237,7 @@ ccl_device float compatible_powf(float x, float y)
ccl_device float safe_powf(float a, float b)
{
- if(a < 0.0f && b != float_to_int(b))
+ if(UNLIKELY(a < 0.0f && b != float_to_int(b)))
return 0.0f;
return compatible_powf(a, b);
@@ -1245,7 +1245,7 @@ ccl_device float safe_powf(float a, float b)
ccl_device float safe_logf(float a, float b)
{
- if(a < 0.0f || b < 0.0f)
+ if(UNLIKELY(a < 0.0f || b < 0.0f))
return 0.0f;
return logf(a)/logf(b);
@@ -1305,7 +1305,7 @@ ccl_device bool ray_aligned_disk_intersect(
float3 disk_N = normalize_len(ray_P - disk_P, &disk_t);
float div = dot(ray_D, disk_N);
- if(div == 0.0f)
+ if(UNLIKELY(div == 0.0f))
return false;
/* compute t to intersection point */
@@ -1335,7 +1335,7 @@ ccl_device bool ray_triangle_intersect(
float3 s1 = cross(ray_D, e2);
const float divisor = dot(s1, e1);
- if(divisor == 0.0f)
+ if(UNLIKELY(divisor == 0.0f))
return false;
const float invdivisor = 1.0f/divisor;
@@ -1378,7 +1378,7 @@ ccl_device bool ray_triangle_intersect_uv(
float3 s1 = cross(ray_D, e2);
const float divisor = dot(s1, e1);
- if(divisor == 0.0f)
+ if(UNLIKELY(divisor == 0.0f))
return false;
const float invdivisor = 1.0f/divisor;
diff --git a/intern/cycles/util/util_md5.cpp b/intern/cycles/util/util_md5.cpp
index c53fbd90c67..add0d18c742 100644
--- a/intern/cycles/util/util_md5.cpp
+++ b/intern/cycles/util/util_md5.cpp
@@ -367,7 +367,7 @@ string MD5Hash::get_hex()
finish(digest);
for(int i = 0; i < 16; i++)
- sprintf(buf + i*2, "%02X", digest[i]);
+ sprintf(buf + i*2, "%02X", (unsigned int)digest[i]);
buf[sizeof(buf)-1] = '\0';
return string(buf);
diff --git a/intern/cycles/util/util_opencl.h b/intern/cycles/util/util_opencl.h
index 5f3f1667bcc..141c5e38273 100644
--- a/intern/cycles/util/util_opencl.h
+++ b/intern/cycles/util/util_opencl.h
@@ -304,7 +304,9 @@ typedef struct _cl_kernel * cl_kernel;
typedef struct _cl_event * cl_event;
typedef struct _cl_sampler * cl_sampler;
-typedef cl_uint cl_bool; /* WARNING! Unlike cl_ types in cl_platform.h, cl_bool is not guaranteed to be the same size as the bool in kernels. */
+/* WARNING! Unlike cl_ types in cl_platform.h,
+ * cl_bool is not guaranteed to be the same size as the bool in kernels. */
+typedef cl_uint cl_bool;
typedef cl_ulong cl_bitfield;
typedef cl_bitfield cl_device_type;
typedef cl_uint cl_platform_info;
diff --git a/intern/cycles/util/util_simd.h b/intern/cycles/util/util_simd.h
index 679556ee59b..f0f37fa57aa 100644
--- a/intern/cycles/util/util_simd.h
+++ b/intern/cycles/util/util_simd.h
@@ -71,7 +71,7 @@ ccl_device_inline const __m128 shuffle_swap(const __m128& a, shuffle_swap_t shuf
#ifdef __KERNEL_SSE41__
ccl_device_inline void gen_idirsplat_swap(const __m128 &pn, const shuffle_swap_t &shuf_identity, const shuffle_swap_t &shuf_swap,
- const float3& idir, __m128 idirsplat[3], shuffle_swap_t shufflexyz[3])
+ const float3& idir, __m128 idirsplat[3], shuffle_swap_t shufflexyz[3])
{
const __m128 idirsplat_raw[] = { _mm_set_ps1(idir.x), _mm_set_ps1(idir.y), _mm_set_ps1(idir.z) };
idirsplat[0] = _mm_xor_ps(idirsplat_raw[0], pn);
@@ -87,7 +87,7 @@ ccl_device_inline void gen_idirsplat_swap(const __m128 &pn, const shuffle_swap_t
}
#else
ccl_device_inline void gen_idirsplat_swap(const __m128 &pn, const shuffle_swap_t &shuf_identity, const shuffle_swap_t &shuf_swap,
- const float3& idir, __m128 idirsplat[3], shuffle_swap_t shufflexyz[3])
+ const float3& idir, __m128 idirsplat[3], shuffle_swap_t shufflexyz[3])
{
idirsplat[0] = _mm_xor_ps(_mm_set_ps1(idir.x), pn);
idirsplat[1] = _mm_xor_ps(_mm_set_ps1(idir.y), pn);
diff --git a/intern/cycles/util/util_system.cpp b/intern/cycles/util/util_system.cpp
index 9a7f1427cbe..0764f7d9345 100644
--- a/intern/cycles/util/util_system.cpp
+++ b/intern/cycles/util/util_system.cpp
@@ -169,14 +169,15 @@ static CPUCapabilities& system_cpu_capabilities()
if( os_uses_xsave_xrestore && cpu_avx_support) {
// Check if the OS will save the YMM registers
uint32_t xcr_feature_mask;
- #if defined(__GNUC__)
- int edx; // not used
- __asm__ (".byte 0x0f, 0x01, 0xd0" : "=a" (xcr_feature_mask) , "=d" (edx) : "c" (0) ); /* actual opcode for xgetbv */
- #elif defined(_MSC_VER) && defined(_XCR_XFEATURE_ENABLED_MASK)
- xcr_feature_mask = (uint32_t)_xgetbv(_XCR_XFEATURE_ENABLED_MASK); /* min VS2010 SP1 compiler is required */
- #else
- xcr_feature_mask = 0;
- #endif
+#if defined(__GNUC__)
+ int edx; /* not used */
+ /* actual opcode for xgetbv */
+ __asm__ (".byte 0x0f, 0x01, 0xd0" : "=a" (xcr_feature_mask) , "=d" (edx) : "c" (0) );
+#elif defined(_MSC_VER) && defined(_XCR_XFEATURE_ENABLED_MASK)
+ xcr_feature_mask = (uint32_t)_xgetbv(_XCR_XFEATURE_ENABLED_MASK); /* min VS2010 SP1 compiler is required */
+#else
+ xcr_feature_mask = 0;
+#endif
caps.avx = (xcr_feature_mask & 0x6) == 0x6;
}
}
diff --git a/intern/cycles/util/util_transform.cpp b/intern/cycles/util/util_transform.cpp
index 12c2270a8d4..14613558501 100644
--- a/intern/cycles/util/util_transform.cpp
+++ b/intern/cycles/util/util_transform.cpp
@@ -75,7 +75,7 @@ static bool transform_matrix4_gj_inverse(float R[][4], float M[][4])
}
}
- if(pivotsize == 0)
+ if(UNLIKELY(pivotsize == 0.0f))
return false;
if(pivot != i) {
@@ -106,7 +106,7 @@ static bool transform_matrix4_gj_inverse(float R[][4], float M[][4])
for(int i = 3; i >= 0; --i) {
float f;
- if((f = M[i][i]) == 0)
+ if(UNLIKELY((f = M[i][i]) == 0.0f))
return false;
for(int j = 0; j < 4; j++) {
@@ -135,15 +135,16 @@ Transform transform_inverse(const Transform& tfm)
memcpy(R, &tfmR, sizeof(R));
memcpy(M, &tfm, sizeof(M));
- if(!transform_matrix4_gj_inverse(R, M)) {
+ if(UNLIKELY(!transform_matrix4_gj_inverse(R, M))) {
/* matrix is degenerate (e.g. 0 scale on some axis), ideally we should
* never be in this situation, but try to invert it anyway with tweak */
M[0][0] += 1e-8f;
M[1][1] += 1e-8f;
M[2][2] += 1e-8f;
- if(!transform_matrix4_gj_inverse(R, M))
+ if(UNLIKELY(!transform_matrix4_gj_inverse(R, M))) {
return transform_identity();
+ }
}
memcpy(&tfmR, R, sizeof(R));
diff --git a/intern/cycles/util/util_transform.h b/intern/cycles/util/util_transform.h
index 4c7ce12d1de..5b3dbe42f69 100644
--- a/intern/cycles/util/util_transform.h
+++ b/intern/cycles/util/util_transform.h
@@ -108,9 +108,9 @@ ccl_device_inline Transform transform_transpose(const Transform a)
}
ccl_device_inline Transform make_transform(float a, float b, float c, float d,
- float e, float f, float g, float h,
- float i, float j, float k, float l,
- float m, float n, float o, float p)
+ float e, float f, float g, float h,
+ float i, float j, float k, float l,
+ float m, float n, float o, float p)
{
Transform t;
diff --git a/intern/cycles/util/util_types.h b/intern/cycles/util/util_types.h
index 5d2037960fc..bfaab3dba3b 100644
--- a/intern/cycles/util/util_types.h
+++ b/intern/cycles/util/util_types.h
@@ -159,8 +159,8 @@ struct int2 {
__forceinline int& operator[](int i) { return *(&x + i); }
};
-#ifdef __KERNEL_SSE__
struct ccl_try_align(16) int3 {
+#ifdef __KERNEL_SSE__
union {
__m128i m128;
struct { int x, y, z, w; };
@@ -171,7 +171,6 @@ struct ccl_try_align(16) int3 {
__forceinline operator const __m128i&(void) const { return m128; }
__forceinline operator __m128i&(void) { return m128; }
#else
-struct ccl_try_align(16) int3 {
int x, y, z, w;
#endif
@@ -179,8 +178,8 @@ struct ccl_try_align(16) int3 {
__forceinline int& operator[](int i) { return *(&x + i); }
};
-#ifdef __KERNEL_SSE__
struct ccl_try_align(16) int4 {
+#ifdef __KERNEL_SSE__
union {
__m128i m128;
struct { int x, y, z, w; };
@@ -191,7 +190,6 @@ struct ccl_try_align(16) int4 {
__forceinline operator const __m128i&(void) const { return m128; }
__forceinline operator __m128i&(void) { return m128; }
#else
-struct ccl_try_align(16) int4 {
int x, y, z, w;
#endif
@@ -227,8 +225,8 @@ struct float2 {
__forceinline float& operator[](int i) { return *(&x + i); }
};
-#ifdef __KERNEL_SSE__
struct ccl_try_align(16) float3 {
+#ifdef __KERNEL_SSE__
union {
__m128 m128;
struct { float x, y, z, w; };
@@ -239,7 +237,6 @@ struct ccl_try_align(16) float3 {
__forceinline operator const __m128&(void) const { return m128; }
__forceinline operator __m128&(void) { return m128; }
#else
-struct ccl_try_align(16) float3 {
float x, y, z, w;
#endif
@@ -247,8 +244,8 @@ struct ccl_try_align(16) float3 {
__forceinline float& operator[](int i) { return *(&x + i); }
};
-#ifdef __KERNEL_SSE__
struct ccl_try_align(16) float4 {
+#ifdef __KERNEL_SSE__
union {
__m128 m128;
struct { float x, y, z, w; };
@@ -259,7 +256,6 @@ struct ccl_try_align(16) float4 {
__forceinline operator const __m128&(void) const { return m128; }
__forceinline operator __m128&(void) { return m128; }
#else
-struct ccl_try_align(16) float4 {
float x, y, z, w;
#endif
@@ -460,6 +456,43 @@ enum InterpolationType {
INTERPOLATION_SMART = 3,
};
+
+/* macros */
+
+/* hints for branch prediction, only use in code that runs a _lot_ */
+#if defined(__GNUC__) && defined(__KERNEL_CPU__)
+# define LIKELY(x) __builtin_expect(!!(x), 1)
+# define UNLIKELY(x) __builtin_expect(!!(x), 0)
+#else
+# define LIKELY(x) (x)
+# define UNLIKELY(x) (x)
+#endif
+
+/* Causes warning:
+ * incompatible types when assigning to type 'Foo' from type 'Bar'
+ * ... the compiler optimizes away the temp var */
+#ifdef __GNUC__
+#define CHECK_TYPE(var, type) { \
+ __typeof(var) *__tmp; \
+ __tmp = (type *)NULL; \
+ (void)__tmp; \
+} (void)0
+
+#define CHECK_TYPE_PAIR(var_a, var_b) { \
+ __typeof(var_a) *__tmp; \
+ __tmp = (__typeof(var_b) *)NULL; \
+ (void)__tmp; \
+} (void)0
+#else
+# define CHECK_TYPE(var, type)
+# define CHECK_TYPE_PAIR(var_a, var_b)
+#endif
+
+/* can be used in simple macros */
+#define CHECK_TYPE_INLINE(val, type) \
+ ((void)(((type)0) != (val)))
+
+
CCL_NAMESPACE_END
#endif /* __UTIL_TYPES_H__ */
diff --git a/intern/cycles/util/util_view.cpp b/intern/cycles/util/util_view.cpp
index 5e3d84c5dd1..6bf9c9ed8c0 100644
--- a/intern/cycles/util/util_view.cpp
+++ b/intern/cycles/util/util_view.cpp
@@ -80,8 +80,8 @@ void view_display_info(const char *info)
void view_display_help()
{
- const int w = V.width / 1.15;
- const int h = V.height / 1.15;
+ const int w = (int)((float)V.width / 1.15f);
+ const int h = (int)((float)V.height / 1.15f);
const int x1 = (V.width - w) / 2;
const int x2 = x1 + w;
diff --git a/intern/ffmpeg/ffmpeg_compat.h b/intern/ffmpeg/ffmpeg_compat.h
index 82240c7cb4f..ac4da5b6133 100644
--- a/intern/ffmpeg/ffmpeg_compat.h
+++ b/intern/ffmpeg/ffmpeg_compat.h
@@ -442,4 +442,8 @@ AVRational av_get_r_frame_rate_compat(const AVStream *stream)
# define AV_OPT_SEARCH_FAKE_OBJ 0
#endif
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 59, 100)
+# define FFMPEG_HAVE_DEPRECATED_FLAGS2
+#endif
+
#endif
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 9900f7e153f..8f1f9867724 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -755,7 +755,7 @@ GHOST_SystemX11::processEvent(XEvent *xe)
case KeyRelease:
{
XKeyEvent *xke = &(xe->xkey);
- KeySym key_sym = XLookupKeysym(xke, 0);
+ KeySym key_sym;
char ascii;
#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
/* utf8_array[] is initial buffer used for Xutf8LookupString().
@@ -771,7 +771,29 @@ GHOST_SystemX11::processEvent(XEvent *xe)
char *utf8_buf = NULL;
#endif
- GHOST_TKey gkey = convertXKey(key_sym);
+ GHOST_TKey gkey;
+
+ /* In keyboards like latin ones,
+ * numbers needs a 'Shift' to be accessed but key_sym
+ * is unmodified (or anyone swapping the keys with xmodmap).
+ *
+ * Here we look at the 'Shifted' version of the key.
+ * If it is a number, then we take it instead of the normal key.
+ *
+ * The modified key is sent in the 'ascii's variable anyway.
+ */
+ if ((xke->keycode >= 10 && xke->keycode < 20) &&
+ ((key_sym = XLookupKeysym(xke, ShiftMask)) >= XK_0) && (key_sym <= XK_9))
+ {
+ /* pass (keep shift'ed key_sym) */
+ }
+ else {
+ /* regular case */
+ key_sym = XLookupKeysym(xke, 0);
+ }
+
+ gkey = convertXKey(key_sym);
+
GHOST_TEventType type = (xke->type == KeyPress) ?
GHOST_kEventKeyDown : GHOST_kEventKeyUp;
diff --git a/intern/guardedalloc/intern/mallocn.c b/intern/guardedalloc/intern/mallocn.c
index 4d00616202e..e85fba7a6d0 100644
--- a/intern/guardedalloc/intern/mallocn.c
+++ b/intern/guardedalloc/intern/mallocn.c
@@ -15,11 +15,6 @@
* 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): Brecht Van Lommel
* Campbell Barton
*
diff --git a/intern/guardedalloc/intern/mallocn_guarded_impl.c b/intern/guardedalloc/intern/mallocn_guarded_impl.c
index 724e7f95845..172c79d50cd 100644
--- a/intern/guardedalloc/intern/mallocn_guarded_impl.c
+++ b/intern/guardedalloc/intern/mallocn_guarded_impl.c
@@ -497,9 +497,9 @@ void *MEM_guarded_mallocN(size_t len, const char *str)
memh = (MemHead *)malloc(len + sizeof(MemHead) + sizeof(MemTail));
- if (memh) {
+ if (LIKELY(memh)) {
make_memhead_header(memh, len, str);
- if (malloc_debug_memset && len)
+ if (UNLIKELY(malloc_debug_memset && len))
memset(memh + 1, 255, len);
#ifdef DEBUG_MEMCOUNTER
@@ -951,7 +951,7 @@ static void rem_memblock(MemHead *memh)
#endif
}
else {
- if (malloc_debug_memset && memh->len)
+ if (UNLIKELY(malloc_debug_memset && memh->len))
memset(memh + 1, 255, memh->len);
free(memh);
}
diff --git a/intern/guardedalloc/intern/mallocn_intern.h b/intern/guardedalloc/intern/mallocn_intern.h
index db45b59b884..b0fd52d2766 100644
--- a/intern/guardedalloc/intern/mallocn_intern.h
+++ b/intern/guardedalloc/intern/mallocn_intern.h
@@ -77,6 +77,14 @@
#define SIZET_ALIGN_4(len) ((len + 3) & ~(size_t)3)
+#ifdef __GNUC__
+# define LIKELY(x) __builtin_expect(!!(x), 1)
+# define UNLIKELY(x) __builtin_expect(!!(x), 0)
+#else
+# define LIKELY(x) (x)
+# define UNLIKELY(x) (x)
+#endif
+
/* Prototypes for counted allocator functions */
size_t MEM_lockfree_allocN_len(const void *vmemh) ATTR_WARN_UNUSED_RESULT;
void MEM_lockfree_freeN(void *vmemh);
diff --git a/intern/guardedalloc/intern/mallocn_lockfree_impl.c b/intern/guardedalloc/intern/mallocn_lockfree_impl.c
index 1d131ed339a..6fc01807af3 100644
--- a/intern/guardedalloc/intern/mallocn_lockfree_impl.c
+++ b/intern/guardedalloc/intern/mallocn_lockfree_impl.c
@@ -15,11 +15,6 @@
* 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): Brecht Van Lommel
* Campbell Barton
* Sergey Sharybin
@@ -126,7 +121,7 @@ void MEM_lockfree_freeN(void *vmemh)
#endif
}
else {
- if (malloc_debug_memset && len) {
+ if (UNLIKELY(malloc_debug_memset && len)) {
memset(memh + 1, 255, len);
}
free(memh);
@@ -219,7 +214,7 @@ void *MEM_lockfree_callocN(size_t len, const char *str)
memh = (MemHead *)calloc(1, len + sizeof(MemHead));
- if (memh) {
+ if (LIKELY(memh)) {
memh->len = len;
atomic_add_u(&totblock, 1);
atomic_add_z(&mem_in_use, len);
@@ -242,8 +237,8 @@ void *MEM_lockfree_mallocN(size_t len, const char *str)
memh = (MemHead *)malloc(len + sizeof(MemHead));
- if (memh) {
- if (malloc_debug_memset && len) {
+ if (LIKELY(memh)) {
+ if (UNLIKELY(malloc_debug_memset && len)) {
memset(memh + 1, 255, len);
}
diff --git a/intern/locale/SConscript b/intern/locale/SConscript
index 4136ac8237d..24828c120ec 100644
--- a/intern/locale/SConscript
+++ b/intern/locale/SConscript
@@ -66,10 +66,6 @@ if env['WITH_BF_INTERNATIONAL']:
locale = env.Clone()
- msgfmt_executable = targetpath
- if env['OURPLATFORM'] in ('win32-vc', 'win64-vc', 'win32-mingw', 'win64-mingw'):
- msgfmt_executable += ".exe"
-
# dependencies
dependencies = [msgfmt_target]
@@ -82,7 +78,7 @@ if env['WITH_BF_INTERNATIONAL']:
po_file = os.path.join(po_dir, f)
mo_file = os.path.join(build_dir, os.path.splitext(f)[0] + ".mo")
- command = "\"%s\" \"%s\" \"%s\"" % (msgfmt_executable, po_file, mo_file)
+ command = "\"%s\" \"%s\" \"%s\"" % (targetpath, po_file, mo_file)
locale.Command(mo_file, po_file, command)
locale.Depends(mo_file, dependencies)
diff --git a/release/datafiles/blender_icons.svg b/release/datafiles/blender_icons.svg
index 84ccb81b75d..7557b81c804 100644
--- a/release/datafiles/blender_icons.svg
+++ b/release/datafiles/blender_icons.svg
@@ -14,7 +14,7 @@
height="640"
id="svg2"
sodipodi:version="0.32"
- inkscape:version="0.48.4 r9939"
+ inkscape:version="0.48.4 r"
version="1.0"
sodipodi:docname="blender_icons.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
@@ -27448,6 +27448,790 @@
style="stop-color:#b7b7b7;stop-opacity:1;"
id="stop16830-7" />
</radialGradient>
+ <linearGradient
+ id="linearGradient18748-9"
+ inkscape:collect="always">
+ <stop
+ id="stop18750-7"
+ offset="0"
+ style="stop-color:#5894d4;stop-opacity:1" />
+ <stop
+ id="stop18752-0"
+ offset="1"
+ style="stop-color:#afd1f5;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient4980">
+ <stop
+ style="stop-color:#5894d4;stop-opacity:1"
+ offset="0"
+ id="stop4982" />
+ <stop
+ style="stop-color:#afd1f5;stop-opacity:1"
+ offset="1"
+ id="stop4984" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient8225-5-1-0-9-5">
+ <stop
+ style="stop-color:#84d458;stop-opacity:1"
+ offset="0"
+ id="stop8227-8-1-1-0-9" />
+ <stop
+ style="stop-color:#c8f5af;stop-opacity:1"
+ offset="1"
+ id="stop8229-7-3-1-4-4" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient6369-5">
+ <stop
+ style="stop-color:#0d1e00;stop-opacity:1"
+ offset="0"
+ id="stop6371-3" />
+ <stop
+ style="stop-color:#001128;stop-opacity:1"
+ offset="1"
+ id="stop6373-8" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient16719">
+ <stop
+ id="stop16721"
+ offset="0"
+ style="stop-color:#84d458;stop-opacity:1" />
+ <stop
+ style="stop-color:#5894d4;stop-opacity:1"
+ offset="0.30000001"
+ id="stop5079" />
+ <stop
+ id="stop16723"
+ offset="1"
+ style="stop-color:#afd1f5;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient6369-3-9">
+ <stop
+ style="stop-color:#0e1e00;stop-opacity:1"
+ offset="0"
+ id="stop6371-2-4" />
+ <stop
+ style="stop-color:#001d1e;stop-opacity:1"
+ offset="1"
+ id="stop6373-0-4" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient7701-5"
+ inkscape:collect="always">
+ <stop
+ id="stop7703-5"
+ offset="0"
+ style="stop-color:#84d458;stop-opacity:1" />
+ <stop
+ style="stop-color:#3dc0c7;stop-opacity:1"
+ offset="0.40000027"
+ id="stop5081" />
+ <stop
+ id="stop7705-2"
+ offset="1"
+ style="stop-color:#aff1f5;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient5153"
+ inkscape:collect="always">
+ <stop
+ id="stop5155"
+ offset="0"
+ style="stop-color:#84d458;stop-opacity:1" />
+ <stop
+ id="stop5157"
+ offset="1"
+ style="stop-color:#c8f5af;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient6522-6">
+ <stop
+ style="stop-color:#0e1e00;stop-opacity:1"
+ offset="0"
+ id="stop6524-8" />
+ <stop
+ style="stop-color:#1b1f09;stop-opacity:1"
+ offset="1"
+ id="stop6526-6" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient16332-1">
+ <stop
+ style="stop-color:#84d458;stop-opacity:1"
+ offset="0"
+ id="stop16334-5" />
+ <stop
+ id="stop5161"
+ offset="0.37500033"
+ style="stop-color:#b5d034;stop-opacity:1" />
+ <stop
+ style="stop-color:#e9f5af;stop-opacity:1"
+ offset="1"
+ id="stop16336-4" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient6541-9">
+ <stop
+ style="stop-color:#132701;stop-opacity:1"
+ offset="0"
+ id="stop6543-9" />
+ <stop
+ style="stop-color:#282100;stop-opacity:1"
+ offset="1"
+ id="stop6545-6" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient15955-8"
+ inkscape:collect="always">
+ <stop
+ id="stop15957-7"
+ offset="0"
+ style="stop-color:#90d868;stop-opacity:1" />
+ <stop
+ style="stop-color:#dacf2a;stop-opacity:1"
+ offset="0.37500033"
+ id="stop5163" />
+ <stop
+ id="stop15959-4"
+ offset="1"
+ style="stop-color:#f5f1af;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient6582-2">
+ <stop
+ style="stop-color:#282100;stop-opacity:1"
+ offset="0"
+ id="stop6584-4" />
+ <stop
+ style="stop-color:#201308;stop-opacity:1"
+ offset="1"
+ id="stop6586-7" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient16021-1">
+ <stop
+ style="stop-color:#dacf2a;stop-opacity:1"
+ offset="0"
+ id="stop16023-4" />
+ <stop
+ id="stop5391"
+ offset="0.37792677"
+ style="stop-color:#ff9a2d;stop-opacity:1" />
+ <stop
+ style="stop-color:#f3c59d;stop-opacity:1"
+ offset="1"
+ id="stop16025-9" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient6590-1">
+ <stop
+ style="stop-color:#290b11;stop-opacity:1"
+ offset="0"
+ id="stop6592-1" />
+ <stop
+ style="stop-color:#271301;stop-opacity:1"
+ offset="1"
+ id="stop6594-7" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient16066-6"
+ inkscape:collect="always">
+ <stop
+ id="stop16068-8"
+ offset="0"
+ style="stop-color:#f13b60;stop-opacity:1" />
+ <stop
+ style="stop-color:#ff9a2d;stop-opacity:1"
+ offset="0.49796259"
+ id="stop4718" />
+ <stop
+ id="stop16070-9"
+ offset="1"
+ style="stop-color:#f3c59d;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient6668-2">
+ <stop
+ style="stop-color:#001128;stop-opacity:1"
+ offset="0"
+ id="stop6670-8" />
+ <stop
+ style="stop-color:#200820;stop-opacity:1"
+ offset="1"
+ id="stop6672-3" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient12160"
+ inkscape:collect="always">
+ <stop
+ id="stop12162"
+ offset="0"
+ style="stop-color:#5894d4;stop-opacity:1" />
+ <stop
+ style="stop-color:#ef79ef;stop-opacity:1"
+ offset="0.72727275"
+ id="stop12164" />
+ <stop
+ id="stop12166"
+ offset="1"
+ style="stop-color:#f7bcf7;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient5660"
+ inkscape:collect="always">
+ <stop
+ id="stop5662"
+ offset="0"
+ style="stop-color:#001128;stop-opacity:1" />
+ <stop
+ id="stop5664"
+ offset="1"
+ style="stop-color:#200820;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient11820">
+ <stop
+ style="stop-color:#afd1f5;stop-opacity:1"
+ offset="0"
+ id="stop11822" />
+ <stop
+ id="stop11824"
+ offset="0.44444144"
+ style="stop-color:#5894d4;stop-opacity:1" />
+ <stop
+ style="stop-color:#5894d4;stop-opacity:1"
+ offset="0.55555254"
+ id="stop11826" />
+ <stop
+ style="stop-color:#ef79ef;stop-opacity:1"
+ offset="1"
+ id="stop11828" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient6668-0-4">
+ <stop
+ style="stop-color:#001128;stop-opacity:1"
+ offset="0"
+ id="stop6670-5-2" />
+ <stop
+ style="stop-color:#200820;stop-opacity:1"
+ offset="1"
+ id="stop6672-0-2" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient10750"
+ inkscape:collect="always">
+ <stop
+ id="stop10752"
+ offset="0"
+ style="stop-color:#afd1f5;stop-opacity:1" />
+ <stop
+ style="stop-color:#5894d4;stop-opacity:1"
+ offset="0.43061388"
+ id="stop10754" />
+ <stop
+ style="stop-color:#5894d4;stop-opacity:1"
+ offset="0.77194387"
+ id="stop10756" />
+ <stop
+ id="stop10758"
+ offset="1"
+ style="stop-color:#ef79ef;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient17527-8-91-7">
+ <stop
+ style="stop-color:#0a0a0a;stop-opacity:1"
+ offset="0"
+ id="stop17529-0-2-6" />
+ <stop
+ style="stop-color:#001128;stop-opacity:1"
+ offset="1"
+ id="stop17531-0-6-8" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient28135-1-17"
+ inkscape:collect="always">
+ <stop
+ id="stop28137-7-06"
+ offset="0"
+ style="stop-color:#afd1f5;stop-opacity:1" />
+ <stop
+ style="stop-color:#5894d4;stop-opacity:1"
+ offset="0.42811331"
+ id="stop5393" />
+ <stop
+ id="stop28139-7-9"
+ offset="1"
+ style="stop-color:#505050;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient17533-0-8-9">
+ <stop
+ style="stop-color:#0a0a0a;stop-opacity:1"
+ offset="0"
+ id="stop17535-3-7-0" />
+ <stop
+ style="stop-color:#001128;stop-opacity:1"
+ offset="1"
+ id="stop17537-75-3-8" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient28135-1-1"
+ inkscape:collect="always">
+ <stop
+ id="stop28137-7-0"
+ offset="0"
+ style="stop-color:#afd1f5;stop-opacity:1" />
+ <stop
+ style="stop-color:#5894d4;stop-opacity:1"
+ offset="0.42811331"
+ id="stop5393-00" />
+ <stop
+ id="stop28139-7-43"
+ offset="1"
+ style="stop-color:#505050;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient17539-85-9-6">
+ <stop
+ style="stop-color:#000f3c;stop-opacity:1"
+ offset="0"
+ id="stop17541-1-5-6" />
+ <stop
+ id="stop17543-9-2-7"
+ offset="0.41666666"
+ style="stop-color:#0a0a0a;stop-opacity:1" />
+ <stop
+ id="stop17545-9-7-9"
+ offset="0.58333331"
+ style="stop-color:#0a0a0a;stop-opacity:1" />
+ <stop
+ style="stop-color:#001128;stop-opacity:1"
+ offset="1"
+ id="stop17547-04-5-5" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient28147-1-4">
+ <stop
+ id="stop28149-4-1"
+ offset="0"
+ style="stop-color:#afd1f5;stop-opacity:1" />
+ <stop
+ style="stop-color:#5894d4;stop-opacity:1"
+ offset="0.18750006"
+ id="stop5469" />
+ <stop
+ style="stop-color:#505050;stop-opacity:1"
+ offset="0.40000001"
+ id="stop28151-7-6" />
+ <stop
+ id="stop28153-8-4"
+ offset="0.60000002"
+ style="stop-color:#505050;stop-opacity:1" />
+ <stop
+ style="stop-color:#5894d4;stop-opacity:1"
+ offset="0.81250006"
+ id="stop5471" />
+ <stop
+ id="stop28155-2-6"
+ offset="1"
+ style="stop-color:#afd1f5;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient6668-2"
+ id="linearGradient17013"
+ gradientUnits="userSpaceOnUse"
+ x1="156.7054"
+ y1="957.10889"
+ x2="162.14577"
+ y2="957.10889" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient12160"
+ id="linearGradient17015"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(0,-21)"
+ x1="155"
+ y1="976.36127"
+ x2="166"
+ y2="976.36127" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient4980"
+ id="linearGradient17017"
+ gradientUnits="userSpaceOnUse"
+ x1="55"
+ y1="959.36218"
+ x2="55"
+ y2="951.36218" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient18748-9"
+ id="linearGradient17019"
+ gradientUnits="userSpaceOnUse"
+ x1="35"
+ y1="959.36218"
+ x2="35"
+ y2="951.36218" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient6369-5"
+ id="linearGradient17021"
+ gradientUnits="userSpaceOnUse"
+ x1="53"
+ y1="961.36218"
+ x2="59"
+ y2="955.36218" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16719"
+ id="linearGradient17023"
+ gradientUnits="userSpaceOnUse"
+ x1="51"
+ y1="960.36218"
+ x2="60"
+ y2="951.36218" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient6369-3-9"
+ id="linearGradient17025"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(0,21)"
+ x1="51"
+ y1="939.36218"
+ x2="61"
+ y2="929.36218" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient7701-5"
+ id="linearGradient17027"
+ gradientUnits="userSpaceOnUse"
+ x1="51"
+ y1="960.36218"
+ x2="60"
+ y2="951.36218" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient5153"
+ id="linearGradient17029"
+ gradientUnits="userSpaceOnUse"
+ x1="51"
+ y1="960.36218"
+ x2="61"
+ y2="951.36218" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient6541-9"
+ id="linearGradient17031"
+ gradientUnits="userSpaceOnUse"
+ x1="54.8125"
+ y1="961.73718"
+ x2="61"
+ y2="956.23718" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient15955-8"
+ id="linearGradient17033"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(0,-21)"
+ x1="53"
+ y1="981.36218"
+ x2="61"
+ y2="972.36218" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient6582-2"
+ id="linearGradient17035"
+ gradientUnits="userSpaceOnUse"
+ x1="54"
+ y1="961.98718"
+ x2="60.9375"
+ y2="955.67468" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16021-1"
+ id="linearGradient17038"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(0,-21)"
+ x1="53"
+ y1="981.36218"
+ x2="61"
+ y2="971.36218" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient6590-1"
+ id="linearGradient17040"
+ gradientUnits="userSpaceOnUse"
+ x1="53.6875"
+ y1="961.48718"
+ x2="60.5625"
+ y2="956.04968" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16066-6"
+ id="linearGradient17042"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(0,-21)"
+ x1="54"
+ y1="981.36218"
+ x2="61"
+ y2="971.36218" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient5660"
+ id="linearGradient17044"
+ gradientUnits="userSpaceOnUse"
+ x1="162.875"
+ y1="955.48627"
+ x2="162.875"
+ y2="959.74042" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient11820"
+ id="linearGradient17046"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(0,-21)"
+ x1="165"
+ y1="971.36127"
+ x2="165"
+ y2="980.36127" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient6668-0-4"
+ id="linearGradient17048"
+ gradientUnits="userSpaceOnUse"
+ x1="164.43785"
+ y1="955.23627"
+ x2="158.9816"
+ y2="955.23627" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient10750"
+ id="linearGradient17050"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(0,-21)"
+ x1="166.07713"
+ y1="970.98602"
+ x2="160.87317"
+ y2="980.77435" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient6522-6"
+ id="linearGradient17052"
+ gradientUnits="userSpaceOnUse"
+ x1="54.268661"
+ y1="962.13489"
+ x2="61.251339"
+ y2="955.94769" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16332-1"
+ id="linearGradient17054"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(0,-21)"
+ x1="52"
+ y1="981.36218"
+ x2="61"
+ y2="972.36218" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient17527-8-91-7"
+ id="linearGradient17056"
+ gradientUnits="userSpaceOnUse"
+ x1="58.125019"
+ y1="951.23718"
+ x2="52.566891"
+ y2="951.23718" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient28135-1-17"
+ id="linearGradient17058"
+ gradientUnits="userSpaceOnUse"
+ x1="51"
+ y1="960.36218"
+ x2="57"
+ y2="955.36218" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient17533-0-8-9"
+ id="linearGradient17060"
+ gradientUnits="userSpaceOnUse"
+ x1="58.125019"
+ y1="951.23718"
+ x2="52.566891"
+ y2="951.23718" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient28135-1-1"
+ id="linearGradient17062"
+ gradientUnits="userSpaceOnUse"
+ x1="51"
+ y1="960.36218"
+ x2="57"
+ y2="955.36218" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient17539-85-9-6"
+ id="linearGradient17064"
+ gradientUnits="userSpaceOnUse"
+ x1="49"
+ y1="955.3623"
+ x2="61"
+ y2="955.3623" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient28147-1-4"
+ id="linearGradient17066"
+ gradientUnits="userSpaceOnUse"
+ x1="50"
+ y1="955.3623"
+ x2="60"
+ y2="955.3623" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient8225-5-1-0-9-5"
+ id="linearGradient17068"
+ gradientUnits="userSpaceOnUse"
+ x1="72"
+ y1="960.36072"
+ x2="80"
+ y2="950.36072" />
+ <linearGradient
+ id="linearGradient319-65-4-8-7">
+ <stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="0"
+ id="stop320-14-9-5-9" />
+ <stop
+ style="stop-color:#ffffff;stop-opacity:0;"
+ offset="1"
+ id="stop321-49-3-6-8" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient319-65-4-8-7"
+ id="linearGradient17904-1-8"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(-105.84265,-101.96449)"
+ x1="386.88852"
+ y1="409.84152"
+ x2="389.14081"
+ y2="412.45016" />
+ <linearGradient
+ id="linearGradient16340">
+ <stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="0"
+ id="stop16342" />
+ <stop
+ style="stop-color:#ffffff;stop-opacity:0;"
+ offset="1"
+ id="stop16344" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient319-65-4-8-7"
+ id="linearGradient17893-5-2"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(-97.05081,-101.92897)"
+ x1="387"
+ y1="409.86362"
+ x2="388.86676"
+ y2="411.88974" />
+ <linearGradient
+ id="linearGradient16347">
+ <stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="0"
+ id="stop16349" />
+ <stop
+ style="stop-color:#ffffff;stop-opacity:0;"
+ offset="1"
+ id="stop16351" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient44939-8-53"
+ id="linearGradient44954-5"
+ gradientUnits="userSpaceOnUse"
+ x1="279.75"
+ y1="101.5"
+ x2="283"
+ y2="105.5"
+ gradientTransform="matrix(0,1,1,0,225,-182.99437)" />
+ <linearGradient
+ id="linearGradient44939-8-53">
+ <stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="0"
+ id="stop44941-8-7" />
+ <stop
+ style="stop-color:#ffffff;stop-opacity:0;"
+ offset="1"
+ id="stop44943-2-5" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient44939-8-53"
+ id="linearGradient16705"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0,-1,-1,0,430.6795,387.09358)"
+ x1="280.20203"
+ y1="101.27402"
+ x2="283.77844"
+ y2="97.589958" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient44939-8-53-7"
+ id="linearGradient16705-4"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0,-1,-1,0,430.6795,387.09358)"
+ x1="280.20203"
+ y1="101.27402"
+ x2="283.77844"
+ y2="97.589958" />
+ <linearGradient
+ id="linearGradient44939-8-53-7">
+ <stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="0"
+ id="stop44941-8-7-6" />
+ <stop
+ style="stop-color:#ffffff;stop-opacity:0;"
+ offset="1"
+ id="stop44943-2-5-2" />
+ </linearGradient>
+ <linearGradient
+ y2="97.589958"
+ x2="283.77844"
+ y1="101.27402"
+ x1="280.20203"
+ gradientTransform="matrix(0,-1,-1,0,430.6795,387.09358)"
+ gradientUnits="userSpaceOnUse"
+ id="linearGradient16728"
+ xlink:href="#linearGradient44939-8-53-7"
+ inkscape:collect="always" />
</defs>
<sodipodi:namedview
id="base"
@@ -27459,16 +28243,16 @@
objecttolerance="10000"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="1.2444625"
- inkscape:cx="124.98646"
- inkscape:cy="335.47029"
+ inkscape:zoom="9.9557"
+ inkscape:cx="101.55361"
+ inkscape:cy="425.39887"
inkscape:document-units="px"
- inkscape:current-layer="g27669-35-7-7"
- showgrid="false"
- inkscape:window-width="1871"
- inkscape:window-height="1056"
- inkscape:window-x="49"
- inkscape:window-y="24"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ inkscape:window-width="1600"
+ inkscape:window-height="845"
+ inkscape:window-x="-8"
+ inkscape:window-y="-8"
inkscape:snap-nodes="false"
inkscape:snap-bbox="true"
showguides="true"
@@ -86884,6 +87668,881 @@
</g>
</g>
</g>
+ <g
+ style="display:inline;enable-background:new"
+ id="g6603"
+ transform="translate(168.02769,-748.47766)">
+ <g
+ id="g16520">
+ <g
+ id="g16552">
+ <path
+ inkscape:connector-curvature="0"
+ inkscape:export-ydpi="90"
+ inkscape:export-xdpi="90"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ id="path53378"
+ d="m 166.5,949.86212 c -0.0525,5e-5 -0.448,0 -0.5,0 -1.9864,0 -2.6748,6.27454 -3.5,10.99914 -1,-5.50278 -4.01655,-5.48468 -5,10e-6 -0.95862,-2.50093 -2.5,-2.50094 -3.5,-10e-6 -0.0346,2e-4 -0.4699,0.002 -0.5,0"
+ style="color:#000000;fill:none;stroke:url(#linearGradient17013);stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ sodipodi:nodetypes="cscccc" />
+ <path
+ sodipodi:nodetypes="cscccc"
+ style="color:#000000;fill:none;stroke:url(#linearGradient17015);stroke-width:1.20000005;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 166.5,949.86212 -0.5,0 c -1.98887,0 -2.6748,6.30855 -3.5,11.03315 -0.98438,-5.50278 -3.99875,-5.52473 -5,-0.034 -0.95299,-2.47883 -2.5,-2.50002 -3.5,9.1e-4 -0.0346,2e-4 -0.4699,0.002 -0.5,0"
+ id="path53380"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ inkscape:connector-curvature="0" />
+ </g>
+ <rect
+ style="opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ id="rect16035-7-6"
+ width="16"
+ height="16"
+ x="152"
+ y="947.36127" />
+ </g>
+ </g>
+ <g
+ style="display:inline;enable-background:new"
+ id="g6624"
+ transform="translate(84.027695,-748.47996)">
+ <g
+ id="g6562">
+ <path
+ sodipodi:nodetypes="cccc"
+ style="color:#000000;fill:none;stroke:#001128;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 61.5,949.86218 -1,0 -11,10.99986 -1,0"
+ id="path3948"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ inkscape:connector-curvature="0" />
+ <path
+ inkscape:connector-curvature="0"
+ inkscape:export-ydpi="90"
+ inkscape:export-xdpi="90"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ id="path3946"
+ d="m 61.5,949.86218 -1,0 -11,10.99986 -1,0"
+ style="color:#000000;fill:none;stroke:url(#linearGradient17017);stroke-width:1.20000005;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ sodipodi:nodetypes="cccc" />
+ </g>
+ <rect
+ style="opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ id="rect18813-7"
+ width="16"
+ height="16"
+ x="47"
+ y="947.36218" />
+ </g>
+ <g
+ style="display:inline;enable-background:new"
+ id="g6558"
+ transform="translate(84.027695,-748.47989)">
+ <path
+ sodipodi:nodetypes="cccc"
+ style="color:#000000;fill:none;stroke:#001128;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 40.5,949.8622 -6,0 0,11 -7,0"
+ id="path6545"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ inkscape:connector-curvature="0" />
+ <path
+ inkscape:connector-curvature="0"
+ inkscape:export-ydpi="90"
+ inkscape:export-xdpi="90"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ id="path6532"
+ d="m 40.5,949.8622 -6,0 0,11 -6.97,0"
+ style="color:#000000;fill:none;stroke:url(#linearGradient17019);stroke-width:1.20000005;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ sodipodi:nodetypes="cccc" />
+ <rect
+ style="opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ id="rect18813-9"
+ width="16"
+ height="16"
+ x="26"
+ y="947.36218" />
+ </g>
+ <g
+ style="display:inline;enable-background:new"
+ transform="translate(126.02769,-748.47996)"
+ id="g4551">
+ <g
+ id="g4553">
+ <path
+ inkscape:connector-curvature="0"
+ inkscape:export-ydpi="90"
+ inkscape:export-xdpi="90"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ id="path4555"
+ d="m 61.5,949.86218 -0.5,0 c -4.95,6.5 -7.066811,10.99986 -12,10.99986 l -0.5,0"
+ style="color:#000000;fill:none;stroke:url(#linearGradient17021);stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ sodipodi:nodetypes="cccc" />
+ <path
+ sodipodi:nodetypes="cccc"
+ style="color:#000000;fill:none;stroke:url(#linearGradient17023);stroke-width:1.20000005;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 61.5,949.86218 -0.5,0 c -4.95,6.5 -7.053239,10.99986 -12,10.99986 l -0.5,0"
+ id="path4557"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ inkscape:connector-curvature="0" />
+ </g>
+ <rect
+ y="947.36218"
+ x="47"
+ height="16"
+ width="16"
+ id="rect4559"
+ style="opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ </g>
+ <g
+ style="display:inline;enable-background:new"
+ id="g7689"
+ transform="translate(147.02769,-748.47996)">
+ <g
+ id="g7691">
+ <path
+ sodipodi:nodetypes="cccc"
+ style="color:#000000;fill:none;stroke:url(#linearGradient17025);stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 61.5,949.86218 -0.5,0 c -2.95,5.5 -7.066811,10.99986 -12,10.99986 l -0.5,0"
+ id="path7693"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ inkscape:connector-curvature="0" />
+ <path
+ inkscape:connector-curvature="0"
+ inkscape:export-ydpi="90"
+ inkscape:export-xdpi="90"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ id="path7695"
+ d="m 61.5,949.86218 -0.5,0 c -3,5.5 -7.053239,10.99986 -12,10.99986 l -0.5,0"
+ style="color:#000000;fill:none;stroke:url(#linearGradient17027);stroke-width:1.20000005;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ sodipodi:nodetypes="cccc" />
+ </g>
+ <rect
+ style="opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ id="rect7697"
+ width="16"
+ height="16"
+ x="47"
+ y="947.36218" />
+ <path
+ inkscape:connector-curvature="0"
+ style="color:#000000;fill:none;stroke:#001d1e;stroke-width:1.79999995;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 50,949.3622 0,1 2,0 0,1 -1,0 0,1 1,0 0,-0.75 1,0 0,-1.5 -1,0 0,-0.75 -2,0 z m 1,3 -1,0 0,1 0,1 3,0 0,-1 -2,0 0,-1 z"
+ id="path15794" />
+ <path
+ id="path41073-2-6"
+ d="m 50,949.3622 0,1 2,0 0,1 -1,0 0,1 1,0 0,-0.75 1,0 0,-1.5 -1,0 0,-0.75 -2,0 z m 1,3 -1,0 0,1 0,1 3,0 0,-1 -2,0 0,-1 z"
+ style="color:#000000;fill:#58ced4;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ inkscape:connector-curvature="0" />
+ </g>
+ <g
+ style="display:inline;enable-background:new"
+ transform="translate(168.02769,-748.47989)"
+ id="g7707">
+ <g
+ id="g7709">
+ <path
+ inkscape:connector-curvature="0"
+ inkscape:export-ydpi="90"
+ inkscape:export-xdpi="90"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ id="path7711"
+ d="m 61.5,949.86218 -0.5,0 c -2.95,8.5 -7.066811,10.99986 -12,10.99986 l -0.5,0"
+ style="color:#000000;fill:none;stroke:#0e1e00;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ sodipodi:nodetypes="cccc" />
+ <path
+ sodipodi:nodetypes="cccc"
+ style="color:#000000;fill:none;stroke:url(#linearGradient17029);stroke-width:1.20000005;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 61.5,949.86218 -0.5,0 c -2.95,8.5 -7.053239,10.99986 -12,10.99986 l -0.5,0"
+ id="path7713"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ inkscape:connector-curvature="0" />
+ </g>
+ <rect
+ y="947.36218"
+ x="47"
+ height="16"
+ width="16"
+ id="rect7715"
+ style="opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <path
+ inkscape:connector-curvature="0"
+ style="color:#000000;fill:none;stroke:#0e1e00;stroke-width:1.79999995;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 50,949.3622 0,1 2,0 0,1 1,0 0,-1.25 -1,0 0,-0.75 -2,0 z m 2,2 -1,0 0,1 1,0 0,-1 z m 0,1 0,1 -2,0 0,1 2,0 0,-0.75 1,0 0,-1.25 -1,0 z"
+ id="path15813" />
+ <path
+ id="path41075-5-1"
+ d="m 50,949.3622 0,1 2,0 0,1 1,0 0,-1.25 -1,0 0,-0.75 -2,0 z m 2,2 -1,0 0,1 1,0 0,-1 z m 0,1 0,1 -2,0 0,1 2,0 0,-0.75 1,0 0,-1.25 -1,0 z"
+ style="color:#000000;fill:#84d458;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ inkscape:connector-curvature="0" />
+ </g>
+ <g
+ style="display:inline;enable-background:new"
+ id="g15886"
+ transform="translate(210.02769,-748.47996)">
+ <g
+ id="g15888">
+ <path
+ sodipodi:nodetypes="cccc"
+ style="color:#000000;fill:none;stroke:url(#linearGradient17031);stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 61.5,949.86218 -0.5,0 c -0.95,6.5 -4.149996,10.99986 -12,10.99986 l -0.5,0"
+ id="path15890"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ inkscape:connector-curvature="0" />
+ <path
+ inkscape:connector-curvature="0"
+ inkscape:export-ydpi="90"
+ inkscape:export-xdpi="90"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ id="path15892"
+ d="m 61.5,949.86218 -0.5,0 c -0.95,6.5 -3.959647,10.99986 -12,10.99986 l -0.5,0"
+ style="color:#000000;fill:none;stroke:url(#linearGradient17033);stroke-width:1.20000005;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ sodipodi:nodetypes="cccc" />
+ </g>
+ <rect
+ style="opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ id="rect15894"
+ width="16"
+ height="16"
+ x="47"
+ y="947.36218" />
+ <path
+ inkscape:connector-curvature="0"
+ style="color:#000000;fill:none;stroke:#282100;stroke-width:1.79999995;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 50,950.3622 0,3 1,0 1,0 0,1 -2,0 0,1 2,0 0,-0.75 1,0 0,-1.5 -1,0 0,-0.75 -1,0 0,-1 2,0 0,-1 -2,0 -1,0 z"
+ id="path15939" />
+ <path
+ id="path41079-6-0"
+ d="m 50,950.3622 0,3 1,0 1,0 0,1 -2,0 0,1 2,0 0,-0.75 1,0 0,-1.5 -1,0 0,-0.75 -1,0 0,-1 2,0 0,-1 -2,0 -1,0 z"
+ style="color:#000000;fill:#dacf2a;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ inkscape:connector-curvature="0" />
+ </g>
+ <g
+ style="display:inline;enable-background:new"
+ transform="translate(231.02769,-748.47989)"
+ id="g15961">
+ <g
+ id="g15963">
+ <path
+ inkscape:connector-curvature="0"
+ inkscape:export-ydpi="90"
+ inkscape:export-xdpi="90"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ id="path15965"
+ d="m 61.5,949.86218 -0.5,0 c -0.95,9.5 -1.956865,10.99986 -12,10.99986 l -0.5,0"
+ style="color:#000000;fill:none;stroke:url(#linearGradient17035);stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ sodipodi:nodetypes="cccc" />
+ <path
+ sodipodi:nodetypes="cccc"
+ style="color:#000000;fill:none;stroke:url(#linearGradient17038);stroke-width:1.20000005;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 61.5,949.86218 -0.5,0 c -0.95,8.5 -1.088169,10.99986 -12,10.99986 l -0.5,0"
+ id="path15967"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ inkscape:connector-curvature="0" />
+ </g>
+ <rect
+ y="947.36218"
+ x="47"
+ height="16"
+ width="16"
+ id="rect15969"
+ style="opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ </g>
+ <g
+ style="display:inline;enable-background:new"
+ id="g16027-0"
+ transform="translate(252.02766,-748.47989)">
+ <g
+ id="g16029">
+ <path
+ sodipodi:nodetypes="cccc"
+ style="color:#000000;fill:none;stroke:url(#linearGradient17040);stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 61,949.86218 -0.5,0 c 0.05,1.5 0.45,9.5 -11.5,10.99986 l -0.5,0"
+ id="path16031"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ inkscape:connector-curvature="0" />
+ <path
+ inkscape:connector-curvature="0"
+ inkscape:export-ydpi="90"
+ inkscape:export-xdpi="90"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ id="path16033"
+ d="m 61,949.86218 -0.5,0 c 0.05,1.5 0.45,9.5 -11.5,10.99986 l -0.5,0"
+ style="color:#000000;fill:none;stroke:url(#linearGradient17042);stroke-width:1.20000005;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ sodipodi:nodetypes="cccc" />
+ </g>
+ <rect
+ style="opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ id="rect16035"
+ width="16"
+ height="16"
+ x="47"
+ y="947.36218" />
+ </g>
+ <g
+ style="display:inline;enable-background:new"
+ transform="translate(189.02769,-748.48231)"
+ id="g16464">
+ <path
+ sodipodi:nodetypes="ccsssssc"
+ style="color:#000000;fill:none;stroke:url(#linearGradient17044);stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 166.5,949.86126 c -0.0525,5e-5 -0.498,8.6e-4 -0.55,8.6e-4 0,0 -0.47718,10.99969 -2.50296,10.99969 -1.91589,0 -0.93193,-6.00055 -2.94704,-6.00055 -1.53921,0 -1.50766,3 -3,3 -1.03656,0 -0.99963,-2 -2,-2 -0.66974,0 -0.90046,1.00059 -1.5,1.00059 -0.0346,0 -0.4699,10e-4 -0.5,-8.7e-4"
+ id="path5578"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ inkscape:connector-curvature="0" />
+ <path
+ inkscape:connector-curvature="0"
+ inkscape:export-ydpi="90"
+ inkscape:export-xdpi="90"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ id="path16468"
+ d="m 166.5,949.86126 c -0.0525,5e-5 -0.498,8.6e-4 -0.55,8.6e-4 0,0 -0.47718,10.99969 -2.50296,10.99969 -1.91589,0 -0.93193,-6.00055 -2.94704,-6.00055 -1.53921,0 -1.50766,3 -3,3 -1.03656,0 -0.99963,-2 -2,-2 -0.66974,0 -0.90046,1.00059 -1.5,1.00059 -0.0346,0 -0.4699,10e-4 -0.5,-8.7e-4"
+ style="color:#000000;fill:none;stroke:url(#linearGradient17046);stroke-width:1.20000005;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ sodipodi:nodetypes="ccsssssc" />
+ <rect
+ style="opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ id="rect16035-7"
+ width="16"
+ height="16"
+ x="152"
+ y="947.36127" />
+ </g>
+ <g
+ style="display:inline;enable-background:new"
+ id="g16576"
+ transform="translate(210.02769,-748.47898)">
+ <path
+ inkscape:connector-curvature="0"
+ inkscape:export-ydpi="90"
+ inkscape:export-xdpi="90"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ id="path16586"
+ d="m 166.5,949.86212 -0.55,0 c -1.95,6.49912 -3.14103,10.49912 -5.95,10.49912 -2.23607,0 -4.02976,-3.49912 -6,-3.49912 l -0.5,0"
+ style="color:#000000;fill:none;stroke:url(#linearGradient17048);stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ sodipodi:nodetypes="ccscc" />
+ <path
+ sodipodi:nodetypes="ccscc"
+ style="color:#000000;fill:none;stroke:url(#linearGradient17050);stroke-width:1.20000005;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 166.5,949.86212 -0.55,0 c -1.95,6.49912 -3.14103,10.49912 -5.95,10.49912 -2.23607,0 -4.02976,-3.49912 -6,-3.49912 l -0.5,0"
+ id="path16580"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ inkscape:connector-curvature="0" />
+ <rect
+ y="947.36127"
+ x="152"
+ height="16"
+ width="16"
+ id="rect16582"
+ style="opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ </g>
+ <g
+ style="display:inline;enable-background:new"
+ transform="translate(189.02769,-748.47989)"
+ id="g4468">
+ <g
+ id="g4470">
+ <path
+ inkscape:connector-curvature="0"
+ inkscape:export-ydpi="90"
+ inkscape:export-xdpi="90"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ id="path4472"
+ d="m 61.5,949.86218 -0.5,0 c -0.95,4.5 -3.05,10.5 -12,10.99986 l -0.5,0"
+ style="color:#000000;fill:none;stroke:url(#linearGradient17052);stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ sodipodi:nodetypes="cccc" />
+ <path
+ sodipodi:nodetypes="cccc"
+ style="color:#000000;fill:none;stroke:url(#linearGradient17054);stroke-width:1.20000005;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 61.5,949.86218 -0.5,0 c -0.95,5.5 -4.05,10.5 -12,10.99986 l -0.5,0"
+ id="path4474"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ inkscape:connector-curvature="0" />
+ </g>
+ <rect
+ y="947.36218"
+ x="47"
+ height="16"
+ width="16"
+ id="rect4477"
+ style="opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path16306"
+ d="m 50,950.3622 0,3 1,0 1,0 0,2 1,0 0,-4 -1,0 0,1 -1,0 0,-2 -1,0 z"
+ style="color:#000000;fill:none;stroke:#1b1f09;stroke-width:1.79999995;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <path
+ style="color:#000000;fill:#b5d034;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 50,950.3622 0,3 1,0 1,0 0,2 1,0 0,-4 -1,0 0,1 -1,0 0,-2 -1,0 z"
+ id="path41067-3-6"
+ inkscape:connector-curvature="0" />
+ </g>
+ <g
+ transform="translate(336.02769,-748.47858)"
+ id="g20295-7-9"
+ style="display:inline;enable-background:new">
+ <g
+ id="g20297-2-1">
+ <path
+ inkscape:connector-curvature="0"
+ inkscape:export-ydpi="90"
+ inkscape:export-xdpi="90"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ id="path20299-51-2"
+ d="m 61.5,949.86218 -0.55,0 c -4.95,6.5 -5.985561,10.99986 -11.95,10.99986 l -0.5,0"
+ style="color:#000000;fill:none;stroke:url(#linearGradient17056);stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ sodipodi:nodetypes="cccc" />
+ <path
+ sodipodi:nodetypes="cccc"
+ style="color:#000000;fill:none;stroke:url(#linearGradient17058);stroke-width:1.20000005;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 61.5,949.86218 -0.55,0 c -4.95,6.5 -6.003239,10.99986 -11.95,10.99986 l -0.5,0"
+ id="path20301-63-8"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ inkscape:connector-curvature="0" />
+ </g>
+ <rect
+ y="947.36218"
+ x="47"
+ height="16"
+ width="16"
+ id="rect20303-3-3"
+ style="opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ </g>
+ <g
+ id="g20305-4-1"
+ transform="matrix(-1,0,0,-1,467.02769,1162.2412)"
+ style="display:inline;enable-background:new">
+ <g
+ id="g20307-1-7">
+ <path
+ sodipodi:nodetypes="cccc"
+ style="color:#000000;fill:none;stroke:url(#linearGradient17060);stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 61.5,949.86218 -0.5,0 c -4.95,6.5 -5.985561,10.99986 -11.95,10.99986 l -0.55,0"
+ id="path20309-1-1"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ inkscape:connector-curvature="0" />
+ <path
+ inkscape:connector-curvature="0"
+ inkscape:export-ydpi="90"
+ inkscape:export-xdpi="90"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ id="path20311-8-0"
+ d="m 61.5,949.86218 -0.5,0 c -4.95,6.5 -5.971989,10.99986 -11.95,10.99986 l -0.55,0"
+ style="color:#000000;fill:none;stroke:url(#linearGradient17062);stroke-width:1.20000005;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ sodipodi:nodetypes="cccc" />
+ </g>
+ <rect
+ style="opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ id="rect20313-92-1"
+ width="16"
+ height="16"
+ x="47"
+ y="947.36218" />
+ </g>
+ <g
+ transform="matrix(-1,0,0,-1,488.02769,1162.2445)"
+ id="g20315-6-2"
+ style="display:inline;enable-background:new">
+ <g
+ id="g20317-6-4">
+ <path
+ inkscape:connector-curvature="0"
+ inkscape:export-ydpi="90"
+ inkscape:export-xdpi="90"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ id="path20319-7-7"
+ d="m 61.5,949.86218 -0.5,0 c -6.013721,0 -5.986773,10.99986 -11.95,10.99986 l -0.55,0"
+ style="color:#000000;fill:none;stroke:url(#linearGradient17064);stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ sodipodi:nodetypes="cccc" />
+ <path
+ sodipodi:nodetypes="cccc"
+ style="color:#000000;fill:none;stroke:url(#linearGradient17066);stroke-width:1.20000005;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 61.5,949.86218 -0.5,0 c -6.013721,0 -5.986773,10.99986 -11.95,10.99986 l -0.55,0"
+ id="path20321-90-9"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ inkscape:connector-curvature="0" />
+ </g>
+ <rect
+ y="947.36218"
+ x="47"
+ height="16"
+ width="16"
+ id="rect20323-5-1"
+ style="opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ </g>
+ <g
+ style="display:inline;enable-background:new"
+ transform="translate(84.027695,-748.48019)"
+ id="g20443-5-0">
+ <path
+ style="color:#000000;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#201308;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 78.565213,960.8622 -8.130425,0"
+ id="path22805-8-4"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
+ <path
+ sodipodi:nodetypes="cc"
+ inkscape:connector-curvature="0"
+ id="path22809-2-4"
+ d="m 79.49996,960.8622 -9,0"
+ style="color:#000000;fill:none;stroke:#c86800;stroke-width:1.20000005;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <path
+ transform="matrix(-0.83333333,0,0,0.83333,9.5,430.86427)"
+ d="m -81,636 c 0,1.65685 -1.343146,3 -3,3 -1.656854,0 -3,-1.34315 -3,-3 0,-1.65685 1.343146,-3 3,-3 1.656854,0 3,1.34315 3,3 z"
+ sodipodi:ry="3"
+ sodipodi:rx="3"
+ sodipodi:cy="636"
+ sodipodi:cx="-84"
+ id="path22807-1-8"
+ style="color:#000000;fill:#462300;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new"
+ sodipodi:type="arc" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path22811-6-3"
+ d="m 80,959.36217 c 0.554,0 1,0.446 1,1 l 0,1 c 0,0.554 -0.446,1 -1,1 l -1,0 c -0.554,0 -1,-0.446 -1,-1 l 0,-1 c 0,-0.554 0.446,-1 1,-1 l 1,0 z m 0,1 -1,0 0,1 1,0 0,-1 z"
+ style="color:#000000;fill:#ff9a2d;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new" />
+ <path
+ sodipodi:nodetypes="cc"
+ inkscape:connector-curvature="0"
+ id="path20449-0-3"
+ d="m 72.434783,949.8622 8.130434,0"
+ style="color:#000000;fill:none;stroke:#201308;stroke-width:3;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <path
+ style="color:#000000;fill:none;stroke:#c86800;stroke-width:1.20000005;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 72.5,949.8622 9,0"
+ id="path20451-8-0"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
+ <path
+ sodipodi:type="arc"
+ style="color:#000000;fill:#462300;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new"
+ id="path22736-5-7"
+ sodipodi:cx="-84"
+ sodipodi:cy="636"
+ sodipodi:rx="3"
+ sodipodi:ry="3"
+ d="m -81,636 c 0,1.65685 -1.343146,3 -3,3 -1.656854,0 -3,-1.34315 -3,-3 0,-1.65685 1.343146,-3 3,-3 1.656854,0 3,1.34315 3,3 z"
+ transform="matrix(0.83333333,0,0,0.83333,142.49996,419.86427)" />
+ <path
+ inkscape:connector-curvature="0"
+ inkscape:export-ydpi="90"
+ inkscape:export-xdpi="90"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ id="path20453-7-1"
+ d="m 82.5,949.86218 c -0.12884,0 -0.37404,-4.1e-4 -0.5,0 -5.995321,0.0193 -5.998907,10.99986 -12,10.99986 -0.155311,0 -0.33371,0 -0.5,0"
+ style="color:#000000;fill:none;stroke:#0e1e00;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ sodipodi:nodetypes="cssc" />
+ <path
+ sodipodi:nodetypes="cssc"
+ style="color:#000000;fill:none;stroke:url(#linearGradient17068);stroke-width:1.20000005;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 82.5,949.86218 c -0.12884,0 -0.37404,-4.1e-4 -0.5,0 -6.02657,0.0194 -5.998907,10.99986 -12,10.99986 -0.155311,0 -0.33371,0 -0.5,0"
+ id="path20457-48-5"
+ inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ inkscape:connector-curvature="0" />
+ <rect
+ y="947.36218"
+ x="68"
+ height="16"
+ width="16"
+ id="rect20459-9-9"
+ style="opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <path
+ style="color:#000000;fill:#ff9a2d;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new"
+ d="m 71.99996,948.36217 c -0.554,0 -1,0.446 -1,1 l 0,1 c 0,0.554 0.446,1 1,1 l 1,0 c 0.554,0 1,-0.446 1,-1 l 0,-1 c 0,-0.554 -0.446,-1 -1,-1 l -1,0 z m 0,1 1,0 0,1 -1,0 0,-1 z"
+ id="rect22555-0-9"
+ inkscape:connector-curvature="0" />
+ <path
+ id="path22295-8"
+ d="m 71.49996,949.86216 0,-0.5014 c 0,-0.2493 0.196575,-0.4986 0.50004,-0.4986 l 0.49996,0"
+ style="fill:none;stroke:#f3c59d;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;display:inline;enable-background:new"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccc" />
+ <path
+ sodipodi:nodetypes="cccc"
+ inkscape:connector-curvature="0"
+ style="color:#000000;fill:none;stroke:#f3c59d;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new"
+ d="m 78.49996,960.86216 0,-0.5014 c 0,-0.2493 0.196575,-0.4986 0.50004,-0.4986 l 0.49996,0"
+ id="path5059" />
+ </g>
+ <g
+ transform="translate(-63.051518,-85.06394)"
+ style="display:inline;enable-background:new"
+ id="g17942-1-7">
+ <rect
+ y="304"
+ x="278"
+ height="16"
+ width="16"
+ id="rect22048-0-1-2-2"
+ style="opacity:0.01000001;fill:#999999;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.89999998;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <g
+ id="g17930-6-4">
+ <rect
+ y="305.5"
+ x="281.5"
+ height="6.0211244"
+ width="9.0000076"
+ id="rect22050-0-1-6-2"
+ style="opacity:0.6;fill:#ffd6aa;fill-opacity:1;fill-rule:evenodd;stroke:#2b1600;stroke-width:0.40000001;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <path
+ sodipodi:nodetypes="ccccccccc"
+ id="path22157-2-9-1-2"
+ d="m 278.90735,308.28551 0,0.5 2.5,2.5 0.5,0 2.5,-2.5 0,-0.5 -2.5,-2.5 -0.5,0 -2.5,2.5 z"
+ style="fill:none;stroke:#552c00;stroke-width:1;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#e98316;fill-opacity:1;fill-rule:evenodd;stroke:none"
+ d="m 279.15735,308.53551 2.5,2.5 2.5,-2.5 -2.5,-2.5 -2.5,2.5 z"
+ id="path22159-1-9-5-8"
+ sodipodi:nodetypes="ccccc"
+ inkscape:connector-curvature="0" />
+ <path
+ id="path22161-4-8-9-9"
+ d="m 279.80239,308.53551 1.85496,-1.83839 1.85496,1.83839 -1.85496,1.86049 z"
+ style="fill:none;stroke:url(#linearGradient17904-1-8);stroke-width:0.89999998;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+ sodipodi:nodetypes="ccccc"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+ d="m 287.69919,308.32103 0,0.5 2.5,2.5 0.5,0 2.5,-2.5 0,-0.5 -2.5,-2.5 -0.5,0 -2.5,2.5 z"
+ id="path22208-0-8-1-5"
+ sodipodi:nodetypes="ccccccccc"
+ inkscape:connector-curvature="0" />
+ <path
+ sodipodi:nodetypes="ccccc"
+ id="path22212-5-4-4-6"
+ d="m 287.94919,308.57103 2.5,2.5 2.5,-2.5 -2.5,-2.5 z"
+ style="fill:#cccccc;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.80000001;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ inkscape:connector-curvature="0" />
+ <path
+ sodipodi:nodetypes="ccccc"
+ style="fill:none;stroke:url(#linearGradient17893-5-2);stroke-width:0.89999998;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+ d="m 288.58981,308.57103 1.85938,-1.83594 1.85547,1.83594 -1.85547,1.875 z"
+ id="path22214-3-8-8-9"
+ inkscape:connector-curvature="0" />
+ </g>
+ <g
+ transform="translate(62.055528,67.113811)"
+ id="g36761-1-3"
+ style="display:inline;enable-background:new">
+ <path
+ style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.80000001;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 223,243 0,10 1,0 0,-1 1,0 1,0 0,2 1,0 0,1 1,0 0,-1 1,0 0,-2 -1,0 0,-2 1,0 1,0 0,-1 -1,0 0,-1 -1,0 0,-1 -1,0 0,-1 -1,0 0,-1 -1,0 0,-1 -1,0 0,-1 -1,0 z"
+ id="path36763-5-3"
+ inkscape:connector-curvature="0" />
+ <g
+ id="g36765-2-8"
+ style="fill:#1a1a1a;display:inline;enable-background:new"
+ transform="translate(5,-6.0000002e-7)">
+ <rect
+ y="243"
+ x="218"
+ height="10"
+ width="1"
+ id="rect36767-7-7"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.80000001;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <rect
+ y="244"
+ x="219"
+ height="1"
+ width="1"
+ id="rect36769-6-7"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.80000001;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <rect
+ y="245"
+ x="220"
+ height="1"
+ width="1"
+ id="rect36771-1-5"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.80000001;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <rect
+ y="246"
+ x="221"
+ height="1"
+ width="1"
+ id="rect36773-4-5"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.80000001;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <rect
+ y="247"
+ x="222"
+ height="1"
+ width="1"
+ id="rect36775-2-3"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.80000001;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <rect
+ y="248"
+ x="223"
+ height="1"
+ width="1"
+ id="rect36777-3-2"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.80000001;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <rect
+ y="249"
+ x="224"
+ height="1"
+ width="1.0000017"
+ id="rect36779-2-6"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.80000001;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <rect
+ y="252"
+ x="219"
+ height="1"
+ width="1"
+ id="rect36781-2-4"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.80000001;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <rect
+ y="251"
+ x="220"
+ height="1"
+ width="1"
+ id="rect36783-1-4"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.80000001;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <rect
+ y="252"
+ x="221"
+ height="2"
+ width="1"
+ id="rect36785-6-6"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.80000001;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <rect
+ y="250"
+ x="222.25"
+ height="2"
+ width="0.75"
+ id="rect36787-8-0"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.80000001;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <rect
+ y="252"
+ x="223"
+ height="1.9999931"
+ width="1"
+ id="rect36789-5-9"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.80000001;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <rect
+ y="254"
+ x="222"
+ height="1.0000006"
+ width="1.5"
+ id="rect36791-7-7"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.80000001;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <rect
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.80000001;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ id="rect36793-6-2"
+ width="1.5"
+ height="1"
+ x="223.5"
+ y="250" />
+ </g>
+ </g>
+ </g>
+ <g
+ style="display:inline;enable-background:new"
+ id="g44081-2"
+ transform="translate(-231.54762,126.06411)">
+ <rect
+ style="opacity:0;fill:#1a1a1a;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.20000005;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ id="rect44079-0"
+ width="16"
+ height="16"
+ x="320"
+ y="73" />
+ <g
+ transform="translate(0,-22.005631)"
+ id="g43931-0">
+ <g
+ id="g43459-4">
+ <g
+ transform="translate(0,21)"
+ id="g43446-0">
+ <path
+ sodipodi:nodetypes="ccc"
+ id="path43450-7"
+ d="m 324.45461,83.386633 4.25,4.244369 4.25,-4.244369"
+ style="fill:none;stroke:#000000;stroke-width:3.5999999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+ inkscape:connector-curvature="0" />
+ </g>
+ <g
+ transform="matrix(-1,0,0,-1,655.70461,184.631)"
+ id="g43442-3">
+ <path
+ style="fill:none;stroke:#dcdcdc;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="M 331.25,80.25 327,76.005631 322.75,80.25"
+ id="path42666-0"
+ sodipodi:nodetypes="ccc"
+ inkscape:connector-curvature="0" />
+ </g>
+ </g>
+ <path
+ style="fill:none;stroke:url(#linearGradient16705);stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 333.4295,103.09358 -4.5,4.5 -0.5,0 -3.87222,-3.79689"
+ id="path44952-5"
+ sodipodi:nodetypes="cccc"
+ inkscape:connector-curvature="0" />
+ </g>
+ <g
+ style="display:inline;enable-background:new"
+ transform="translate(-0.12714727,-29.00633)"
+ id="g43931-0-3">
+ <g
+ id="g43459-4-9">
+ <g
+ transform="translate(0,21)"
+ id="g43446-0-2">
+ <path
+ sodipodi:nodetypes="ccc"
+ id="path43450-7-3"
+ d="m 324.45461,83.386633 4.25,4.244369 4.25,-4.244369"
+ style="fill:none;stroke:#000000;stroke-width:3.5999999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+ inkscape:connector-curvature="0" />
+ </g>
+ <g
+ transform="matrix(-1,0,0,-1,655.70461,184.631)"
+ id="g43442-3-7">
+ <path
+ style="fill:none;stroke:#dcdcdc;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="M 331.25,80.25 327,76.005631 322.75,80.25"
+ id="path42666-0-5"
+ sodipodi:nodetypes="ccc"
+ inkscape:connector-curvature="0" />
+ </g>
+ </g>
+ <path
+ style="fill:none;stroke:url(#linearGradient16728);stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 333.4295,103.09358 -4.5,4.5 -0.5,0 -3.87222,-3.79689"
+ id="path44952-5-9"
+ sodipodi:nodetypes="cccc"
+ inkscape:connector-curvature="0" />
+ </g>
+ </g>
</g>
<g
inkscape:groupmode="layer"
diff --git a/release/datafiles/blender_icons16/icon16_action_tweak.dat b/release/datafiles/blender_icons16/icon16_action_tweak.dat
new file mode 100644
index 00000000000..d2d1ec853d1
--- /dev/null
+++ b/release/datafiles/blender_icons16/icon16_action_tweak.dat
Binary files differ
diff --git a/release/datafiles/blender_icons16/icon16_ipo_back.dat b/release/datafiles/blender_icons16/icon16_ipo_back.dat
new file mode 100644
index 00000000000..2c32cc176d7
--- /dev/null
+++ b/release/datafiles/blender_icons16/icon16_ipo_back.dat
Binary files differ
diff --git a/release/datafiles/blender_icons16/icon16_ipo_bezier.dat b/release/datafiles/blender_icons16/icon16_ipo_bezier.dat
new file mode 100644
index 00000000000..527507cf009
--- /dev/null
+++ b/release/datafiles/blender_icons16/icon16_ipo_bezier.dat
Binary files differ
diff --git a/release/datafiles/blender_icons16/icon16_ipo_bounce.dat b/release/datafiles/blender_icons16/icon16_ipo_bounce.dat
new file mode 100644
index 00000000000..bede5e12e57
--- /dev/null
+++ b/release/datafiles/blender_icons16/icon16_ipo_bounce.dat
Binary files differ
diff --git a/release/datafiles/blender_icons16/icon16_ipo_circ.dat b/release/datafiles/blender_icons16/icon16_ipo_circ.dat
new file mode 100644
index 00000000000..c7b392003ed
--- /dev/null
+++ b/release/datafiles/blender_icons16/icon16_ipo_circ.dat
Binary files differ
diff --git a/release/datafiles/blender_icons16/icon16_ipo_constant.dat b/release/datafiles/blender_icons16/icon16_ipo_constant.dat
new file mode 100644
index 00000000000..cb8882850ab
--- /dev/null
+++ b/release/datafiles/blender_icons16/icon16_ipo_constant.dat
Binary files differ
diff --git a/release/datafiles/blender_icons16/icon16_ipo_cubic.dat b/release/datafiles/blender_icons16/icon16_ipo_cubic.dat
new file mode 100644
index 00000000000..6a84b66f725
--- /dev/null
+++ b/release/datafiles/blender_icons16/icon16_ipo_cubic.dat
Binary files differ
diff --git a/release/datafiles/blender_icons16/icon16_ipo_ease_in.dat b/release/datafiles/blender_icons16/icon16_ipo_ease_in.dat
new file mode 100644
index 00000000000..e5c1c1dc051
--- /dev/null
+++ b/release/datafiles/blender_icons16/icon16_ipo_ease_in.dat
Binary files differ
diff --git a/release/datafiles/blender_icons16/icon16_ipo_ease_in_out.dat b/release/datafiles/blender_icons16/icon16_ipo_ease_in_out.dat
new file mode 100644
index 00000000000..cf8ad3264f8
--- /dev/null
+++ b/release/datafiles/blender_icons16/icon16_ipo_ease_in_out.dat
Binary files differ
diff --git a/release/datafiles/blender_icons16/icon16_ipo_ease_out.dat b/release/datafiles/blender_icons16/icon16_ipo_ease_out.dat
new file mode 100644
index 00000000000..bf68ab3169f
--- /dev/null
+++ b/release/datafiles/blender_icons16/icon16_ipo_ease_out.dat
Binary files differ
diff --git a/release/datafiles/blender_icons16/icon16_ipo_elastic.dat b/release/datafiles/blender_icons16/icon16_ipo_elastic.dat
new file mode 100644
index 00000000000..5db0f974912
--- /dev/null
+++ b/release/datafiles/blender_icons16/icon16_ipo_elastic.dat
Binary files differ
diff --git a/release/datafiles/blender_icons16/icon16_ipo_expo.dat b/release/datafiles/blender_icons16/icon16_ipo_expo.dat
new file mode 100644
index 00000000000..0456875782f
--- /dev/null
+++ b/release/datafiles/blender_icons16/icon16_ipo_expo.dat
Binary files differ
diff --git a/release/datafiles/blender_icons16/icon16_ipo_linear.dat b/release/datafiles/blender_icons16/icon16_ipo_linear.dat
new file mode 100644
index 00000000000..84deef4dfe1
--- /dev/null
+++ b/release/datafiles/blender_icons16/icon16_ipo_linear.dat
Binary files differ
diff --git a/release/datafiles/blender_icons16/icon16_ipo_quad.dat b/release/datafiles/blender_icons16/icon16_ipo_quad.dat
new file mode 100644
index 00000000000..f8dc28cf3fb
--- /dev/null
+++ b/release/datafiles/blender_icons16/icon16_ipo_quad.dat
Binary files differ
diff --git a/release/datafiles/blender_icons16/icon16_ipo_quart.dat b/release/datafiles/blender_icons16/icon16_ipo_quart.dat
new file mode 100644
index 00000000000..9279f9551d3
--- /dev/null
+++ b/release/datafiles/blender_icons16/icon16_ipo_quart.dat
Binary files differ
diff --git a/release/datafiles/blender_icons16/icon16_ipo_quint.dat b/release/datafiles/blender_icons16/icon16_ipo_quint.dat
new file mode 100644
index 00000000000..d76c781ac73
--- /dev/null
+++ b/release/datafiles/blender_icons16/icon16_ipo_quint.dat
Binary files differ
diff --git a/release/datafiles/blender_icons16/icon16_ipo_sine.dat b/release/datafiles/blender_icons16/icon16_ipo_sine.dat
new file mode 100644
index 00000000000..4b1d22c360e
--- /dev/null
+++ b/release/datafiles/blender_icons16/icon16_ipo_sine.dat
Binary files differ
diff --git a/release/datafiles/blender_icons16/icon16_nla_pushdown.dat b/release/datafiles/blender_icons16/icon16_nla_pushdown.dat
new file mode 100644
index 00000000000..37e5cacb333
--- /dev/null
+++ b/release/datafiles/blender_icons16/icon16_nla_pushdown.dat
Binary files differ
diff --git a/release/datafiles/blender_icons32/icon32_action_tweak.dat b/release/datafiles/blender_icons32/icon32_action_tweak.dat
new file mode 100644
index 00000000000..140e5a3f8be
--- /dev/null
+++ b/release/datafiles/blender_icons32/icon32_action_tweak.dat
Binary files differ
diff --git a/release/datafiles/blender_icons32/icon32_ipo_back.dat b/release/datafiles/blender_icons32/icon32_ipo_back.dat
new file mode 100644
index 00000000000..23897582e44
--- /dev/null
+++ b/release/datafiles/blender_icons32/icon32_ipo_back.dat
Binary files differ
diff --git a/release/datafiles/blender_icons32/icon32_ipo_bezier.dat b/release/datafiles/blender_icons32/icon32_ipo_bezier.dat
new file mode 100644
index 00000000000..c05766e3a96
--- /dev/null
+++ b/release/datafiles/blender_icons32/icon32_ipo_bezier.dat
Binary files differ
diff --git a/release/datafiles/blender_icons32/icon32_ipo_bounce.dat b/release/datafiles/blender_icons32/icon32_ipo_bounce.dat
new file mode 100644
index 00000000000..540ef0d1406
--- /dev/null
+++ b/release/datafiles/blender_icons32/icon32_ipo_bounce.dat
Binary files differ
diff --git a/release/datafiles/blender_icons32/icon32_ipo_circ.dat b/release/datafiles/blender_icons32/icon32_ipo_circ.dat
new file mode 100644
index 00000000000..698e52f1d05
--- /dev/null
+++ b/release/datafiles/blender_icons32/icon32_ipo_circ.dat
Binary files differ
diff --git a/release/datafiles/blender_icons32/icon32_ipo_constant.dat b/release/datafiles/blender_icons32/icon32_ipo_constant.dat
new file mode 100644
index 00000000000..275c124f6cf
--- /dev/null
+++ b/release/datafiles/blender_icons32/icon32_ipo_constant.dat
Binary files differ
diff --git a/release/datafiles/blender_icons32/icon32_ipo_cubic.dat b/release/datafiles/blender_icons32/icon32_ipo_cubic.dat
new file mode 100644
index 00000000000..9df1bf06528
--- /dev/null
+++ b/release/datafiles/blender_icons32/icon32_ipo_cubic.dat
Binary files differ
diff --git a/release/datafiles/blender_icons32/icon32_ipo_ease_in.dat b/release/datafiles/blender_icons32/icon32_ipo_ease_in.dat
new file mode 100644
index 00000000000..d84bea40aff
--- /dev/null
+++ b/release/datafiles/blender_icons32/icon32_ipo_ease_in.dat
Binary files differ
diff --git a/release/datafiles/blender_icons32/icon32_ipo_ease_in_out.dat b/release/datafiles/blender_icons32/icon32_ipo_ease_in_out.dat
new file mode 100644
index 00000000000..a3ce296db39
--- /dev/null
+++ b/release/datafiles/blender_icons32/icon32_ipo_ease_in_out.dat
Binary files differ
diff --git a/release/datafiles/blender_icons32/icon32_ipo_ease_out.dat b/release/datafiles/blender_icons32/icon32_ipo_ease_out.dat
new file mode 100644
index 00000000000..70e96b29eea
--- /dev/null
+++ b/release/datafiles/blender_icons32/icon32_ipo_ease_out.dat
Binary files differ
diff --git a/release/datafiles/blender_icons32/icon32_ipo_elastic.dat b/release/datafiles/blender_icons32/icon32_ipo_elastic.dat
new file mode 100644
index 00000000000..dd65bfccf79
--- /dev/null
+++ b/release/datafiles/blender_icons32/icon32_ipo_elastic.dat
Binary files differ
diff --git a/release/datafiles/blender_icons32/icon32_ipo_expo.dat b/release/datafiles/blender_icons32/icon32_ipo_expo.dat
new file mode 100644
index 00000000000..4fa63d6838f
--- /dev/null
+++ b/release/datafiles/blender_icons32/icon32_ipo_expo.dat
Binary files differ
diff --git a/release/datafiles/blender_icons32/icon32_ipo_linear.dat b/release/datafiles/blender_icons32/icon32_ipo_linear.dat
new file mode 100644
index 00000000000..c0764a712af
--- /dev/null
+++ b/release/datafiles/blender_icons32/icon32_ipo_linear.dat
Binary files differ
diff --git a/release/datafiles/blender_icons32/icon32_ipo_quad.dat b/release/datafiles/blender_icons32/icon32_ipo_quad.dat
new file mode 100644
index 00000000000..0693c648238
--- /dev/null
+++ b/release/datafiles/blender_icons32/icon32_ipo_quad.dat
Binary files differ
diff --git a/release/datafiles/blender_icons32/icon32_ipo_quart.dat b/release/datafiles/blender_icons32/icon32_ipo_quart.dat
new file mode 100644
index 00000000000..a14a3046107
--- /dev/null
+++ b/release/datafiles/blender_icons32/icon32_ipo_quart.dat
Binary files differ
diff --git a/release/datafiles/blender_icons32/icon32_ipo_quint.dat b/release/datafiles/blender_icons32/icon32_ipo_quint.dat
new file mode 100644
index 00000000000..daf7dda359b
--- /dev/null
+++ b/release/datafiles/blender_icons32/icon32_ipo_quint.dat
Binary files differ
diff --git a/release/datafiles/blender_icons32/icon32_ipo_sine.dat b/release/datafiles/blender_icons32/icon32_ipo_sine.dat
new file mode 100644
index 00000000000..304c09ea036
--- /dev/null
+++ b/release/datafiles/blender_icons32/icon32_ipo_sine.dat
Binary files differ
diff --git a/release/datafiles/blender_icons32/icon32_nla_pushdown.dat b/release/datafiles/blender_icons32/icon32_nla_pushdown.dat
new file mode 100644
index 00000000000..83216ac5367
--- /dev/null
+++ b/release/datafiles/blender_icons32/icon32_nla_pushdown.dat
Binary files differ
diff --git a/release/datafiles/brushicons/clone.png b/release/datafiles/brushicons/clone.png
index b10faadef85..ce5e418bb79 100644
--- a/release/datafiles/brushicons/clone.png
+++ b/release/datafiles/brushicons/clone.png
Binary files differ
diff --git a/release/datafiles/brushicons/smear.png b/release/datafiles/brushicons/smear.png
index 5d42b3b24ee..756689d6b01 100644
--- a/release/datafiles/brushicons/smear.png
+++ b/release/datafiles/brushicons/smear.png
Binary files differ
diff --git a/release/datafiles/brushicons/soften.png b/release/datafiles/brushicons/soften.png
index 07367a4c189..84957a12b93 100644
--- a/release/datafiles/brushicons/soften.png
+++ b/release/datafiles/brushicons/soften.png
Binary files differ
diff --git a/release/datafiles/brushicons/texdraw.png b/release/datafiles/brushicons/texdraw.png
index 94faa584c19..86d9f269fe6 100644
--- a/release/datafiles/brushicons/texdraw.png
+++ b/release/datafiles/brushicons/texdraw.png
Binary files differ
diff --git a/release/datafiles/locale b/release/datafiles/locale
-Subproject c842f10f94dd7e5b8a5f28b1ece91cff3890aed
+Subproject cb1967cc63a6d2d75d2b59cdf91c5f5645285ae
diff --git a/release/scripts/addons b/release/scripts/addons
-Subproject 8ad356e3324cddef42d41f9b9b588ef1ebd2f8b
+Subproject c50944e808d6c74148237e85866e893628f0fee
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
-Subproject 7485bc6b11e32e6c9d4d13b273ec7a2d8eddf59
+Subproject 31545d25c9cb41d271a3f3ef84d327708572290
diff --git a/release/scripts/freestyle/modules/freestyle/chainingiterators.py b/release/scripts/freestyle/modules/freestyle/chainingiterators.py
index c4e22192a89..ae0a8a04294 100644
--- a/release/scripts/freestyle/modules/freestyle/chainingiterators.py
+++ b/release/scripts/freestyle/modules/freestyle/chainingiterators.py
@@ -39,8 +39,10 @@ from freestyle.types import (
from freestyle.predicates import (
ExternalContourUP1D,
)
-from freestyle.utils import ContextFunctions as CF
-
+from freestyle.utils import (
+ ContextFunctions as CF,
+ stroke_normal,
+ )
import bpy
diff --git a/release/scripts/freestyle/modules/freestyle/predicates.py b/release/scripts/freestyle/modules/freestyle/predicates.py
index 08017953c35..ce6f0a35ffe 100644
--- a/release/scripts/freestyle/modules/freestyle/predicates.py
+++ b/release/scripts/freestyle/modules/freestyle/predicates.py
@@ -155,7 +155,6 @@ class pyParameterUP0D(UnaryPredicate0D):
## Unary predicates for 1D elements (curves)
############################################
-
class AndUP1D(UnaryPredicate1D):
def __init__(self, pred1, pred2):
UnaryPredicate1D.__init__(self)
@@ -515,11 +514,42 @@ class pyClosedCurveUP1D(UnaryPredicate1D):
## Binary predicates for 1D elements (curves)
#############################################
+class AndBP1D(BinaryPredicate1D):
+ def __init__(self, pred1, pred2):
+ BinaryPredicate1D.__init__(self)
+ self.__pred1 = pred1
+ self.__pred2 = pred2
+
+ def __call__(self, inter1, inter2):
+ return self.__pred1(inter1, inter2) and self.__pred2(inter1, inter2)
+
+
+class OrBP1D(BinaryPredicate1D):
+ def __init__(self, pred1, pred2):
+ BinaryPredicate1D.__init__(self)
+ self.__pred1 = pred1
+ self.__pred2 = pred2
+
+ def __call__(self, inter1, inter2):
+ return self.__pred1(inter1, inter2) or self.__pred2(inter1, inter2)
+
+
+class NotBP1D(BinaryPredicate1D):
+ def __init__(self, pred):
+ BinaryPredicate1D.__init__(self)
+ self.__pred = pred
+
+ def __call__(self, inter1, inter2):
+ return not self.__pred(inter1, inter2)
+
class pyZBP1D(BinaryPredicate1D):
+ def __init__(self, iType=IntegrationType.MEAN):
+ BinaryPredicate1D.__init__(self)
+ self._GetZ = GetZF1D(iType)
+
def __call__(self, i1, i2):
- func = GetZF1D()
- return (func(i1) > func(i2))
+ return (self._GetZ(i1) > self._GetZ(i2))
class pyZDiscontinuityBP1D(BinaryPredicate1D):
diff --git a/release/scripts/freestyle/modules/freestyle/shaders.py b/release/scripts/freestyle/modules/freestyle/shaders.py
index a6ff61653be..ca14df7ac97 100644
--- a/release/scripts/freestyle/modules/freestyle/shaders.py
+++ b/release/scripts/freestyle/modules/freestyle/shaders.py
@@ -30,6 +30,7 @@ to be a collection of examples for shader definition in Python
from _freestyle import (
BackboneStretcherShader,
BezierCurveShader,
+ BlenderTextureShader,
CalligraphicShader,
ColorNoiseShader,
ColorVariationPatternShader,
@@ -44,6 +45,7 @@ from _freestyle import (
SmoothingShader,
SpatialNoiseShader,
StrokeTextureShader,
+ StrokeTextureStepShader,
TextureAssignerShader,
ThicknessNoiseShader,
ThicknessVariationPatternShader,
diff --git a/release/scripts/freestyle/modules/freestyle/utils.py b/release/scripts/freestyle/modules/freestyle/utils.py
index 6d2c9da8146..24ff86d5ef6 100644
--- a/release/scripts/freestyle/modules/freestyle/utils.py
+++ b/release/scripts/freestyle/modules/freestyle/utils.py
@@ -26,3 +26,44 @@ from _freestyle import (
getCurrentScene,
integrate,
)
+
+# constructs for definition of helper functions in Python
+from freestyle.types import (
+ StrokeVertexIterator,
+ )
+import mathutils
+
+
+def stroke_normal(it):
+ """
+ Compute the 2D normal at the stroke vertex pointed by the iterator
+ 'it'. It is noted that Normal2DF0D computes normals based on
+ underlying FEdges instead, which is inappropriate for strokes when
+ they have already been modified by stroke geometry modifiers.
+ """
+ # first stroke segment
+ it_next = StrokeVertexIterator(it)
+ it_next.increment()
+ if it.is_begin:
+ e = it_next.object.point_2d - it.object.point_2d
+ n = mathutils.Vector((e[1], -e[0]))
+ n.normalize()
+ return n
+ # last stroke segment
+ it_prev = StrokeVertexIterator(it)
+ it_prev.decrement()
+ if it_next.is_end:
+ e = it.object.point_2d - it_prev.object.point_2d
+ n = mathutils.Vector((e[1], -e[0]))
+ n.normalize()
+ return n
+ # two subsequent stroke segments
+ e1 = it_next.object.point_2d - it.object.point_2d
+ e2 = it.object.point_2d - it_prev.object.point_2d
+ n1 = mathutils.Vector((e1[1], -e1[0]))
+ n2 = mathutils.Vector((e2[1], -e2[0]))
+ n1.normalize()
+ n2.normalize()
+ n = n1 + n2
+ n.normalize()
+ return n
diff --git a/release/scripts/freestyle/modules/parameter_editor.py b/release/scripts/freestyle/modules/parameter_editor.py
index f3dd66b78cc..3304229e5ff 100644
--- a/release/scripts/freestyle/modules/parameter_editor.py
+++ b/release/scripts/freestyle/modules/parameter_editor.py
@@ -23,6 +23,7 @@
from freestyle.types import (
BinaryPredicate1D,
+ IntegrationType,
Interface0DIterator,
Nature,
Noise,
@@ -51,6 +52,8 @@ from freestyle.predicates import (
ExternalContourUP1D,
FalseBP1D,
FalseUP1D,
+ Length2DBP1D,
+ NotBP1D,
NotUP1D,
OrUP1D,
QuantitativeInvisibilityUP1D,
@@ -58,16 +61,19 @@ from freestyle.predicates import (
TrueUP1D,
WithinImageBoundaryUP1D,
pyNatureUP1D,
+ pyZBP1D,
)
from freestyle.shaders import (
BackboneStretcherShader,
BezierCurveShader,
+ BlenderTextureShader,
ConstantColorShader,
GuidingLinesShader,
PolygonalizationShader,
SamplingShader,
SpatialNoiseShader,
StrokeShader,
+ StrokeTextureStepShader,
TipRemoverShader,
pyBluePrintCirclesShader,
pyBluePrintEllipsesShader,
@@ -76,6 +82,7 @@ from freestyle.shaders import (
from freestyle.utils import (
ContextFunctions,
getCurrentScene,
+ stroke_normal,
)
from _freestyle import (
blendRamp,
@@ -582,13 +589,15 @@ class SinusDisplacementShader(StrokeShader):
self._wavelength = wavelength
self._amplitude = amplitude
self._phase = phase / wavelength * 2 * math.pi
- self._getNormal = Normal2DF0D()
def shade(self, stroke):
+ # separately iterate over stroke vertices to compute normals
+ buf = []
for it, distance in iter_distance_along_stroke(stroke):
- v = it.object
- n = self._getNormal(Interface0DIterator(it))
- n = n * self._amplitude * math.cos(distance / self._wavelength * 2 * math.pi + self._phase)
+ buf.append((it.object, distance, stroke_normal(it)))
+ # iterate over the vertices again to displace them
+ for v, distance, normal in buf:
+ n = normal * self._amplitude * math.cos(distance / self._wavelength * 2 * math.pi + self._phase)
v.point = v.point + n
stroke.update_length()
@@ -639,18 +648,19 @@ class Offset2DShader(StrokeShader):
self.__start = start
self.__end = end
self.__xy = mathutils.Vector((x, y))
- self.__getNormal = Normal2DF0D()
def shade(self, stroke):
+ # first iterate over stroke vertices to compute normals
+ buf = []
it = stroke.stroke_vertices_begin()
while not it.is_end:
- v = it.object
- u = v.u
- a = self.__start + u * (self.__end - self.__start)
- n = self.__getNormal(Interface0DIterator(it))
+ buf.append((it.object, stroke_normal(it)))
+ it.increment()
+ # again iterate over the vertices to add displacement
+ for v, n in buf:
+ a = self.__start + v.u * (self.__end - self.__start)
n = n * a
v.point = v.point + n + self.__xy
- it.increment()
stroke.update_length()
@@ -945,7 +955,8 @@ class DashedLineShader(StrokeShader):
if index == len(self._pattern):
index = 0
visible = not visible
- it.object.attribute.visible = visible
+ if not visible:
+ it.object.attribute.visible = visible
it.increment()
@@ -1159,6 +1170,14 @@ class StrokeCleaner(StrokeShader):
stroke.update_length()
+integration_types = {
+ 'MEAN': IntegrationType.MEAN,
+ 'MIN': IntegrationType.MIN,
+ 'MAX': IntegrationType.MAX,
+ 'FIRST': IntegrationType.FIRST,
+ 'LAST': IntegrationType.LAST}
+
+
# main function for parameter processing
def process(layer_name, lineset_name):
@@ -1287,6 +1306,16 @@ def process(layer_name, lineset_name):
length_min = linestyle.length_min if linestyle.use_length_min else None
length_max = linestyle.length_max if linestyle.use_length_max else None
Operators.select(LengthThresholdUP1D(length_min, length_max))
+ # sort selected chains
+ if linestyle.use_sorting:
+ integration = integration_types.get(linestyle.integration_type, IntegrationType.MEAN)
+ if linestyle.sort_key == 'DISTANCE_FROM_CAMERA':
+ bpred = pyZBP1D(integration)
+ elif linestyle.sort_key == '2D_LENGTH':
+ bpred = Length2DBP1D()
+ if linestyle.sort_order == 'REVERSE':
+ bpred = NotBP1D(bpred)
+ Operators.sort(bpred)
# prepare a list of stroke shaders
shaders_list = []
###
@@ -1341,6 +1370,14 @@ def process(layer_name, lineset_name):
elif m.type == '2D_TRANSFORM':
shaders_list.append(Transform2DShader(
m.pivot, m.scale_x, m.scale_y, m.angle, m.pivot_u, m.pivot_x, m.pivot_y))
+ if linestyle.use_texture:
+ has_tex = False
+ for slot in linestyle.texture_slots:
+ if slot is not None:
+ shaders_list.append(BlenderTextureShader(slot))
+ has_tex = True
+ if has_tex:
+ shaders_list.append(StrokeTextureStepShader(linestyle.texture_spacing))
color = linestyle.color
if (not linestyle.use_chaining) or (linestyle.chaining == 'PLAIN' and linestyle.use_same_object):
thickness_position = linestyle.thickness_position
diff --git a/release/scripts/freestyle/styles/anisotropic_diffusion.py b/release/scripts/freestyle/styles/anisotropic_diffusion.py
index f241f72fefe..b17e5c2a38c 100644
--- a/release/scripts/freestyle/styles/anisotropic_diffusion.py
+++ b/release/scripts/freestyle/styles/anisotropic_diffusion.py
@@ -26,7 +26,6 @@ from freestyle.predicates import (
AndUP1D,
ExternalContourUP1D,
NotUP1D,
- Operators,
QuantitativeInvisibilityUP1D,
TrueBP1D,
TrueUP1D,
diff --git a/release/scripts/modules/addon_utils.py b/release/scripts/modules/addon_utils.py
index e76bcc02751..88356b676d2 100644
--- a/release/scripts/modules/addon_utils.py
+++ b/release/scripts/modules/addon_utils.py
@@ -229,9 +229,9 @@ def check(module_name):
def _addon_ensure(module_name):
addons = _user_preferences.addons
- addon = _user_preferences.addons.get(module_name)
+ addon = addons.get(module_name)
if not addon:
- addon = _user_preferences.addons.new()
+ addon = addons.new()
addon.module = module_name
diff --git a/release/scripts/modules/animsys_refactor.py b/release/scripts/modules/animsys_refactor.py
index 8899bbf1ad7..aaa06c32312 100644
--- a/release/scripts/modules/animsys_refactor.py
+++ b/release/scripts/modules/animsys_refactor.py
@@ -25,6 +25,10 @@ rna values in fcurves and drivers.
Currently unused, but might become useful later again.
"""
+import sys
+import bpy
+
+
IS_TESTING = False
@@ -34,9 +38,21 @@ def drepr(string):
return '"%s"' % repr(string)[1:-1].replace("\"", "\\\"").replace("\\'", "'")
+def classes_recursive(base_type, clss=None):
+ if clss is None:
+ clss = [base_type]
+ else:
+ clss.append(base_type)
+
+ for base_type_iter in base_type.__bases__:
+ if base_type_iter is not object:
+ classes_recursive(base_type_iter, clss)
+
+ return clss
+
+
class DataPathBuilder(object):
- """ Dummy class used to parse fcurve and driver data paths.
- """
+ """Dummy class used to parse fcurve and driver data paths."""
__slots__ = ("data_path", )
def __init__(self, attrs):
@@ -55,38 +71,54 @@ class DataPathBuilder(object):
raise Exception("unsupported accessor %r of type %r (internal error)" % (key, type(key)))
return DataPathBuilder(self.data_path + (str_value, ))
- def resolve(self, real_base, rna_update_from_map=None):
- """ Return (attribute, value) pairs.
- """
+ def resolve(self, real_base, rna_update_from_map, fcurve, log):
+ """Return (attribute, value) pairs."""
pairs = []
base = real_base
for item in self.data_path:
if base is not Ellipsis:
- try:
- # this only works when running with an old blender
- # where the old path will resolve
- base = eval("base" + item)
- except:
- base_new = Ellipsis
- # guess the new name
- if item.startswith("."):
- for item_new in rna_update_from_map.get(item[1:], ()):
- try:
- print("base." + item_new)
- base_new = eval("base." + item_new)
+ base_new = Ellipsis
+ # find the new name
+ if item.startswith("."):
+ for class_name, item_new, options in rna_update_from_map.get(item[1:], []) + [(None, item[1:], None)]:
+ if callable(item_new):
+ # No type check here, callback is assumed to know what it's doing.
+ base_new, item_new = item_new(base, class_name, item[1:], fcurve, options)
+ if base_new is not Ellipsis:
break # found, don't keep looking
- except:
- pass
-
- if base_new is Ellipsis:
- print("Failed to resolve data path:", self.data_path)
- base = base_new
-
- pairs.append((item, base))
+ else:
+ # Type check!
+ type_ok = True
+ if class_name is not None:
+ type_ok = False
+ for base_type in classes_recursive(type(base)):
+ if base_type.__name__ == class_name:
+ type_ok = True
+ break
+ if type_ok:
+ try:
+ #print("base." + item_new)
+ base_new = eval("base." + item_new)
+ break # found, don't keep looking
+ except:
+ pass
+ item_new = "." + item_new
+ else:
+ item_new = item
+ try:
+ base_new = eval("base" + item_new)
+ except:
+ pass
+
+ if base_new is Ellipsis:
+ print("Failed to resolve data path:", self.data_path, file=log)
+ base = base_new
+ else:
+ item_new = item
+
+ pairs.append((item_new, base))
return pairs
-import bpy
-
def id_iter():
type_iter = type(bpy.data.objects)
@@ -110,20 +142,7 @@ def anim_data_actions(anim_data):
return [act for act in actions if act]
-def classes_recursive(base_type, clss=None):
- if clss is None:
- clss = [base_type]
- else:
- clss.append(base_type)
-
- for base_type_iter in base_type.__bases__:
- if base_type_iter is not object:
- classes_recursive(base_type_iter, clss)
-
- return clss
-
-
-def find_path_new(id_data, data_path, rna_update_dict, rna_update_from_map):
+def find_path_new(id_data, data_path, rna_update_from_map, fcurve, log):
# note!, id_data can be ID type or a node tree
# ignore ID props for now
if data_path.startswith("["):
@@ -131,46 +150,28 @@ def find_path_new(id_data, data_path, rna_update_dict, rna_update_from_map):
# recursive path fixing, likely will be one in most cases.
data_path_builder = eval("DataPathBuilder(tuple())." + data_path)
- data_resolve = data_path_builder.resolve(id_data, rna_update_from_map)
+ data_resolve = data_path_builder.resolve(id_data, rna_update_from_map, fcurve, log)
path_new = [pair[0] for pair in data_resolve]
- # print(data_resolve)
- data_base = id_data
-
- for i, (attr, data) in enumerate(data_resolve):
- if data is Ellipsis:
- break
-
- if attr.startswith("."):
- # try all classes
- for data_base_type in classes_recursive(type(data_base)):
- attr_new = rna_update_dict.get(data_base_type.__name__, {}).get(attr[1:])
- if attr_new:
- path_new[i] = "." + attr_new
+ return "".join(path_new)[1:] # skip the first "."
- # set this as the base for further properties
- data_base = data
- data_path_new = "".join(path_new)[1:] # skip the first "."
- return data_path_new
-
-
-def update_data_paths(rna_update):
- """ rna_update triple [(class_name, from, to), ...]
+def update_data_paths(rna_update, log=sys.stdout):
+ """
+ rna_update triple [(class_name, from, to or to_callback, callback options), ...]
+ to_callback is a function with this signature: update_cb(base, class_name, old_path, fcurve, options)
+ where base is current object, class_name is the expected type name of base (callback has to handle
+ this), old_path it the org name of base's property, fcurve is the affected fcurve (!),
+ and options is an opaque data.
+ class_name, fcurve and options may be None!
"""
-
- # make a faster lookup dict
- rna_update_dict = {}
- for ren_class, ren_from, ren_to in rna_update:
- rna_update_dict.setdefault(ren_class, {})[ren_from] = ren_to
rna_update_from_map = {}
- for ren_class, ren_from, ren_to in rna_update:
- rna_update_from_map.setdefault(ren_from, []).append(ren_to)
+ for ren_class, ren_from, ren_to, options in rna_update:
+ rna_update_from_map.setdefault(ren_from, []).append((ren_class, ren_to, options))
for id_data in id_iter():
-
# check node-trees too
anim_data_ls = [(id_data, getattr(id_data, "animation_data", None))]
node_tree = getattr(id_data, "node_tree", None)
@@ -183,13 +184,13 @@ def update_data_paths(rna_update):
for fcurve in anim_data.drivers:
data_path = fcurve.data_path
- data_path_new = find_path_new(anim_data_base, data_path, rna_update_dict, rna_update_from_map)
+ data_path_new = find_path_new(anim_data_base, data_path, rna_update_from_map, fcurve, log)
# print(data_path_new)
if data_path_new != data_path:
if not IS_TESTING:
fcurve.data_path = data_path_new
fcurve.driver.is_valid = True # reset to allow this to work again
- print("driver-fcurve (%s): %s -> %s" % (id_data.name, data_path, data_path_new))
+ print("driver-fcurve (%s): %s -> %s" % (id_data.name, data_path, data_path_new), file=log)
for var in fcurve.driver.variables:
if var.type == 'SINGLE_PROP':
@@ -198,32 +199,33 @@ def update_data_paths(rna_update):
data_path = tar.data_path
if id_data_other and data_path:
- data_path_new = find_path_new(id_data_other, data_path, rna_update_dict, rna_update_from_map)
+ data_path_new = find_path_new(id_data_other, data_path, rna_update_from_map, None, log)
# print(data_path_new)
if data_path_new != data_path:
if not IS_TESTING:
tar.data_path = data_path_new
- print("driver (%s): %s -> %s" % (id_data_other.name, data_path, data_path_new))
+ print("driver (%s): %s -> %s" % (id_data_other.name, data_path, data_path_new),
+ file=log)
for action in anim_data_actions(anim_data):
for fcu in action.fcurves:
data_path = fcu.data_path
- data_path_new = find_path_new(anim_data_base, data_path, rna_update_dict, rna_update_from_map)
+ data_path_new = find_path_new(anim_data_base, data_path, rna_update_from_map, fcu, log)
# print(data_path_new)
if data_path_new != data_path:
if not IS_TESTING:
fcu.data_path = data_path_new
- print("fcurve (%s): %s -> %s" % (id_data.name, data_path, data_path_new))
+ print("fcurve (%s): %s -> %s" % (id_data.name, data_path, data_path_new), file=log)
if __name__ == "__main__":
# Example, should be called externally
- # (class, from, to)
+ # (class, from, to or to_callback, callback_options)
replace_ls = [
- ("AnimVizMotionPaths", "frame_after", "frame_after"),
- ("AnimVizMotionPaths", "frame_before", "frame_before"),
- ("AnimVizOnionSkinning", "frame_after", "frame_after"),
+ ("AnimVizMotionPaths", "frame_after", "frame_after", None),
+ ("AnimVizMotionPaths", "frame_before", "frame_before", None),
+ ("AnimVizOnionSkinning", "frame_after", "frame_after", None),
]
update_data_paths(replace_ls)
diff --git a/release/scripts/modules/bpy/ops.py b/release/scripts/modules/bpy/ops.py
index e457c087ab8..f5455ce5018 100644
--- a/release/scripts/modules/bpy/ops.py
+++ b/release/scripts/modules/bpy/ops.py
@@ -201,11 +201,13 @@ class BPyOpsSubModOp(object):
return op_get_instance(self.idname())
def __repr__(self): # useful display, repr(op)
- import bpy
+ # import bpy
idname = self.idname()
as_string = op_as_string(idname)
- # XXX You never quite know what you get from bpy.types, with operators... Operator and OperatorProperties
- # are shadowing each other, and not in the same way for native ops and py ones! See T39158.
+ # XXX You never quite know what you get from bpy.types,
+ # with operators... Operator and OperatorProperties
+ # are shadowing each other, and not in the same way for
+ # native ops and py ones! See T39158.
# op_class = getattr(bpy.types, idname)
op_class = op_get_rna(idname)
descr = op_class.bl_rna.description
diff --git a/release/scripts/modules/bpy_extras/view3d_utils.py b/release/scripts/modules/bpy_extras/view3d_utils.py
index 7a075e93e1a..ad555a417d7 100644
--- a/release/scripts/modules/bpy_extras/view3d_utils.py
+++ b/release/scripts/modules/bpy_extras/view3d_utils.py
@@ -73,16 +73,11 @@ def region_2d_to_origin_3d(region, rv3d, coord):
:return: The origin of the viewpoint in 3d space.
:rtype: :class:`mathutils.Vector`
"""
- from mathutils import Vector
-
viewinv = rv3d.view_matrix.inverted()
if rv3d.is_perspective:
- from mathutils.geometry import intersect_line_plane
-
origin_start = viewinv.translation.copy()
else:
- from mathutils.geometry import intersect_point_line
persmat = rv3d.perspective_matrix.copy()
dx = (2.0 * coord[0] / region.width) - 1.0
dy = (2.0 * coord[1] / region.height) - 1.0
diff --git a/release/scripts/modules/nodeitems_utils.py b/release/scripts/modules/nodeitems_utils.py
index 7418452b039..f017c76ae6f 100644
--- a/release/scripts/modules/nodeitems_utils.py
+++ b/release/scripts/modules/nodeitems_utils.py
@@ -18,7 +18,6 @@
# <pep8 compliant>
import bpy
-from bpy.types import Menu, Panel
class NodeCategory():
@@ -92,7 +91,6 @@ def register_node_categories(identifier, cat_list):
def draw_node_item(self, context):
layout = self.layout
col = layout.column()
- default_context = bpy.app.translations.contexts.default
for item in self.category.items(context):
item.draw(item, col, context)
diff --git a/release/scripts/modules/rna_keymap_ui.py b/release/scripts/modules/rna_keymap_ui.py
index dde26d6e284..12d99a00d44 100644
--- a/release/scripts/modules/rna_keymap_ui.py
+++ b/release/scripts/modules/rna_keymap_ui.py
@@ -292,7 +292,6 @@ def draw_filtered(display_keymaps, filter_type, filter_text, layout):
kmi_type_set.add(v)
return kmi_type_set
- kmi_type_set_combine = None
for i, kmi_type in enumerate(filter_text_split):
kmi_type_set = kmi_type_set_from_string(kmi_type)
diff --git a/release/scripts/presets/keyconfig/3dsmax.py b/release/scripts/presets/keyconfig/3dsmax.py
index 19f1c23b5ab..808ba7cee81 100644
--- a/release/scripts/presets/keyconfig/3dsmax.py
+++ b/release/scripts/presets/keyconfig/3dsmax.py
@@ -270,7 +270,7 @@ kmi.properties.name = 'VIEW3D_MT_bone_options_enable'
kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS', alt=True)
kmi.properties.name = 'VIEW3D_MT_bone_options_disable'
kmi = km.keymap_items.new('armature.layers_show_all', 'ACCENT_GRAVE', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('pose.armature_layers', 'M', 'PRESS', shift=True)
+kmi = km.keymap_items.new('armature.armature_layers', 'M', 'PRESS', shift=True)
kmi = km.keymap_items.new('pose.bone_layers', 'M', 'PRESS')
kmi = km.keymap_items.new('transform.transform', 'S', 'PRESS', ctrl=True, alt=True)
kmi.properties.mode = 'BONE_SIZE'
diff --git a/release/scripts/presets/keyconfig/maya.py b/release/scripts/presets/keyconfig/maya.py
index 9becc1091eb..3a5a6c7570a 100644
--- a/release/scripts/presets/keyconfig/maya.py
+++ b/release/scripts/presets/keyconfig/maya.py
@@ -326,7 +326,7 @@ kmi.properties.name = 'VIEW3D_MT_pose_group'
kmi = km.keymap_items.new('wm.call_menu', 'RIGHTMOUSE', 'PRESS')
kmi.properties.name = 'VIEW3D_MT_bone_options_toggle'
kmi = km.keymap_items.new('armature.layers_show_all', 'ACCENT_GRAVE', 'PRESS', ctrl=True)
-kmi = km.keymap_items.new('pose.armature_layers', 'M', 'PRESS', shift=True)
+kmi = km.keymap_items.new('armature.armature_layers', 'M', 'PRESS', shift=True)
kmi = km.keymap_items.new('pose.bone_layers', 'M', 'PRESS')
kmi = km.keymap_items.new('transform.transform', 'S', 'PRESS', ctrl=True, alt=True)
kmi = km.keymap_items.new('anim.keyframe_insert_menu', 'S', 'PRESS')
diff --git a/release/scripts/startup/bl_operators/add_mesh_torus.py b/release/scripts/startup/bl_operators/add_mesh_torus.py
index 39b0df1dd65..449a4cef1ef 100644
--- a/release/scripts/startup/bl_operators/add_mesh_torus.py
+++ b/release/scripts/startup/bl_operators/add_mesh_torus.py
@@ -22,7 +22,6 @@ from bpy.types import Operator
from bpy.props import (FloatProperty,
IntProperty,
- BoolProperty,
)
from bpy.app.translations import pgettext_data as data_
diff --git a/release/scripts/startup/bl_operators/anim.py b/release/scripts/startup/bl_operators/anim.py
index 41f39b90464..e8890bfd936 100644
--- a/release/scripts/startup/bl_operators/anim.py
+++ b/release/scripts/startup/bl_operators/anim.py
@@ -23,6 +23,7 @@ if "bpy" in locals():
if "anim_utils" in locals():
imp.reload(anim_utils)
+
import bpy
from bpy.types import Operator
from bpy.props import (IntProperty,
@@ -281,3 +282,85 @@ class ClearUselessActions(Operator):
self.report({'INFO'}, "Removed %d empty and/or fake-user only Actions"
% removed)
return {'FINISHED'}
+
+
+class UpdateAnimatedTransformConstraint(Operator):
+ """Update fcurves/drivers affecting Transform constraints (use it with files from 2.70 and earlier)"""
+ bl_idname = "anim.update_animated_transform_constraints"
+ bl_label = "Update Animated Transform Constraints"
+ bl_options = {'REGISTER', 'UNDO'}
+
+ use_convert_to_radians = BoolProperty(
+ name="Convert To Radians",
+ description="Convert fcurves/drivers affecting rotations to radians (Warning: use this only once!)",
+ default=True,
+ )
+
+ def execute(self, context):
+ import animsys_refactor
+ from math import radians
+ import io
+
+ from_paths = {"from_max_x", "from_max_y", "from_max_z", "from_min_x", "from_min_y", "from_min_z"}
+ to_paths = {"to_max_x", "to_max_y", "to_max_z", "to_min_x", "to_min_y", "to_min_z"}
+ paths = from_paths | to_paths
+
+ def update_cb(base, class_name, old_path, fcurve, options):
+ print(options)
+ def handle_deg2rad(fcurve):
+ if fcurve is not None:
+ if hasattr(fcurve, "keyframes"):
+ for k in fcurve.keyframes:
+ k.co.y = radians(k.co.y)
+ for mod in fcurve.modifiers:
+ if mod.type == 'GENERATOR':
+ if mod.mode == 'POLYNOMIAL':
+ mod.coefficients[:] = [radians(c) for c in mod.coefficients]
+ else: # if mod.type == 'POLYNOMIAL_FACTORISED':
+ mod.coefficients[:2] = [radians(c) for c in mod.coefficients[:2]]
+ elif mod.type == 'FNGENERATOR':
+ mod.amplitude = radians(mod.amplitude)
+ fcurve.update()
+
+ data = ...
+ try:
+ data = eval("base." + old_path)
+ except:
+ pass
+ ret = (data, old_path)
+ if isinstance(base, bpy.types.TransformConstraint) and data is not ...:
+ new_path = None
+ map_info = base.map_from if old_path in from_paths else base.map_to
+ if map_info == 'ROTATION':
+ new_path = old_path + "_rot"
+ if options is not None and options["use_convert_to_radians"]:
+ handle_deg2rad(fcurve)
+ elif map_info == 'SCALE':
+ new_path = old_path + "_scale"
+
+ if new_path is not None:
+ data = ...
+ try:
+ data = eval("base." + new_path)
+ except:
+ pass
+ ret = (data, new_path)
+ #print(ret)
+
+ return ret
+
+ options = {"use_convert_to_radians": self.use_convert_to_radians}
+ replace_ls = [("TransformConstraint", p, update_cb, options) for p in paths]
+ log = io.StringIO()
+
+ animsys_refactor.update_data_paths(replace_ls, log)
+
+ context.scene.frame_set(context.scene.frame_current)
+
+ log = log.getvalue()
+ if log:
+ print(log)
+ text = bpy.data.texts.new("UpdateAnimatedTransformConstraint Report")
+ text.from_string(log)
+ self.report({'INFO'}, "Complete report available on '{}' text datablock".format(text.name))
+ return {'FINISHED'}
diff --git a/release/scripts/startup/bl_operators/freestyle.py b/release/scripts/startup/bl_operators/freestyle.py
index 73232232e23..453be519abf 100644
--- a/release/scripts/startup/bl_operators/freestyle.py
+++ b/release/scripts/startup/bl_operators/freestyle.py
@@ -105,7 +105,7 @@ class SCENE_OT_freestyle_add_edge_marks_to_keying_set(bpy.types.Operator):
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
for i, edge in enumerate(mesh.edges):
if not edge.hide and edge.select:
- path = 'edges[%d].use_freestyle_edge_mark' % i
+ path = 'edges[%d].use_freestyle_mark' % i
ks.paths.add(mesh, path, index=0)
bpy.ops.object.mode_set(mode=ob_mode, toggle=False)
return {'FINISHED'}
@@ -136,7 +136,7 @@ class SCENE_OT_freestyle_add_face_marks_to_keying_set(bpy.types.Operator):
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
for i, polygon in enumerate(mesh.polygons):
if not polygon.hide and polygon.select:
- path = 'polygons[%d].use_freestyle_face_mark' % i
+ path = 'polygons[%d].use_freestyle_mark' % i
ks.paths.add(mesh, path, index=0)
bpy.ops.object.mode_set(mode=ob_mode, toggle=False)
return {'FINISHED'}
diff --git a/release/scripts/startup/bl_operators/mesh.py b/release/scripts/startup/bl_operators/mesh.py
index cead7d66097..f86c31cd9cc 100644
--- a/release/scripts/startup/bl_operators/mesh.py
+++ b/release/scripts/startup/bl_operators/mesh.py
@@ -87,7 +87,6 @@ class MeshMirrorUV(Operator):
polys = mesh.polygons
loops = mesh.loops
- verts = mesh.vertices
uv_loops = mesh.uv_layers.active.data
nbr_polys = len(polys)
diff --git a/release/scripts/startup/bl_operators/node.py b/release/scripts/startup/bl_operators/node.py
index 13189b2e9d3..9bdd9289700 100644
--- a/release/scripts/startup/bl_operators/node.py
+++ b/release/scripts/startup/bl_operators/node.py
@@ -61,7 +61,6 @@ class NodeAddOperator():
@staticmethod
def store_mouse_cursor(context, event):
space = context.space_data
- v2d = context.region.view2d
tree = space.edit_tree
# convert mouse position to the View2D for later node placement
diff --git a/release/scripts/startup/bl_operators/object.py b/release/scripts/startup/bl_operators/object.py
index ae13ba8b559..5661e25bc0f 100644
--- a/release/scripts/startup/bl_operators/object.py
+++ b/release/scripts/startup/bl_operators/object.py
@@ -248,13 +248,17 @@ class SubdivisionSet(Operator):
for mod in obj.modifiers:
if mod.type == 'MULTIRES':
if not relative:
- if level <= mod.total_levels:
- if obj.mode == 'SCULPT':
- if mod.sculpt_levels != level:
- mod.sculpt_levels = level
- elif obj.mode == 'OBJECT':
- if mod.levels != level:
- mod.levels = level
+ if level > mod.total_levels:
+ sub = level - mod.total_levels
+ for i in range (0, sub):
+ bpy.ops.object.multires_subdivide(modifier="Multires")
+
+ if obj.mode == 'SCULPT':
+ if mod.sculpt_levels != level:
+ mod.sculpt_levels = level
+ elif obj.mode == 'OBJECT':
+ if mod.levels != level:
+ mod.levels = level
return
else:
if obj.mode == 'SCULPT':
@@ -276,8 +280,14 @@ class SubdivisionSet(Operator):
# add a new modifier
try:
- mod = obj.modifiers.new("Subsurf", 'SUBSURF')
- mod.levels = level
+ if obj.mode == 'SCULPT':
+ mod = obj.modifiers.new("Multires", 'MULTIRES')
+ if level > 0:
+ for i in range(0, level):
+ bpy.ops.object.multires_subdivide(modifier="Multires")
+ else:
+ mod = obj.modifiers.new("Subsurf", 'SUBSURF')
+ mod.levels = level
except:
self.report({'WARNING'},
"Modifiers cannot be added to object: " + obj.name)
@@ -687,7 +697,6 @@ class TransformsToDeltasAnim(Operator):
DELTA_PATHS = STANDARD_TO_DELTA_PATHS.values()
# try to apply on each selected object
- success = False
for obj in context.selected_editable_objects:
adt = obj.animation_data
if (adt is None) or (adt.action is None):
@@ -792,7 +801,6 @@ class LodByName(Operator):
return (context.active_object is not None)
def execute(self, context):
- scene = context.scene
ob = context.active_object
prefix = ""
@@ -843,7 +851,6 @@ class LodClearAll(Operator):
return (context.active_object is not None)
def execute(self, context):
- scene = context.scene
ob = context.active_object
if ob.lod_levels:
diff --git a/release/scripts/startup/bl_operators/rigidbody.py b/release/scripts/startup/bl_operators/rigidbody.py
index f9461c85341..9a3aae53ceb 100644
--- a/release/scripts/startup/bl_operators/rigidbody.py
+++ b/release/scripts/startup/bl_operators/rigidbody.py
@@ -143,6 +143,9 @@ class BakeToKeyframes(Operator):
scene.frame_set(f)
for j, obj in enumerate(objects):
mat = bake[i][j]
+ # convert world space transform to parent space, so parented objects don't get offset after baking
+ if (obj.parent):
+ mat = obj.matrix_parent_inverse.inverted() * obj.parent.matrix_world.inverted() * mat
obj.location = mat.to_translation()
diff --git a/release/scripts/startup/bl_operators/uvcalc_smart_project.py b/release/scripts/startup/bl_operators/uvcalc_smart_project.py
index 1a8bd44e846..bf8b10ac4af 100644
--- a/release/scripts/startup/bl_operators/uvcalc_smart_project.py
+++ b/release/scripts/startup/bl_operators/uvcalc_smart_project.py
@@ -250,7 +250,8 @@ def optiRotateUvIsland(faces):
# orient them vertically (could be an option)
minx, miny, maxx, maxy = boundsIsland(faces)
w, h = maxx - minx, maxy - miny
- if h < w:
+ # use epsilon so we dont randomly rotate (almost) perfect squares.
+ if h + 0.00001 < w:
from math import pi
angle = pi / 2.0
rotate_uvs(uv_points, angle)
diff --git a/release/scripts/startup/bl_operators/vertexpaint_dirt.py b/release/scripts/startup/bl_operators/vertexpaint_dirt.py
index cd3ffb9c232..68c9bc143be 100644
--- a/release/scripts/startup/bl_operators/vertexpaint_dirt.py
+++ b/release/scripts/startup/bl_operators/vertexpaint_dirt.py
@@ -183,7 +183,6 @@ class VertexPaintDirt(Operator):
def execute(self, context):
import time
- from math import radians
obj = context.object
mesh = obj.data
diff --git a/release/scripts/startup/bl_operators/view3d.py b/release/scripts/startup/bl_operators/view3d.py
index da6628617e7..85cc9210c2d 100644
--- a/release/scripts/startup/bl_operators/view3d.py
+++ b/release/scripts/startup/bl_operators/view3d.py
@@ -19,7 +19,6 @@
# <pep8-80 compliant>
import bpy
-import mathutils
from bpy.types import Operator
from bpy.props import BoolProperty
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py
index 3fdde1a1339..86ae8fdc4e6 100644
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@ -19,7 +19,7 @@
# <pep8 compliant>
import bpy
-from bpy.types import Menu, Operator
+from bpy.types import Operator
from bpy.props import (StringProperty,
BoolProperty,
IntProperty,
diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py
index 793cbf8ce80..6b72ef12dcc 100644
--- a/release/scripts/startup/bl_ui/__init__.py
+++ b/release/scripts/startup/bl_ui/__init__.py
@@ -195,7 +195,6 @@ class UI_UL_list(bpy.types.UIList):
return a list mapping org_idx -> new_idx,
or an empty list if no sorting has been done.
"""
- neworder = [None] * len(items)
_sort = [(idx, getattr(it, propname, "")) for idx, it in enumerate(items)]
return cls.sort_items_helper(_sort, lambda e: e[1].lower())
diff --git a/release/scripts/startup/bl_ui/properties_constraint.py b/release/scripts/startup/bl_ui/properties_constraint.py
index 91999e1f5ee..50107604b3b 100644
--- a/release/scripts/startup/bl_ui/properties_constraint.py
+++ b/release/scripts/startup/bl_ui/properties_constraint.py
@@ -653,21 +653,22 @@ class ConstraintButtonsPanel():
col.row().prop(con, "map_from", expand=True)
split = layout.split()
+ ext = "" if con.map_from == 'LOCATION' else "_rot" if con.map_from == 'ROTATION' else "_scale"
sub = split.column(align=True)
sub.label(text="X:")
- sub.prop(con, "from_min_x", text="Min")
- sub.prop(con, "from_max_x", text="Max")
+ sub.prop(con, "from_min_x" + ext, text="Min")
+ sub.prop(con, "from_max_x" + ext, text="Max")
sub = split.column(align=True)
sub.label(text="Y:")
- sub.prop(con, "from_min_y", text="Min")
- sub.prop(con, "from_max_y", text="Max")
+ sub.prop(con, "from_min_y" + ext, text="Min")
+ sub.prop(con, "from_max_y" + ext, text="Max")
sub = split.column(align=True)
sub.label(text="Z:")
- sub.prop(con, "from_min_z", text="Min")
- sub.prop(con, "from_max_z", text="Max")
+ sub.prop(con, "from_min_z" + ext, text="Min")
+ sub.prop(con, "from_max_z" + ext, text="Max")
col = layout.column()
row = col.row()
@@ -694,27 +695,28 @@ class ConstraintButtonsPanel():
col.row().prop(con, "map_to", expand=True)
split = layout.split()
+ ext = "" if con.map_to == 'LOCATION' else "_rot" if con.map_to == 'ROTATION' else "_scale"
col = split.column()
col.label(text="X:")
sub = col.column(align=True)
- sub.prop(con, "to_min_x", text="Min")
- sub.prop(con, "to_max_x", text="Max")
+ sub.prop(con, "to_min_x" + ext, text="Min")
+ sub.prop(con, "to_max_x" + ext, text="Max")
col = split.column()
col.label(text="Y:")
sub = col.column(align=True)
- sub.prop(con, "to_min_y", text="Min")
- sub.prop(con, "to_max_y", text="Max")
+ sub.prop(con, "to_min_y" + ext, text="Min")
+ sub.prop(con, "to_max_y" + ext, text="Max")
col = split.column()
col.label(text="Z:")
sub = col.column(align=True)
- sub.prop(con, "to_min_z", text="Min")
- sub.prop(con, "to_max_z", text="Max")
+ sub.prop(con, "to_min_z" + ext, text="Min")
+ sub.prop(con, "to_max_z" + ext, text="Max")
self.space_template(layout, con)
@@ -856,7 +858,7 @@ class OBJECT_PT_constraints(ConstraintButtonsPanel, Panel):
obj = context.object
- if obj.type == 'ARMATURE' and obj.mode in {'EDIT', 'POSE'}:
+ if obj.type == 'ARMATURE' and obj.mode in {'POSE'}:
box = layout.box()
box.alert = True # XXX: this should apply to the box background
box.label(icon='INFO', text="Constraints for active bone do not live here")
diff --git a/release/scripts/startup/bl_ui/properties_data_armature.py b/release/scripts/startup/bl_ui/properties_data_armature.py
index f4ec2ce1f31..c6823f17153 100644
--- a/release/scripts/startup/bl_ui/properties_data_armature.py
+++ b/release/scripts/startup/bl_ui/properties_data_armature.py
@@ -292,7 +292,7 @@ class DATA_PT_motion_paths(MotionPathButtonsPanel, Panel):
return (context.object) and (context.armature)
def draw(self, context):
- layout = self.layout
+ # layout = self.layout
ob = context.object
avs = ob.pose.animation_visualization
diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py
index edf3354db4f..622c9ba2445 100644
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@ -76,7 +76,7 @@ class MESH_UL_shape_keys(UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
# assert(isinstance(item, bpy.types.ShapeKey)
obj = active_data
- key = data
+ # key = data
key_block = item
if self.layout_type in {'DEFAULT', 'COMPACT'}:
split = layout.split(0.66, False)
@@ -323,7 +323,6 @@ class DATA_PT_uv_texture(MeshButtonsPanel, Panel):
layout = self.layout
me = context.mesh
- lay = me.uv_textures.active
row = layout.row()
col = row.column()
@@ -343,7 +342,6 @@ class DATA_PT_vertex_colors(MeshButtonsPanel, Panel):
layout = self.layout
me = context.mesh
- lay = me.vertex_colors.active
row = layout.row()
col = row.column()
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 8e3e289ea3b..60187ff1cd5 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -283,29 +283,28 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
def DISPLACE(self, layout, ob, md):
has_texture = (md.texture is not None)
- split = layout.split()
-
- col = split.column()
+ col = layout.column(align=True)
col.label(text="Texture:")
col.template_ID(md, "texture", new="texture.new")
- col.label(text="Vertex Group:")
- col.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
- col = split.column()
+ split = layout.split()
+
+ col = split.column(align=True)
col.label(text="Direction:")
col.prop(md, "direction", text="")
- colsub = col.column()
- colsub.active = has_texture
- colsub.label(text="Texture Coordinates:")
- colsub.prop(md, "texture_coords", text="")
+ col.label(text="Vertex Group:")
+ col.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
+
+ col = split.column(align=True)
+ col.active = has_texture
+ col.label(text="Texture Coordinates:")
+ col.prop(md, "texture_coords", text="")
if md.texture_coords == 'OBJECT':
- row = layout.row()
- row.active = has_texture
- row.prop(md, "texture_coords_object", text="Object")
+ col.label(text="Object:")
+ col.prop(md, "texture_coords_object", text="")
elif md.texture_coords == 'UV' and ob.type == 'MESH':
- row = layout.row()
- row.active = has_texture
- row.prop_search(md, "uv_layer", ob.data, "uv_textures")
+ col.label(text="UV Map:")
+ col.prop_search(md, "uv_layer", ob.data, "uv_textures", text="")
layout.separator()
diff --git a/release/scripts/startup/bl_ui/properties_freestyle.py b/release/scripts/startup/bl_ui/properties_freestyle.py
index 197b0d2f970..31a638d3c7e 100644
--- a/release/scripts/startup/bl_ui/properties_freestyle.py
+++ b/release/scripts/startup/bl_ui/properties_freestyle.py
@@ -61,7 +61,7 @@ class RENDER_PT_freestyle(RenderFreestyleButtonsPanel, Panel):
row = layout.row()
row.label(text="Line style settings are in the Render Layers tab")
- row.operator("wm.properties_context_change", text="", icon='BUTS').context = 'RENDER_LAYER'
+ row.operator("wm.properties_context_change", text="", icon='RENDERLAYERS').context = 'RENDER_LAYER'
# Render layer properties
@@ -534,20 +534,18 @@ class RENDERLAYER_PT_freestyle_linestyle(RenderLayerFreestyleEditorButtonsPanel,
row.prop(linestyle, "panel", expand=True)
if linestyle.panel == 'STROKES':
## Chaining
- layout.label(text="Chaining:")
+ layout.prop(linestyle, "use_chaining", text="Chaining:")
split = layout.split(align=True)
+ split.active = linestyle.use_chaining
# First column
col = split.column()
- col.prop(linestyle, "use_chaining", text="Enable Chaining")
- sub = col.row()
- sub.active = linestyle.use_chaining
- sub.prop(linestyle, "use_same_object")
- # Second column
- col = split.column()
col.active = linestyle.use_chaining
col.prop(linestyle, "chaining", text="")
if linestyle.chaining == 'SKETCHY':
col.prop(linestyle, "rounds")
+ # Second column
+ col = split.column()
+ col.prop(linestyle, "use_same_object")
## Splitting
layout.label(text="Splitting:")
@@ -603,23 +601,33 @@ class RENDERLAYER_PT_freestyle_linestyle(RenderLayerFreestyleEditorButtonsPanel,
sub.active = linestyle.use_length_max
sub.prop(linestyle, "length_max")
+ ## Sorting
+ layout.prop(linestyle, "use_sorting", text="Sorting:")
+ col = layout.column()
+ col.active = linestyle.use_sorting
+ row = col.row(align=True)
+ row.prop(linestyle, "sort_key", text="")
+ sub = row.row()
+ sub.active = linestyle.sort_key in {'DISTANCE_FROM_CAMERA'}
+ sub.prop(linestyle, "integration_type", text="")
+ row = col.row(align=True)
+ row.prop(linestyle, "sort_order", expand=True)
+
## Caps
layout.label(text="Caps:")
row = layout.row(align=True)
row.prop(linestyle, "caps", expand=True)
## Dashed lines
- layout.label(text="Dashed Line:")
+ layout.prop(linestyle, "use_dashed_line", text="Dashed Line:")
row = layout.row(align=True)
- row.prop(linestyle, "use_dashed_line", text="")
- sub = row.row(align=True)
- sub.active = linestyle.use_dashed_line
- sub.prop(linestyle, "dash1", text="D1")
- sub.prop(linestyle, "gap1", text="G1")
- sub.prop(linestyle, "dash2", text="D2")
- sub.prop(linestyle, "gap2", text="G2")
- sub.prop(linestyle, "dash3", text="D3")
- sub.prop(linestyle, "gap3", text="G3")
+ row.active = linestyle.use_dashed_line
+ row.prop(linestyle, "dash1", text="D1")
+ row.prop(linestyle, "gap1", text="G1")
+ row.prop(linestyle, "dash2", text="D2")
+ row.prop(linestyle, "gap2", text="G2")
+ row.prop(linestyle, "dash3", text="D3")
+ row.prop(linestyle, "gap3", text="G3")
elif linestyle.panel == 'COLOR':
col = layout.column()
@@ -646,9 +654,11 @@ class RENDERLAYER_PT_freestyle_linestyle(RenderLayerFreestyleEditorButtonsPanel,
row = col.row()
row.label(text="Base Thickness:")
row.prop(linestyle, "thickness")
- row = col.row()
+ subcol = col.column()
+ subcol.active = linestyle.chaining == 'PLAIN' and linestyle.use_same_object
+ row = subcol.row()
row.prop(linestyle, "thickness_position", expand=True)
- row = col.row()
+ row = subcol.row()
row.prop(linestyle, "thickness_ratio")
row.active = (linestyle.thickness_position == 'RELATIVE')
col = layout.column()
@@ -664,6 +674,19 @@ class RENDERLAYER_PT_freestyle_linestyle(RenderLayerFreestyleEditorButtonsPanel,
for modifier in linestyle.geometry_modifiers:
self.draw_geometry_modifier(context, modifier)
+ elif linestyle.panel == 'TEXTURE':
+ layout.separator()
+
+ row = layout.row()
+ row.prop(linestyle, "use_texture")
+ row.prop(linestyle, "texture_spacing", text="Spacing Along Stroke")
+
+ row = layout.row()
+ op = row.operator("wm.properties_context_change",
+ text="Go to Linestyle Textures Properties",
+ icon='TEXTURE')
+ op.context = 'TEXTURE'
+
elif linestyle.panel == 'MISC':
pass
diff --git a/release/scripts/startup/bl_ui/properties_mask_common.py b/release/scripts/startup/bl_ui/properties_mask_common.py
index eef7b00f0be..9a2857cc7b8 100644
--- a/release/scripts/startup/bl_ui/properties_mask_common.py
+++ b/release/scripts/startup/bl_ui/properties_mask_common.py
@@ -377,7 +377,6 @@ class MASK_MT_select(Menu):
def draw(self, context):
layout = self.layout
- sc = context.space_data
layout.operator("mask.select_border")
layout.operator("mask.select_circle")
diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py
index 9e56c269b2b..e3fcb0ef53e 100644
--- a/release/scripts/startup/bl_ui/properties_material.py
+++ b/release/scripts/startup/bl_ui/properties_material.py
@@ -73,7 +73,7 @@ class MATERIAL_MT_specials(Menu):
class MATERIAL_UL_matslots(UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
# assert(isinstance(item, bpy.types.MaterialSlot)
- ob = data
+ # ob = data
slot = item
ma = slot.material
if self.layout_type in {'DEFAULT', 'COMPACT'}:
@@ -216,15 +216,18 @@ class MATERIAL_PT_pipeline(MaterialButtonsPanel, Panel):
sub.active = mat_type
sub.prop(mat, "use_sky")
sub.prop(mat, "invert_z")
+ col.prop(mat, "pass_index")
col = split.column()
col.active = mat_type
+ col.prop(mat, "use_cast_shadows", text="Cast")
col.prop(mat, "use_cast_shadows_only", text="Cast Only")
- col.prop(mat, "shadow_cast_alpha", text="Casting Alpha")
col.prop(mat, "use_cast_buffer_shadows")
+ sub = col.column()
+ sub.active = mat.use_cast_buffer_shadows
+ sub.prop(mat, "shadow_cast_alpha", text="Casting Alpha")
col.prop(mat, "use_cast_approximate")
- col.prop(mat, "pass_index")
class MATERIAL_PT_diffuse(MaterialButtonsPanel, Panel):
@@ -814,24 +817,30 @@ class MATERIAL_PT_shadow(MaterialButtonsPanel, Panel):
col = split.column()
col.prop(mat, "use_shadows", text="Receive")
col.prop(mat, "use_transparent_shadows", text="Receive Transparent")
- if simple_material(base_mat):
- col.prop(mat, "use_cast_shadows_only", text="Cast Only")
- col.prop(mat, "shadow_cast_alpha", text="Casting Alpha")
col.prop(mat, "use_only_shadow", text="Shadows Only")
sub = col.column()
sub.active = mat.use_only_shadow
sub.prop(mat, "shadow_only_type", text="")
- col = split.column()
+ if not simple_material(base_mat):
+ col = split.column()
+
+ col.prop(mat, "use_ray_shadow_bias", text="Auto Ray Bias")
+ sub = col.column()
+ sub.active = (not mat.use_ray_shadow_bias)
+ sub.prop(mat, "shadow_ray_bias", text="Ray Bias")
+
if simple_material(base_mat):
+ col = split.column()
+
+ col.prop(mat, "use_cast_shadows", text="Cast")
+ col.prop(mat, "use_cast_shadows_only", text="Cast Only")
col.prop(mat, "use_cast_buffer_shadows")
sub = col.column()
sub.active = mat.use_cast_buffer_shadows
+ if simple_material(base_mat):
+ sub.prop(mat, "shadow_cast_alpha", text="Casting Alpha")
sub.prop(mat, "shadow_buffer_bias", text="Buffer Bias")
- col.prop(mat, "use_ray_shadow_bias", text="Auto Ray Bias")
- sub = col.column()
- sub.active = (not mat.use_ray_shadow_bias)
- sub.prop(mat, "shadow_ray_bias", text="Ray Bias")
if simple_material(base_mat):
col.prop(mat, "use_cast_approximate")
diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py
index b0872f47ea6..3ff9ab9e12f 100644
--- a/release/scripts/startup/bl_ui/properties_object.py
+++ b/release/scripts/startup/bl_ui/properties_object.py
@@ -324,7 +324,7 @@ class OBJECT_PT_motion_paths(MotionPathButtonsPanel, Panel):
return (context.object)
def draw(self, context):
- layout = self.layout
+ # layout = self.layout
ob = context.object
avs = ob.animation_visualization
diff --git a/release/scripts/startup/bl_ui/properties_render_layer.py b/release/scripts/startup/bl_ui/properties_render_layer.py
index 488f0416880..2494e49d812 100644
--- a/release/scripts/startup/bl_ui/properties_render_layer.py
+++ b/release/scripts/startup/bl_ui/properties_render_layer.py
@@ -18,7 +18,7 @@
# <pep8 compliant>
import bpy
-from bpy.types import Menu, Panel, UIList
+from bpy.types import Panel, UIList
class RenderLayerButtonsPanel():
diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py
index 10574c88abb..049161fdce8 100644
--- a/release/scripts/startup/bl_ui/properties_scene.py
+++ b/release/scripts/startup/bl_ui/properties_scene.py
@@ -182,7 +182,6 @@ class SCENE_PT_color_management(SceneButtonsPanel, Panel):
layout = self.layout
scene = context.scene
- rd = scene.render
col = layout.column()
col.label(text="Display:")
diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py
index 009309479ec..9aa137ca9ea 100644
--- a/release/scripts/startup/bl_ui/properties_texture.py
+++ b/release/scripts/startup/bl_ui/properties_texture.py
@@ -25,6 +25,7 @@ from bpy.types import (Brush,
Material,
Object,
ParticleSettings,
+ FreestyleLineStyle,
Texture,
World)
@@ -94,6 +95,10 @@ def context_tex_datablock(context):
if idblock:
return idblock
+ idblock = context.line_style
+ if idblock:
+ return idblock
+
if context.particle_system:
idblock = context.particle_system.settings
@@ -134,6 +139,7 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel, Panel):
context.world or
context.lamp or
context.texture or
+ context.line_style or
context.particle_system or
isinstance(context.space_data.pin_id, ParticleSettings) or
context.texture_user) and
@@ -952,11 +958,28 @@ class TEXTURE_PT_mapping(TextureSlotPanel, Panel):
split.label(text="Object:")
split.prop(tex, "object", text="")
+ elif tex.texture_coords == 'ALONG_STROKE':
+ split = layout.split(percentage=0.3)
+ split.label(text="Use Tips:")
+ split.prop(tex, "use_tips", text="")
+
if isinstance(idblock, Brush):
if context.sculpt_object or context.image_paint_object:
brush_texture_settings(layout, idblock, context.sculpt_object)
else:
- if isinstance(idblock, Material):
+ if isinstance(idblock, FreestyleLineStyle):
+ split = layout.split(percentage=0.3)
+ split.label(text="Projection:")
+ split.prop(tex, "mapping", text="")
+
+ split = layout.split(percentage=0.3)
+ split.separator()
+ row = split.row()
+ row.prop(tex, "mapping_x", text="")
+ row.prop(tex, "mapping_y", text="")
+ row.prop(tex, "mapping_z", text="")
+
+ elif isinstance(idblock, Material):
split = layout.split(percentage=0.3)
split.label(text="Projection:")
split.prop(tex, "mapping", text="")
@@ -1129,6 +1152,15 @@ class TEXTURE_PT_influence(TextureSlotPanel, Panel):
factor_but(col, "use_map_kink", "kink_factor", "Kink")
factor_but(col, "use_map_rough", "rough_factor", "Rough")
+ elif isinstance(idblock, FreestyleLineStyle):
+ split = layout.split()
+
+ col = split.column()
+ factor_but(col, "use_map_color_diffuse", "diffuse_color_factor", "Color")
+ col = split.column()
+ factor_but(col, "use_map_alpha", "alpha_factor", "Alpha")
+
+
layout.separator()
if not isinstance(idblock, ParticleSettings):
diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py
index 76cb666c342..96ad70e0015 100644
--- a/release/scripts/startup/bl_ui/space_clip.py
+++ b/release/scripts/startup/bl_ui/space_clip.py
@@ -262,7 +262,6 @@ class CLIP_PT_tools_marker(CLIP_PT_tracking_panel, Panel):
sc = context.space_data
clip = sc.clip
- settings = clip.tracking.settings
col = layout.column(align=True)
row = col.row(align=True)
@@ -641,7 +640,6 @@ class CLIP_PT_plane_track(CLIP_PT_tracking_panel, Panel):
def draw(self, context):
layout = self.layout
- sc = context.space_data
clip = context.space_data.clip
active_track = clip.tracking.plane_tracks.active
@@ -769,11 +767,19 @@ class CLIP_PT_tracking_lens(Panel):
sub.prop(clip.tracking.camera, "focal_length_pixels")
sub.prop(clip.tracking.camera, "units", text="")
- col = layout.column(align=True)
+ col = layout.column()
col.label(text="Lens Distortion:")
- col.prop(clip.tracking.camera, "k1")
- col.prop(clip.tracking.camera, "k2")
- col.prop(clip.tracking.camera, "k3")
+ camera = clip.tracking.camera
+ col.prop(camera, "distortion_model", text="")
+ if camera.distortion_model == 'POLYNOMIAL':
+ col = layout.column(align=True)
+ col.prop(camera, "k1")
+ col.prop(camera, "k2")
+ col.prop(camera, "k3")
+ elif camera.distortion_model == 'DIVISION':
+ col = layout.column(align=True)
+ col.prop(camera, "division_k1")
+ col.prop(camera, "division_k2")
class CLIP_PT_display(CLIP_PT_clip_view_panel, Panel):
@@ -1078,7 +1084,6 @@ class CLIP_PT_footage_info(CLIP_PT_clip_view_panel, Panel):
layout = self.layout
sc = context.space_data
- clip = sc.clip
col = layout.column()
col.template_movieclip_information(sc, "clip", sc.clip_user)
@@ -1142,6 +1147,7 @@ class CLIP_MT_view(Menu):
layout.operator_context = 'INVOKE_DEFAULT'
layout.prop(sc, "show_seconds")
+ layout.prop(sc, "show_locked_time")
layout.separator()
layout.separator()
diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py
index 269c960ee7e..eeb08916416 100644
--- a/release/scripts/startup/bl_ui/space_dopesheet.py
+++ b/release/scripts/startup/bl_ui/space_dopesheet.py
@@ -173,6 +173,7 @@ class DOPESHEET_MT_view(Menu):
layout.prop(st, "use_marker_sync")
layout.prop(st, "show_seconds")
+ layout.prop(st, "show_locked_time")
layout.separator()
layout.operator("anim.previewrange_set")
diff --git a/release/scripts/startup/bl_ui/space_graph.py b/release/scripts/startup/bl_ui/space_graph.py
index 67fc2867536..353c689b484 100644
--- a/release/scripts/startup/bl_ui/space_graph.py
+++ b/release/scripts/startup/bl_ui/space_graph.py
@@ -105,6 +105,7 @@ class GRAPH_MT_view(Menu):
layout.prop(st, "use_only_selected_keyframe_handles")
layout.prop(st, "show_seconds")
+ layout.prop(st, "show_locked_time")
layout.separator()
layout.operator("anim.previewrange_set")
diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py
index 9bf6aaa1703..f19e77eff8e 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -458,7 +458,6 @@ class MASK_MT_editor_menus(Menu):
sima = context.space_data
ima = sima.image
- show_render = sima.show_render
show_uvedit = sima.show_uvedit
show_maskedit = sima.show_maskedit
@@ -759,7 +758,6 @@ class IMAGE_PT_tools_brush_texture(BrushButtonsPanel, Panel):
toolsettings = context.tool_settings.image_paint
brush = toolsettings.brush
- tex_slot = brush.texture_slot
col = layout.column()
col.template_ID_preview(brush, "texture", new="texture.new", rows=3, cols=8)
@@ -775,7 +773,6 @@ class IMAGE_PT_tools_mask_texture(BrushButtonsPanel, Panel):
layout = self.layout
brush = context.tool_settings.image_paint.brush
- tex_slot_alpha = brush.mask_texture_slot
col = layout.column()
diff --git a/release/scripts/startup/bl_ui/space_nla.py b/release/scripts/startup/bl_ui/space_nla.py
index e41086f6da1..baadc69d9f6 100644
--- a/release/scripts/startup/bl_ui/space_nla.py
+++ b/release/scripts/startup/bl_ui/space_nla.py
@@ -74,12 +74,14 @@ class NLA_MT_view(Menu):
layout.prop(st, "show_frame_indicator")
layout.prop(st, "show_seconds")
+ layout.prop(st, "show_locked_time")
layout.prop(st, "show_strip_curves")
layout.separator()
layout.operator("anim.previewrange_set")
layout.operator("anim.previewrange_clear")
+ layout.operator("nla.previewrange_set")
layout.separator()
layout.operator("nla.view_all")
@@ -132,7 +134,8 @@ class NLA_MT_edit(Menu):
layout.operator_menu_enum("nla.snap", "type", text="Snap")
layout.separator()
- layout.operator("nla.duplicate")
+ layout.operator("nla.duplicate", text="Duplicate")
+ layout.operator("nla.duplicate", text="Linked Duplicate").linked = True
layout.operator("nla.split")
layout.operator("nla.delete")
@@ -145,6 +148,9 @@ class NLA_MT_edit(Menu):
layout.operator("nla.action_sync_length").active = False
layout.separator()
+ layout.operator("nla.make_single_user")
+
+ layout.separator()
layout.operator("nla.swap")
layout.operator("nla.move_up")
layout.operator("nla.move_down")
diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py
index 830bdf92ecc..959043f7931 100644
--- a/release/scripts/startup/bl_ui/space_node.py
+++ b/release/scripts/startup/bl_ui/space_node.py
@@ -164,7 +164,7 @@ class NODE_MT_view(Menu):
layout.operator("node.backimage_move", text="Backdrop move")
layout.operator("node.backimage_zoom", text="Backdrop zoom in").factor = 1.2
- layout.operator("node.backimage_zoom", text="Backdrop zoom out").factor = 0.833
+ layout.operator("node.backimage_zoom", text="Backdrop zoom out").factor = 0.83333
layout.operator("node.backimage_fit", text="Fit backdrop to available space")
layout.separator()
@@ -274,7 +274,6 @@ class NODE_PT_active_node_generic(Panel):
@classmethod
def poll(cls, context):
- space = context.space_data
return context.active_node is not None
def draw(self, context):
@@ -293,7 +292,6 @@ class NODE_PT_active_node_color(Panel):
@classmethod
def poll(cls, context):
- space = context.space_data
return context.active_node is not None
def draw_header(self, context):
@@ -323,7 +321,6 @@ class NODE_PT_active_node_properties(Panel):
@classmethod
def poll(cls, context):
- space = context.space_data
return context.active_node is not None
def draw(self, context):
diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py
index 823aa2acf89..b77078bf5d4 100644
--- a/release/scripts/startup/bl_ui/space_sequencer.py
+++ b/release/scripts/startup/bl_ui/space_sequencer.py
@@ -160,7 +160,16 @@ class SEQUENCER_MT_view(Menu):
if st.view_type in {'PREVIEW', 'SEQUENCER_PREVIEW'}:
layout.operator_context = 'INVOKE_REGION_PREVIEW'
layout.operator("sequencer.view_all_preview", text="Fit preview in window")
- layout.operator("sequencer.view_zoom_ratio", text="Show preview 1:1").ratio = 1.0
+
+ layout.separator()
+
+ ratios = ((1, 8), (1, 4), (1, 2), (1, 1), (2, 1), (4, 1), (8, 1))
+
+ for a, b in ratios:
+ layout.operator("sequencer.view_zoom_ratio", text=iface_("Zoom %d:%d") % (a, b), translate=False).ratio = a / b
+
+ layout.separator()
+
layout.operator_context = 'INVOKE_DEFAULT'
# # XXX, invokes in the header view
@@ -486,7 +495,6 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
- sequencer = context.scene.sequence_editor
strip = act_strip(context)
if strip.input_count > 0:
diff --git a/release/scripts/startup/bl_ui/space_time.py b/release/scripts/startup/bl_ui/space_time.py
index c0d55536991..c96b8fd568e 100644
--- a/release/scripts/startup/bl_ui/space_time.py
+++ b/release/scripts/startup/bl_ui/space_time.py
@@ -122,15 +122,17 @@ class TIME_MT_view(Menu):
def draw(self, context):
layout = self.layout
+ scene = context.scene
st = context.space_data
layout.prop(st, "show_seconds")
+ layout.prop(st, "show_locked_time")
layout.operator("time.view_all")
layout.separator()
layout.prop(st, "show_frame_indicator")
- layout.prop(st, "show_only_selected")
+ layout.prop(scene, "show_keys_from_selected_only")
layout.separator()
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index d43e6d1f697..a7856b340e5 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -30,8 +30,7 @@ class VIEW3D_HT_header(Header):
layout = self.layout
view = context.space_data
- mode_string = context.mode
- edit_object = context.edit_object
+ # mode_string = context.mode
obj = context.active_object
toolsettings = context.tool_settings
@@ -127,7 +126,7 @@ class VIEW3D_MT_editor_menus(Menu):
layout.menu("VIEW3D_MT_select_paint_mask")
elif mesh.use_paint_mask_vertex and mode_string == 'PAINT_WEIGHT':
layout.menu("VIEW3D_MT_select_paint_mask_vertex")
- elif mode_string not in {'EDIT_TEXT', 'SCULPT'}:
+ elif mode_string != 'SCULPT':
layout.menu("VIEW3D_MT_select_%s" % mode_string.lower())
if mode_string == 'OBJECT':
@@ -1787,7 +1786,7 @@ class VIEW3D_MT_pose(Menu):
layout.separator()
layout.operator_context = 'INVOKE_AREA'
- layout.operator("pose.armature_layers", text="Change Armature Layers...")
+ layout.operator("armature.armature_layers", text="Change Armature Layers...")
layout.operator("pose.bone_layers", text="Change Bone Layers...")
layout.separator()
@@ -2168,6 +2167,13 @@ class VIEW3D_MT_edit_mesh_vertices(Menu):
layout.separator()
+ op = layout.operator("mesh.mark_sharp", text="Shade Smooth")
+ op.use_verts = True
+ op.clear = True
+ layout.operator("mesh.mark_sharp", text="Shade Sharp").use_verts = True
+
+ layout.separator()
+
layout.operator("mesh.bevel").vertex_only = True
layout.operator("mesh.convex_hull")
layout.operator("mesh.vertices_smooth")
@@ -2211,7 +2217,7 @@ class VIEW3D_MT_edit_mesh_edges(Menu):
layout.separator()
- layout.operator("mesh.mark_sharp").clear = False
+ layout.operator("mesh.mark_sharp")
layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
layout.separator()
@@ -2777,8 +2783,6 @@ class VIEW3D_PT_view3d_display(Panel):
view = context.space_data
scene = context.scene
- gs = scene.game_settings
- obj = context.object
col = layout.column()
col.prop(view, "show_only_render")
@@ -2936,14 +2940,14 @@ class VIEW3D_PT_view3d_meshdisplay(Panel):
col.separator()
col.label(text="Normals:")
- row = col.row()
+ row = col.row(align=True)
- sub = row.row(align=True)
- sub.prop(mesh, "show_normal_vertex", text="", icon='VERTEXSEL')
- sub.prop(mesh, "show_normal_face", text="", icon='FACESEL')
+ row.prop(mesh, "show_normal_vertex", text="", icon='VERTEXSEL')
+ row.prop(mesh, "show_normal_loop", text="", icon='VERTEXSEL')
+ row.prop(mesh, "show_normal_face", text="", icon='FACESEL')
sub = row.row(align=True)
- sub.active = mesh.show_normal_vertex or mesh.show_normal_face
+ sub.active = mesh.show_normal_vertex or mesh.show_normal_face or mesh.show_normal_loop
sub.prop(context.scene.tool_settings, "normal_size", text="Size")
col.separator()
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 4e9dc1163e2..0797592b4eb 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -385,10 +385,20 @@ class VIEW3D_PT_tools_shading(View3DPanel, Panel):
layout = self.layout
col = layout.column(align=True)
- col.label(text="Shading:")
+ col.label(text="Faces:")
row = col.row(align=True)
row.operator("mesh.faces_shade_smooth", text="Smooth")
row.operator("mesh.faces_shade_flat", text="Flat")
+ col.label(text="Edges:")
+ row = col.row(align=True)
+ row.operator("mesh.mark_sharp", text="Smooth").clear = True
+ row.operator("mesh.mark_sharp", text="Sharp")
+ col.label(text="Vertices:")
+ row = col.row(align=True)
+ op = row.operator("mesh.mark_sharp", text="Smooth")
+ op.use_verts = True
+ op.clear = True
+ row.operator("mesh.mark_sharp", text="Sharp").use_verts = True
col = layout.column(align=True)
col.label(text="Normals:")
@@ -603,19 +613,28 @@ class VIEW3D_PT_tools_textedit(View3DPanel, Panel):
# ********** default tools for editmode_armature ****************
-class VIEW3D_PT_tools_armatureedit(View3DPanel, Panel):
+class VIEW3D_PT_tools_armatureedit_transform(View3DPanel, Panel):
+ bl_category = "Tools"
bl_context = "armature_edit"
- bl_label = "Armature Tools"
+ bl_label = "Transform"
def draw(self, context):
layout = self.layout
col = layout.column(align=True)
- col.label(text="Transform:")
col.operator("transform.translate")
col.operator("transform.rotate")
col.operator("transform.resize", text="Scale")
+
+class VIEW3D_PT_tools_armatureedit(View3DPanel, Panel):
+ bl_category = "Tools"
+ bl_context = "armature_edit"
+ bl_label = "Armature Tools"
+
+ def draw(self, context):
+ layout = self.layout
+
col = layout.column(align=True)
col.label(text="Bones:")
col.operator("armature.bone_primitive_add", text="Add")
@@ -635,6 +654,7 @@ class VIEW3D_PT_tools_armatureedit(View3DPanel, Panel):
class VIEW3D_PT_tools_armatureedit_options(View3DPanel, Panel):
+ bl_category = "Options"
bl_context = "armature_edit"
bl_label = "Armature Options"
@@ -643,6 +663,7 @@ class VIEW3D_PT_tools_armatureedit_options(View3DPanel, Panel):
self.layout.prop(arm, "use_mirror_x")
+
# ********** default tools for editmode_mball ****************
@@ -1079,7 +1100,6 @@ class VIEW3D_PT_tools_brush_texture(Panel, View3DPaintPanel):
settings = self.paint_settings(context)
brush = settings.brush
- tex_slot = brush.texture_slot
col = layout.column()
@@ -1103,7 +1123,6 @@ class VIEW3D_PT_tools_mask_texture(View3DPanel, Panel):
layout = self.layout
brush = context.tool_settings.image_paint.brush
- tex_slot_alpha = brush.mask_texture_slot
col = layout.column()
@@ -1296,14 +1315,6 @@ class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel):
col.prop(sculpt, "gravity_object")
col.separator()
- col = layout.column(align=True)
- col.label(text="Threads:")
- col.row(align=True).prop(scene, "omp_threads_mode", expand=True)
- sub = col.column(align=True)
- sub.enabled = (scene.omp_threads_mode != 'AUTO')
- sub.prop(scene, "omp_threads")
- col.separator()
-
layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
layout.prop(sculpt, "show_low_resolution")
layout.prop(sculpt, "use_deform_only")
diff --git a/release/scripts/templates_py/custom_nodes.py b/release/scripts/templates_py/custom_nodes.py
index bf89c0debad..992ef734859 100644
--- a/release/scripts/templates_py/custom_nodes.py
+++ b/release/scripts/templates_py/custom_nodes.py
@@ -49,13 +49,15 @@ class MyCustomSocket(NodeSocket):
def draw_color(self, context, node):
return (1.0, 0.4, 0.216, 0.5)
+
# Mix-in class for all custom nodes in this tree type.
# Defines a poll function to enable instantiation.
-class MyCustomTreeNode :
+class MyCustomTreeNode:
@classmethod
def poll(cls, ntree):
return ntree.bl_idname == 'CustomTreeType'
+
# Derived from the Node base type.
class MyCustomNode(Node, MyCustomTreeNode):
# === Basics ===
@@ -123,6 +125,7 @@ class MyCustomNode(Node, MyCustomTreeNode):
import nodeitems_utils
from nodeitems_utils import NodeCategory, NodeItem
+
# our own base class with an appropriate poll function,
# so the categories only show up in our own tree type
class MyNodeCategory(NodeCategory):
@@ -143,12 +146,12 @@ node_categories = [
# NB: settings values are stored as string expressions,
# for this reason they should be converted to strings using repr()
NodeItem("CustomNodeType", label="Node A", settings={
- "myStringProperty" : repr("Lorem ipsum dolor sit amet"),
- "myFloatProperty" : repr(1.0),
+ "myStringProperty": repr("Lorem ipsum dolor sit amet"),
+ "myFloatProperty": repr(1.0),
}),
NodeItem("CustomNodeType", label="Node B", settings={
- "myStringProperty" : repr("consectetur adipisicing elit"),
- "myFloatProperty" : repr(2.0),
+ "myStringProperty": repr("consectetur adipisicing elit"),
+ "myFloatProperty": repr(2.0),
}),
]),
]
diff --git a/release/scripts/templates_py/operator_modal_view3d_raycast.py b/release/scripts/templates_py/operator_modal_view3d_raycast.py
index eac76922187..4d0355047f4 100644
--- a/release/scripts/templates_py/operator_modal_view3d_raycast.py
+++ b/release/scripts/templates_py/operator_modal_view3d_raycast.py
@@ -16,7 +16,6 @@ def main(context, event, ray_max=10000.0):
ray_origin = view3d_utils.region_2d_to_origin_3d(region, rv3d, coord)
ray_target = ray_origin + (view_vector * ray_max)
-
def visible_objects_and_duplis():
"""Loop over (object, matrix) pairs (mesh only)"""
diff --git a/release/scripts/templates_py/ui_panel.py b/release/scripts/templates_py/ui_panel.py
index cacdb83e815..855d05700c5 100644
--- a/release/scripts/templates_py/ui_panel.py
+++ b/release/scripts/templates_py/ui_panel.py
@@ -42,22 +42,22 @@ class LayoutDemoPanel(bpy.types.Panel):
col.label(text="Column Two:")
col.prop(scene, "frame_start")
col.prop(scene, "frame_end")
-
+
# Big render button
layout.label(text="Big Button:")
row = layout.row()
row.scale_y = 3.0
row.operator("render.render")
-
+
# Different sizes in a row
layout.label(text="Different button sizes:")
row = layout.row(align=True)
row.operator("render.render")
-
+
sub = row.row()
sub.scale_x = 2.0
sub.operator("render.render")
-
+
row.operator("render.render")
diff --git a/scons b/scons
-Subproject 59512aadd1d16d7b9327f0eefafb23513b4f213
+Subproject 2d6ebcb23909058b846aa232ecb2fee497924cf
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index 324d20b2703..2bdae87dc83 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -54,7 +54,6 @@
#include "BLI_string_utf8.h"
#include "BLI_threads.h"
#include "BLI_alloca.h"
-#include "BLI_linklist.h" /* linknode */
#include "BIF_gl.h"
#include "BLF_api.h"
@@ -150,10 +149,10 @@ static void blf_font_ensure_ascii_table(FontBLF *font)
#define BLF_KERNING_VARS(_font, _has_kerning, _kern_mode) \
- const short _has_kerning = FT_HAS_KERNING((_font)->face); \
+ const bool _has_kerning = FT_HAS_KERNING((_font)->face); \
const FT_UInt _kern_mode = (_has_kerning == 0) ? 0 : \
(((_font)->flags & BLF_KERNING_DEFAULT) ? \
- ft_kerning_default : FT_KERNING_UNFITTED) \
+ ft_kerning_default : (FT_UInt)FT_KERNING_UNFITTED) \
#define BLF_KERNING_STEP(_font, _kern_mode, _g_prev, _g, _delta, _pen_x) \
diff --git a/source/blender/blenfont/intern/blf_lang.c b/source/blender/blenfont/intern/blf_lang.c
index 623d8b7652a..2852b8161c8 100644
--- a/source/blender/blenfont/intern/blf_lang.c
+++ b/source/blender/blenfont/intern/blf_lang.c
@@ -42,7 +42,6 @@
#include "BLI_path_util.h"
#include "BLI_string.h"
-#include "BKE_global.h"
#include "DNA_userdef_types.h"
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index ff1c04fd00d..1ab5ec51de8 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -156,7 +156,7 @@ typedef enum DMDrawFlag {
typedef enum DMForeachFlag {
DM_FOREACH_NOP = 0,
- DM_FOREACH_USE_NORMAL = (1 << 0), /* foreachMappedVert, foreachMappedFaceCenter */
+ DM_FOREACH_USE_NORMAL = (1 << 0), /* foreachMappedVert, foreachMappedLoop, foreachMappedFaceCenter */
} DMForeachFlag;
typedef enum DMDirtyFlag {
@@ -184,6 +184,8 @@ struct DerivedMesh {
DerivedMeshType type;
float auto_bump_scale;
DMDirtyFlag dirty;
+ int totmat; /* total materials. Will be valid only before object drawing. */
+ struct Material **mat; /* material array. Will be valid only before object drawing */
/* use for converting to BMesh which doesn't store bevel weight and edge crease by default */
char cd_flag;
@@ -191,6 +193,9 @@ struct DerivedMesh {
/** Calculate vert and face normals */
void (*calcNormals)(DerivedMesh *dm);
+ /** Calculate loop (split) normals */
+ void (*calcLoopNormals)(DerivedMesh *dm, const float split_angle);
+
/** Recalculates mesh tessellation */
void (*recalcTessellation)(DerivedMesh *dm);
@@ -304,6 +309,15 @@ struct DerivedMesh {
const float v0co[3], const float v1co[3]),
void *userData);
+ /** Iterate over each mapped loop in the derived mesh, calling the given function
+ * with the original loop index and the mapped loops's new coordinate and normal.
+ */
+ void (*foreachMappedLoop)(DerivedMesh *dm,
+ void (*func)(void *userData, int vertex_index, int face_index,
+ const float co[3], const float no[3]),
+ void *userData,
+ DMForeachFlag flag);
+
/** Iterate over each mapped face in the derived mesh, calling the
* given function with the original face and the mapped face's (or
* faces') center and normal.
@@ -354,7 +368,7 @@ struct DerivedMesh {
*
* Also called for *final* editmode DerivedMeshes
*/
- void (*drawEdges)(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges);
+ void (*drawEdges)(DerivedMesh *dm, bool drawLooseEdges, bool drawAllEdges);
/** Draw all loose edges (edges w/ no adjoining faces) */
void (*drawLooseEdges)(DerivedMesh *dm);
@@ -367,7 +381,7 @@ struct DerivedMesh {
* Also called for *final* editmode DerivedMeshes
*/
void (*drawFacesSolid)(DerivedMesh *dm, float (*partial_redraw_planes)[4],
- int fast, DMSetMaterial setMaterial);
+ bool fast, DMSetMaterial setMaterial);
/** Draw all faces using MTFace
* - Drawing options too complicated to enumerate, look at code.
@@ -446,7 +460,7 @@ struct DerivedMesh {
* - setFace is called to verify if a face must be hidden
*/
void (*drawMappedFacesMat)(DerivedMesh *dm,
- void (*setMaterial)(void *userData, int, void *attribs),
+ void (*setMaterial)(void *userData, int matnr, void *attribs),
bool (*setFace)(void *userData, int index), void *userData);
/** Release reference to the DerivedMesh. This function decides internally
@@ -578,6 +592,7 @@ void DM_ensure_tessface(DerivedMesh *dm);
void DM_update_tessface_data(DerivedMesh *dm);
+void DM_update_materials(DerivedMesh *dm, struct Object *ob);
/** interpolates vertex data from the vertices indexed by src_indices in the
* source mesh using the given weights and stores the result in the vertex
* indexed by dest_index in the dest mesh
@@ -747,4 +762,10 @@ BLI_INLINE int DM_origindex_mface_mpoly(const int *index_mf_to_mpoly, const int
return (j != ORIGINDEX_NONE) ? (index_mp_to_orig ? index_mp_to_orig[j] : j) : ORIGINDEX_NONE;
}
+struct MVert *DM_get_vert_array(struct DerivedMesh *dm, bool *allocated);
+struct MEdge *DM_get_edge_array(struct DerivedMesh *dm, bool *allocated);
+struct MLoop *DM_get_loop_array(struct DerivedMesh *dm, bool *allocated);
+struct MPoly *DM_get_poly_array(struct DerivedMesh *dm, bool *allocated);
+struct MFace *DM_get_tessface_array(struct DerivedMesh *dm, bool *allocated);
+
#endif /* __BKE_DERIVEDMESH_H__ */
diff --git a/source/blender/blenkernel/BKE_anim.h b/source/blender/blenkernel/BKE_anim.h
index e87fef1c864..e49fe98aa14 100644
--- a/source/blender/blenkernel/BKE_anim.h
+++ b/source/blender/blenkernel/BKE_anim.h
@@ -71,5 +71,17 @@ struct ListBase *object_duplilist(struct EvaluationContext *eval_ctx, struct Sce
void free_object_duplilist(struct ListBase *lb);
int count_duplilist(struct Object *ob);
-#endif
+typedef struct DupliExtraData {
+ float obmat[4][4];
+} DupliExtraData;
+
+typedef struct DupliApplyData {
+ int num_objects;
+ DupliExtraData *extra;
+} DupliApplyData;
+DupliApplyData *duplilist_apply_matrix(struct ListBase *duplilist);
+void duplilist_restore_matrix(struct ListBase *duplilist, DupliApplyData *apply_data);
+void duplilist_free_apply_data(DupliApplyData *apply_data);
+
+#endif
diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h
index a0ec6c7757f..80d2750fe82 100644
--- a/source/blender/blenkernel/BKE_animsys.h
+++ b/source/blender/blenkernel/BKE_animsys.h
@@ -48,7 +48,7 @@ struct AnimMapper;
/* AnimData API */
/* Check if the given ID-block can have AnimData */
-short id_type_can_have_animdata(struct ID *id);
+bool id_type_can_have_animdata(struct ID *id);
/* Get AnimData from the given ID-block */
struct AnimData *BKE_animdata_from_id(struct ID *id);
@@ -57,7 +57,7 @@ struct AnimData *BKE_animdata_from_id(struct ID *id);
struct AnimData *BKE_id_add_animdata(struct ID *id);
/* Set active action used by AnimData from the given ID-block */
-short BKE_animdata_set_action(struct ReportList *reports, struct ID *id, struct bAction *act);
+bool BKE_animdata_set_action(struct ReportList *reports, struct ID *id, struct bAction *act);
/* Free AnimData */
void BKE_free_animdata(struct ID *id);
@@ -66,7 +66,7 @@ void BKE_free_animdata(struct ID *id);
struct AnimData *BKE_copy_animdata(struct AnimData *adt, const bool do_action);
/* Copy AnimData */
-int BKE_copy_animdata_id(struct ID *id_to, struct ID *id_from, const bool do_action);
+bool BKE_copy_animdata_id(struct ID *id_to, struct ID *id_from, const bool do_action);
/* Copy AnimData Actions */
void BKE_copy_animdata_id_action(struct ID *id);
@@ -106,12 +106,12 @@ void BKE_keyingsets_free(struct ListBase *list);
/* Fix all the paths for the the given ID + Action */
void BKE_action_fix_paths_rename(struct ID *owner_id, struct bAction *act, const char *prefix, const char *oldName,
- const char *newName, int oldSubscript, int newSubscript, int verify_paths);
+ const char *newName, int oldSubscript, int newSubscript, bool verify_paths);
/* Fix all the paths for the given ID+AnimData */
void BKE_animdata_fix_paths_rename(struct ID *owner_id, struct AnimData *adt, struct ID *ref_id, const char *prefix,
const char *oldName, const char *newName, int oldSubscript, int newSubscript,
- int verify_paths);
+ bool verify_paths);
/* Fix all the paths for the entire database... */
void BKE_all_animdata_fix_paths_rename(ID *ref_id, const char *prefix, const char *oldName, const char *newName);
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index 415a912d666..e4ebe0e0ed5 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -42,10 +42,10 @@ extern "C" {
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 270
-#define BLENDER_SUBVERSION 0
+#define BLENDER_SUBVERSION 5
/* 262 was the last editmesh release but it has compatibility code for bmesh data */
-#define BLENDER_MINVERSION 262
-#define BLENDER_MINSUBVERSION 0
+#define BLENDER_MINVERSION 270
+#define BLENDER_MINSUBVERSION 5
/* used by packaging tools */
/* can be left blank, otherwise a,b,c... etc with no quotes */
@@ -99,7 +99,7 @@ extern int BKE_undo_valid(const char *name);
extern void BKE_reset_undo(void);
extern void BKE_undo_number(struct bContext *C, int nr);
extern const char *BKE_undo_get_name(int nr, int *active);
-extern int BKE_undo_save_file(const char *filename);
+extern bool BKE_undo_save_file(const char *filename);
extern struct Main *BKE_undo_get_main(struct Scene **scene);
/* copybuffer */
diff --git a/source/blender/blenkernel/BKE_cdderivedmesh.h b/source/blender/blenkernel/BKE_cdderivedmesh.h
index 4e6d69503c0..dffc2b665c2 100644
--- a/source/blender/blenkernel/BKE_cdderivedmesh.h
+++ b/source/blender/blenkernel/BKE_cdderivedmesh.h
@@ -100,6 +100,8 @@ void CDDM_calc_normals_mapping(struct DerivedMesh *dm);
void CDDM_calc_normals(struct DerivedMesh *dm);
void CDDM_calc_normals_tessface(struct DerivedMesh *dm);
+void CDDM_calc_loop_normals(struct DerivedMesh *dm, const float split_angle);
+
/* calculates edges for a CDDerivedMesh (from face data)
* this completely replaces the current edge data in the DerivedMesh
* builds edges from the tessellated face data.
diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h
index 8a9d3589a4f..87da74dc119 100644
--- a/source/blender/blenkernel/BKE_constraint.h
+++ b/source/blender/blenkernel/BKE_constraint.h
@@ -62,7 +62,7 @@ typedef struct bConstraintOb {
/* ---------------------------------------------------------------------------- */
/* Callback format for performing operations on ID-pointers for Constraints */
-typedef void (*ConstraintIDFunc)(struct bConstraint *con, struct ID **idpoin, short isReference, void *userdata);
+typedef void (*ConstraintIDFunc)(struct bConstraint *con, struct ID **idpoin, bool is_reference, void *userdata);
/* ....... */
@@ -98,7 +98,7 @@ typedef struct bConstraintTypeInfo {
/* for multi-target constraints: return that list; otherwise make a temporary list (returns number of targets) */
int (*get_constraint_targets)(struct bConstraint *con, struct ListBase *list);
/* for single-target constraints only: flush data back to source data, and the free memory used */
- void (*flush_constraint_targets)(struct bConstraint *con, struct ListBase *list, short nocopy);
+ void (*flush_constraint_targets)(struct bConstraint *con, struct ListBase *list, bool no_copy);
/* evaluation */
/* set the ct->matrix for the given constraint target (at the given ctime) */
@@ -108,50 +108,44 @@ typedef struct bConstraintTypeInfo {
} bConstraintTypeInfo;
/* Function Prototypes for bConstraintTypeInfo's */
-bConstraintTypeInfo *BKE_constraint_get_typeinfo(struct bConstraint *con);
-bConstraintTypeInfo *BKE_get_constraint_typeinfo(int type);
+bConstraintTypeInfo *BKE_constraint_typeinfo_get(struct bConstraint *con);
+bConstraintTypeInfo *BKE_constraint_typeinfo_from_type(int type);
-/* ---------------------------------------------------------------------------- */
-/* Useful macros for testing various common flag combinations */
-
-/* Constraint Target Macros */
-#define VALID_CONS_TARGET(ct) ((ct) && (ct->tar))
/* ---------------------------------------------------------------------------- */
/* Constraint function prototypes */
-void BKE_unique_constraint_name(struct bConstraint *con, struct ListBase *list);
+void BKE_constraint_unique_name(struct bConstraint *con, struct ListBase *list);
-void BKE_free_constraints(struct ListBase *list);
-void BKE_copy_constraints(struct ListBase *dst, const struct ListBase *src, bool do_extern);
-void BKE_relink_constraints(struct ListBase *list);
-void BKE_id_loop_constraints(struct ListBase *list, ConstraintIDFunc func, void *userdata);
-void BKE_free_constraint_data(struct bConstraint *con);
+void BKE_constraints_free(struct ListBase *list);
+void BKE_constraints_copy(struct ListBase *dst, const struct ListBase *src, bool do_extern);
+void BKE_constraints_relink(struct ListBase *list);
+void BKE_constraints_id_loop(struct ListBase *list, ConstraintIDFunc func, void *userdata);
+void BKE_constraint_free_data(struct bConstraint *con);
/* Constraint API function prototypes */
-struct bConstraint *BKE_constraints_get_active(struct ListBase *list);
-void BKE_constraints_set_active(ListBase *list, struct bConstraint *con);
-struct bConstraint *BKE_constraints_findByName(struct ListBase *list, const char *name);
+struct bConstraint *BKE_constraints_active_get(struct ListBase *list);
+void BKE_constraints_active_set(ListBase *list, struct bConstraint *con);
+struct bConstraint *BKE_constraints_find_name(struct ListBase *list, const char *name);
-struct bConstraint *BKE_add_ob_constraint(struct Object *ob, const char *name, short type);
-struct bConstraint *BKE_add_pose_constraint(struct Object *ob, struct bPoseChannel *pchan, const char *name, short type);
+struct bConstraint *BKE_constraint_add_for_object(struct Object *ob, const char *name, short type);
+struct bConstraint *BKE_constraint_add_for_pose(struct Object *ob, struct bPoseChannel *pchan, const char *name, short type);
-int BKE_remove_constraint(ListBase *list, struct bConstraint *con);
-void BKE_remove_constraints_type(ListBase *list, short type, short last_only);
+bool BKE_constraint_remove(ListBase *list, struct bConstraint *con);
/* Constraints + Proxies function prototypes */
-void BKE_extract_proxylocal_constraints(struct ListBase *dst, struct ListBase *src);
-short BKE_proxylocked_constraints_owner(struct Object *ob, struct bPoseChannel *pchan);
+void BKE_constraints_proxylocal_extract(struct ListBase *dst, struct ListBase *src);
+bool BKE_constraints_proxylocked_owner(struct Object *ob, struct bPoseChannel *pchan);
/* Constraint Evaluation function prototypes */
struct bConstraintOb *BKE_constraints_make_evalob(struct Scene *scene, struct Object *ob, void *subdata, short datatype);
-void BKE_constraints_clear_evalob(struct bConstraintOb *cob);
+void BKE_constraints_clear_evalob(struct bConstraintOb *cob);
void BKE_constraint_mat_convertspace(struct Object *ob, struct bPoseChannel *pchan, float mat[4][4], short from, short to);
-void BKE_get_constraint_target_matrix(struct Scene *scene, struct bConstraint *con, int n, short ownertype, void *ownerdata, float mat[4][4], float ctime);
-void BKE_get_constraint_targets_for_solving(struct bConstraint *con, struct bConstraintOb *ob, struct ListBase *targets, float ctime);
-void BKE_solve_constraints(struct ListBase *conlist, struct bConstraintOb *cob, float ctime);
+void BKE_constraint_target_matrix_get(struct Scene *scene, struct bConstraint *con, int n, short ownertype, void *ownerdata, float mat[4][4], float ctime);
+void BKE_constraint_targets_for_solving_get(struct bConstraint *con, struct bConstraintOb *ob, struct ListBase *targets, float ctime);
+void BKE_constraints_solve(struct ListBase *conlist, struct bConstraintOb *cob, float ctime);
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h
index 877e376b343..e30c8ecee2b 100644
--- a/source/blender/blenkernel/BKE_context.h
+++ b/source/blender/blenkernel/BKE_context.h
@@ -234,6 +234,7 @@ int ctx_data_list_count(const bContext *C, int (*func)(const bContext *, ListBas
struct Main *CTX_data_main(const bContext *C);
struct Scene *CTX_data_scene(const bContext *C);
struct ToolSettings *CTX_data_tool_settings(const bContext *C);
+struct FreestyleLineStyle *CTX_data_linestyle_from_scene(struct Scene *scene);
const char *CTX_data_mode_string(const bContext *C);
int CTX_data_mode_enum(const bContext *C);
diff --git a/source/blender/blenkernel/BKE_crazyspace.h b/source/blender/blenkernel/BKE_crazyspace.h
new file mode 100644
index 00000000000..feed1594d90
--- /dev/null
+++ b/source/blender/blenkernel/BKE_crazyspace.h
@@ -0,0 +1,54 @@
+/*
+ * ***** 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) 2008 Blender Foundation.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file BKE_crazyspace.h
+ * \ingroup bke
+ */
+
+#ifndef __BKE_CRAZYSPACE_H__
+#define __BKE_CRAZYSPACE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+struct Scene;
+struct Object;
+struct BMEditMesh;
+struct Mesh;
+
+/* crazyspace.c */
+float (*BKE_crazyspace_get_mapped_editverts(struct Scene *scene, struct Object *obedit))[3];
+void BKE_crazyspace_set_quats_editmesh(struct BMEditMesh *em, float (*origcos)[3], float (*mappedcos)[3], float (*quats)[4],
+ const bool use_select);
+void BKE_crazyspace_set_quats_mesh(struct Mesh *me, float (*origcos)[3], float (*mappedcos)[3], float (*quats)[4]);
+int BKE_sculpt_get_first_deform_matrices(struct Scene *scene, struct Object *ob, float (**deformmats)[3][3], float (**deformcos)[3]);
+void BKE_crazyspace_build_sculpt(struct Scene *scene, struct Object *ob, float (**deformmats)[3][3], float (**deformcos)[3]);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h
index c4dfd9d4e30..0f9f8cb2f08 100644
--- a/source/blender/blenkernel/BKE_curve.h
+++ b/source/blender/blenkernel/BKE_curve.h
@@ -149,6 +149,7 @@ void BKE_nurb_knot_calc_v(struct Nurb *nu);
/* nurb checks if they can be drawn, also clamp order func */
bool BKE_nurb_check_valid_u(struct Nurb *nu);
bool BKE_nurb_check_valid_v(struct Nurb *nu);
+bool BKE_nurb_check_valid_uv(struct Nurb *nu);
bool BKE_nurb_order_clamp_u(struct Nurb *nu);
bool BKE_nurb_order_clamp_v(struct Nurb *nu);
diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h
index 046bb8e0e8d..0e86be9b97c 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -197,7 +197,10 @@ int BKE_fcm_envelope_find_index(struct FCM_EnvelopeData *array, float frame, int
/* ************** F-Curves API ******************** */
-/* -------- Data Managemnt -------- */
+/* threshold for binary-searching keyframes - threshold here should be good enough for now, but should become userpref */
+#define BEZT_BINARYSEARCH_THRESH 0.01f /* was 0.00001, but giving errors */
+
+/* -------- Data Management -------- */
void free_fcurve(struct FCurve *fcu);
struct FCurve *copy_fcurve(struct FCurve *fcu);
diff --git a/source/blender/blenkernel/BKE_freestyle.h b/source/blender/blenkernel/BKE_freestyle.h
index 84a4bc255af..a3fcdd667e8 100644
--- a/source/blender/blenkernel/BKE_freestyle.h
+++ b/source/blender/blenkernel/BKE_freestyle.h
@@ -38,6 +38,11 @@
extern "C" {
#endif
+struct FreestyleConfig;
+struct FreestyleSettings;
+struct FreestyleLineSet;
+struct FreestyleModuleConfig;
+
/* FreestyleConfig */
void BKE_freestyle_config_init(FreestyleConfig *config);
void BKE_freestyle_config_free(FreestyleConfig *config);
@@ -50,7 +55,8 @@ void BKE_freestyle_module_move_up(FreestyleConfig *config, FreestyleModuleConfig
void BKE_freestyle_module_move_down(FreestyleConfig *config, FreestyleModuleConfig *module_conf);
/* FreestyleConfig.linesets */
-FreestyleLineSet *BKE_freestyle_lineset_add(FreestyleConfig *config);
+FreestyleLineSet *BKE_freestyle_lineset_add(FreestyleConfig *config, const char *name);
+bool BKE_freestyle_lineset_delete(FreestyleConfig *config, FreestyleLineSet *lineset);
FreestyleLineSet *BKE_freestyle_lineset_get_active(FreestyleConfig *config);
short BKE_freestyle_lineset_get_active_index(FreestyleConfig *config);
void BKE_freestyle_lineset_set_active_index(FreestyleConfig *config, short index);
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h
index 61f70d7f7e7..a7aa4c6969a 100644
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@ -195,8 +195,6 @@ enum {
#define G_TRANSFORM_SEQ 4
#define G_TRANSFORM_FCURVES 8
-/* G.special1 */
-
/* Memory is allocated where? blender.c */
extern Global G;
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index 44a9885cd87..55c71ff49cf 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -49,7 +49,7 @@ struct PropertyRNA;
void *BKE_libblock_alloc(struct Main *bmain, short type, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
void *BKE_libblock_copy_ex(struct Main *bmain, struct ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
-void *BKE_libblock_copy_nolib(struct ID *id) ATTR_NONNULL();
+void *BKE_libblock_copy_nolib(struct ID *id, const bool do_action) ATTR_NONNULL();
void *BKE_libblock_copy(struct ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
void BKE_libblock_copy_data(struct ID *id, const struct ID *id_from, const bool do_action);
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index 9c57b7c9a71..587dea5095c 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -127,6 +127,9 @@ bool BKE_mesh_uv_cdlayer_rename(struct Mesh *me, const char *old_name, const cha
float (*BKE_mesh_vertexCos_get(struct Mesh *me, int *r_numVerts))[3];
+struct Mesh *BKE_mesh_new_from_object(struct Main *bmain, struct Scene *sce, struct Object *ob,
+ int apply_modifiers, int settings, int calc_tessface, int calc_undeformed);
+
/* vertex level transformations & checks (no derived mesh) */
bool BKE_mesh_minmax(struct Mesh *me, float r_min[3], float r_max[3]);
@@ -192,7 +195,7 @@ void BKE_mesh_calc_poly_center(
struct MVert *mvarray, float cent[3]);
float BKE_mesh_calc_poly_area(
struct MPoly *mpoly, struct MLoop *loopstart,
- struct MVert *mvarray, const float polynormal[3]);
+ struct MVert *mvarray);
void BKE_mesh_calc_poly_angles(
struct MPoly *mpoly, struct MLoop *loopstart,
struct MVert *mvarray, float angles[]);
@@ -215,7 +218,7 @@ void BKE_mesh_loops_to_mface_corners(
struct CustomData *pdata, unsigned int lindex[4], int findex,
const int polyindex, const int mf_len,
const int numTex, const int numCol,
- const bool hasPCol, const bool hasOrigSpace);
+ const bool hasPCol, const bool hasOrigSpace, const bool hasLNor);
void BKE_mesh_loops_to_tessdata(
struct CustomData *fdata, struct CustomData *ldata, struct CustomData *pdata, struct MFace *mface,
int *polyindices, unsigned int (*loopindices)[4], const int num_faces);
diff --git a/source/blender/blenkernel/BKE_nla.h b/source/blender/blenkernel/BKE_nla.h
index 344797dd15a..0c29179aa1c 100644
--- a/source/blender/blenkernel/BKE_nla.h
+++ b/source/blender/blenkernel/BKE_nla.h
@@ -47,8 +47,8 @@ void free_nlastrip(ListBase *strips, struct NlaStrip *strip);
void free_nlatrack(ListBase *tracks, struct NlaTrack *nlt);
void free_nladata(ListBase *tracks);
-struct NlaStrip *copy_nlastrip(struct NlaStrip *strip);
-struct NlaTrack *copy_nlatrack(struct NlaTrack *nlt);
+struct NlaStrip *copy_nlastrip(struct NlaStrip *strip, const bool use_same_action);
+struct NlaTrack *copy_nlatrack(struct NlaTrack *nlt, const bool use_same_actions);
void copy_nladata(ListBase *dst, ListBase *src);
struct NlaTrack *add_nlatrack(struct AnimData *adt, struct NlaTrack *prev);
@@ -62,13 +62,13 @@ struct NlaStrip *add_nla_soundstrip(struct Scene *scene, struct Speaker *spk);
bool BKE_nlastrips_has_space(ListBase *strips, float start, float end);
void BKE_nlastrips_sort_strips(ListBase *strips);
-short BKE_nlastrips_add_strip(ListBase *strips, struct NlaStrip *strip);
+bool BKE_nlastrips_add_strip(ListBase *strips, struct NlaStrip *strip);
-void BKE_nlastrips_make_metas(ListBase *strips, short temp);
-void BKE_nlastrips_clear_metas(ListBase *strips, short onlySel, short onlyTemp);
+void BKE_nlastrips_make_metas(ListBase *strips, bool is_temp);
+void BKE_nlastrips_clear_metas(ListBase *strips, bool only_sel, bool only_temp);
void BKE_nlastrips_clear_metastrip(ListBase *strips, struct NlaStrip *strip);
-short BKE_nlameta_add_strip(struct NlaStrip *mstrip, struct NlaStrip *strip);
+bool BKE_nlameta_add_strip(struct NlaStrip *mstrip, struct NlaStrip *strip);
void BKE_nlameta_flush_transforms(struct NlaStrip *mstrip);
/* ............ */
@@ -81,24 +81,24 @@ void BKE_nlatrack_solo_toggle(struct AnimData *adt, struct NlaTrack *nlt);
bool BKE_nlatrack_has_space(struct NlaTrack *nlt, float start, float end);
void BKE_nlatrack_sort_strips(struct NlaTrack *nlt);
-short BKE_nlatrack_add_strip(struct NlaTrack *nlt, struct NlaStrip *strip);
+bool BKE_nlatrack_add_strip(struct NlaTrack *nlt, struct NlaStrip *strip);
-short BKE_nlatrack_get_bounds(struct NlaTrack *nlt, float bounds[2]);
+bool BKE_nlatrack_get_bounds(struct NlaTrack *nlt, float bounds[2]);
/* ............ */
struct NlaStrip *BKE_nlastrip_find_active(struct NlaTrack *nlt);
void BKE_nlastrip_set_active(struct AnimData *adt, struct NlaStrip *strip);
-short BKE_nlastrip_within_bounds(struct NlaStrip *strip, float min, float max);
+bool BKE_nlastrip_within_bounds(struct NlaStrip *strip, float min, float max);
void BKE_nlastrip_recalculate_bounds(struct NlaStrip *strip);
void BKE_nlastrip_validate_name(struct AnimData *adt, struct NlaStrip *strip);
/* ............ */
-short BKE_nlatrack_has_animated_strips(struct NlaTrack *nlt);
-short BKE_nlatracks_have_animated_strips(ListBase *tracks);
+bool BKE_nlatrack_has_animated_strips(struct NlaTrack *nlt);
+bool BKE_nlatracks_have_animated_strips(ListBase *tracks);
void BKE_nlastrip_validate_fcurves(struct NlaStrip *strip);
void BKE_nla_validate_state(struct AnimData *adt);
@@ -107,7 +107,7 @@ void BKE_nla_validate_state(struct AnimData *adt);
void BKE_nla_action_pushdown(struct AnimData *adt);
-short BKE_nla_tweakmode_enter(struct AnimData *adt);
+bool BKE_nla_tweakmode_enter(struct AnimData *adt);
void BKE_nla_tweakmode_exit(struct AnimData *adt);
/* ----------------------------- */
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 1d76cabf78b..13a32ee1528 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -44,6 +44,7 @@
#include "DNA_scene_types.h"
#include "DNA_texture_types.h"
#include "DNA_world_types.h"
+#include "DNA_linestyle_types.h"
#include "RNA_types.h"
@@ -632,6 +633,7 @@ struct NodeTreeIterStore {
Tex *tex;
Lamp *lamp;
World *world;
+ FreestyleLineStyle *linestyle;
};
void BKE_node_tree_iter_init(struct NodeTreeIterStore *ntreeiter, struct Main *bmain);
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 4b4deea044d..c0da816ca59 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -92,7 +92,7 @@ void *BKE_object_obdata_add_from_type(struct Main *bmain, int type);
void BKE_object_lod_add(struct Object *ob);
void BKE_object_lod_sort(struct Object *ob);
bool BKE_object_lod_remove(struct Object *ob, int level);
-bool BKE_object_lod_update(struct Object *ob, float camera_position[3]);
+void BKE_object_lod_update(struct Object *ob, const float camera_position[3]);
bool BKE_object_lod_is_usable(struct Object *ob, struct Scene *scene);
struct Object *BKE_object_lod_meshob_get(struct Object *ob, struct Scene *scene);
struct Object *BKE_object_lod_matob_get(struct Object *ob, struct Scene *scene);
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 12c4e0b8435..0061280684f 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -47,6 +47,7 @@ struct Object;
struct Paint;
struct PBVH;
struct Scene;
+struct Sculpt;
struct StrokeCache;
struct Tex;
struct ImagePool;
@@ -126,7 +127,7 @@ typedef struct SculptSession {
struct MPoly *mpoly;
struct MLoop *mloop;
int totvert, totpoly;
- float *face_normals;
+ float (*face_normals)[3];
struct KeyBlock *kb;
float *vmask;
@@ -135,7 +136,9 @@ typedef struct SculptSession {
/* BMesh for dynamic topology sculpting */
struct BMesh *bm;
- int bm_smooth_shading;
+ int cd_vert_node_offset;
+ int cd_face_node_offset;
+ bool bm_smooth_shading;
/* Undo/redo log for dynamic topology sculpting */
struct BMLog *bm_log;
@@ -144,13 +147,13 @@ typedef struct SculptSession {
bool show_diffuse_color;
/* Paiting on deformed mesh */
- int modifiers_active; /* object is deformed with some modifiers */
+ bool modifiers_active; /* object is deformed with some modifiers */
float (*orig_cos)[3]; /* coords of undeformed mesh */
float (*deform_cos)[3]; /* coords of deformed mesh but without stroke displacement */
float (*deform_imats)[3][3]; /* crazyspace deformation matrices */
/* Partial redraw */
- int partial_redraw;
+ bool partial_redraw;
/* Used to cache the render of the active texture */
unsigned int texcache_side, *texcache, texcache_actual;
@@ -163,15 +166,25 @@ typedef struct SculptSession {
struct StrokeCache *cache;
/* last paint/sculpt stroke location */
- int last_stroke_valid;
+ bool last_stroke_valid;
float last_stroke[3];
float average_stroke_accum[3];
int average_stroke_counter;
} SculptSession;
-void free_sculptsession(struct Object *ob);
-void free_sculptsession_deformMats(struct SculptSession *ss);
-void sculptsession_bm_to_me(struct Object *ob, bool reorder);
-void sculptsession_bm_to_me_for_render(struct Object *object);
+void BKE_free_sculptsession(struct Object *ob);
+void BKE_free_sculptsession_deformMats(struct SculptSession *ss);
+void BKE_sculptsession_bm_to_me(struct Object *ob, bool reorder);
+void BKE_sculptsession_bm_to_me_for_render(struct Object *object);
+void BKE_sculpt_update_mesh_elements(struct Scene *scene, struct Sculpt *sd, struct Object *ob,
+ bool need_pmap, bool need_mask);
+struct MultiresModifierData *BKE_sculpt_multires_active(struct Scene *scene, struct Object *ob);
+int BKE_sculpt_mask_layers_ensure(struct Object *ob,
+ struct MultiresModifierData *mmd);
+
+enum {
+ SCULPT_MASK_LAYER_CALC_VERT = (1 << 0),
+ SCULPT_MASK_LAYER_CALC_LOOP = (1 << 1)
+};
#endif
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index b6f7a2b0e1a..619b1afe765 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -67,8 +67,7 @@ void BKE_pbvh_build_grids(PBVH *bvh, struct CCGElem **grid_elems,
struct DMGridAdjacency *gridadj, int totgrid,
struct CCGKey *key, void **gridfaces, struct DMFlagMat *flagmats,
unsigned int **grid_hidden);
-void BKE_pbvh_build_bmesh(PBVH *bvh, struct BMesh *bm, int smooth_shading,
- struct BMLog *log);
+void BKE_pbvh_build_bmesh(PBVH *bvh, struct BMesh *bm, bool smooth_shading, struct BMLog *log, const int cd_vert_node_offset, const int cd_face_node_offset);
void BKE_pbvh_free(PBVH *bvh);
void BKE_pbvh_free_layer_disp(PBVH *bvh);
@@ -112,7 +111,7 @@ void BKE_pbvh_raycast_project_ray_root(PBVH *bvh, bool original, float ray_start
void BKE_pbvh_node_draw(PBVHNode *node, void *data);
void BKE_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*face_nors)[3],
- int (*setMaterial)(int, void *attribs), bool wireframe);
+ int (*setMaterial)(int matnr, void *attribs), bool wireframe);
/* PBVH Access */
typedef enum {
@@ -129,6 +128,10 @@ void BKE_pbvh_bounding_box(const PBVH *bvh, float min[3], float max[3]);
/* multires hidden data, only valid for type == PBVH_GRIDS */
unsigned int **BKE_pbvh_grid_hidden(const PBVH *bvh);
+int BKE_pbvh_count_grid_quads(BLI_bitmap **grid_hidden,
+ int *grid_indices, int totgrid,
+ int gridsize);
+
/* multires level, only valid for type == PBVH_GRIDS */
void BKE_pbvh_get_grid_key(const PBVH *pbvh, struct CCGKey *key);
@@ -186,6 +189,7 @@ bool BKE_pbvh_node_planes_exclude_AABB(PBVHNode *node, void *data);
struct GSet *BKE_pbvh_bmesh_node_unique_verts(PBVHNode *node);
struct GSet *BKE_pbvh_bmesh_node_other_verts(PBVHNode *node);
+struct GSet *BKE_pbvh_bmesh_node_faces(PBVHNode *node);
void BKE_pbvh_bmesh_node_save_orig(PBVHNode *node);
void BKE_pbvh_bmesh_after_stroke(PBVH *bvh);
@@ -193,7 +197,7 @@ void BKE_pbvh_bmesh_after_stroke(PBVH *bvh);
void BKE_pbvh_update(PBVH *bvh, int flags, float (*face_nors)[3]);
void BKE_pbvh_redraw_BB(PBVH *bvh, float bb_min[3], float bb_max[3]);
-void BKE_pbvh_get_grid_updates(PBVH *bvh, int clear, void ***gridfaces, int *totface);
+void BKE_pbvh_get_grid_updates(PBVH *bvh, int clear, void ***r_gridfaces, int *r_totface);
void BKE_pbvh_grids_update(PBVH *bvh, struct CCGElem **grid_elems,
struct DMGridAdjacency *gridadj, void **gridfaces,
struct DMFlagMat *flagmats, unsigned int **grid_hidden);
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h
index 5fe890461e0..a10a3f3f59f 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -137,7 +137,6 @@ bool BKE_scene_check_rigidbody_active(const struct Scene *scene);
int BKE_scene_num_threads(const struct Scene *scene);
int BKE_render_num_threads(const struct RenderData *r);
-int BKE_scene_num_omp_threads(const struct Scene *scene);
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h
index eb0aec50300..50ca5fcdf7b 100644
--- a/source/blender/blenkernel/BKE_sound.h
+++ b/source/blender/blenkernel/BKE_sound.h
@@ -140,6 +140,6 @@ void *sound_get_factory(void *sound);
float sound_get_length(struct bSound *sound);
-int sound_is_jack_supported(void);
+bool sound_is_jack_supported(void);
-#endif
+#endif /* __BKE_SOUND_H__ */
diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h
index c136a30595d..4ad84dceb53 100644
--- a/source/blender/blenkernel/BKE_texture.h
+++ b/source/blender/blenkernel/BKE_texture.h
@@ -41,6 +41,7 @@ struct bNode;
struct Brush;
struct ColorBand;
struct EnvMap;
+struct FreestyleLineStyle;
struct HaloRen;
struct Lamp;
struct LampRen;
@@ -85,6 +86,7 @@ void BKE_texture_make_local(struct Tex *tex);
struct Tex *give_current_object_texture(struct Object *ob);
struct Tex *give_current_material_texture(struct Material *ma);
struct Tex *give_current_lamp_texture(struct Lamp *la);
+struct Tex *give_current_linestyle_texture(struct FreestyleLineStyle *linestyle);
struct Tex *give_current_world_texture(struct World *world);
struct Tex *give_current_brush_texture(struct Brush *br);
struct Tex *give_current_particle_texture(struct ParticleSettings *part);
@@ -98,6 +100,7 @@ void set_current_brush_texture(struct Brush *br, struct Tex *tex);
void set_current_world_texture(struct World *wo, struct Tex *tex);
void set_current_material_texture(struct Material *ma, struct Tex *tex);
void set_current_lamp_texture(struct Lamp *la, struct Tex *tex);
+void set_current_linestyle_texture(struct FreestyleLineStyle *linestyle, struct Tex *tex);
void set_current_particle_texture(struct ParticleSettings *part, struct Tex *tex);
bool has_current_material_texture(struct Material *ma);
diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h
index ecf6b789227..6d155ba37de 100644
--- a/source/blender/blenkernel/BKE_tracking.h
+++ b/source/blender/blenkernel/BKE_tracking.h
@@ -175,7 +175,8 @@ void BKE_tracking_camera_get_reconstructed_interpolate(struct MovieTracking *tra
int framenr, float mat[4][4]);
/* **** Distortion/Undistortion **** */
-struct MovieDistortion *BKE_tracking_distortion_new(void);
+struct MovieDistortion *BKE_tracking_distortion_new(struct MovieTracking *tracking,
+ int calibration_width, int calibration_height);
void BKE_tracking_distortion_update(struct MovieDistortion *distortion, struct MovieTracking *tracking,
int calibration_width, int calibration_height);
void BKE_tracking_distortion_set_threads(struct MovieDistortion *distortion, int threads);
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 749a5eb408d..0caf7d11c55 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -78,7 +78,8 @@ set(SRC
intern/colortools.c
intern/constraint.c
intern/context.c
- intern/curve.c
+ intern/crazyspace.c
+ intern/curve.c
intern/customdata.c
intern/customdata_file.c
intern/deform.c
@@ -191,6 +192,7 @@ set(SRC
BKE_colortools.h
BKE_constraint.h
BKE_context.h
+ BKE_crazyspace.h
BKE_curve.h
BKE_customdata.h
BKE_customdata_file.h
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 1a9ca234f8d..5339c3fc5d5 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -39,21 +39,18 @@
#include "DNA_key_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
-#include "DNA_armature_types.h"
#include "DNA_object_types.h"
-#include "DNA_scene_types.h" // N_T
+#include "DNA_scene_types.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
-#include "BLI_memarena.h"
#include "BLI_utildefines.h"
#include "BLI_linklist.h"
-#include "BKE_pbvh.h"
#include "BKE_cdderivedmesh.h"
-#include "BKE_displist.h"
#include "BKE_editmesh.h"
#include "BKE_key.h"
+#include "BKE_material.h"
#include "BKE_modifier.h"
#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
@@ -62,8 +59,6 @@
#include "BKE_paint.h"
#include "BKE_texture.h"
#include "BKE_multires.h"
-#include "BKE_armature.h"
-#include "BKE_particle.h"
#include "BKE_bvhutils.h"
#include "BKE_deform.h"
#include "BKE_global.h" /* For debug flag, DM_update_tessface_data() func. */
@@ -349,6 +344,12 @@ int DM_release(DerivedMesh *dm)
CustomData_free(&dm->loopData, dm->numLoopData);
CustomData_free(&dm->polyData, dm->numPolyData);
+ if (dm->mat) {
+ MEM_freeN(dm->mat);
+ dm->mat = NULL;
+ dm->totmat = 0;
+ }
+
return 1;
}
else {
@@ -392,6 +393,12 @@ void DM_ensure_normals(DerivedMesh *dm)
BLI_assert((dm->dirty & DM_DIRTY_NORMALS) == 0);
}
+static void DM_calc_loop_normals(DerivedMesh *dm, float split_angle)
+{
+ dm->calcLoopNormals(dm, split_angle);
+ dm->dirty |= DM_DIRTY_TESS_CDLAYERS;
+}
+
/* note: until all modifiers can take MPoly's as input,
* use this at the start of modifiers */
void DM_ensure_tessface(DerivedMesh *dm)
@@ -446,7 +453,8 @@ void DM_update_tessface_data(DerivedMesh *dm)
if (CustomData_has_layer(fdata, CD_MTFACE) ||
CustomData_has_layer(fdata, CD_MCOL) ||
CustomData_has_layer(fdata, CD_PREVIEW_MCOL) ||
- CustomData_has_layer(fdata, CD_ORIGSPACE))
+ CustomData_has_layer(fdata, CD_ORIGSPACE) ||
+ CustomData_has_layer(fdata, CD_TESSLOOPNORMAL))
{
loopindex = MEM_mallocN(sizeof(*loopindex) * totface, __func__);
@@ -482,6 +490,23 @@ void DM_update_tessface_data(DerivedMesh *dm)
dm->dirty &= ~DM_DIRTY_TESS_CDLAYERS;
}
+void DM_update_materials(DerivedMesh *dm, Object *ob)
+{
+ int i, totmat = ob->totcol + 1; /* materials start from 1, default material is 0 */
+ dm->totmat = totmat;
+
+ /* invalidate old materials */
+ if (dm->mat)
+ MEM_freeN(dm->mat);
+
+ dm->mat = MEM_callocN(totmat * sizeof(*dm->mat), "DerivedMesh.mat");
+
+ for (i = 1; i < totmat; i++) {
+ dm->mat[i] = give_current_material(ob, i);
+ }
+}
+
+
void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob, CustomDataMask mask)
{
/* dm might depend on me, so we need to do everything with a local copy */
@@ -1447,6 +1472,9 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
/* XXX Same as above... For now, only weights preview in WPaint mode. */
const bool do_mod_wmcol = do_init_wmcol;
+ const bool do_loop_normals = (me->flag & ME_AUTOSMOOTH);
+ const float loop_normals_split_angle = me->smoothresh;
+
VirtualModifierData virtualModifierData;
ModifierApplyFlag app_flags = useRenderParams ? MOD_APPLY_RENDER : 0;
@@ -1565,13 +1593,14 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
continue;
}
if (sculpt_mode &&
- (!has_multires || multires_applied || ob->sculpt->bm))
+ (!has_multires || multires_applied || sculpt_dyntopo))
{
bool unsupported = false;
if (md->type == eModifierType_Multires && ((MultiresModifierData *)md)->sculptlvl == 0) {
/* If multires is on level 0 skip it silently without warning message. */
- continue;
+ if (!sculpt_dyntopo)
+ continue;
}
if (sculpt_dyntopo && !useRenderParams)
@@ -1583,9 +1612,15 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
unsupported |= multires_applied;
if (unsupported) {
- modifier_setError(md, "Not supported in sculpt mode");
+ if (sculpt_dyntopo)
+ modifier_setError(md, "Not supported in dyntopo");
+ else
+ modifier_setError(md, "Not supported in sculpt mode");
continue;
}
+ else {
+ modifier_setError(md, "Hide, Mask and optimized display disabled");
+ }
}
if (needMapping && !modifier_supportsMapping(md)) continue;
if (useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) continue;
@@ -1841,47 +1876,13 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
add_orco_dm(ob, NULL, *deform_r, NULL, CD_ORCO);
}
- {
- /* calculating normals can re-calculate tessfaces in some cases */
-#if 0
- int num_tessface = finaldm->getNumTessFaces(finaldm);
-#endif
- /* --------------------------------------------------------------------- */
- /* First calculate the polygon and vertex normals, re-tessellation
- * copies these into the tessface's normal layer */
-
-
- /* comment because this causes a bug when deform is applied after a
- * bug when applied after a subsurf modifier (SubSurf -> Cast) for eg,
- * it also looks like this isn't even needed since code above recalc's
- * normals - campbell */
-#if 0
- finaldm->calcNormals(finaldm);
-#endif
+ if (do_loop_normals) {
+ /* Compute loop normals (note: will compute poly and vert normals as well, if needed!) */
+ DM_calc_loop_normals(finaldm, loop_normals_split_angle);
+ }
- /* Re-tessellation is necessary to push render data (uvs, textures, colors)
- * from loops and polys onto the tessfaces. This may be currently be
- * redundant in cases where the render mode doesn't use these inputs, but
- * ideally eventually tessellation would happen on-demand, and this is one
- * of the primary places it would be needed. */
-#if 0
- if (num_tessface == 0 && finaldm->getNumTessFaces(finaldm) == 0)
-#else
- if (finaldm->getNumTessFaces(finaldm) == 0) /* || !CustomData_has_layer(&finaldm->faceData, CD_ORIGINDEX)) */
-#endif
- {
- finaldm->recalcTessellation(finaldm);
- }
- /* 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 (finaldm->dirty & DM_DIRTY_TESS_CDLAYERS) {
- /* A tessellation already exists, it should always have a CD_ORIGINDEX. */
- BLI_assert(CustomData_has_layer(&finaldm->faceData, CD_ORIGINDEX));
- DM_update_tessface_data(finaldm);
- }
- /* Need to watch this, it can cause issues, see bug [#29338] */
- /* take care with this block, we really need testing frameworks */
- /* --------------------------------------------------------------------- */
+ {
+ DM_ensure_tessface(finaldm);
/* without this, drawing ngon tri's faces will show ugly tessellated face
* normals and will also have to calculate normals on the fly, try avoid
@@ -1890,8 +1891,11 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
* which deals with drawing differently.
*
* Only calc vertex normals if they are flagged as dirty.
+ * If using loop normals, poly nors have already been computed.
*/
- dm_ensure_display_normals(finaldm);
+ if (!do_loop_normals) {
+ dm_ensure_display_normals(finaldm);
+ }
}
#ifdef WITH_GAMEENGINE
@@ -1958,7 +1962,7 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
ModifierData *md, *previewmd = NULL;
float (*deformedVerts)[3] = NULL;
CustomDataMask mask, previewmask = 0, append_mask = 0;
- DerivedMesh *dm, *orcodm = NULL;
+ DerivedMesh *dm = NULL, *orcodm = NULL;
int i, numVerts = 0, cageIndex = modifiers_getCageIndex(scene, ob, NULL, 1);
CDMaskLink *datamasks, *curr;
int required_mode = eModifierMode_Realtime | eModifierMode_Editmode;
@@ -1974,13 +1978,15 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
const bool do_mod_wmcol = do_init_wmcol;
VirtualModifierData virtualModifierData;
+ const bool do_loop_normals = (((Mesh *)(ob->data))->flag & ME_AUTOSMOOTH);
+ const float loop_normals_split_angle = ((Mesh *)(ob->data))->smoothresh;
+
modifiers_clearErrors(ob);
if (cage_r && cageIndex == -1) {
*cage_r = getEditDerivedBMesh(em, ob, NULL);
}
- dm = NULL;
md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
/* copied from mesh_calc_modifiers */
@@ -2188,6 +2194,14 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
DM_update_statvis_color(scene, ob, *final_r);
}
+ if (do_loop_normals) {
+ /* Compute loop normals */
+ DM_calc_loop_normals(*final_r, loop_normals_split_angle);
+ if (cage_r && *cage_r && (*cage_r != *final_r)) {
+ DM_calc_loop_normals(*cage_r, loop_normals_split_angle);
+ }
+ }
+
/* --- */
/* BMESH_ONLY, ensure tessface's used for drawing,
* but don't recalculate if the last modifier in the stack gives us tessfaces
@@ -2205,8 +2219,10 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
}
/* --- */
- /* same as mesh_calc_modifiers */
- dm_ensure_display_normals(*final_r);
+ /* same as mesh_calc_modifiers (if using loop normals, poly nors have already been computed). */
+ if (!do_loop_normals) {
+ dm_ensure_display_normals(*final_r);
+ }
/* add an orco layer if needed */
if (dataMask & CD_MASK_ORCO)
@@ -2245,7 +2261,8 @@ static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask,
if ((ob->mode & OB_MODE_SCULPT) && ob->sculpt) {
/* create PBVH immediately (would be created on the fly too,
* but this avoids waiting on first stroke) */
- ob->sculpt->pbvh = ob->derivedFinal->getPBVH(ob, ob->derivedFinal);
+
+ BKE_sculpt_update_mesh_elements(scene, scene->toolsettings->sculpt, ob, false, false);
}
BLI_assert(!(ob->derivedFinal->dirty & DM_DIRTY_NORMALS));
@@ -2518,7 +2535,8 @@ DMCoNo *mesh_get_mapped_verts_nors(Scene *scene, Object *ob)
/* ******************* GLSL ******************** */
typedef struct {
- float *precomputedFaceNormals;
+ float (*precomputedFaceNormals)[3];
+ short (*precomputedLoopNormals)[4][3];
MTFace *mtface; /* texture coordinates */
MFace *mface; /* indices */
MVert *mvert; /* vertices & normals */
@@ -2570,11 +2588,14 @@ static void GetNormal(const SMikkTSpaceContext *pContext, float r_no[3], const i
{
//assert(vert_index >= 0 && vert_index < 4);
SGLSLMeshToTangent *pMesh = (SGLSLMeshToTangent *) pContext->m_pUserData;
+ const bool smoothnormal = (pMesh->mface[face_num].flag & ME_SMOOTH) != 0;
- const int smoothnormal = (pMesh->mface[face_num].flag & ME_SMOOTH);
- if (!smoothnormal) { // flat
+ if (pMesh->precomputedLoopNormals) {
+ normal_short_to_float_v3(r_no, pMesh->precomputedLoopNormals[face_num][vert_index]);
+ }
+ else if (!smoothnormal) { // flat
if (pMesh->precomputedFaceNormals) {
- copy_v3_v3(r_no, &pMesh->precomputedFaceNormals[3 * face_num]);
+ copy_v3_v3(r_no, pMesh->precomputedFaceNormals[face_num]);
}
else {
MFace *mf = &pMesh->mface[face_num];
@@ -2614,12 +2635,17 @@ void DM_add_tangent_layer(DerivedMesh *dm)
MFace *mface;
float (*orco)[3] = NULL, (*tangent)[4];
int /* totvert, */ totface;
- float *nors;
+ float (*fnors)[3];
+ short (*tlnors)[4][3];
if (CustomData_get_layer_index(&dm->faceData, CD_TANGENT) != -1)
return;
- nors = dm->getTessFaceDataArray(dm, CD_NORMAL);
+ fnors = dm->getTessFaceDataArray(dm, CD_NORMAL);
+ /* Note, we assume we do have tessellated loop normals at this point (in case it is object-enabled),
+ * have to check this is valid...
+ */
+ tlnors = dm->getTessFaceDataArray(dm, CD_TESSLOOPNORMAL);
/* check we have all the needed layers */
/* totvert = dm->getNumVerts(dm); */ /* UNUSED */
@@ -2645,7 +2671,8 @@ void DM_add_tangent_layer(DerivedMesh *dm)
SMikkTSpaceContext sContext = {NULL};
SMikkTSpaceInterface sInterface = {NULL};
- mesh2tangent.precomputedFaceNormals = nors;
+ mesh2tangent.precomputedFaceNormals = fnors;
+ mesh2tangent.precomputedLoopNormals = tlnors;
mesh2tangent.mtface = mtface;
mesh2tangent.mface = mface;
mesh2tangent.mvert = mvert;
@@ -2769,9 +2796,9 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm)
int t;
for (t = 0; t < nr_tris_to_pile; t++) {
float f2x_area_uv;
- float *p0 = verts[indices[t * 3 + 0]];
- float *p1 = verts[indices[t * 3 + 1]];
- float *p2 = verts[indices[t * 3 + 2]];
+ const float *p0 = verts[indices[t * 3 + 0]];
+ const float *p1 = verts[indices[t * 3 + 1]];
+ const float *p2 = verts[indices[t * 3 + 2]];
float edge_t0[2], edge_t1[2];
sub_v2_v2v2(edge_t0, tex_coords[indices[t * 3 + 1]], tex_coords[indices[t * 3 + 0]]);
@@ -3073,7 +3100,7 @@ static void navmesh_DM_drawFacesTex(DerivedMesh *dm,
static void navmesh_DM_drawFacesSolid(DerivedMesh *dm,
float (*partial_redraw_planes)[4],
- int UNUSED(fast), DMSetMaterial setMaterial)
+ bool UNUSED(fast), DMSetMaterial setMaterial)
{
(void) partial_redraw_planes;
(void) setMaterial;
@@ -3326,3 +3353,84 @@ bool DM_is_valid(DerivedMesh *dm)
}
#endif /* NDEBUG */
+
+/* -------------------------------------------------------------------- */
+
+MVert *DM_get_vert_array(DerivedMesh *dm, bool *allocated)
+{
+ CustomData *vert_data = dm->getVertDataLayout(dm);
+ MVert *mvert = CustomData_get_layer(vert_data, CD_MVERT);
+ *allocated = false;
+
+ if (mvert == NULL) {
+ mvert = MEM_mallocN(sizeof(MVert) * dm->getNumVerts(dm), "dmvh vert data array");
+ dm->copyVertArray(dm, mvert);
+ *allocated = true;
+ }
+
+ return mvert;
+}
+
+MEdge *DM_get_edge_array(DerivedMesh *dm, bool *allocated)
+{
+ CustomData *edge_data = dm->getEdgeDataLayout(dm);
+ MEdge *medge = CustomData_get_layer(edge_data, CD_MEDGE);
+ *allocated = false;
+
+ if (medge == NULL) {
+ medge = MEM_mallocN(sizeof(MEdge) * dm->getNumEdges(dm), "dm medge data array");
+ dm->copyEdgeArray(dm, medge);
+ *allocated = true;
+ }
+
+ return medge;
+}
+
+MLoop *DM_get_loop_array(DerivedMesh *dm, bool *allocated)
+{
+ CustomData *loop_data = dm->getEdgeDataLayout(dm);
+ MLoop *mloop = CustomData_get_layer(loop_data, CD_MLOOP);
+ *allocated = false;
+
+ if (mloop == NULL) {
+ mloop = MEM_mallocN(sizeof(MLoop) * dm->getNumLoops(dm), "dm loop data array");
+ dm->copyLoopArray(dm, mloop);
+ *allocated = true;
+ }
+
+ return mloop;
+}
+
+MPoly *DM_get_poly_array(DerivedMesh *dm, bool *allocated)
+{
+ CustomData *poly_data = dm->getPolyDataLayout(dm);
+ MPoly *mpoly = CustomData_get_layer(poly_data, CD_MPOLY);
+ *allocated = false;
+
+ if (mpoly == NULL) {
+ mpoly = MEM_mallocN(sizeof(MPoly) * dm->getNumPolys(dm), "dm poly data array");
+ dm->copyPolyArray(dm, mpoly);
+ *allocated = true;
+ }
+
+ return mpoly;
+}
+
+MFace *DM_get_tessface_array(DerivedMesh *dm, bool *allocated)
+{
+ CustomData *tessface_data = dm->getTessFaceDataLayout(dm);
+ MFace *mface = CustomData_get_layer(tessface_data, CD_MFACE);
+ *allocated = false;
+
+ if (mface == NULL) {
+ int numTessFaces = dm->getNumTessFaces(dm);
+
+ if (numTessFaces > 0) {
+ mface = MEM_mallocN(sizeof(MFace) * numTessFaces, "bvh mface data array");
+ dm->copyTessFaceArray(dm, mface);
+ *allocated = true;
+ }
+ }
+
+ return mface;
+}
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index d5efa09bdc9..3219219bee5 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -588,14 +588,6 @@ void BKE_pose_copy_data(bPose **dst, bPose *src, const bool copy_constraints)
outPose = MEM_callocN(sizeof(bPose), "pose");
BLI_duplicatelist(&outPose->chanbase, &src->chanbase);
- if (outPose->chanbase.first) {
- bPoseChannel *pchan;
- for (pchan = outPose->chanbase.first; pchan; pchan = pchan->next) {
- if (pchan->custom) {
- id_us_plus(&pchan->custom->id);
- }
- }
- }
outPose->iksolver = src->iksolver;
outPose->ikdata = NULL;
@@ -603,8 +595,18 @@ void BKE_pose_copy_data(bPose **dst, bPose *src, const bool copy_constraints)
outPose->avs = src->avs;
for (pchan = outPose->chanbase.first; pchan; pchan = pchan->next) {
+
+ if (pchan->custom) {
+ id_us_plus(&pchan->custom->id);
+ }
+
+ /* warning, O(n2) here, but it's a rarely used feature. */
+ if (pchan->custom_tx) {
+ pchan->custom_tx = BKE_pose_channel_find_name(outPose, pchan->custom_tx->name);
+ }
+
if (copy_constraints) {
- BKE_copy_constraints(&listb, &pchan->constraints, true); // BKE_copy_constraints NULLs listb
+ BKE_constraints_copy(&listb, &pchan->constraints, true); // BKE_constraints_copy NULLs listb
pchan->constraints = listb;
pchan->mpath = NULL; /* motion paths should not get copied yet... */
}
@@ -727,7 +729,7 @@ void BKE_pose_channel_free_ex(bPoseChannel *pchan, bool do_id_user)
pchan->mpath = NULL;
}
- BKE_free_constraints(&pchan->constraints);
+ BKE_constraints_free(&pchan->constraints);
if (pchan->prop) {
IDP_FreeProperty(pchan->prop);
@@ -843,7 +845,7 @@ void BKE_pose_channel_copy_data(bPoseChannel *pchan, const bPoseChannel *pchan_f
pchan->iklinweight = pchan_from->iklinweight;
/* constraints */
- BKE_copy_constraints(&pchan->constraints, &pchan_from->constraints, true);
+ BKE_constraints_copy(&pchan->constraints, &pchan_from->constraints, true);
/* id-properties */
if (pchan->prop) {
@@ -1127,7 +1129,7 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan,
* - we cannot use the groups, since they may not be grouped in that way...
*/
for (fcu = act->curves.first; fcu; fcu = fcu->next) {
- char *bPtr = NULL, *pPtr = NULL;
+ const char *bPtr = NULL, *pPtr = NULL;
/* if enough flags have been found, we can stop checking unless we're also getting the curves */
if ((flags == ACT_TRANS_ALL) && (curves == NULL))
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index 167baec3d9f..4cce69dc824 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -535,6 +535,9 @@ void calc_curvepath(Object *ob, ListBase *nurbs)
bevp = bevpfirst;
bevpn = bevp + 1;
bevplast = bevpfirst + (bl->nr - 1);
+ if (UNLIKELY(bevpn > bevplast)) {
+ bevpn = cycl ? bevpfirst : bevplast;
+ }
fp = dist + 1;
maxdist = dist + tot;
fac = 1.0f / ((float)path->len - 1.0f);
@@ -545,17 +548,23 @@ void calc_curvepath(Object *ob, ListBase *nurbs)
d = ((float)a) * fac;
/* we're looking for location (distance) 'd' in the array */
- while ((fp < maxdist) && (d >= *fp)) {
- fp++;
- if (bevp < bevplast) bevp++;
- bevpn = bevp + 1;
- if (UNLIKELY(bevpn > bevplast)) {
- bevpn = cycl ? bevpfirst : bevplast;
+ if (LIKELY(tot > 0)) {
+ while ((fp < maxdist) && (d >= *fp)) {
+ fp++;
+ if (bevp < bevplast) bevp++;
+ bevpn = bevp + 1;
+ if (UNLIKELY(bevpn > bevplast)) {
+ bevpn = cycl ? bevpfirst : bevplast;
+ }
}
+
+ fac1 = (*(fp) - d) / (*(fp) - *(fp - 1));
+ fac2 = 1.0f - fac1;
+ }
+ else {
+ fac1 = 1.0f;
+ fac2 = 0.0f;
}
-
- fac1 = (*(fp) - d) / (*(fp) - *(fp - 1));
- fac2 = 1.0f - fac1;
interp_v3_v3v3(pp->vec, bevp->vec, bevpn->vec, fac2);
pp->vec[3] = fac1 * bevp->alfa + fac2 * bevpn->alfa;
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 7bd5e2207a5..6a9c4c851b2 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -74,7 +74,7 @@
/* Getter/Setter -------------------------------------------- */
/* Check if ID can have AnimData */
-short id_type_can_have_animdata(ID *id)
+bool id_type_can_have_animdata(ID *id)
{
/* sanity check */
if (id == NULL)
@@ -157,10 +157,10 @@ AnimData *BKE_id_add_animdata(ID *id)
/* Action Setter --------------------------------------- */
/* Called when user tries to change the active action of an AnimData block (via RNA, Outliner, etc.) */
-short BKE_animdata_set_action(ReportList *reports, ID *id, bAction *act)
+bool BKE_animdata_set_action(ReportList *reports, ID *id, bAction *act)
{
AnimData *adt = BKE_animdata_from_id(id);
- short ok = 0;
+ bool ok = false;
/* animdata validity check */
if (adt == NULL) {
@@ -279,7 +279,7 @@ AnimData *BKE_copy_animdata(AnimData *adt, const bool do_action)
return dadt;
}
-int BKE_copy_animdata_id(ID *id_to, ID *id_from, const bool do_action)
+bool BKE_copy_animdata_id(ID *id_to, ID *id_from, const bool do_action)
{
AnimData *adt;
@@ -386,10 +386,10 @@ void BKE_relink_animdata(AnimData *adt)
* < basepath: (str) shorter path fragment to look for
* > returns (bool) whether there is a match
*/
-static short animpath_matches_basepath(const char path[], const char basepath[])
+static bool animpath_matches_basepath(const char path[], const char basepath[])
{
/* we need start of path to be basepath */
- return (path && basepath) && (strstr(path, basepath) == path);
+ return (path && basepath) && STRPREFIX(path, basepath);
}
/* Move F-Curves in src action to dst action, setting up all the necessary groups
@@ -567,7 +567,7 @@ static bool check_rna_path_is_valid(ID *owner_id, const char *path)
/* Check if some given RNA Path needs fixing - free the given path and set a new one as appropriate
* NOTE: we assume that oldName and newName have [" "] padding around them
*/
-static char *rna_path_rename_fix(ID *owner_id, const char *prefix, const char *oldName, const char *newName, char *oldpath, int verify_paths)
+static char *rna_path_rename_fix(ID *owner_id, const char *prefix, const char *oldName, const char *newName, char *oldpath, bool verify_paths)
{
char *prefixPtr = strstr(oldpath, prefix);
char *oldNamePtr = strstr(oldpath, oldName);
@@ -581,7 +581,7 @@ static char *rna_path_rename_fix(ID *owner_id, const char *prefix, const char *o
/* if we haven't aren't able to resolve the path now, try again after fixing it */
if (!verify_paths || check_rna_path_is_valid(owner_id, oldpath) == 0) {
DynStr *ds = BLI_dynstr_new();
- char *postfixPtr = oldNamePtr + oldNameLen;
+ const char *postfixPtr = oldNamePtr + oldNameLen;
char *newPath = NULL;
char oldChar;
@@ -626,14 +626,14 @@ static char *rna_path_rename_fix(ID *owner_id, const char *prefix, const char *o
/* Check RNA-Paths for a list of F-Curves */
static void fcurves_path_rename_fix(ID *owner_id, const char *prefix, const char *oldName, const char *newName,
- const char *oldKey, const char *newKey, ListBase *curves, int verify_paths)
+ const char *oldKey, const char *newKey, ListBase *curves, bool verify_paths)
{
FCurve *fcu;
/* we need to check every curve... */
for (fcu = curves->first; fcu; fcu = fcu->next) {
if (fcu->rna_path) {
- char *old_path = fcu->rna_path;
+ const char *old_path = fcu->rna_path;
/* firstly, handle the F-Curve's own path */
fcu->rna_path = rna_path_rename_fix(owner_id, prefix, oldKey, newKey, fcu->rna_path, verify_paths);
@@ -654,7 +654,7 @@ static void fcurves_path_rename_fix(ID *owner_id, const char *prefix, const char
/* Check RNA-Paths for a list of Drivers */
static void drivers_path_rename_fix(ID *owner_id, ID *ref_id, const char *prefix, const char *oldName, const char *newName,
- const char *oldKey, const char *newKey, ListBase *curves, int verify_paths)
+ const char *oldKey, const char *newKey, ListBase *curves, bool verify_paths)
{
FCurve *fcu;
@@ -695,7 +695,7 @@ static void drivers_path_rename_fix(ID *owner_id, ID *ref_id, const char *prefix
/* Fix all RNA-Paths for Actions linked to NLA Strips */
static void nlastrips_path_rename_fix(ID *owner_id, const char *prefix, const char *oldName, const char *newName,
- const char *oldKey, const char *newKey, ListBase *strips, int verify_paths)
+ const char *oldKey, const char *newKey, ListBase *strips, bool verify_paths)
{
NlaStrip *strip;
@@ -720,7 +720,7 @@ static void nlastrips_path_rename_fix(ID *owner_id, const char *prefix, const ch
* i.e. pose.bones["Bone"]
*/
void BKE_action_fix_paths_rename(ID *owner_id, bAction *act, const char *prefix, const char *oldName,
- const char *newName, int oldSubscript, int newSubscript, int verify_paths)
+ const char *newName, int oldSubscript, int newSubscript, bool verify_paths)
{
char *oldN, *newN;
@@ -759,7 +759,7 @@ void BKE_action_fix_paths_rename(ID *owner_id, bAction *act, const char *prefix,
* i.e. pose.bones["Bone"]
*/
void BKE_animdata_fix_paths_rename(ID *owner_id, AnimData *adt, ID *ref_id, const char *prefix, const char *oldName,
- const char *newName, int oldSubscript, int newSubscript, int verify_paths)
+ const char *newName, int oldSubscript, int newSubscript, bool verify_paths)
{
NlaTrack *nlt;
char *oldN, *newN;
@@ -894,7 +894,7 @@ void BKE_animdata_main_cb(Main *mainptr, ID_AnimData_Edit_Callback func, void *u
AnimData *adt = BKE_animdata_from_id(id); \
NtId_Type *ntp = (NtId_Type *)id; \
if (ntp->nodetree) { \
- AnimData *adt2 = BKE_animdata_from_id((ID *)ntp); \
+ AnimData *adt2 = BKE_animdata_from_id((ID *)ntp->nodetree); \
if (adt2) func(id, adt2, user_data); \
} \
if (adt) func(id, adt, user_data); \
@@ -1259,7 +1259,7 @@ void BKE_keyingsets_free(ListBase *list)
* - path: original path string (as stored in F-Curve data)
* - dst: destination string to write data to
*/
-static short animsys_remap_path(AnimMapper *UNUSED(remap), char *path, char **dst)
+static bool animsys_remap_path(AnimMapper *UNUSED(remap), char *path, char **dst)
{
/* is there a valid remapping table to use? */
#if 0
@@ -1279,7 +1279,7 @@ static short animsys_remap_path(AnimMapper *UNUSED(remap), char *path, char **ds
#define ANIMSYS_FLOAT_AS_BOOL(value) ((value) > ((1.0f - FLT_EPSILON)))
/* Write the given value to a setting using RNA, and return success */
-static short animsys_write_rna_setting(PointerRNA *ptr, char *path, int array_index, float value)
+static bool animsys_write_rna_setting(PointerRNA *ptr, char *path, int array_index, float value)
{
PropertyRNA *prop;
PointerRNA new_ptr;
@@ -1401,7 +1401,7 @@ static short animsys_write_rna_setting(PointerRNA *ptr, char *path, int array_in
* where some channels will not exist, but shouldn't lock up Action */
if (G.debug & G_DEBUG) {
printf("Animato: Invalid path. ID = '%s', '%s[%d]'\n",
- (ptr && ptr->id.data) ? (((ID *)ptr->id.data)->name + 2) : "<No ID>",
+ (ptr->id.data) ? (((ID *)ptr->id.data)->name + 2) : "<No ID>",
path, array_index);
}
return 0;
@@ -1409,11 +1409,11 @@ static short animsys_write_rna_setting(PointerRNA *ptr, char *path, int array_in
}
/* Simple replacement based data-setting of the FCurve using RNA */
-static short animsys_execute_fcurve(PointerRNA *ptr, AnimMapper *remap, FCurve *fcu)
+static bool animsys_execute_fcurve(PointerRNA *ptr, AnimMapper *remap, FCurve *fcu)
{
char *path = NULL;
- short free_path = 0;
- short ok = 0;
+ bool free_path = false;
+ bool ok = false;
/* get path, remapped as appropriate to work in its new environment */
free_path = animsys_remap_path(remap, fcu->rna_path, &path);
@@ -1463,7 +1463,7 @@ static void animsys_evaluate_drivers(PointerRNA *ptr, AnimData *adt, float ctime
*/
for (fcu = adt->drivers.first; fcu; fcu = fcu->next) {
ChannelDriver *driver = fcu->driver;
- short ok = 0;
+ bool ok = false;
/* check if this driver's curve should be skipped */
if ((fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED)) == 0) {
@@ -2117,7 +2117,6 @@ 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)
{
- ListBase tmp_channels = {NULL, NULL};
ListBase tmp_modifiers = {NULL, NULL};
NlaStrip *strip = nes->strip;
NlaEvalStrip *tmp_nes;
@@ -2130,26 +2129,23 @@ static void nlastrip_evaluate_meta(PointerRNA *ptr, ListBase *channels, ListBase
*
* NOTE: keep this in sync with animsys_evaluate_nla()
*/
-
+
/* join this strip's modifiers to the parent's modifiers (own modifiers first) */
nlaeval_fmodifiers_join_stacks(&tmp_modifiers, &strip->modifiers, modifiers);
/* 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);
- if (tmp_nes == NULL)
- return;
-
- /* evaluate child-strip into tmp_channels buffer before accumulating
- * in the accumulation buffer
- */
- nlastrip_evaluate(ptr, &tmp_channels, &tmp_modifiers, tmp_nes);
-
- /* accumulate temp-buffer and full-buffer, using the 'real' strip */
- nlaevalchan_buffers_accumulate(channels, &tmp_channels, nes);
- /* free temp eval-strip */
- MEM_freeN(tmp_nes);
+ /* 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);
+
+ /* free temp eval-strip */
+ MEM_freeN(tmp_nes);
+ }
/* unlink this strip's modifiers from the parent's modifiers again */
nlaeval_fmodifiers_split_stacks(&strip->modifiers, modifiers);
@@ -2159,7 +2155,7 @@ static void nlastrip_evaluate_meta(PointerRNA *ptr, ListBase *channels, ListBase
void nlastrip_evaluate(PointerRNA *ptr, ListBase *channels, ListBase *modifiers, NlaEvalStrip *nes)
{
NlaStrip *strip = nes->strip;
-
+
/* to prevent potential infinite recursion problems (i.e. transition strip, beside meta strip containing a transition
* several levels deep inside it), we tag the current strip as being evaluated, and clear this when we leave
*/
@@ -2249,6 +2245,9 @@ static void animsys_evaluate_nla(ListBase *echannels, PointerRNA *ptr, AnimData
ListBase estrips = {NULL, NULL};
NlaEvalStrip *nes;
+ NlaStrip dummy_strip = {NULL}; /* dummy strip for active action */
+
+
/* 1. get the stack of strips to evaluate at current time (influence calculated here) */
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next, track_index++) {
/* stop here if tweaking is on and this strip is the tweaking track (it will be the first one that's 'disabled')... */
@@ -2266,7 +2265,7 @@ static void animsys_evaluate_nla(ListBase *echannels, PointerRNA *ptr, AnimData
* - used for mainly for still allowing normal action evaluation...
*/
if (nlt->strips.first)
- has_strips = 1;
+ has_strips = true;
/* otherwise, get strip to evaluate for this channel */
nes = nlastrips_ctime_get_strip(&estrips, &nlt->strips, track_index, ctime);
@@ -2282,7 +2281,6 @@ static void animsys_evaluate_nla(ListBase *echannels, PointerRNA *ptr, AnimData
/* if there are strips, evaluate action as per NLA rules */
if ((has_strips) || (adt->actstrip)) {
/* make dummy NLA strip, and add that to the stack */
- NlaStrip dummy_strip = {NULL};
ListBase dummy_trackslist;
dummy_trackslist.first = dummy_trackslist.last = &dummy_strip;
@@ -2305,6 +2303,9 @@ static void animsys_evaluate_nla(ListBase *echannels, PointerRNA *ptr, AnimData
dummy_strip.blendmode = adt->act_blendmode;
dummy_strip.extendmode = adt->act_extendmode;
dummy_strip.influence = adt->act_influence;
+
+ /* NOTE: must set this, or else the default setting overrides, and this setting doesn't work */
+ dummy_strip.flag |= NLASTRIP_FLAG_USR_INFLUENCE;
}
/* add this to our list of evaluation strips */
@@ -2313,7 +2314,10 @@ static void animsys_evaluate_nla(ListBase *echannels, PointerRNA *ptr, AnimData
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);
+ BLI_freelistN(&estrips);
return;
}
}
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 60ec4817f81..fda252e81fd 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -47,7 +47,6 @@
#include "DNA_mesh_types.h"
#include "DNA_lattice_types.h"
#include "DNA_meshdata_types.h"
-#include "DNA_nla_types.h"
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
@@ -594,7 +593,6 @@ static void pchan_b_bone_defmats(bPoseChannel *pchan, bPoseChanDeform *pdef_info
Mat4 b_bone[MAX_BBONE_SUBDIV], b_bone_rest[MAX_BBONE_SUBDIV];
Mat4 *b_bone_mats;
DualQuat *b_bone_dual_quats = NULL;
- float tmat[4][4] = MAT4_UNITY;
int a;
b_bone_spline_setup(pchan, 0, b_bone);
@@ -620,6 +618,8 @@ static void pchan_b_bone_defmats(bPoseChannel *pchan, bPoseChanDeform *pdef_info
* - transform back into global space */
for (a = 0; a < bone->segments; a++) {
+ float tmat[4][4];
+
invert_m4_m4(tmat, b_bone_rest[a].mat);
mul_serie_m4(b_bone_mats[a + 1].mat, pchan->chan_mat, bone->arm_mat, b_bone[a].mat, tmat, b_bone_mats[0].mat,
@@ -1108,10 +1108,11 @@ void BKE_armature_mat_world_to_pose(Object *ob, float inmat[4][4], float outmat[
* pose-channel into its local space (i.e. 'visual'-keyframing) */
void BKE_armature_loc_world_to_pose(Object *ob, const float inloc[3], float outloc[3])
{
- float xLocMat[4][4] = MAT4_UNITY;
+ float xLocMat[4][4];
float nLocMat[4][4];
/* build matrix for location */
+ unit_m4(xLocMat);
copy_v3_v3(xLocMat[3], inloc);
/* get bone-space cursor matrix and extract location */
@@ -1277,10 +1278,11 @@ void BKE_armature_mat_bone_to_pose(bPoseChannel *pchan, float inmat[4][4], float
* pose-channel into its local space (i.e. 'visual'-keyframing) */
void BKE_armature_loc_pose_to_bone(bPoseChannel *pchan, const float inloc[3], float outloc[3])
{
- float xLocMat[4][4] = MAT4_UNITY;
+ float xLocMat[4][4];
float nLocMat[4][4];
/* build matrix for location */
+ unit_m4(xLocMat);
copy_v3_v3(xLocMat[3], inloc);
/* get bone-space cursor matrix and extract location */
@@ -1414,6 +1416,7 @@ void BKE_rotMode_change_values(float quat[4], float eul[3], float axis[3], float
* pose_mat(b)= arm_mat(b) * chan_mat(b)
*
* *************************************************************************** */
+
/* Computes vector and roll based on a rotation.
* "mat" must contain only a rotation, and no scaling. */
void mat3_to_vec_roll(float mat[3][3], float r_vec[3], float *r_roll)
@@ -1433,52 +1436,101 @@ void mat3_to_vec_roll(float mat[3][3], float r_vec[3], float *r_roll)
}
}
-/* Calculates the rest matrix of a bone based
- * On its vector and a roll around that vector */
+/* Calculates the rest matrix of a bone based on its vector and a roll around that vector. */
+/* Given v = (v.x, v.y, v.z) our (normalized) bone vector, we want the rotation matrix M
+ * from the Y axis (so that M * (0, 1, 0) = v).
+ * -> The rotation axis a lays on XZ plane, and it is orthonormal to v, hence to the projection of v onto XZ plane.
+ * -> a = (v.z, 0, -v.x)
+ * We know a is eigenvector of M (so M * a = a).
+ * Finally, we have w, such that M * w = (0, 1, 0) (i.e. the vector that will be aligned with Y axis once transformed).
+ * We know w is symmetric to v by the Y axis.
+ * -> w = (-v.x, v.y, -v.z)
+ *
+ * Solving this, we get (x, y and z being the components of v):
+ * ┌ (x^2 * y + z^2) / (x^2 + z^2), x, x * z * (y - 1) / (x^2 + z^2) ┐
+ * M = │ x * (y^2 - 1) / (x^2 + z^2), y, z * (y^2 - 1) / (x^2 + z^2) │
+ * └ x * z * (y - 1) / (x^2 + z^2), z, (x^2 + z^2 * y) / (x^2 + z^2) ┘
+ *
+ * This is stable as long as v (the bone) is not too much aligned with +/-Y (i.e. x and z components
+ * are not too close to 0).
+ *
+ * Since v is normalized, we have x^2 + y^2 + z^2 = 1, hence x^2 + z^2 = 1 - y^2 = (1 - y)(1 + y).
+ * This allows to simplifies M like this:
+ * ┌ 1 - x^2 / (1 + y), x, -x * z / (1 + y) ┐
+ * M = │ -x, y, -z │
+ * └ -x * z / (1 + y), z, 1 - z^2 / (1 + y) ┘
+ *
+ * Written this way, we see the case v = +Y is no more a singularity. The only one remaining is the bone being
+ * aligned with -Y.
+ *
+ * Let's handle the asymptotic behavior when bone vector is reaching the limit of y = -1. Each of the four corner
+ * elements can vary from -1 to 1, depending on the axis a chosen for doing the rotation. And the "rotation" here
+ * is in fact established by mirroring XZ plane by that given axis, then inversing the Y-axis.
+ * For sufficiently small x and z, and with y approaching -1, all elements but the four corner ones of M
+ * will degenerate. So let's now focus on these corner elements.
+ *
+ * We rewrite M so that it only contains its four corner elements, and combine the 1 / (1 + y) factor:
+ * ┌ 1 + y - x^2, -x * z ┐
+ * M* = 1 / (1 + y) * │ │
+ * └ -x * z, 1 + y - z^2 ┘
+ *
+ * When y is close to -1, computing 1 / (1 + y) will cause severe numerical instability, so we ignore it and
+ * normalize M instead. We know y^2 = 1 - (x^2 + z^2), and y < 0, hence y = -sqrt(1 - (x^2 + z^2)).
+ * Since x and z are both close to 0, we apply the binomial expansion to the first order:
+ * y = -sqrt(1 - (x^2 + z^2)) = -1 + (x^2 + z^2) / 2. Which gives:
+ * ┌ z^2 - x^2, -2 * x * z ┐
+ * M* = 1 / (x^2 + z^2) * │ │
+ * └ -2 * x * z, x^2 - z^2 ┘
+ */
void vec_roll_to_mat3(const float vec[3], const float roll, float mat[3][3])
{
- float nor[3], axis[3], target[3] = {0, 1, 0};
+#define THETA_THRESHOLD_NEGY 1.0e-9f
+#define THETA_THRESHOLD_NEGY_CLOSE 1.0e-5f
+
+ float nor[3];
float theta;
float rMatrix[3][3], bMatrix[3][3];
normalize_v3_v3(nor, vec);
- /* Find Axis & Amount for bone matrix */
- cross_v3_v3v3(axis, target, nor);
+ theta = 1.0f + nor[1];
- /* was 0.0000000000001, caused bug [#23954], smaller values give unstable
- * roll when toggling editmode.
+ /* With old algo, 1.0e-13f caused T23954 and T31333, 1.0e-6f caused T27675 and T30438,
+ * so using 1.0e-9f as best compromise.
*
- * was 0.00001, causes bug [#27675], with 0.00000495,
- * so a value inbetween these is needed.
+ * New algo is supposed much more precise, since less complex computations are performed,
+ * but it uses two different threshold values...
*
- * was 0.000001, causes bug [#30438] (which is same as [#27675, imho).
- * Resetting it to org value seems to cause no more [#23954]...
- *
- * was 0.0000000000001, caused bug [#31333], smaller values give unstable
- * roll when toggling editmode again...
- * No good value here, trying 0.000000001 as best compromise. :/
+ * Note: When theta is close to zero, we have to check we do have non-null X/Z components as well
+ * (due to float precision errors, we can have nor = (0.0, 0.99999994, 0.0)...).
*/
- if (len_squared_v3(axis) > 1.0e-9f) {
- /* if nor is *not* a multiple of target ... */
- normalize_v3(axis);
-
- theta = angle_normalized_v3v3(target, nor);
-
- /* Make Bone matrix*/
- axis_angle_normalized_to_mat3(bMatrix, axis, theta);
+ if (theta > THETA_THRESHOLD_NEGY_CLOSE || ((nor[0] || nor[2]) && theta > THETA_THRESHOLD_NEGY)) {
+ /* nor is *not* -Y.
+ * We got these values for free... so be happy with it... ;)
+ */
+ bMatrix[0][1] = -nor[0];
+ bMatrix[1][0] = nor[0];
+ bMatrix[1][1] = nor[1];
+ bMatrix[1][2] = nor[2];
+ bMatrix[2][1] = -nor[2];
+ if (theta > THETA_THRESHOLD_NEGY_CLOSE) {
+ /* If nor is far enough from -Y, apply the general case. */
+ bMatrix[0][0] = 1 - nor[0] * nor[0] / theta;
+ bMatrix[2][2] = 1 - nor[2] * nor[2] / theta;
+ bMatrix[2][0] = bMatrix[0][2] = -nor[0] * nor[2] / theta;
+ }
+ else {
+ /* If nor is too close to -Y, apply the special case. */
+ theta = nor[0] * nor[0] + nor[2] * nor[2];
+ bMatrix[0][0] = (nor[0] + nor[2]) * (nor[0] - nor[2]) / -theta;
+ bMatrix[2][2] = -bMatrix[0][0];
+ bMatrix[2][0] = bMatrix[0][2] = 2.0f * nor[0] * nor[2] / theta;
+ }
}
else {
- /* if nor is a multiple of target ... */
- float updown;
-
- /* point same direction, or opposite? */
- updown = (dot_v3v3(target, nor) > 0) ? 1.0f : -1.0f;
-
- /* I think this should work... */
- bMatrix[0][0] = updown; bMatrix[0][1] = 0.0; bMatrix[0][2] = 0.0;
- bMatrix[1][0] = 0.0; bMatrix[1][1] = updown; bMatrix[1][2] = 0.0;
- bMatrix[2][0] = 0.0; bMatrix[2][1] = 0.0; bMatrix[2][2] = 1.0;
+ /* If nor is -Y, simple symmetry by Z axis. */
+ unit_m3(bMatrix);
+ bMatrix[0][0] = bMatrix[1][1] = -1.0;
}
/* Make Roll matrix */
@@ -1486,6 +1538,9 @@ void vec_roll_to_mat3(const float vec[3], const float roll, float mat[3][3])
/* Combine and output result */
mul_m3_m3m3(mat, rMatrix, bMatrix);
+
+#undef THETA_THRESHOLD_NEGY
+#undef THETA_THRESHOLD_NEGY_CLOSE
}
@@ -1615,16 +1670,16 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected
* 2. copy proxy-pchan's constraints on-to new
* 3. add extracted local constraints back on top
*
- * Note for BKE_copy_constraints: when copying constraints, disable 'do_extern' otherwise
+ * Note for BKE_constraints_copy: when copying constraints, disable 'do_extern' otherwise
* we get the libs direct linked in this blend.
*/
- BKE_extract_proxylocal_constraints(&proxylocal_constraints, &pchan->constraints);
- BKE_copy_constraints(&pchanw.constraints, &pchanp->constraints, false);
+ BKE_constraints_proxylocal_extract(&proxylocal_constraints, &pchan->constraints);
+ BKE_constraints_copy(&pchanw.constraints, &pchanp->constraints, false);
BLI_movelisttolist(&pchanw.constraints, &proxylocal_constraints);
/* constraints - set target ob pointer to own object */
for (con = pchanw.constraints.first; con; con = con->next) {
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
@@ -2429,7 +2484,7 @@ void BKE_pose_where_is_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float
cob = BKE_constraints_make_evalob(scene, ob, pchan, CONSTRAINT_OBTYPE_BONE);
/* Solve PoseChannel's Constraints */
- BKE_solve_constraints(&pchan->constraints, cob, ctime); /* ctime doesnt alter objects */
+ BKE_constraints_solve(&pchan->constraints, cob, ctime); /* ctime doesnt alter objects */
/* cleanup after Constraint Solving
* - applies matrix back to pchan, and frees temporary struct used
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 9b1f2e87f9e..8b87f5b0cea 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -29,15 +29,15 @@
* \ingroup bke
*/
+#ifndef _GNU_SOURCE
+/* Needed for O_NOFOLLOW on some platforms. */
+# define _GNU_SOURCE 1
+#endif
#ifndef _WIN32
# include <unistd.h> // for read close
#else
# include <io.h> // for open close read
-# define open _open
-# define read _read
-# define close _close
-# define write _write
#endif
#include <stdlib.h>
@@ -52,12 +52,9 @@
#include "DNA_userdef_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
-#include "DNA_sequence_types.h"
-#include "DNA_sound_types.h"
#include "DNA_windowmanager_types.h"
#include "BLI_blenlib.h"
-#include "BLI_dynstr.h"
#include "BLI_utildefines.h"
#include "BLI_callbacks.h"
@@ -69,7 +66,6 @@
#include "BKE_brush.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
-#include "BKE_displist.h"
#include "BKE_global.h"
#include "BKE_idprop.h"
#include "BKE_image.h"
@@ -504,20 +500,22 @@ int BKE_read_file_from_memfile(bContext *C, MemFile *memfile, ReportList *report
int BKE_read_file_userdef(const char *filepath, ReportList *reports)
{
BlendFileData *bfd;
- int retval = 0;
-
+ int retval = BKE_READ_FILE_FAIL;
+
bfd = BLO_read_from_file(filepath, reports);
- if (bfd->user) {
- retval = BKE_READ_FILE_OK_USERPREFS;
-
- /* only here free userdef themes... */
- BKE_userdef_free();
-
- U = *bfd->user;
- MEM_freeN(bfd->user);
+ if (bfd) {
+ if (bfd->user) {
+ retval = BKE_READ_FILE_OK_USERPREFS;
+
+ /* only here free userdef themes... */
+ BKE_userdef_free();
+
+ U = *bfd->user;
+ MEM_freeN(bfd->user);
+ }
+ BKE_main_free(bfd->main);
+ MEM_freeN(bfd);
}
- BKE_main_free(bfd->main);
- MEM_freeN(bfd);
return retval;
}
@@ -798,13 +796,16 @@ const char *BKE_undo_get_name(int nr, int *active)
return NULL;
}
-/* saves .blend using undo buffer, returns 1 == success */
-int BKE_undo_save_file(const char *filename)
+/**
+ * Saves .blend using undo buffer.
+ *
+ * \return success.
+ */
+bool BKE_undo_save_file(const char *filename)
{
UndoElem *uel;
MemFileChunk *chunk;
- const int flag = O_BINARY + O_WRONLY + O_CREAT + O_TRUNC + O_EXCL;
- int file;
+ int file, oflags;
if ((U.uiflag & USER_GLOBALUNDO) == 0) {
return 0;
@@ -816,16 +817,21 @@ int BKE_undo_save_file(const char *filename)
return 0;
}
- /* first try create the file, if it exists call without 'O_CREAT',
- * to avoid writing to a symlink - use 'O_EXCL' (CVE-2008-1103) */
- errno = 0;
- file = BLI_open(filename, flag, 0666);
- if (file < 0) {
- if (errno == EEXIST) {
- errno = 0;
- file = BLI_open(filename, flag & ~O_CREAT, 0666);
- }
- }
+ /* note: This is currently used for autosave and 'quit.blend', where _not_ following symlinks is OK,
+ * however if this is ever executed explicitly by the user, we may want to allow writing to symlinks.
+ */
+
+ oflags = O_BINARY | O_WRONLY | O_CREAT | O_TRUNC;
+#ifdef O_NOFOLLOW
+ /* use O_NOFOLLOW to avoid writing to a symlink - use 'O_EXCL' (CVE-2008-1103) */
+ oflags |= O_NOFOLLOW;
+#else
+ /* TODO(sergey): How to deal with symlinks on windows? */
+# ifndef _MSC_VER
+# warning "Symbolic links will be followed on undo save, possibly causing CVE-2008-1103"
+# endif
+#endif
+ file = BLI_open(filename, oflags, 0666);
if (file == -1) {
fprintf(stderr, "Unable to save '%s': %s\n",
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index c34b237f53e..967e89e0dd1 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -38,7 +38,6 @@
#include "BKE_brush.h"
#include "BKE_colortools.h"
#include "BKE_global.h"
-#include "BKE_image.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_paint.h"
@@ -634,15 +633,9 @@ float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br,
rgba[2] = intensity;
rgba[3] = 1.0f;
}
- else {
- if (br->mtex.tex->type == TEX_IMAGE && br->mtex.tex->ima) {
- ImBuf *tex_ibuf = BKE_image_pool_acquire_ibuf(br->mtex.tex->ima, &br->mtex.tex->iuser, pool);
- /* For consistency, sampling always returns color in linear space */
- if (tex_ibuf && tex_ibuf->rect_float == NULL) {
- IMB_colormanagement_colorspace_to_scene_linear_v3(rgba, tex_ibuf->rect_colorspace);
- }
- BKE_image_pool_release_ibuf(br->mtex.tex->ima, tex_ibuf, pool);
- }
+ /* For consistency, sampling always returns color in linear space */
+ else if (ups->do_linear_conversion) {
+ IMB_colormanagement_colorspace_to_scene_linear_v3(rgba, ups->colorspace);
}
return intensity;
diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c
index 7838fac09b5..f85a91b66cb 100644
--- a/source/blender/blenkernel/intern/bvhutils.c
+++ b/source/blender/blenkernel/intern/bvhutils.c
@@ -111,7 +111,7 @@ float nearest_point_in_tri_surface_squared(
B0 = dot_v3v3(diff, e0);
B1 = dot_v3v3(diff, e1);
C = dot_v3v3(diff, diff);
- Det = fabs(A00 * A11 - A01 * A01);
+ Det = fabsf(A00 * A11 - A01 * A01);
S = A01 * B1 - A11 * B0;
T = A01 * B0 - A00 * B1;
@@ -371,7 +371,7 @@ static void mesh_faces_nearest_point(void *userdata, int index, const float co[3
MVert *vert = data->vert;
MFace *face = data->face + index;
- float *t0, *t1, *t2, *t3;
+ const float *t0, *t1, *t2, *t3;
t0 = vert[face->v1].co;
t1 = vert[face->v2].co;
t2 = vert[face->v3].co;
@@ -406,7 +406,7 @@ static void editmesh_faces_nearest_point(void *userdata, int index, const float
BMEditMesh *em = data->em_evil;
const BMLoop **ltri = (const BMLoop **)em->looptris[index];
- float *t0, *t1, *t2;
+ const float *t0, *t1, *t2;
t0 = ltri[0]->v->co;
t1 = ltri[1]->v->co;
t2 = ltri[2]->v->co;
@@ -433,7 +433,7 @@ static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *r
MVert *vert = data->vert;
MFace *face = data->face + index;
- float *t0, *t1, *t2, *t3;
+ const float *t0, *t1, *t2, *t3;
t0 = vert[face->v1].co;
t1 = vert[face->v2].co;
t2 = vert[face->v3].co;
@@ -471,7 +471,7 @@ static void editmesh_faces_spherecast(void *userdata, int index, const BVHTreeRa
BMEditMesh *em = data->em_evil;
const BMLoop **ltri = (const BMLoop **)em->looptris[index];
- float *t0, *t1, *t2;
+ const float *t0, *t1, *t2;
t0 = ltri[0]->v->co;
t1 = ltri[1]->v->co;
t2 = ltri[2]->v->co;
@@ -503,7 +503,7 @@ static void mesh_edges_nearest_point(void *userdata, int index, const float co[3
MEdge *edge = data->edge + index;
float nearest_tmp[3], dist_sq;
- float *t0, *t1;
+ const float *t0, *t1;
t0 = vert[edge->v1].co;
t1 = vert[edge->v2].co;
@@ -519,55 +519,6 @@ static void mesh_edges_nearest_point(void *userdata, int index, const float co[3
}
}
-static MVert *get_dm_vert_data_array(DerivedMesh *dm, bool *allocated)
-{
- CustomData *vert_data = dm->getVertDataLayout(dm);
- MVert *mvert = CustomData_get_layer(vert_data, CD_MVERT);
- *allocated = false;
-
- if (mvert == NULL) {
- mvert = MEM_mallocN(sizeof(MVert) * dm->getNumVerts(dm), "bvh vert data array");
- dm->copyVertArray(dm, mvert);
- *allocated = true;
- }
-
- return mvert;
-}
-
-static MEdge *get_dm_edge_data_array(DerivedMesh *dm, bool *allocated)
-{
- CustomData *edge_data = dm->getEdgeDataLayout(dm);
- MEdge *medge = CustomData_get_layer(edge_data, CD_MEDGE);
- *allocated = false;
-
- if (medge == NULL) {
- medge = MEM_mallocN(sizeof(MEdge) * dm->getNumEdges(dm), "bvh medge data array");
- dm->copyEdgeArray(dm, medge);
- *allocated = true;
- }
-
- return medge;
-}
-
-static MFace *get_dm_tessface_data_array(DerivedMesh *dm, bool *allocated)
-{
- CustomData *tessface_data = dm->getTessFaceDataLayout(dm);
- MFace *mface = CustomData_get_layer(tessface_data, CD_MFACE);
- *allocated = false;
-
- if (mface == NULL) {
- int numTessFaces = dm->getNumTessFaces(dm);
-
- if (numTessFaces > 0) {
- mface = MEM_mallocN(sizeof(MFace) * numTessFaces, "bvh mface data array");
- dm->copyTessFaceArray(dm, mface);
- *allocated = true;
- }
- }
-
- return mface;
-}
-
/*
* BVH builders
*/
@@ -582,7 +533,7 @@ BVHTree *bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *dm, float e
tree = bvhcache_find(&dm->bvhCache, BVHTREE_FROM_VERTICES);
BLI_rw_mutex_unlock(&cache_rwlock);
- vert = get_dm_vert_data_array(dm, &vert_allocated);
+ vert = DM_get_vert_array(dm, &vert_allocated);
/* Not in cache */
if (tree == NULL) {
@@ -629,7 +580,7 @@ BVHTree *bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *dm, float e
data->vert = vert;
data->vert_allocated = vert_allocated;
- data->face = get_dm_tessface_data_array(dm, &data->face_allocated);
+ data->face = DM_get_tessface_array(dm, &data->face_allocated);
data->sphere_radius = epsilon;
}
@@ -657,8 +608,8 @@ BVHTree *bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *dm, float e
BLI_rw_mutex_unlock(&cache_rwlock);
if (em == NULL) {
- vert = get_dm_vert_data_array(dm, &vert_allocated);
- face = get_dm_tessface_data_array(dm, &face_allocated);
+ vert = DM_get_vert_array(dm, &vert_allocated);
+ face = DM_get_tessface_array(dm, &face_allocated);
}
/* Not in cache */
@@ -827,8 +778,8 @@ BVHTree *bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *dm, float e
tree = bvhcache_find(&dm->bvhCache, BVHTREE_FROM_EDGES);
BLI_rw_mutex_unlock(&cache_rwlock);
- vert = get_dm_vert_data_array(dm, &vert_allocated);
- edge = get_dm_edge_data_array(dm, &edge_allocated);
+ vert = DM_get_vert_array(dm, &vert_allocated);
+ edge = DM_get_edge_array(dm, &edge_allocated);
/* Not in cache */
if (tree == NULL) {
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index 32a008c3d33..ba8fe83155e 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -40,7 +40,6 @@
#include "BLI_blenlib.h"
#include "BLI_edgehash.h"
#include "BLI_utildefines.h"
-#include "BLI_scanfill.h"
#include "BKE_pbvh.h"
#include "BKE_cdderivedmesh.h"
@@ -223,24 +222,39 @@ static const MeshElemMap *cdDM_getPolyMap(Object *ob, DerivedMesh *dm)
return cddm->pmap;
}
-static bool can_pbvh_draw(Object *ob, DerivedMesh *dm)
+static bool check_sculpt_object_deformed(Object *object, bool for_construction)
{
- CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
- Mesh *me = ob->data;
- int deformed = 0;
+ bool deformed = false;
- /* active modifiers means extra deformation, which can't be handled correct
+ /* 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 |= ob->sculpt->modifiers_active;
+ * 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;
+}
- /* 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 |= ob->sculpt->kb && (ob->shapeflag & OB_SHAPE_LOCK) == 0;
+static bool can_pbvh_draw(Object *ob, DerivedMesh *dm)
+{
+ CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
+ Mesh *me = ob->data;
+ bool deformed = check_sculpt_object_deformed(ob, false);
- if (deformed)
- return 0;
+ if (deformed) {
+ return false;
+ }
return cddm->mvert == me->mvert || ob->sculpt->kb;
}
@@ -269,7 +283,8 @@ static PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm)
BKE_pbvh_build_bmesh(cddm->pbvh, ob->sculpt->bm,
ob->sculpt->bm_smooth_shading,
- ob->sculpt->bm_log);
+ ob->sculpt->bm_log, ob->sculpt->cd_vert_node_offset,
+ ob->sculpt->cd_face_node_offset);
pbvh_show_diffuse_color_set(cddm->pbvh, ob->sculpt->show_diffuse_color);
}
@@ -279,21 +294,20 @@ 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) {
- SculptSession *ss = ob->sculpt;
Mesh *me = ob->data;
- int deformed = 0;
+ bool deformed;
cddm->pbvh = BKE_pbvh_new();
cddm->pbvh_draw = can_pbvh_draw(ob, dm);
- pbvh_show_diffuse_color_set(cddm->pbvh, ob->sculpt->show_diffuse_color);
-
BKE_mesh_tessface_ensure(me);
BKE_pbvh_build_mesh(cddm->pbvh, me->mface, me->mvert,
me->totface, me->totvert, &me->vdata);
- deformed = ss->modifiers_active || me->key;
+ pbvh_show_diffuse_color_set(cddm->pbvh, ob->sculpt->show_diffuse_color);
+
+ deformed = check_sculpt_object_deformed(ob, true);
if (deformed && ob->derivedDeform) {
DerivedMesh *deformdm = ob->derivedDeform;
@@ -421,7 +435,7 @@ static void cdDM_drawUVEdges(DerivedMesh *dm)
}
}
-static void cdDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges)
+static void cdDM_drawEdges(DerivedMesh *dm, bool drawLooseEdges, bool drawAllEdges)
{
CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
MVert *mvert = cddm->mvert;
@@ -531,22 +545,15 @@ static void cdDM_drawLooseEdges(DerivedMesh *dm)
static void cdDM_drawFacesSolid(DerivedMesh *dm,
float (*partial_redraw_planes)[4],
- int UNUSED(fast), DMSetMaterial setMaterial)
+ bool UNUSED(fast), DMSetMaterial setMaterial)
{
CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
MVert *mvert = cddm->mvert;
MFace *mface = cddm->mface;
- float *nors = dm->getTessFaceDataArray(dm, CD_NORMAL);
+ const float *nors = dm->getTessFaceDataArray(dm, CD_NORMAL);
+ short (*lnors)[4][3] = dm->getTessFaceDataArray(dm, CD_TESSLOOPNORMAL);
int a, glmode = -1, shademodel = -1, matnr = -1, drawCurrentMat = 1;
-#define PASSVERT(index) { \
- if (shademodel == GL_SMOOTH) { \
- short *no = mvert[index].no; \
- glNormal3sv(no); \
- } \
- glVertex3fv(mvert[index].co); \
-} (void)0
-
if (cddm->pbvh && cddm->pbvh_draw) {
if (dm->numTessFaceData) {
float (*face_nors)[3] = CustomData_get_layer(&dm->faceData, CD_NORMAL);
@@ -567,7 +574,7 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm,
new_glmode = mface->v4 ? GL_QUADS : GL_TRIANGLES;
new_matnr = mface->mat_nr + 1;
- new_shademodel = (mface->flag & ME_SMOOTH) ? GL_SMOOTH : GL_FLAT;
+ new_shademodel = (lnors || (mface->flag & ME_SMOOTH)) ? GL_SMOOTH : GL_FLAT;
if (new_glmode != glmode || new_matnr != matnr || new_shademodel != shademodel) {
glEnd();
@@ -579,7 +586,19 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm,
}
if (drawCurrentMat) {
- if (shademodel == GL_FLAT) {
+ if (lnors) {
+ glNormal3sv((const GLshort *)lnors[0][0]);
+ glVertex3fv(mvert[mface->v1].co);
+ glNormal3sv((const GLshort *)lnors[0][1]);
+ glVertex3fv(mvert[mface->v2].co);
+ glNormal3sv((const GLshort *)lnors[0][2]);
+ glVertex3fv(mvert[mface->v3].co);
+ if (mface->v4) {
+ glNormal3sv((const GLshort *)lnors[0][3]);
+ glVertex3fv(mvert[mface->v4].co);
+ }
+ }
+ else if (shademodel == GL_FLAT) {
if (nors) {
glNormal3fv(nors);
}
@@ -594,17 +613,31 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm,
}
glNormal3fv(nor);
}
+ glVertex3fv(mvert[mface->v1].co);
+ glVertex3fv(mvert[mface->v2].co);
+ glVertex3fv(mvert[mface->v3].co);
+ if (mface->v4) {
+ glVertex3fv(mvert[mface->v4].co);
+ }
}
-
- PASSVERT(mface->v1);
- PASSVERT(mface->v2);
- PASSVERT(mface->v3);
- if (mface->v4) {
- PASSVERT(mface->v4);
+ else { /* shademodel == GL_SMOOTH */
+ glNormal3sv(mvert[mface->v1].no);
+ glVertex3fv(mvert[mface->v1].co);
+ glNormal3sv(mvert[mface->v2].no);
+ glVertex3fv(mvert[mface->v2].co);
+ glNormal3sv(mvert[mface->v3].no);
+ glVertex3fv(mvert[mface->v3].co);
+ if (mface->v4) {
+ glNormal3sv(mvert[mface->v4].no);
+ glVertex3fv(mvert[mface->v4].co);
+ }
}
}
- if (nors) nors += 3;
+ if (nors)
+ nors += 3;
+ if (lnors)
+ lnors++;
}
glEnd();
}
@@ -623,7 +656,6 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm,
GPU_buffer_unbind();
}
-#undef PASSVERT
glShadeModel(GL_FLAT);
}
@@ -636,7 +668,8 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
MVert *mv = cddm->mvert;
MFace *mf = DM_get_tessface_data_layer(dm, CD_MFACE);
- float *nors = dm->getTessFaceDataArray(dm, CD_NORMAL);
+ const float *nors = dm->getTessFaceDataArray(dm, CD_NORMAL);
+ short (*lnors)[4][3] = dm->getTessFaceDataArray(dm, CD_TESSLOOPNORMAL);
MTFace *tf = DM_get_tessface_data_layer(dm, CD_MTFACE);
MCol *mcol;
int i, orig;
@@ -722,7 +755,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
if (draw_option != DM_DRAW_OPTION_NO_MCOL && mcol)
cp = (unsigned char *) &mcol[i * 4];
- if (!(mf->flag & ME_SMOOTH)) {
+ if (!(lnors || (mf->flag & ME_SMOOTH))) {
if (nors) {
glNormal3fv(nors);
}
@@ -742,32 +775,39 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
if (tf) glTexCoord2fv(tf[i].uv[0]);
if (cp) glColor3ub(cp[3], cp[2], cp[1]);
mvert = &mv[mf->v1];
- if (mf->flag & ME_SMOOTH) glNormal3sv(mvert->no);
+ if (lnors) glNormal3sv((const GLshort *)lnors[0][0]);
+ else if (mf->flag & ME_SMOOTH) glNormal3sv(mvert->no);
glVertex3fv(mvert->co);
-
+
if (tf) glTexCoord2fv(tf[i].uv[1]);
if (cp) glColor3ub(cp[7], cp[6], cp[5]);
mvert = &mv[mf->v2];
- if (mf->flag & ME_SMOOTH) glNormal3sv(mvert->no);
+ if (lnors) glNormal3sv((const GLshort *)lnors[0][1]);
+ else if (mf->flag & ME_SMOOTH) glNormal3sv(mvert->no);
glVertex3fv(mvert->co);
if (tf) glTexCoord2fv(tf[i].uv[2]);
if (cp) glColor3ub(cp[11], cp[10], cp[9]);
mvert = &mv[mf->v3];
- if (mf->flag & ME_SMOOTH) glNormal3sv(mvert->no);
+ if (lnors) glNormal3sv((const GLshort *)lnors[0][2]);
+ else if (mf->flag & ME_SMOOTH) glNormal3sv(mvert->no);
glVertex3fv(mvert->co);
if (mf->v4) {
if (tf) glTexCoord2fv(tf[i].uv[3]);
if (cp) glColor3ub(cp[15], cp[14], cp[13]);
mvert = &mv[mf->v4];
- if (mf->flag & ME_SMOOTH) glNormal3sv(mvert->no);
+ if (lnors) glNormal3sv((const GLshort *)lnors[0][3]);
+ else if (mf->flag & ME_SMOOTH) glNormal3sv(mvert->no);
glVertex3fv(mvert->co);
}
glEnd();
}
- if (nors) nors += 3;
+ if (nors)
+ nors += 3;
+ if (lnors)
+ lnors++;
}
}
else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
@@ -864,7 +904,8 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm,
MVert *mv = cddm->mvert;
MFace *mf = cddm->mface;
MCol *mcol;
- float *nors = DM_get_tessface_data_layer(dm, CD_NORMAL);
+ const float *nors = DM_get_tessface_data_layer(dm, CD_NORMAL);
+ short (*lnors)[4][3] = dm->getTessFaceDataArray(dm, CD_TESSLOOPNORMAL);
int colType, useColors = flag & DM_DRAW_USE_COLORS;
int i, orig;
@@ -895,7 +936,7 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm,
if (GPU_buffer_legacy(dm) || G.f & G_BACKBUFSEL) {
DEBUG_VBO("Using legacy code. cdDM_drawMappedFaces\n");
for (i = 0; i < dm->numTessFaceData; i++, mf++) {
- int drawSmooth = (flag & DM_DRAW_ALWAYS_SMOOTH) ? 1 : (mf->flag & ME_SMOOTH);
+ int drawSmooth = ((flag & DM_DRAW_ALWAYS_SMOOTH) || lnors) ? 1 : (mf->flag & ME_SMOOTH);
DMDrawOption draw_option = DM_DRAW_OPTION_NORMAL;
orig = (index_mf_to_mpoly) ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, i) : i;
@@ -921,7 +962,23 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm,
glShadeModel(GL_SMOOTH);
glBegin(mf->v4 ? GL_QUADS : GL_TRIANGLES);
- if (!drawSmooth) {
+ if (lnors) {
+ if (cp) glColor3ub(cp[3], cp[2], cp[1]);
+ glNormal3sv((const GLshort *)lnors[0][0]);
+ glVertex3fv(mv[mf->v1].co);
+ if (cp) glColor3ub(cp[7], cp[6], cp[5]);
+ glNormal3sv((const GLshort *)lnors[0][1]);
+ glVertex3fv(mv[mf->v2].co);
+ if (cp) glColor3ub(cp[11], cp[10], cp[9]);
+ glNormal3sv((const GLshort *)lnors[0][2]);
+ glVertex3fv(mv[mf->v3].co);
+ if (mf->v4) {
+ if (cp) glColor3ub(cp[15], cp[14], cp[13]);
+ glNormal3sv((const GLshort *)lnors[0][3]);
+ glVertex3fv(mv[mf->v4].co);
+ }
+ }
+ else if (!drawSmooth) {
if (nors) {
glNormal3fv(nors);
}
@@ -970,7 +1027,10 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm,
glDisable(GL_POLYGON_STIPPLE);
}
- if (nors) nors += 3;
+ if (nors)
+ nors += 3;
+ if (lnors)
+ lnors++;
}
}
else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
@@ -1062,7 +1122,8 @@ static void cdDM_drawMappedFacesTex(DerivedMesh *dm,
cdDM_drawFacesTex_common(dm, NULL, setDrawOptions, compareDrawOptions, userData);
}
-static void cddm_draw_attrib_vertex(DMVertexAttribs *attribs, MVert *mvert, int a, int index, int vert, int smoothnormal)
+static void cddm_draw_attrib_vertex(DMVertexAttribs *attribs, MVert *mvert, int a, int index, int vert,
+ short (*lnor)[3], int smoothnormal)
{
const float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
int b;
@@ -1119,9 +1180,13 @@ static void cddm_draw_attrib_vertex(DMVertexAttribs *attribs, MVert *mvert, int
}
/* vertex normal */
- if (smoothnormal)
+ if (lnor) {
+ glNormal3sv((const GLshort *)lnor);
+ }
+ else if (smoothnormal) {
glNormal3sv(mvert[index].no);
-
+ }
+
/* vertex coordinate */
glVertex3fv(mvert[index].co);
}
@@ -1138,6 +1203,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
MFace *mface = cddm->mface;
/* MTFace *tf = dm->getTessFaceDataArray(dm, CD_MTFACE); */ /* UNUSED */
float (*nors)[3] = dm->getTessFaceDataArray(dm, CD_NORMAL);
+ short (*lnors)[4][3] = dm->getTessFaceDataArray(dm, CD_TESSLOOPNORMAL);
int a, b, matnr, new_matnr;
bool do_draw;
int orig;
@@ -1176,7 +1242,8 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
glBegin(GL_QUADS);
for (a = 0; a < dm->numTessFaceData; a++, mface++) {
- const int smoothnormal = (mface->flag & ME_SMOOTH);
+ const int smoothnormal = lnors || (mface->flag & ME_SMOOTH);
+ short (*ln1)[3] = NULL, (*ln2)[3] = NULL, (*ln3)[3] = NULL, (*ln4)[3] = NULL;
new_matnr = mface->mat_nr + 1;
if (new_matnr != matnr) {
@@ -1222,20 +1289,28 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
}
}
- cddm_draw_attrib_vertex(&attribs, mvert, a, mface->v1, 0, smoothnormal);
- cddm_draw_attrib_vertex(&attribs, mvert, a, mface->v2, 1, smoothnormal);
- cddm_draw_attrib_vertex(&attribs, mvert, a, mface->v3, 2, smoothnormal);
+ if (lnors) {
+ ln1 = &lnors[0][0];
+ ln2 = &lnors[0][1];
+ ln3 = &lnors[0][2];
+ ln4 = &lnors[0][3];
+ lnors++;
+ }
+
+ cddm_draw_attrib_vertex(&attribs, mvert, a, mface->v1, 0, ln1, smoothnormal);
+ cddm_draw_attrib_vertex(&attribs, mvert, a, mface->v2, 1, ln2, smoothnormal);
+ cddm_draw_attrib_vertex(&attribs, mvert, a, mface->v3, 2, ln3, smoothnormal);
if (mface->v4)
- cddm_draw_attrib_vertex(&attribs, mvert, a, mface->v4, 3, smoothnormal);
+ cddm_draw_attrib_vertex(&attribs, mvert, a, mface->v4, 3, ln4, smoothnormal);
else
- cddm_draw_attrib_vertex(&attribs, mvert, a, mface->v3, 2, smoothnormal);
+ cddm_draw_attrib_vertex(&attribs, mvert, a, mface->v3, 2, ln3, smoothnormal);
}
glEnd();
}
else {
GPUBuffer *buffer = NULL;
- char *varray = NULL;
+ const char *varray = NULL;
int numdata = 0, elementsize = 0, offset;
int start = 0, numfaces = 0 /* , prevdraw = 0 */ /* UNUSED */, curface = 0;
int i;
@@ -1373,7 +1448,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
}
}
if (attribs.tottang && attribs.tang.array) {
- float *tang = attribs.tang.array[a * 4 + 0];
+ const float *tang = attribs.tang.array[a * 4 + 0];
copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset], tang);
tang = attribs.tang.array[a * 4 + 1];
copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset + elementsize], tang);
@@ -1418,7 +1493,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
}
}
if (attribs.tottang && attribs.tang.array) {
- float *tang = attribs.tang.array[a * 4 + 2];
+ const float *tang = attribs.tang.array[a * 4 + 2];
copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset], tang);
tang = attribs.tang.array[a * 4 + 3];
copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset + elementsize], tang);
@@ -1456,7 +1531,7 @@ static void cdDM_drawFacesGLSL(DerivedMesh *dm, DMSetMaterial setMaterial)
}
static void cdDM_drawMappedFacesMat(DerivedMesh *dm,
- void (*setMaterial)(void *userData, int, void *attribs),
+ void (*setMaterial)(void *userData, int matnr, void *attribs),
bool (*setFace)(void *userData, int index), void *userData)
{
CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
@@ -1465,6 +1540,7 @@ static void cdDM_drawMappedFacesMat(DerivedMesh *dm,
MVert *mvert = cddm->mvert;
MFace *mf = cddm->mface;
float (*nors)[3] = dm->getTessFaceDataArray(dm, CD_NORMAL);
+ short (*lnors)[4][3] = dm->getTessFaceDataArray(dm, CD_TESSLOOPNORMAL);
int a, matnr, new_matnr;
int orig;
@@ -1499,7 +1575,8 @@ static void cdDM_drawMappedFacesMat(DerivedMesh *dm,
glBegin(GL_QUADS);
for (a = 0; a < dm->numTessFaceData; a++, mf++) {
- const int smoothnormal = (mf->flag & ME_SMOOTH);
+ const int smoothnormal = lnors || (mf->flag & ME_SMOOTH);
+ short (*ln1)[3] = NULL, (*ln2)[3] = NULL, (*ln3)[3] = NULL, (*ln4)[3] = NULL;
/* material */
new_matnr = mf->mat_nr + 1;
@@ -1539,15 +1616,23 @@ static void cdDM_drawMappedFacesMat(DerivedMesh *dm,
}
}
+ if (lnors) {
+ ln1 = &lnors[0][0];
+ ln2 = &lnors[0][1];
+ ln3 = &lnors[0][2];
+ ln4 = &lnors[0][3];
+ lnors++;
+ }
+
/* vertices */
- cddm_draw_attrib_vertex(&attribs, mvert, a, mf->v1, 0, smoothnormal);
- cddm_draw_attrib_vertex(&attribs, mvert, a, mf->v2, 1, smoothnormal);
- cddm_draw_attrib_vertex(&attribs, mvert, a, mf->v3, 2, smoothnormal);
+ cddm_draw_attrib_vertex(&attribs, mvert, a, mf->v1, 0, ln1, smoothnormal);
+ cddm_draw_attrib_vertex(&attribs, mvert, a, mf->v2, 1, ln2, smoothnormal);
+ cddm_draw_attrib_vertex(&attribs, mvert, a, mf->v3, 2, ln3, smoothnormal);
if (mf->v4)
- cddm_draw_attrib_vertex(&attribs, mvert, a, mf->v4, 3, smoothnormal);
+ cddm_draw_attrib_vertex(&attribs, mvert, a, mf->v4, 3, ln4, smoothnormal);
else
- cddm_draw_attrib_vertex(&attribs, mvert, a, mf->v3, 2, smoothnormal);
+ cddm_draw_attrib_vertex(&attribs, mvert, a, mf->v3, 2, ln3, smoothnormal);
}
glEnd();
@@ -1585,7 +1670,7 @@ static void cdDM_foreachMappedVert(
DMForeachFlag flag)
{
MVert *mv = CDDM_get_verts(dm);
- int *index = DM_get_vert_data_layer(dm, CD_ORIGINDEX);
+ const int *index = DM_get_vert_data_layer(dm, CD_ORIGINDEX);
int i;
if (index) {
@@ -1625,6 +1710,35 @@ static void cdDM_foreachMappedEdge(
}
}
+static void cdDM_foreachMappedLoop(
+ DerivedMesh *dm,
+ void (*func)(void *userData, int vertex_index, int face_index, const float co[3], const float no[3]),
+ void *userData,
+ DMForeachFlag flag)
+{
+ /* We can't use dm->getLoopDataLayout(dm) here, we want to always access dm->loopData, EditDerivedBMesh would
+ * return loop data from bmesh itself. */
+ const float (*lnors)[3] = (flag & DM_FOREACH_USE_NORMAL) ? DM_get_loop_data_layer(dm, CD_NORMAL) : NULL;
+
+ const MVert *mv = CDDM_get_verts(dm);
+ const MLoop *ml = CDDM_get_loops(dm);
+ const MPoly *mp = CDDM_get_polys(dm);
+ const int *v_index = DM_get_vert_data_layer(dm, CD_ORIGINDEX);
+ const int *f_index = DM_get_poly_data_layer(dm, CD_ORIGINDEX);
+ int p_idx, i;
+
+ for (p_idx = 0; p_idx < dm->numPolyData; ++p_idx, ++mp) {
+ for (i = 0; i < mp->totloop; ++i, ++ml) {
+ const int v_idx = v_index ? v_index[ml->v] : ml->v;
+ const int f_idx = f_index ? f_index[p_idx] : p_idx;
+ const float *no = lnors ? *lnors++ : NULL;
+ if (!ELEM(ORIGINDEX_NONE, v_idx, f_idx)) {
+ func(userData, v_idx, f_idx, mv[ml->v].co, no);
+ }
+ }
+ }
+}
+
static void cdDM_foreachMappedFaceCenter(
DerivedMesh *dm,
void (*func)(void *userData, int index, const float cent[3], const float no[3]),
@@ -1738,6 +1852,7 @@ static CDDerivedMesh *cdDM_create(const char *desc)
dm->getTessFaceDataArray = DM_get_tessface_data_layer;
dm->calcNormals = CDDM_calc_normals;
+ dm->calcLoopNormals = CDDM_calc_loop_normals;
dm->recalcTessellation = CDDM_recalc_tessellation;
dm->getVertCos = cdDM_getVertCos;
@@ -1764,6 +1879,7 @@ static CDDerivedMesh *cdDM_create(const char *desc)
dm->foreachMappedVert = cdDM_foreachMappedVert;
dm->foreachMappedEdge = cdDM_foreachMappedEdge;
+ dm->foreachMappedLoop = cdDM_foreachMappedLoop;
dm->foreachMappedFaceCenter = cdDM_foreachMappedFaceCenter;
dm->release = cdDM_release;
@@ -2096,6 +2212,8 @@ static DerivedMesh *cddm_from_bmesh_ex(struct BMesh *bm, const bool use_mdisps,
mloop->e = BM_elem_index_get(l_iter->e);
CustomData_from_bmesh_block(&bm->ldata, &dm->loopData, l_iter->head.data, j);
+ BM_elem_index_set(l_iter, j); /* set_inline */
+
j++;
mloop++;
} while ((l_iter = l_iter->next) != l_first);
@@ -2104,7 +2222,7 @@ static DerivedMesh *cddm_from_bmesh_ex(struct BMesh *bm, const bool use_mdisps,
if (add_orig) *index++ = i;
}
- bm->elem_index_dirty &= ~BM_FACE;
+ bm->elem_index_dirty &= ~(BM_FACE | BM_LOOP);
dm->cd_flag = BM_mesh_cd_flag_from_bmesh(bm);
@@ -2289,8 +2407,7 @@ void CDDM_calc_normals_mapping_ex(DerivedMesh *dm, const bool only_face_normals)
CustomData_free_layers(&dm->faceData, CD_NORMAL, dm->numTessFaceData);
}
-
- face_nors = MEM_mallocN(sizeof(float) * 3 * dm->numTessFaceData, "face_nors");
+ face_nors = MEM_mallocN(sizeof(*face_nors) * dm->numTessFaceData, "face_nors");
/* calculate face normals */
BKE_mesh_calc_normals_mapping_ex(cddm->mvert, dm->numVertData, CDDM_get_loops(dm), CDDM_get_polys(dm),
@@ -2298,8 +2415,7 @@ void CDDM_calc_normals_mapping_ex(DerivedMesh *dm, const bool only_face_normals)
CustomData_get_layer(&dm->faceData, CD_ORIGINDEX), face_nors,
only_face_normals);
- CustomData_add_layer(&dm->faceData, CD_NORMAL, CD_ASSIGN,
- face_nors, dm->numTessFaceData);
+ CustomData_add_layer(&dm->faceData, CD_NORMAL, CD_ASSIGN, face_nors, dm->numTessFaceData);
cddm->dm.dirty &= ~DM_DIRTY_NORMALS;
}
@@ -2353,6 +2469,48 @@ void CDDM_calc_normals(DerivedMesh *dm)
#endif
+void CDDM_calc_loop_normals(DerivedMesh *dm, const float split_angle)
+{
+ MVert *mverts = dm->getVertArray(dm);
+ MEdge *medges = dm->getEdgeArray(dm);
+ MLoop *mloops = dm->getLoopArray(dm);
+ MPoly *mpolys = dm->getPolyArray(dm);
+
+ CustomData *ldata, *pdata;
+
+ float (*lnors)[3];
+ float (*pnors)[3];
+
+ const int numVerts = dm->getNumVerts(dm);
+ const int numEdges = dm->getNumEdges(dm);
+ const int numLoops = dm->getNumLoops(dm);
+ const int numPolys = dm->getNumPolys(dm);
+
+ ldata = dm->getLoopDataLayout(dm);
+ if (CustomData_has_layer(ldata, CD_NORMAL)) {
+ lnors = CustomData_get_layer(ldata, CD_NORMAL);
+ }
+ else {
+ lnors = CustomData_add_layer(ldata, CD_NORMAL, CD_CALLOC, NULL, numLoops);
+ }
+
+ /* Compute poly (always needed) and vert normals. */
+ /* Note we can't use DM_ensure_normals, since it won't keep computed poly nors... */
+ pdata = dm->getPolyDataLayout(dm);
+ pnors = CustomData_get_layer(pdata, CD_NORMAL);
+ if (!pnors) {
+ pnors = CustomData_add_layer(pdata, CD_NORMAL, CD_CALLOC, NULL, numPolys);
+ }
+ BKE_mesh_calc_normals_poly(mverts, numVerts, mloops, mpolys, numLoops, numPolys, pnors,
+ (dm->dirty & DM_DIRTY_NORMALS) ? false : true);
+
+ dm->dirty &= ~DM_DIRTY_NORMALS;
+
+ BKE_mesh_normals_loop_split(mverts, numVerts, medges, numEdges, mloops, lnors, numLoops,
+ mpolys, pnors, numPolys, split_angle);
+}
+
+
void CDDM_calc_normals_tessface(DerivedMesh *dm)
{
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
@@ -2633,33 +2791,28 @@ void CDDM_calc_edges_tessface(DerivedMesh *dm)
{
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
CustomData edgeData;
- EdgeHashIterator *ehi;
+ EdgeSetIterator *ehi;
MFace *mf = cddm->mface;
MEdge *med;
- EdgeHash *eh;
+ EdgeSet *eh;
int i, *index, numEdges, numFaces = dm->numTessFaceData;
- eh = BLI_edgehash_new_ex(__func__, BLI_EDGEHASH_SIZE_GUESS_FROM_POLYS(numFaces));
+ eh = BLI_edgeset_new_ex(__func__, BLI_EDGEHASH_SIZE_GUESS_FROM_POLYS(numFaces));
for (i = 0; i < numFaces; i++, mf++) {
- if (!BLI_edgehash_haskey(eh, mf->v1, mf->v2))
- BLI_edgehash_insert(eh, mf->v1, mf->v2, NULL);
- if (!BLI_edgehash_haskey(eh, mf->v2, mf->v3))
- BLI_edgehash_insert(eh, mf->v2, mf->v3, NULL);
+ BLI_edgeset_reinsert(eh, mf->v1, mf->v2);
+ BLI_edgeset_reinsert(eh, mf->v2, mf->v3);
if (mf->v4) {
- if (!BLI_edgehash_haskey(eh, mf->v3, mf->v4))
- BLI_edgehash_insert(eh, mf->v3, mf->v4, NULL);
- if (!BLI_edgehash_haskey(eh, mf->v4, mf->v1))
- BLI_edgehash_insert(eh, mf->v4, mf->v1, NULL);
+ BLI_edgeset_reinsert(eh, mf->v3, mf->v4);
+ BLI_edgeset_reinsert(eh, mf->v4, mf->v1);
}
else {
- if (!BLI_edgehash_haskey(eh, mf->v3, mf->v1))
- BLI_edgehash_insert(eh, mf->v3, mf->v1, NULL);
+ BLI_edgeset_reinsert(eh, mf->v3, mf->v1);
}
}
- numEdges = BLI_edgehash_size(eh);
+ numEdges = BLI_edgeset_size(eh);
/* write new edges into a temporary CustomData */
CustomData_reset(&edgeData);
@@ -2669,16 +2822,16 @@ void CDDM_calc_edges_tessface(DerivedMesh *dm)
med = CustomData_get_layer(&edgeData, CD_MEDGE);
index = CustomData_get_layer(&edgeData, CD_ORIGINDEX);
- for (ehi = BLI_edgehashIterator_new(eh), i = 0;
- BLI_edgehashIterator_isDone(ehi) == false;
- BLI_edgehashIterator_step(ehi), i++, med++, index++)
+ for (ehi = BLI_edgesetIterator_new(eh), i = 0;
+ BLI_edgesetIterator_isDone(ehi) == false;
+ BLI_edgesetIterator_step(ehi), i++, med++, index++)
{
- BLI_edgehashIterator_getKey(ehi, &med->v1, &med->v2);
+ BLI_edgesetIterator_getKey(ehi, &med->v1, &med->v2);
med->flag = ME_EDGEDRAW | ME_EDGERENDER;
*index = ORIGINDEX_NONE;
}
- BLI_edgehashIterator_free(ehi);
+ BLI_edgesetIterator_free(ehi);
/* free old CustomData and assign new one */
CustomData_free(&dm->edgeData, dm->numEdgeData);
@@ -2687,7 +2840,7 @@ void CDDM_calc_edges_tessface(DerivedMesh *dm)
cddm->medge = CustomData_get_layer(&dm->edgeData, CD_MEDGE);
- BLI_edgehash_free(eh, NULL);
+ BLI_edgeset_free(eh);
}
/* warning, this uses existing edges but CDDM_calc_edges_tessface() doesn't */
@@ -2702,7 +2855,7 @@ void CDDM_calc_edges(DerivedMesh *dm)
EdgeHash *eh;
unsigned int eh_reserve;
int v1, v2;
- int *eindex;
+ const int *eindex;
int i, j, *index;
const int numFaces = dm->numPolyData;
const int numLoops = dm->numLoopData;
@@ -2724,9 +2877,7 @@ void CDDM_calc_edges(DerivedMesh *dm)
for (j = 0; j < mp->totloop; j++, ml++) {
v1 = ml->v;
v2 = ME_POLY_LOOP_NEXT(cddm->mloop, mp, j)->v;
- if (!BLI_edgehash_haskey(eh, v1, v2)) {
- BLI_edgehash_insert(eh, v1, v2, NULL);
- }
+ BLI_edgehash_reinsert(eh, v1, v2, NULL);
}
}
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index f7e522811fa..cedd9eae597 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -34,7 +34,6 @@
#include "DNA_cloth_types.h"
#include "DNA_group_types.h"
-#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
#include "DNA_object_force.h"
#include "DNA_scene_types.h"
@@ -44,16 +43,9 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_edgehash.h"
-#include "BLI_ghash.h"
-#include "BLI_memarena.h"
-#include "BLI_rand.h"
-#include "BKE_DerivedMesh.h"
#include "BKE_cloth.h"
-#include "BKE_global.h"
-#include "BKE_mesh.h"
#include "BKE_modifier.h"
-#include "BKE_object.h"
#include "BKE_scene.h"
#ifdef WITH_BULLET
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index 75d24fa3a49..c6d07a959d1 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -47,7 +47,6 @@
#include "BKE_colortools.h"
#include "BKE_curve.h"
#include "BKE_fcurve.h"
-#include "BKE_paint.h"
#include "IMB_colormanagement.h"
@@ -961,7 +960,7 @@ void BKE_histogram_update_sample_line(Histogram *hist, ImBuf *ibuf, const ColorM
const ColorManagedDisplaySettings *display_settings)
{
int i, x, y;
- float *fp;
+ const float *fp;
float rgb[3];
unsigned char *cp;
@@ -1024,7 +1023,7 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, const ColorManagedViewSettings *
int x, y, c;
unsigned int nl, na, nr, ng, nb;
double divl, diva, divr, divg, divb;
- float *rf = NULL;
+ const float *rf = NULL;
unsigned char *rc = NULL;
unsigned int *bin_lum, *bin_r, *bin_g, *bin_b, *bin_a;
int savedlines, saveline;
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 7ec00352853..52cfa92ceaf 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -46,18 +46,15 @@
#include "BLF_translation.h"
#include "DNA_armature_types.h"
-#include "DNA_camera_types.h"
#include "DNA_constraint_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "DNA_action_types.h"
#include "DNA_curve_types.h"
-#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_lattice_types.h"
#include "DNA_scene_types.h"
-#include "DNA_text_types.h"
#include "DNA_tracking_types.h"
#include "DNA_movieclip_types.h"
@@ -65,7 +62,6 @@
#include "BKE_action.h"
#include "BKE_anim.h" /* for the curve calculation part */
#include "BKE_armature.h"
-#include "BKE_blender.h"
#include "BKE_bvhutils.h"
#include "BKE_camera.h"
#include "BKE_constraint.h"
@@ -75,11 +71,9 @@
#include "BKE_DerivedMesh.h" /* for geometry targets */
#include "BKE_cdderivedmesh.h" /* for geometry targets */
#include "BKE_object.h"
-#include "BKE_ipo.h"
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_idprop.h"
-#include "BKE_mesh.h"
#include "BKE_shrinkwrap.h"
#include "BKE_editmesh.h"
#include "BKE_tracking.h"
@@ -89,6 +83,12 @@
# include "BPY_extern.h"
#endif
+/* ---------------------------------------------------------------------------- */
+/* Useful macros for testing various common flag combinations */
+
+/* Constraint Target Macros */
+#define VALID_CONS_TARGET(ct) ((ct) && (ct->tar))
+
/* Workaround for cyclic depenndnecy with curves.
* In such case curve_cache might not be ready yet,
*/
@@ -103,7 +103,7 @@
/* -------------- Naming -------------- */
/* Find the first available, non-duplicate name for a given constraint */
-void BKE_unique_constraint_name(bConstraint *con, ListBase *list)
+void BKE_constraint_unique_name(bConstraint *con, ListBase *list)
{
BLI_uniquename(list, con, DATA_("Const"), '.', offsetof(bConstraint, name), sizeof(con->name));
}
@@ -454,7 +454,7 @@ static void contarget_get_lattice_mat(Object *ob, const char *substring, float m
Lattice *lt = (Lattice *)ob->data;
DispList *dl = ob->curve_cache ? BKE_displist_find(&ob->curve_cache->disp, DL_VERTS) : NULL;
- float *co = dl ? dl->verts : NULL;
+ const float *co = dl ? dl->verts : NULL;
BPoint *bp = lt->def;
MDeformVert *dv = lt->dvert;
@@ -665,11 +665,11 @@ static void default_get_tarmat(bConstraint *con, bConstraintOb *UNUSED(cob), bCo
* (Hopefully all compilers will be happy with the lines with just a space on them. Those are
* really just to help this code easier to read)
*/
-#define SINGLETARGET_FLUSH_TARS(con, datatar, datasubtarget, ct, list, nocopy) \
+#define SINGLETARGET_FLUSH_TARS(con, datatar, datasubtarget, ct, list, no_copy) \
{ \
if (ct) { \
bConstraintTarget *ctn = ct->next; \
- if (nocopy == 0) { \
+ if (no_copy == 0) { \
datatar = ct->tar; \
BLI_strncpy(datasubtarget, ct->subtarget, sizeof(datasubtarget)); \
con->tarspace = (char)ct->space; \
@@ -686,11 +686,11 @@ static void default_get_tarmat(bConstraint *con, bConstraintOb *UNUSED(cob), bCo
* (Hopefully all compilers will be happy with the lines with just a space on them. Those are
* really just to help this code easier to read)
*/
-#define SINGLETARGETNS_FLUSH_TARS(con, datatar, ct, list, nocopy) \
+#define SINGLETARGETNS_FLUSH_TARS(con, datatar, ct, list, no_copy) \
{ \
if (ct) { \
bConstraintTarget *ctn = ct->next; \
- if (nocopy == 0) { \
+ if (no_copy == 0) { \
datatar = ct->tar; \
con->tarspace = (char)ct->space; \
} \
@@ -735,14 +735,14 @@ static int childof_get_tars(bConstraint *con, ListBase *list)
return 0;
}
-static void childof_flush_tars(bConstraint *con, ListBase *list, short nocopy)
+static void childof_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
{
if (con && list) {
bChildOfConstraint *data = con->data;
bConstraintTarget *ct = list->first;
/* the following macro is used for all standard single-target constraints */
- SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
+ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, no_copy);
}
}
@@ -870,14 +870,14 @@ static int trackto_get_tars(bConstraint *con, ListBase *list)
return 0;
}
-static void trackto_flush_tars(bConstraint *con, ListBase *list, short nocopy)
+static void trackto_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
{
if (con && list) {
bTrackToConstraint *data = con->data;
bConstraintTarget *ct = list->first;
/* the following macro is used for all standard single-target constraints */
- SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
+ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, no_copy);
}
}
@@ -1052,15 +1052,15 @@ static int kinematic_get_tars(bConstraint *con, ListBase *list)
return 0;
}
-static void kinematic_flush_tars(bConstraint *con, ListBase *list, short nocopy)
+static void kinematic_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
{
if (con && list) {
bKinematicConstraint *data = con->data;
bConstraintTarget *ct = list->first;
/* the following macro is used for all standard single-target constraints */
- SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
- SINGLETARGET_FLUSH_TARS(con, data->poletar, data->polesubtarget, ct, list, nocopy);
+ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, no_copy);
+ SINGLETARGET_FLUSH_TARS(con, data->poletar, data->polesubtarget, ct, list, no_copy);
}
}
@@ -1140,14 +1140,14 @@ static int followpath_get_tars(bConstraint *con, ListBase *list)
return 0;
}
-static void followpath_flush_tars(bConstraint *con, ListBase *list, short nocopy)
+static void followpath_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
{
if (con && list) {
bFollowPathConstraint *data = con->data;
bConstraintTarget *ct = list->first;
/* the following macro is used for all standard single-target constraints */
- SINGLETARGETNS_FLUSH_TARS(con, data->tar, ct, list, nocopy);
+ SINGLETARGETNS_FLUSH_TARS(con, data->tar, ct, list, no_copy);
}
}
@@ -1488,14 +1488,14 @@ static int loclike_get_tars(bConstraint *con, ListBase *list)
return 0;
}
-static void loclike_flush_tars(bConstraint *con, ListBase *list, short nocopy)
+static void loclike_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
{
if (con && list) {
bLocateLikeConstraint *data = con->data;
bConstraintTarget *ct = list->first;
/* the following macro is used for all standard single-target constraints */
- SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
+ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, no_copy);
}
}
@@ -1578,14 +1578,14 @@ static int rotlike_get_tars(bConstraint *con, ListBase *list)
return 0;
}
-static void rotlike_flush_tars(bConstraint *con, ListBase *list, short nocopy)
+static void rotlike_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
{
if (con && list) {
bRotateLikeConstraint *data = con->data;
bConstraintTarget *ct = list->first;
/* the following macro is used for all standard single-target constraints */
- SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
+ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, no_copy);
}
}
@@ -1690,14 +1690,14 @@ static int sizelike_get_tars(bConstraint *con, ListBase *list)
return 0;
}
-static void sizelike_flush_tars(bConstraint *con, ListBase *list, short nocopy)
+static void sizelike_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
{
if (con && list) {
bSizeLikeConstraint *data = con->data;
bConstraintTarget *ct = list->first;
/* the following macro is used for all standard single-target constraints */
- SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
+ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, no_copy);
}
}
@@ -1779,14 +1779,14 @@ static int translike_get_tars(bConstraint *con, ListBase *list)
return 0;
}
-static void translike_flush_tars(bConstraint *con, ListBase *list, short nocopy)
+static void translike_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
{
if (con && list) {
bTransLikeConstraint *data = con->data;
bConstraintTarget *ct = list->first;
/* the following macro is used for all standard single-target constraints */
- SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
+ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, no_copy);
}
}
@@ -2038,14 +2038,14 @@ static int actcon_get_tars(bConstraint *con, ListBase *list)
return 0;
}
-static void actcon_flush_tars(bConstraint *con, ListBase *list, short nocopy)
+static void actcon_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
{
if (con && list) {
bActionConstraint *data = con->data;
bConstraintTarget *ct = list->first;
/* the following macro is used for all standard single-target constraints */
- SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
+ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, no_copy);
}
}
@@ -2202,14 +2202,14 @@ static int locktrack_get_tars(bConstraint *con, ListBase *list)
return 0;
}
-static void locktrack_flush_tars(bConstraint *con, ListBase *list, short nocopy)
+static void locktrack_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
{
if (con && list) {
bLockTrackConstraint *data = con->data;
bConstraintTarget *ct = list->first;
/* the following macro is used for all standard single-target constraints */
- SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
+ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, no_copy);
}
}
@@ -2509,14 +2509,14 @@ static int distlimit_get_tars(bConstraint *con, ListBase *list)
return 0;
}
-static void distlimit_flush_tars(bConstraint *con, ListBase *list, short nocopy)
+static void distlimit_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
{
if (con && list) {
bDistLimitConstraint *data = con->data;
bConstraintTarget *ct = list->first;
/* the following macro is used for all standard single-target constraints */
- SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
+ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, no_copy);
}
}
@@ -2636,14 +2636,14 @@ static int stretchto_get_tars(bConstraint *con, ListBase *list)
return 0;
}
-static void stretchto_flush_tars(bConstraint *con, ListBase *list, short nocopy)
+static void stretchto_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
{
if (con && list) {
bStretchToConstraint *data = con->data;
bConstraintTarget *ct = list->first;
/* the following macro is used for all standard single-target constraints */
- SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
+ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, no_copy);
}
}
@@ -2808,14 +2808,14 @@ static int minmax_get_tars(bConstraint *con, ListBase *list)
return 0;
}
-static void minmax_flush_tars(bConstraint *con, ListBase *list, short nocopy)
+static void minmax_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
{
if (con && list) {
bMinMaxConstraint *data = con->data;
bConstraintTarget *ct = list->first;
/* the following macro is used for all standard single-target constraints */
- SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
+ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, no_copy);
}
}
@@ -2951,14 +2951,14 @@ static int rbj_get_tars(bConstraint *con, ListBase *list)
return 0;
}
-static void rbj_flush_tars(bConstraint *con, ListBase *list, short nocopy)
+static void rbj_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
{
if (con && list) {
bRigidBodyJointConstraint *data = con->data;
bConstraintTarget *ct = list->first;
/* the following macro is used for all standard single-target constraints */
- SINGLETARGETNS_FLUSH_TARS(con, data->tar, ct, list, nocopy);
+ SINGLETARGETNS_FLUSH_TARS(con, data->tar, ct, list, no_copy);
}
}
@@ -3002,14 +3002,14 @@ static int clampto_get_tars(bConstraint *con, ListBase *list)
return 0;
}
-static void clampto_flush_tars(bConstraint *con, ListBase *list, short nocopy)
+static void clampto_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
{
if (con && list) {
bClampToConstraint *data = con->data;
bConstraintTarget *ct = list->first;
/* the following macro is used for all standard single-target constraints */
- SINGLETARGETNS_FLUSH_TARS(con, data->tar, ct, list, nocopy);
+ SINGLETARGETNS_FLUSH_TARS(con, data->tar, ct, list, no_copy);
}
}
@@ -3182,14 +3182,14 @@ static int transform_get_tars(bConstraint *con, ListBase *list)
return 0;
}
-static void transform_flush_tars(bConstraint *con, ListBase *list, short nocopy)
+static void transform_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
{
if (con && list) {
bTransformConstraint *data = con->data;
bConstraintTarget *ct = list->first;
/* the following macro is used for all standard single-target constraints */
- SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
+ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, no_copy);
}
}
@@ -3200,13 +3200,14 @@ static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
/* only evaluate if there is a target */
if (VALID_CONS_TARGET(ct)) {
+ float *from_min, *from_max, *to_min, *to_max;
float loc[3], eul[3], size[3];
float dvec[3], sval[3];
int i;
/* obtain target effect */
switch (data->from) {
- case 2: /* scale */
+ case TRANS_SCALE:
mat4_to_size(dvec, ct->matrix);
if (is_negative_m4(ct->matrix)) {
@@ -3217,13 +3218,19 @@ static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
*/
negate_v3(dvec);
}
+ from_min = data->from_min_scale;
+ from_max = data->from_max_scale;
break;
- case 1: /* rotation (convert to degrees first) */
+ case TRANS_ROTATION:
mat4_to_eulO(dvec, cob->rotOrder, ct->matrix);
- mul_v3_fl(dvec, RAD2DEGF(1.0f)); /* rad -> deg */
+ from_min = data->from_min_rot;
+ from_max = data->from_max_rot;
break;
- default: /* location */
+ case TRANS_LOCATION:
+ default:
copy_v3_v3(dvec, ct->matrix[3]);
+ from_min = data->from_min;
+ from_max = data->from_max;
break;
}
@@ -3235,8 +3242,8 @@ static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
/* determine where in range current transforms lie */
if (data->expo) {
for (i = 0; i < 3; i++) {
- if (data->from_max[i] - data->from_min[i])
- sval[i] = (dvec[i] - data->from_min[i]) / (data->from_max[i] - data->from_min[i]);
+ if (from_max[i] - from_min[i])
+ sval[i] = (dvec[i] - from_min[i]) / (from_max[i] - from_min[i]);
else
sval[i] = 0.0f;
}
@@ -3244,9 +3251,9 @@ static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
else {
/* clamp transforms out of range */
for (i = 0; i < 3; i++) {
- CLAMP(dvec[i], data->from_min[i], data->from_max[i]);
- if (data->from_max[i] - data->from_min[i])
- sval[i] = (dvec[i] - data->from_min[i]) / (data->from_max[i] - data->from_min[i]);
+ CLAMP(dvec[i], from_min[i], from_max[i]);
+ if (from_max[i] - from_min[i])
+ sval[i] = (dvec[i] - from_min[i]) / (from_max[i] - from_min[i]);
else
sval[i] = 0.0f;
}
@@ -3255,32 +3262,30 @@ static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
/* apply transforms */
switch (data->to) {
- case 2: /* scaling */
- for (i = 0; i < 3; i++)
- size[i] = data->to_min[i] + (sval[(int)data->map[i]] * (data->to_max[i] - data->to_min[i]));
+ case TRANS_SCALE:
+ to_min = data->to_min_scale;
+ to_max = data->to_max_scale;
+ for (i = 0; i < 3; i++) {
+ /* multiply with original scale (so that it can still be scaled) */
+ size[i] *= to_min[i] + (sval[(int)data->map[i]] * (to_max[i] - to_min[i]));
+ }
break;
- case 1: /* rotation */
+ case TRANS_ROTATION:
+ to_min = data->to_min_rot;
+ to_max = data->to_max_rot;
for (i = 0; i < 3; i++) {
- float tmin, tmax;
- float val;
-
- tmin = data->to_min[i];
- tmax = data->to_max[i];
-
- /* all values here should be in degrees */
- val = tmin + (sval[(int)data->map[i]] * (tmax - tmin));
-
- /* now convert final value back to radians, and add to original rotation (so that it can still be rotated) */
- eul[i] += DEG2RADF(val);
+ /* add to original rotation (so that it can still be rotated) */
+ eul[i] += to_min[i] + (sval[(int)data->map[i]] * (to_max[i] - to_min[i]));
}
break;
- default: /* location */
- /* get new location */
- for (i = 0; i < 3; i++)
- loc[i] = (data->to_min[i] + (sval[(int)data->map[i]] * (data->to_max[i] - data->to_min[i])));
-
- /* add original location back on (so that it can still be moved) */
- add_v3_v3v3(loc, cob->matrix[3], loc);
+ case TRANS_LOCATION:
+ default:
+ to_min = data->to_min;
+ to_max = data->to_max;
+ for (i = 0; i < 3; i++) {
+ /* add to original location (so that it can still be moved) */
+ loc[i] += (to_min[i] + (sval[(int)data->map[i]] * (to_max[i] - to_min[i])));
+ }
break;
}
@@ -3337,13 +3342,13 @@ static int shrinkwrap_get_tars(bConstraint *con, ListBase *list)
}
-static void shrinkwrap_flush_tars(bConstraint *con, ListBase *list, short nocopy)
+static void shrinkwrap_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
{
if (con && list) {
bShrinkwrapConstraint *data = con->data;
bConstraintTarget *ct = list->first;
- SINGLETARGETNS_FLUSH_TARS(con, data->target, ct, list, nocopy);
+ SINGLETARGETNS_FLUSH_TARS(con, data->target, ct, list, no_copy);
}
}
@@ -3520,14 +3525,14 @@ static int damptrack_get_tars(bConstraint *con, ListBase *list)
return 0;
}
-static void damptrack_flush_tars(bConstraint *con, ListBase *list, short nocopy)
+static void damptrack_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
{
if (con && list) {
bDampTrackConstraint *data = con->data;
bConstraintTarget *ct = list->first;
/* the following macro is used for all standard single-target constraints */
- SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
+ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, no_copy);
}
}
@@ -3665,14 +3670,14 @@ static int splineik_get_tars(bConstraint *con, ListBase *list)
return 0;
}
-static void splineik_flush_tars(bConstraint *con, ListBase *list, short nocopy)
+static void splineik_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
{
if (con && list) {
bSplineIKConstraint *data = con->data;
bConstraintTarget *ct = list->first;
/* the following macro is used for all standard single-target constraints */
- SINGLETARGETNS_FLUSH_TARS(con, data->tar, ct, list, nocopy);
+ SINGLETARGETNS_FLUSH_TARS(con, data->tar, ct, list, no_copy);
}
}
@@ -3733,14 +3738,14 @@ static int pivotcon_get_tars(bConstraint *con, ListBase *list)
return 0;
}
-static void pivotcon_flush_tars(bConstraint *con, ListBase *list, short nocopy)
+static void pivotcon_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
{
if (con && list) {
bPivotConstraint *data = con->data;
bConstraintTarget *ct = list->first;
/* the following macro is used for all standard single-target constraints */
- SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
+ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, no_copy);
}
}
@@ -4243,7 +4248,7 @@ static void constraints_init_typeinfo(void)
/* This function should be used for getting the appropriate type-info when only
* a constraint type is known
*/
-bConstraintTypeInfo *BKE_get_constraint_typeinfo(int type)
+bConstraintTypeInfo *BKE_constraint_typeinfo_from_type(int type)
{
/* initialize the type-info list? */
if (CTI_INIT) {
@@ -4268,11 +4273,11 @@ bConstraintTypeInfo *BKE_get_constraint_typeinfo(int type)
/* This function should always be used to get the appropriate type-info, as it
* has checks which prevent segfaults in some weird cases.
*/
-bConstraintTypeInfo *BKE_constraint_get_typeinfo(bConstraint *con)
+bConstraintTypeInfo *BKE_constraint_typeinfo_get(bConstraint *con)
{
/* only return typeinfo for valid constraints */
if (con)
- return BKE_get_constraint_typeinfo(con->type);
+ return BKE_constraint_typeinfo_from_type(con->type);
else
return NULL;
}
@@ -4284,10 +4289,10 @@ bConstraintTypeInfo *BKE_constraint_get_typeinfo(bConstraint *con)
/* ---------- Data Management ------- */
-/* helper function for BKE_free_constraint_data() - unlinks references */
-static void con_unlink_refs_cb(bConstraint *UNUSED(con), ID **idpoin, short isReference, void *UNUSED(userData))
+/* helper function for BKE_constraint_free_data() - unlinks references */
+static void con_unlink_refs_cb(bConstraint *UNUSED(con), ID **idpoin, bool is_reference, void *UNUSED(userData))
{
- if (*idpoin && isReference)
+ if (*idpoin && is_reference)
id_us_min(*idpoin);
}
@@ -4295,10 +4300,10 @@ static void con_unlink_refs_cb(bConstraint *UNUSED(con), ID **idpoin, short isRe
* be sure to run BIK_clear_data() when freeing an IK constraint,
* unless DAG_relations_tag_update is called.
*/
-void BKE_free_constraint_data(bConstraint *con)
+void BKE_constraint_free_data(bConstraint *con)
{
if (con->data) {
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
if (cti) {
/* perform any special freeing constraint may have */
@@ -4316,13 +4321,13 @@ void BKE_free_constraint_data(bConstraint *con)
}
/* Free all constraints from a constraint-stack */
-void BKE_free_constraints(ListBase *list)
+void BKE_constraints_free(ListBase *list)
{
bConstraint *con;
/* Free constraint data and also any extra data */
for (con = list->first; con; con = con->next)
- BKE_free_constraint_data(con);
+ BKE_constraint_free_data(con);
/* Free the whole list */
BLI_freelistN(list);
@@ -4330,10 +4335,10 @@ void BKE_free_constraints(ListBase *list)
/* Remove the specified constraint from the given constraint stack */
-int BKE_remove_constraint(ListBase *list, bConstraint *con)
+bool BKE_constraint_remove(ListBase *list, bConstraint *con)
{
if (con) {
- BKE_free_constraint_data(con);
+ BKE_constraint_free_data(con);
BLI_freelinkN(list, con);
return 1;
}
@@ -4341,33 +4346,13 @@ int BKE_remove_constraint(ListBase *list, bConstraint *con)
return 0;
}
-/* Remove all the constraints of the specified type from the given constraint stack */
-void BKE_remove_constraints_type(ListBase *list, short type, short last_only)
-{
- bConstraint *con, *conp;
-
- if (list == NULL)
- return;
-
- /* remove from the end of the list to make it faster to find the last instance */
- for (con = list->last; con; con = conp) {
- conp = con->prev;
-
- if (con->type == type) {
- BKE_remove_constraint(list, con);
- if (last_only)
- return;
- }
- }
-}
-
/* ......... */
/* Creates a new constraint, initializes its data, and returns it */
static bConstraint *add_new_constraint_internal(const char *name, short type)
{
bConstraint *con = MEM_callocN(sizeof(bConstraint), "Constraint");
- bConstraintTypeInfo *cti = BKE_get_constraint_typeinfo(type);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_from_type(type);
const char *newName;
/* Set up a generic constraint datablock */
@@ -4417,17 +4402,17 @@ static bConstraint *add_new_constraint(Object *ob, bPoseChannel *pchan, const ch
* (otherwise unique-naming code will fail, since it assumes element exists in list)
*/
BLI_addtail(list, con);
- BKE_unique_constraint_name(con, list);
+ BKE_constraint_unique_name(con, list);
/* if the target list is a list on some PoseChannel belonging to a proxy-protected
* Armature layer, we must tag newly added constraints with a flag which allows them
* to persist after proxy syncing has been done
*/
- if (BKE_proxylocked_constraints_owner(ob, pchan))
+ if (BKE_constraints_proxylocked_owner(ob, pchan))
con->flag |= CONSTRAINT_PROXY_LOCAL;
/* make this constraint the active one */
- BKE_constraints_set_active(list, con);
+ BKE_constraints_active_set(list, con);
}
/* set type+owner specific immutable settings */
@@ -4451,7 +4436,7 @@ static bConstraint *add_new_constraint(Object *ob, bPoseChannel *pchan, const ch
/* ......... */
/* Add new constraint for the given bone */
-bConstraint *BKE_add_pose_constraint(Object *ob, bPoseChannel *pchan, const char *name, short type)
+bConstraint *BKE_constraint_add_for_pose(Object *ob, bPoseChannel *pchan, const char *name, short type)
{
if (pchan == NULL)
return NULL;
@@ -4460,15 +4445,15 @@ bConstraint *BKE_add_pose_constraint(Object *ob, bPoseChannel *pchan, const char
}
/* Add new constraint for the given object */
-bConstraint *BKE_add_ob_constraint(Object *ob, const char *name, short type)
+bConstraint *BKE_constraint_add_for_object(Object *ob, const char *name, short type)
{
return add_new_constraint(ob, NULL, name, type);
}
/* ......... */
-/* helper for BKE_relink_constraints() - call ID_NEW() on every ID reference the constraint has */
-static void con_relink_id_cb(bConstraint *UNUSED(con), ID **idpoin, short UNUSED(isReference), void *UNUSED(userdata))
+/* helper for BKE_constraints_relink() - call ID_NEW() on every ID reference the constraint has */
+static void con_relink_id_cb(bConstraint *UNUSED(con), ID **idpoin, bool UNUSED(is_reference), void *UNUSED(userdata))
{
/* ID_NEW() expects a struct with inline "id" member as first
* since we've got the actual ID block, let's just inline this
@@ -4481,20 +4466,20 @@ static void con_relink_id_cb(bConstraint *UNUSED(con), ID **idpoin, short UNUSED
}
/* Reassign links that constraints have to other data (called during file loading?) */
-void BKE_relink_constraints(ListBase *conlist)
+void BKE_constraints_relink(ListBase *conlist)
{
/* just a wrapper around ID-loop for just calling ID_NEW() on all ID refs */
- BKE_id_loop_constraints(conlist, con_relink_id_cb, NULL);
+ BKE_constraints_id_loop(conlist, con_relink_id_cb, NULL);
}
/* Run the given callback on all ID-blocks in list of constraints */
-void BKE_id_loop_constraints(ListBase *conlist, ConstraintIDFunc func, void *userdata)
+void BKE_constraints_id_loop(ListBase *conlist, ConstraintIDFunc func, void *userdata)
{
bConstraint *con;
for (con = conlist->first; con; con = con->next) {
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
if (cti) {
if (cti->id_looper)
@@ -4505,23 +4490,23 @@ void BKE_id_loop_constraints(ListBase *conlist, ConstraintIDFunc func, void *use
/* ......... */
-/* helper for BKE_copy_constraints(), to be used for making sure that ID's are valid */
-static void con_extern_cb(bConstraint *UNUSED(con), ID **idpoin, short UNUSED(isReference), void *UNUSED(userData))
+/* helper for BKE_constraints_copy(), to be used for making sure that ID's are valid */
+static void con_extern_cb(bConstraint *UNUSED(con), ID **idpoin, bool UNUSED(is_reference), void *UNUSED(userData))
{
if (*idpoin && (*idpoin)->lib)
id_lib_extern(*idpoin);
}
-/* helper for BKE_copy_constraints(), to be used for making sure that usercounts of copied ID's are fixed up */
-static void con_fix_copied_refs_cb(bConstraint *UNUSED(con), ID **idpoin, short isReference, void *UNUSED(userData))
+/* helper for BKE_constraints_copy(), to be used for making sure that usercounts of copied ID's are fixed up */
+static void con_fix_copied_refs_cb(bConstraint *UNUSED(con), ID **idpoin, bool is_reference, void *UNUSED(userData))
{
/* increment usercount if this is a reference type */
- if ((*idpoin) && (isReference))
+ if ((*idpoin) && (is_reference))
id_us_plus(*idpoin);
}
/* duplicate all of the constraints in a constraint stack */
-void BKE_copy_constraints(ListBase *dst, const ListBase *src, bool do_extern)
+void BKE_constraints_copy(ListBase *dst, const ListBase *src, bool do_extern)
{
bConstraint *con, *srccon;
@@ -4529,7 +4514,7 @@ void BKE_copy_constraints(ListBase *dst, const ListBase *src, bool do_extern)
BLI_duplicatelist(dst, src);
for (con = dst->first, srccon = src->first; con && srccon; srccon = srccon->next, con = con->next) {
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
/* make a new copy of the constraint's data */
con->data = MEM_dupallocN(con->data);
@@ -4556,13 +4541,13 @@ void BKE_copy_constraints(ListBase *dst, const ListBase *src, bool do_extern)
/* ......... */
-bConstraint *BKE_constraints_findByName(ListBase *list, const char *name)
+bConstraint *BKE_constraints_find_name(ListBase *list, const char *name)
{
return BLI_findstring(list, name, offsetof(bConstraint, name));
}
/* finds the 'active' constraint in a constraint stack */
-bConstraint *BKE_constraints_get_active(ListBase *list)
+bConstraint *BKE_constraints_active_get(ListBase *list)
{
bConstraint *con;
@@ -4579,7 +4564,7 @@ bConstraint *BKE_constraints_get_active(ListBase *list)
}
/* Set the given constraint as the active one (clearing all the others) */
-void BKE_constraints_set_active(ListBase *list, bConstraint *con)
+void BKE_constraints_active_set(ListBase *list, bConstraint *con)
{
bConstraint *c;
@@ -4596,7 +4581,7 @@ void BKE_constraints_set_active(ListBase *list, bConstraint *con)
/* -------- Constraints and Proxies ------- */
/* Rescue all constraints tagged as being CONSTRAINT_PROXY_LOCAL (i.e. added to bone that's proxy-synced in this file) */
-void BKE_extract_proxylocal_constraints(ListBase *dst, ListBase *src)
+void BKE_constraints_proxylocal_extract(ListBase *dst, ListBase *src)
{
bConstraint *con, *next;
@@ -4613,7 +4598,7 @@ void BKE_extract_proxylocal_constraints(ListBase *dst, ListBase *src)
}
/* Returns if the owner of the constraint is proxy-protected */
-short BKE_proxylocked_constraints_owner(Object *ob, bPoseChannel *pchan)
+bool BKE_constraints_proxylocked_owner(Object *ob, bPoseChannel *pchan)
{
/* Currently, constraints can only be on object or bone level */
if (ob && ob->proxy) {
@@ -4642,9 +4627,9 @@ short BKE_proxylocked_constraints_owner(Object *ob, bPoseChannel *pchan)
* 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.
*/
-void BKE_get_constraint_target_matrix(Scene *scene, bConstraint *con, int index, short ownertype, void *ownerdata, float mat[4][4], float ctime)
+void BKE_constraint_target_matrix_get(Scene *scene, bConstraint *con, int index, short ownertype, void *ownerdata, float mat[4][4], float ctime)
{
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintOb *cob;
bConstraintTarget *ct;
@@ -4709,9 +4694,9 @@ void BKE_get_constraint_target_matrix(Scene *scene, bConstraint *con, int index,
}
/* Get the list of targets required for solving a constraint */
-void BKE_get_constraint_targets_for_solving(bConstraint *con, bConstraintOb *cob, ListBase *targets, float ctime)
+void BKE_constraint_targets_for_solving_get(bConstraint *con, bConstraintOb *cob, ListBase *targets, float ctime)
{
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
if (cti && cti->get_constraint_targets) {
bConstraintTarget *ct;
@@ -4744,7 +4729,7 @@ void BKE_get_constraint_targets_for_solving(bConstraint *con, bConstraintOb *cob
* BKE_constraints_make_evalob and BKE_constraints_clear_evalob should be called before and
* after running this function, to sort out cob
*/
-void BKE_solve_constraints(ListBase *conlist, bConstraintOb *cob, float ctime)
+void BKE_constraints_solve(ListBase *conlist, bConstraintOb *cob, float ctime)
{
bConstraint *con;
float oldmat[4][4];
@@ -4756,7 +4741,7 @@ void BKE_solve_constraints(ListBase *conlist, bConstraintOb *cob, float ctime)
/* loop over available constraints, solving and blending them */
for (con = conlist->first; con; con = con->next) {
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
/* these we can skip completely (invalid constraints...) */
@@ -4779,7 +4764,7 @@ void BKE_solve_constraints(ListBase *conlist, bConstraintOb *cob, float ctime)
BKE_constraint_mat_convertspace(cob->ob, cob->pchan, cob->matrix, CONSTRAINT_SPACE_WORLD, con->ownspace);
/* prepare targets for constraint solving */
- BKE_get_constraint_targets_for_solving(con, cob, &targets, ctime);
+ BKE_constraint_targets_for_solving_get(con, cob, &targets, ctime);
/* Solve the constraint and put result in cob->matrix */
cti->evaluate_constraint(con, cob, &targets);
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index eeb1f4b9e4f..89ba2e9d68b 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -36,6 +36,7 @@
#include "DNA_view3d_types.h"
#include "DNA_windowmanager_types.h"
#include "DNA_object_types.h"
+#include "DNA_linestyle_types.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
@@ -47,6 +48,7 @@
#include "BKE_context.h"
#include "BKE_main.h"
#include "BKE_screen.h"
+#include "BKE_freestyle.h"
#include "RNA_access.h"
@@ -232,18 +234,31 @@ struct bContextDataResult {
short type; /* 0: normal, 1: seq */
};
-static void *ctx_wm_python_context_get(const bContext *C, const char *member, void *fall_through)
+static void *ctx_wm_python_context_get(
+ const bContext *C,
+ const char *member, const StructRNA *member_type,
+ void *fall_through)
{
#ifdef WITH_PYTHON
if (UNLIKELY(C && CTX_py_dict_get(C))) {
bContextDataResult result;
memset(&result, 0, sizeof(bContextDataResult));
BPY_context_member_get((bContext *)C, member, &result);
- if (result.ptr.data)
- return result.ptr.data;
+
+ if (result.ptr.data) {
+ if (RNA_struct_is_a(result.ptr.type, member_type)) {
+ return result.ptr.data;
+ }
+ else {
+ printf("PyContext '%s' is a '%s', expected a '%s'\n",
+ member,
+ RNA_struct_identifier(result.ptr.type),
+ RNA_struct_identifier(member_type));
+ }
+ }
}
#else
- (void)C, (void)member;
+ (void)C, (void)member, (void)member_type;
#endif
/* don't allow UI context access from non-main threads */
@@ -608,17 +623,17 @@ wmWindowManager *CTX_wm_manager(const bContext *C)
wmWindow *CTX_wm_window(const bContext *C)
{
- return ctx_wm_python_context_get(C, "window", C->wm.window);
+ return ctx_wm_python_context_get(C, "window", &RNA_Window, C->wm.window);
}
bScreen *CTX_wm_screen(const bContext *C)
{
- return ctx_wm_python_context_get(C, "screen", C->wm.screen);
+ return ctx_wm_python_context_get(C, "screen", &RNA_Screen, C->wm.screen);
}
ScrArea *CTX_wm_area(const bContext *C)
{
- return ctx_wm_python_context_get(C, "area", C->wm.area);
+ return ctx_wm_python_context_get(C, "area", &RNA_Area, C->wm.area);
}
SpaceLink *CTX_wm_space_data(const bContext *C)
@@ -629,7 +644,7 @@ SpaceLink *CTX_wm_space_data(const bContext *C)
ARegion *CTX_wm_region(const bContext *C)
{
- return ctx_wm_python_context_get(C, "region", C->wm.region);
+ return ctx_wm_python_context_get(C, "region", &RNA_Region, C->wm.region);
}
void *CTX_wm_region_data(const bContext *C)
@@ -1077,3 +1092,15 @@ int CTX_data_visible_pose_bones(const bContext *C, ListBase *list)
return ctx_data_collection_get(C, "visible_pose_bones", list);
}
+FreestyleLineStyle *CTX_data_linestyle_from_scene(Scene *scene)
+{
+ SceneRenderLayer *actsrl = BLI_findlink(&scene->r.layers, scene->r.actlay);
+ FreestyleConfig *config = &actsrl->freestyleConfig;
+ FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(config);
+
+ if (lineset) {
+ return lineset->linestyle;
+ }
+
+ return NULL;
+}
diff --git a/source/blender/editors/util/crazyspace.c b/source/blender/blenkernel/intern/crazyspace.c
index b90cfad28a5..3fde1cdd710 100644
--- a/source/blender/editors/util/crazyspace.c
+++ b/source/blender/blenkernel/intern/crazyspace.c
@@ -25,8 +25,8 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/editors/util/crazyspace.c
- * \ingroup edutil
+/** \file blender/blenkernel/intern/crazyspace.c
+ * \ingroup bke
*/
@@ -42,14 +42,13 @@
#include "BLI_math.h"
#include "BLI_bitmap.h"
+#include "BKE_crazyspace.h"
#include "BKE_DerivedMesh.h"
#include "BKE_modifier.h"
#include "BKE_multires.h"
#include "BKE_mesh.h"
#include "BKE_editmesh.h"
-#include "ED_util.h"
-
typedef struct {
float (*vertexcos)[3];
BLI_bitmap *vertex_visit;
@@ -119,7 +118,7 @@ static int modifiers_disable_subsurf_temporary(Object *ob)
}
/* disable subsurf temporal, get mapped cos, and enable it */
-float (*crazyspace_get_mapped_editverts(Scene *scene, Object *obedit))[3]
+float (*BKE_crazyspace_get_mapped_editverts(Scene *scene, Object *obedit))[3]
{
Mesh *me = obedit->data;
DerivedMesh *dm;
@@ -154,7 +153,7 @@ float (*crazyspace_get_mapped_editverts(Scene *scene, Object *obedit))[3]
return vertexcos;
}
-void crazyspace_set_quats_editmesh(BMEditMesh *em, float (*origcos)[3], float (*mappedcos)[3], float (*quats)[4],
+void BKE_crazyspace_set_quats_editmesh(BMEditMesh *em, float (*origcos)[3], float (*mappedcos)[3], float (*quats)[4],
const bool use_select)
{
BMFace *f;
@@ -216,7 +215,7 @@ void crazyspace_set_quats_editmesh(BMEditMesh *em, float (*origcos)[3], float (*
}
}
-void crazyspace_set_quats_mesh(Mesh *me, float (*origcos)[3], float (*mappedcos)[3], float (*quats)[4])
+void BKE_crazyspace_set_quats_mesh(Mesh *me, float (*origcos)[3], float (*mappedcos)[3], float (*quats)[4])
{
int i;
MVert *mvert;
@@ -329,7 +328,7 @@ int editbmesh_get_first_deform_matrices(Scene *scene, Object *ob, BMEditMesh *em
return numleft;
}
-int sculpt_get_first_deform_matrices(Scene *scene, Object *ob, float (**deformmats)[3][3], float (**deformcos)[3])
+int BKE_sculpt_get_first_deform_matrices(Scene *scene, Object *ob, float (**deformmats)[3][3], float (**deformcos)[3])
{
ModifierData *md;
DerivedMesh *dm;
@@ -388,9 +387,9 @@ int sculpt_get_first_deform_matrices(Scene *scene, Object *ob, float (**deformma
return numleft;
}
-void crazyspace_build_sculpt(Scene *scene, Object *ob, float (**deformmats)[3][3], float (**deformcos)[3])
+void BKE_crazyspace_build_sculpt(Scene *scene, Object *ob, float (**deformmats)[3][3], float (**deformcos)[3])
{
- int totleft = sculpt_get_first_deform_matrices(scene, ob, deformmats, deformcos);
+ int totleft = BKE_sculpt_get_first_deform_matrices(scene, ob, deformmats, deformcos);
if (totleft) {
/* there are deformation modifier which doesn't support deformation matrices
@@ -422,7 +421,7 @@ void crazyspace_build_sculpt(Scene *scene, Object *ob, float (**deformmats)[3][3
quats = MEM_mallocN(me->totvert * sizeof(*quats), "crazy quats");
- crazyspace_set_quats_mesh(me, origVerts, deformedVerts, quats);
+ BKE_crazyspace_set_quats_mesh(me, origVerts, deformedVerts, quats);
for (i = 0; i < me->totvert; i++) {
float qmat[3][3], tmat[3][3];
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index ae45ca55c5d..14fd44e594a 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -51,7 +51,6 @@
#include "DNA_object_types.h"
#include "BKE_animsys.h"
-#include "BKE_anim.h"
#include "BKE_curve.h"
#include "BKE_displist.h"
#include "BKE_font.h"
@@ -701,19 +700,13 @@ void BKE_nurb_minmax(Nurb *nu, bool use_radius, float min[3], float max[3])
/* be sure to call makeknots after this */
void BKE_nurb_points_add(Nurb *nu, int number)
{
- BPoint *tmp = nu->bp;
+ BPoint *bp;
int i;
- nu->bp = (BPoint *)MEM_mallocN((nu->pntsu + number) * sizeof(BPoint), "rna_Curve_spline_points_add");
-
- if (tmp) {
- memmove(nu->bp, tmp, nu->pntsu * sizeof(BPoint));
- MEM_freeN(tmp);
- }
- memset(nu->bp + nu->pntsu, 0, number * sizeof(BPoint));
+ nu->bp = MEM_recallocN(nu->bp, (nu->pntsu + number) * sizeof(BPoint));
- for (i = 0, tmp = nu->bp + nu->pntsu; i < number; i++, tmp++) {
- tmp->radius = 1.0f;
+ for (i = 0, bp = &nu->bp[nu->pntsu]; i < number; i++, bp++) {
+ bp->radius = 1.0f;
}
nu->pntsu += number;
@@ -721,19 +714,13 @@ void BKE_nurb_points_add(Nurb *nu, int number)
void BKE_nurb_bezierPoints_add(Nurb *nu, int number)
{
- BezTriple *tmp = nu->bezt;
+ BezTriple *bezt;
int i;
- nu->bezt = (BezTriple *)MEM_mallocN((nu->pntsu + number) * sizeof(BezTriple), "rna_Curve_spline_points_add");
- if (tmp) {
- memmove(nu->bezt, tmp, nu->pntsu * sizeof(BezTriple));
- MEM_freeN(tmp);
- }
+ nu->bezt = MEM_recallocN(nu->bp, (nu->pntsu + number) * sizeof(BezTriple));
- memset(nu->bezt + nu->pntsu, 0, number * sizeof(BezTriple));
-
- for (i = 0, tmp = nu->bezt + nu->pntsu; i < number; i++, tmp++) {
- tmp->radius = 1.0f;
+ for (i = 0, bezt = &nu->bezt[nu->pntsu]; i < number; i++, bezt++) {
+ bezt->radius = 1.0f;
}
nu->pntsu += number;
@@ -1598,7 +1585,7 @@ float *BKE_curve_make_orco(Scene *scene, Object *ob, int *r_numVerts)
fp[2] = 0.0;
}
else {
- float *vert;
+ const float *vert;
int realv = v % dl->nr;
int realu = u % dl->parts;
@@ -2872,7 +2859,8 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
/* 2D Curves */
for (bl = bev->first; bl; bl = bl->next) {
if (bl->nr < 2) {
- /* do nothing */
+ BevPoint *bevp = (BevPoint *)(bl + 1);
+ unit_qt(bevp->quat);
}
else if (bl->nr == 2) { /* 2 pnt, treat separate */
make_bevel_list_segment_2D(bl);
@@ -2886,7 +2874,8 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
/* 3D Curves */
for (bl = bev->first; bl; bl = bl->next) {
if (bl->nr < 2) {
- /* do nothing */
+ BevPoint *bevp = (BevPoint *)(bl + 1);
+ unit_qt(bevp->quat);
}
else if (bl->nr == 2) { /* 2 pnt, treat separate */
make_bevel_list_segment_3D(bl);
@@ -2910,6 +2899,7 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n
float *p1, *p2, *p3, pt[3];
float dvec_a[3], dvec_b[3];
float len, len_a, len_b;
+ float len_ratio;
const float eps = 1e-5;
if (bezt->h1 == 0 && bezt->h2 == 0) {
@@ -2954,6 +2944,7 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n
if (len_a == 0.0f) len_a = 1.0f;
if (len_b == 0.0f) len_b = 1.0f;
+ len_ratio = len_a / len_b;
if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) || ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) { /* auto */
float tvec[3];
@@ -3014,7 +3005,7 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n
if ( (ydiff1 <= 0.0f && ydiff2 <= 0.0f) || (ydiff1 >= 0.0f && ydiff2 >= 0.0f) ) {
bezt->vec[2][1] = bezt->vec[1][1];
}
- else { /* andles should not be beyond y coord of two others */
+ else { /* handles should not be beyond y coord of two others */
if (ydiff1 <= 0.0f) {
if (next->vec[1][1] < bezt->vec[2][1]) {
bezt->vec[2][1] = next->vec[1][1];
@@ -3090,15 +3081,18 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n
len_a = len_v3v3(p2, p2_h1);
len_b = len_v3v3(p2, p2_h2);
- if (len_a == 0.0f)
- len_a = 1.0f;
- if (len_b == 0.0f)
- len_b = 1.0f;
+ if (is_fcurve == false) {
+ if (len_a == 0.0f)
+ len_a = 1.0f;
+ if (len_b == 0.0f)
+ len_b = 1.0f;
+ len_ratio = len_a / len_b;
+ }
if (bezt->f1 & SELECT) { /* order of calculation */
if (ELEM(bezt->h2, HD_ALIGN, HD_ALIGN_DOUBLESIDE)) { /* aligned */
if (len_a > eps) {
- len = len_b / len_a;
+ len = 1.0f / len_ratio;
p2_h2[0] = p2[0] + len * (p2[0] - p2_h1[0]);
p2_h2[1] = p2[1] + len * (p2[1] - p2_h1[1]);
p2_h2[2] = p2[2] + len * (p2[2] - p2_h1[2]);
@@ -3106,7 +3100,7 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n
}
if (ELEM(bezt->h1, HD_ALIGN, HD_ALIGN_DOUBLESIDE)) {
if (len_b > eps) {
- len = len_a / len_b;
+ len = len_ratio;
p2_h1[0] = p2[0] + len * (p2[0] - p2_h2[0]);
p2_h1[1] = p2[1] + len * (p2[1] - p2_h2[1]);
p2_h1[2] = p2[2] + len * (p2[2] - p2_h2[2]);
@@ -3116,7 +3110,7 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n
else {
if (ELEM(bezt->h1, HD_ALIGN, HD_ALIGN_DOUBLESIDE)) {
if (len_b > eps) {
- len = len_a / len_b;
+ len = len_ratio;
p2_h1[0] = p2[0] + len * (p2[0] - p2_h2[0]);
p2_h1[1] = p2[1] + len * (p2[1] - p2_h2[1]);
p2_h1[2] = p2[2] + len * (p2[2] - p2_h2[2]);
@@ -3124,7 +3118,7 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n
}
if (ELEM(bezt->h2, HD_ALIGN, HD_ALIGN_DOUBLESIDE)) { /* aligned */
if (len_a > eps) {
- len = len_b / len_a;
+ len = 1.0f / len_ratio;
p2_h2[0] = p2[0] + len * (p2[0] - p2_h1[0]);
p2_h2[1] = p2[1] + len * (p2[1] - p2_h1[1]);
p2_h2[2] = p2[2] + len * (p2[2] - p2_h1[2]);
@@ -3671,7 +3665,7 @@ float (*BKE_curve_nurbs_vertexCos_get(ListBase *lb, int *r_numVerts))[3]
void BK_curve_nurbs_vertexCos_apply(ListBase *lb, float (*vertexCos)[3])
{
- float *co = vertexCos[0];
+ const float *co = vertexCos[0];
Nurb *nu;
int i;
@@ -3757,8 +3751,6 @@ void BKE_curve_nurbs_keyVertexTilts_apply(ListBase *lb, float *key)
bool BKE_nurb_check_valid_u(struct Nurb *nu)
{
- if (nu == NULL)
- return false;
if (nu->pntsu <= 1)
return false;
if (nu->type != CU_NURBS)
@@ -3779,8 +3771,6 @@ bool BKE_nurb_check_valid_u(struct Nurb *nu)
}
bool BKE_nurb_check_valid_v(struct Nurb *nu)
{
- if (nu == NULL)
- return false;
if (nu->pntsv <= 1)
return false;
if (nu->type != CU_NURBS)
@@ -3801,6 +3791,16 @@ bool BKE_nurb_check_valid_v(struct Nurb *nu)
return true;
}
+bool BKE_nurb_check_valid_uv(struct Nurb *nu)
+{
+ if (!BKE_nurb_check_valid_u(nu))
+ return false;
+ if ((nu->pntsv > 1) && !BKE_nurb_check_valid_v(nu))
+ return false;
+
+ return true;
+}
+
bool BKE_nurb_order_clamp_u(struct Nurb *nu)
{
bool changed = false;
@@ -3889,7 +3889,7 @@ bool BKE_nurb_type_convert(Nurb *nu, const short type, const bool use_handles)
bp++;
}
else {
- char *f = &bezt->f1;
+ const char *f = &bezt->f1;
for (c = 0; c < 3; c++, f++) {
copy_v3_v3(bp->vec, bezt->vec[c]);
bp->vec[3] = 1.0;
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 41eb2f5982e..fd4350123b4 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -49,7 +49,6 @@
#include "BLI_path_util.h"
#include "BLI_math.h"
#include "BLI_mempool.h"
-#include "BLI_alloca.h"
#include "BLF_translation.h"
@@ -1059,6 +1058,19 @@ static void layerInterp_mvert_skin(void **sources, const float *weights,
vs->flag &= ~MVERT_SKIN_ROOT;
}
+static void layerSwap_flnor(void *data, const int *corner_indices)
+{
+ short (*flnors)[4][3] = data;
+ short nors[4][3];
+ int i = 4;
+
+ while (i--) {
+ copy_v3_v3_short(nors[i], (*flnors)[corner_indices[i]]);
+ }
+
+ memcpy(flnors, nors, sizeof(nors));
+}
+
static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
/* 0: CD_MVERT */
{sizeof(MVert), "MVert", 1, NULL, NULL, NULL, NULL, NULL, NULL},
@@ -1170,6 +1182,8 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
{sizeof(FreestyleFace), "FreestyleFace", 1, NULL, NULL, NULL, NULL, NULL, NULL},
/* 39: CD_MLOOPTANGENT */
{sizeof(float[4]), "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
+ /* 40: CD_TESSLOOPNORMAL */
+ {sizeof(short[4][3]), "", 0, NULL, NULL, NULL, NULL, layerSwap_flnor, NULL},
};
/* note, numbers are from trunk and need updating for bmesh */
@@ -1185,7 +1199,7 @@ static const char *LAYERTYPENAMES[CD_NUMTYPES] = {
/* 25-29 */ "CDMPoly", "CDMLoop", "CDShapeKeyIndex", "CDShapeKey", "CDBevelWeight",
/* 30-34 */ "CDSubSurfCrease", "CDOrigSpaceLoop", "CDPreviewLoopCol", "CDBMElemPyPtr", "CDPaintMask",
/* 35-36 */ "CDGridPaintMask", "CDMVertSkin",
- /* 37-38 */ "CDFreestyleEdge", "CDFreestyleFace", "CDMLoopTangent",
+ /* 37-40 */ "CDFreestyleEdge", "CDFreestyleFace", "CDMLoopTangent", "CDTessLoopNormal",
};
@@ -1217,9 +1231,9 @@ const CustomDataMask CD_MASK_BMESH =
CD_MASK_PROP_STR | CD_MASK_SHAPEKEY | CD_MASK_SHAPE_KEYINDEX | CD_MASK_MDISPS |
CD_MASK_CREASE | CD_MASK_BWEIGHT | CD_MASK_RECAST | CD_MASK_PAINT_MASK |
CD_MASK_GRID_PAINT_MASK | CD_MASK_MVERT_SKIN | CD_MASK_FREESTYLE_EDGE | CD_MASK_FREESTYLE_FACE;
-const CustomDataMask CD_MASK_FACECORNERS =
+const CustomDataMask CD_MASK_FACECORNERS = /* XXX Not used anywhere! */
CD_MASK_MTFACE | CD_MASK_MCOL | CD_MASK_MTEXPOLY | CD_MASK_MLOOPUV |
- CD_MASK_MLOOPCOL;
+ CD_MASK_MLOOPCOL | CD_MASK_NORMAL | CD_MASK_MLOOPTANGENT;
const CustomDataMask CD_MASK_EVERYTHING =
CD_MASK_MVERT | CD_MASK_MSTICKY /* DEPRECATED */ | CD_MASK_MDEFORMVERT | CD_MASK_MEDGE | CD_MASK_MFACE |
CD_MASK_MTFACE | CD_MASK_MCOL | CD_MASK_ORIGINDEX | CD_MASK_NORMAL /* | CD_MASK_POLYINDEX */ | CD_MASK_PROP_FLT |
@@ -1229,7 +1243,9 @@ const CustomDataMask CD_MASK_EVERYTHING =
CD_MASK_MPOLY | CD_MASK_MLOOP | CD_MASK_SHAPE_KEYINDEX | CD_MASK_SHAPEKEY | CD_MASK_BWEIGHT | CD_MASK_CREASE |
CD_MASK_ORIGSPACE_MLOOP | CD_MASK_PREVIEW_MLOOPCOL | CD_MASK_BM_ELEM_PYPTR |
/* BMESH ONLY END */
- CD_MASK_PAINT_MASK | CD_MASK_GRID_PAINT_MASK | CD_MASK_MVERT_SKIN | CD_MASK_FREESTYLE_EDGE | CD_MASK_FREESTYLE_FACE;
+ CD_MASK_PAINT_MASK | CD_MASK_GRID_PAINT_MASK | CD_MASK_MVERT_SKIN |
+ CD_MASK_FREESTYLE_EDGE | CD_MASK_FREESTYLE_FACE |
+ CD_MASK_MLOOPTANGENT | CD_MASK_TESSLOOPNORMAL;
static const LayerTypeInfo *layerType_getInfo(int type)
{
@@ -1970,7 +1986,7 @@ static void CustomData_copy_data_layer(const CustomData *source, CustomData *des
int src_offset;
int dest_offset;
- char *src_data = source->layers[src_i].data;
+ const char *src_data = source->layers[src_i].data;
char *dest_data = dest->layers[dest_i].data;
typeInfo = layerType_getInfo(source->layers[src_i].type);
@@ -2283,6 +2299,9 @@ void CustomData_to_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *l
else if (fdata->layers[i].type == CD_MDISPS) {
CustomData_add_layer_named(ldata, CD_MDISPS, CD_CALLOC, NULL, totloop, fdata->layers[i].name);
}
+ else if (fdata->layers[i].type == CD_TESSLOOPNORMAL) {
+ CustomData_add_layer_named(ldata, CD_NORMAL, CD_CALLOC, NULL, totloop, fdata->layers[i].name);
+ }
}
}
@@ -2304,6 +2323,9 @@ void CustomData_from_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData
else if (ldata->layers[i].type == CD_ORIGSPACE_MLOOP) {
CustomData_add_layer_named(fdata, CD_ORIGSPACE, CD_CALLOC, NULL, total, ldata->layers[i].name);
}
+ else if (ldata->layers[i].type == CD_NORMAL) {
+ CustomData_add_layer_named(fdata, CD_TESSLOOPNORMAL, CD_CALLOC, NULL, total, ldata->layers[i].name);
+ }
}
CustomData_bmesh_update_active_layers(fdata, pdata, ldata);
@@ -2589,7 +2611,7 @@ void CustomData_bmesh_copy_data(const CustomData *source, CustomData *dest,
if (dest->layers[dest_i].type == source->layers[src_i].type &&
strcmp(dest->layers[dest_i].name, source->layers[src_i].name) == 0)
{
- char *src_data = (char *)src_block + source->layers[src_i].offset;
+ const char *src_data = (char *)src_block + source->layers[src_i].offset;
char *dest_data = (char *)*dest_block + dest->layers[dest_i].offset;
typeInfo = layerType_getInfo(source->layers[src_i].type);
@@ -2908,7 +2930,7 @@ void CustomData_to_bmesh_block(const CustomData *source, CustomData *dest,
/* if we found a matching layer, copy the data */
if (dest->layers[dest_i].type == source->layers[src_i].type) {
int offset = dest->layers[dest_i].offset;
- char *src_data = source->layers[src_i].data;
+ const char *src_data = source->layers[src_i].data;
char *dest_data = (char *)*dest_block + offset;
typeInfo = layerType_getInfo(dest->layers[dest_i].type);
@@ -2958,7 +2980,7 @@ void CustomData_from_bmesh_block(const CustomData *source, CustomData *dest,
/* if we found a matching layer, copy the data */
if (dest->layers[dest_i].type == source->layers[src_i].type) {
int offset = source->layers[src_i].offset;
- char *src_data = (char *)src_block + offset;
+ const char *src_data = (char *)src_block + offset;
char *dest_data = dest->layers[dest_i].data;
typeInfo = layerType_getInfo(dest->layers[dest_i].type);
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 69b07472ea9..21579098266 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -64,7 +64,6 @@
#include "BKE_effect.h"
#include "BKE_fcurve.h"
#include "BKE_global.h"
-#include "BKE_group.h"
#include "BKE_image.h"
#include "BKE_key.h"
#include "BKE_library.h"
@@ -508,7 +507,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
for (con = pchan->constraints.first; con; con = con->next) {
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
@@ -796,7 +795,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
/* object constraints */
for (con = ob->constraints.first; con; con = con->next) {
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
@@ -1978,7 +1977,7 @@ static void dag_object_time_update_flags(Main *bmain, Scene *scene, Object *ob)
if (ob->constraints.first) {
bConstraint *con;
for (con = ob->constraints.first; con; con = con->next) {
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
@@ -2481,7 +2480,7 @@ static void dag_id_flush_update(Main *bmain, Scene *sce, ID *id)
for (obt = bmain->object.first; obt; obt = obt->id.next) {
bConstraint *con;
for (con = obt->constraints.first; con; con = con->next) {
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
if (ELEM3(cti->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_CAMERASOLVER,
CONSTRAINT_TYPE_OBJECTSOLVER))
{
@@ -2590,13 +2589,7 @@ void DAG_ids_check_recalc(Main *bmain, Scene *scene, bool time)
/* we tag based on first ID type character to avoid
* looping over all ID's in case there are no tags */
- if (id &&
-#ifdef WITH_FREESTYLE
- /* XXX very weak... added check for '27' to ignore freestyle added objects */
- id->name[2] > 27 &&
-#endif
- bmain->id_tag_update[id->name[0]])
- {
+ if (id && bmain->id_tag_update[id->name[0]]) {
updated = true;
break;
}
@@ -2854,7 +2847,7 @@ void DAG_pose_sort(Object *ob)
addtoroot = 0;
}
for (con = pchan->constraints.first; con; con = con->next) {
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index cdff6e249a7..8c21ee15da2 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -40,7 +40,6 @@
#include "DNA_meshdata_types.h"
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
-#include "DNA_material_types.h"
#include "DNA_vfont_types.h"
#include "BLI_blenlib.h"
@@ -54,9 +53,7 @@
#include "BKE_displist.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_object.h"
-#include "BKE_main.h"
#include "BKE_mball.h"
-#include "BKE_material.h"
#include "BKE_curve.h"
#include "BKE_key.h"
#include "BKE_anim.h"
@@ -891,7 +888,7 @@ static float (*displist_get_allverts(ListBase *dispbase, int *totvert))[3]
static void displist_apply_allverts(ListBase *dispbase, float (*allverts)[3])
{
DispList *dl;
- float *fp;
+ const float *fp;
fp = (float *)allverts;
for (dl = dispbase->first; dl; dl = dl->next) {
@@ -1216,7 +1213,7 @@ void BKE_displist_make_surf(Scene *scene, Object *ob, ListBase *dispbase,
curve_calc_modifiers_pre(scene, ob, &nubase, for_render, use_render_resolution);
for (nu = nubase.first; nu; nu = nu->next) {
- if (for_render || nu->hide == 0) {
+ if ((for_render || nu->hide == 0) && BKE_nurb_check_valid_uv(nu)) {
int resolu = nu->resolu, resolv = nu->resolv;
if (use_render_resolution) {
@@ -1794,7 +1791,7 @@ float *BKE_displist_make_orco(Scene *scene, Object *ob, DerivedMesh *dm_final,
void BKE_displist_minmax(ListBase *dispbase, float min[3], float max[3])
{
DispList *dl;
- float *vert;
+ const float *vert;
int a, tot = 0;
int doit = 0;
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index a778a074722..11737bccef2 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -48,20 +48,15 @@
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
-#include "DNA_space_types.h"
#include "DNA_texture_types.h"
#include "BKE_animsys.h"
#include "BKE_armature.h"
#include "BKE_bvhutils.h" /* bvh tree */
-#include "BKE_blender.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_constraint.h"
-#include "BKE_context.h"
#include "BKE_customdata.h"
-#include "BKE_colortools.h"
#include "BKE_deform.h"
-#include "BKE_depsgraph.h"
#include "BKE_DerivedMesh.h"
#include "BKE_dynamicpaint.h"
#include "BKE_effect.h"
@@ -323,7 +318,7 @@ static void dynamicPaint_setPreview(DynamicPaintSurface *t_surface)
bool dynamicPaint_outputLayerExists(struct DynamicPaintSurface *surface, Object *ob, int output)
{
- char *name;
+ const char *name;
if (output == 0)
name = surface->output_name;
@@ -536,7 +531,7 @@ static int subframe_updateObject(Scene *scene, Object *ob, int flags, int parent
/* also update constraint targets */
for (con = ob->constraints.first; con; con = con->next) {
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
if (cti && cti->get_constraint_targets) {
@@ -1678,7 +1673,7 @@ static void dynamicPaint_applySurfaceDisplace(DynamicPaintSurface *surface, Deri
if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE) {
MVert *mvert = result->getVertArray(result);
int i;
- float *value = (float *)sData->type_data;
+ const float *value = (float *)sData->type_data;
#pragma omp parallel for schedule(static)
for (i = 0; i < sData->total_points; i++) {
@@ -2103,7 +2098,7 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh
float closest_point[2], lambda, dir_vec[2];
int target_uv1, target_uv2, final_pixel[2], final_index;
- float *s_uv1, *s_uv2, *t_uv1, *t_uv2;
+ const float *s_uv1, *s_uv2, *t_uv1, *t_uv2;
pixel[0] = ((float)(px + neighX[n_index]) + 0.5f) / (float)w;
pixel[1] = ((float)(py + neighY[n_index]) + 0.5f) / (float)h;
@@ -2235,11 +2230,13 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh
int dynamicPaint_createUVSurface(Scene *scene, DynamicPaintSurface *surface)
{
/* Antialias jitter point relative coords */
- float jitter5sample[10] = {0.0f, 0.0f,
- -0.2f, -0.4f,
- 0.2f, 0.4f,
- 0.4f, -0.2f,
- -0.4f, 0.3f};
+ const float jitter5sample[10] = {
+ 0.0f, 0.0f,
+ -0.2f, -0.4f,
+ 0.2f, 0.4f,
+ 0.4f, -0.2f,
+ -0.4f, 0.3f,
+ };
int ty;
int w, h;
int numOfFaces;
@@ -2901,7 +2898,7 @@ static void mesh_faces_spherecast_dp(void *userdata, int index, const BVHTreeRay
MFace *face = data->face + index;
short quad = 0;
- float *t0, *t1, *t2, *t3;
+ const float *t0, *t1, *t2, *t3;
t0 = vert[face->v1].co;
t1 = vert[face->v2].co;
t2 = vert[face->v3].co;
@@ -2937,7 +2934,7 @@ static void mesh_faces_nearest_point_dp(void *userdata, int index, const float c
MFace *face = data->face + index;
short quad = 0;
- float *t0, *t1, *t2, *t3;
+ const float *t0, *t1, *t2, *t3;
t0 = vert[face->v1].co;
t1 = vert[face->v2].co;
t2 = vert[face->v3].co;
diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c
index b7c5c605254..99e7282fb79 100644
--- a/source/blender/blenkernel/intern/editderivedmesh.c
+++ b/source/blender/blenkernel/intern/editderivedmesh.c
@@ -52,7 +52,6 @@
#include "BKE_editmesh.h"
#include "BKE_editmesh_bvh.h"
-#include "DNA_mesh_types.h"
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
@@ -171,6 +170,31 @@ static void emDM_calcNormals(DerivedMesh *dm)
dm->dirty &= ~DM_DIRTY_NORMALS;
}
+static void emDM_calcLoopNormals(DerivedMesh *dm, const float split_angle)
+{
+ EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
+ BMesh *bm = bmdm->em->bm;
+ const float (*vertexCos)[3], (*vertexNos)[3], (*polyNos)[3];
+ float (*loopNos)[3];
+
+ /* calculate loop normals from poly and vertex normals */
+ emDM_ensureVertNormals(bmdm);
+ emDM_ensurePolyNormals(bmdm);
+ dm->dirty &= ~DM_DIRTY_NORMALS;
+
+ vertexCos = bmdm->vertexCos;
+ vertexNos = bmdm->vertexNos;
+ polyNos = bmdm->polyNos;
+
+ loopNos = dm->getLoopDataArray(dm, CD_NORMAL);
+ if (!loopNos) {
+ DM_add_loop_layer(dm, CD_NORMAL, CD_CALLOC, NULL);
+ loopNos = dm->getLoopDataArray(dm, CD_NORMAL);
+ }
+
+ BM_loops_calc_normal_vcos(bm, vertexCos, vertexNos, polyNos, split_angle, loopNos);
+}
+
static void emDM_recalcTessellation(DerivedMesh *UNUSED(dm))
{
/* do nothing */
@@ -274,8 +298,8 @@ static void emDM_drawMappedEdges(DerivedMesh *dm,
}
}
static void emDM_drawEdges(DerivedMesh *dm,
- int UNUSED(drawLooseEdges),
- int UNUSED(drawAllEdges))
+ bool UNUSED(drawLooseEdges),
+ bool UNUSED(drawAllEdges))
{
emDM_drawMappedEdges(dm, NULL, NULL);
}
@@ -353,6 +377,39 @@ static void emDM_drawUVEdges(DerivedMesh *dm)
glEnd();
}
+static void emDM_foreachMappedLoop(
+ DerivedMesh *dm,
+ void (*func)(void *userData, int vertex_index, int face_index, const float co[3], const float no[3]),
+ void *userData,
+ DMForeachFlag flag)
+{
+ /* We can't use dm->getLoopDataLayout(dm) here, we want to always access dm->loopData, EditDerivedBMesh would
+ * return loop data from bmesh itself. */
+ const float (*lnors)[3] = (flag & DM_FOREACH_USE_NORMAL) ? DM_get_loop_data_layer(dm, CD_NORMAL) : NULL;
+
+ EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
+ BMesh *bm = bmdm->em->bm;
+ BMFace *efa;
+ BMIter iter;
+
+ const float (*vertexCos)[3] = bmdm->vertexCos;
+ int f_idx;
+
+ BM_mesh_elem_index_ensure(bm, BM_VERT);
+
+ BM_ITER_MESH_INDEX (efa, &iter, bm, BM_FACES_OF_MESH, f_idx) {
+ BMLoop *l_iter, *l_first;
+
+ l_iter = l_first = BM_FACE_FIRST_LOOP(efa);
+ do {
+ const BMVert *eve = l_iter->v;
+ const int v_idx = BM_elem_index_get(eve);
+ const float *no = lnors ? *lnors++ : NULL;
+ func(userData, v_idx, f_idx, vertexCos ? vertexCos[v_idx] : eve->co, no);
+ } while ((l_iter = l_iter->next) != l_first);
+ }
+}
+
static void emDM_foreachMappedFaceCenter(
DerivedMesh *dm,
void (*func)(void *userData, int index, const float co[3], const float no[3]),
@@ -410,6 +467,7 @@ static void emDM_drawMappedFaces(DerivedMesh *dm,
int i, flush;
const int skip_normals = !glIsEnabled(GL_LIGHTING); /* could be passed as an arg */
+ const float (*lnors)[3] = dm->getLoopDataArray(dm, CD_NORMAL);
MLoopCol *lcol[3] = {NULL} /* , dummylcol = {0} */;
unsigned char(*color_vert_array)[4] = em->derivedVertColor;
unsigned char(*color_face_array)[4] = em->derivedFaceColor;
@@ -455,14 +513,14 @@ static void emDM_drawMappedFaces(DerivedMesh *dm,
polyNos = bmdm->polyNos;
}
- BM_mesh_elem_index_ensure(bm, BM_VERT | BM_FACE);
+ BM_mesh_elem_index_ensure(bm, lnors ? BM_VERT | BM_FACE | BM_LOOP : BM_VERT | BM_FACE);
for (i = 0; i < tottri; i++) {
BMLoop **ltri = looptris[i];
int drawSmooth;
efa = ltri[0]->f;
- drawSmooth = (flag & DM_DRAW_ALWAYS_SMOOTH) ? 1 : BM_elem_flag_test(efa, BM_ELEM_SMOOTH);
+ drawSmooth = lnors || ((flag & DM_DRAW_ALWAYS_SMOOTH) ? 1 : BM_elem_flag_test(efa, BM_ELEM_SMOOTH));
draw_option = (!setDrawOptions ?
DM_DRAW_OPTION_NORMAL :
@@ -515,13 +573,16 @@ static void emDM_drawMappedFaces(DerivedMesh *dm,
}
else {
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r));
- glNormal3fv(vertexNos[BM_elem_index_get(ltri[0]->v)]);
+ if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[0])]);
+ else glNormal3fv(vertexNos[BM_elem_index_get(ltri[0]->v)]);
glVertex3fv(vertexCos[BM_elem_index_get(ltri[0]->v)]);
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
- glNormal3fv(vertexNos[BM_elem_index_get(ltri[1]->v)]);
+ if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[1])]);
+ else glNormal3fv(vertexNos[BM_elem_index_get(ltri[1]->v)]);
glVertex3fv(vertexCos[BM_elem_index_get(ltri[1]->v)]);
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r));
- glNormal3fv(vertexNos[BM_elem_index_get(ltri[2]->v)]);
+ if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[2])]);
+ else glNormal3fv(vertexNos[BM_elem_index_get(ltri[2]->v)]);
glVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]);
}
}
@@ -540,14 +601,14 @@ static void emDM_drawMappedFaces(DerivedMesh *dm,
}
}
else {
- BM_mesh_elem_index_ensure(bm, BM_FACE);
+ BM_mesh_elem_index_ensure(bm, lnors ? BM_FACE | BM_LOOP : BM_FACE);
for (i = 0; i < tottri; i++) {
BMLoop **ltri = looptris[i];
int drawSmooth;
efa = ltri[0]->f;
- drawSmooth = (flag & DM_DRAW_ALWAYS_SMOOTH) ? 1 : BM_elem_flag_test(efa, BM_ELEM_SMOOTH);
+ drawSmooth = lnors || ((flag & DM_DRAW_ALWAYS_SMOOTH) ? 1 : BM_elem_flag_test(efa, BM_ELEM_SMOOTH));
draw_option = (!setDrawOptions ?
DM_DRAW_OPTION_NORMAL :
@@ -601,13 +662,16 @@ static void emDM_drawMappedFaces(DerivedMesh *dm,
}
else {
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r));
- glNormal3fv(ltri[0]->v->no);
+ if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[0])]);
+ else glNormal3fv(ltri[0]->v->no);
glVertex3fv(ltri[0]->v->co);
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
- glNormal3fv(ltri[1]->v->no);
+ if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[1])]);
+ else glNormal3fv(ltri[1]->v->no);
glVertex3fv(ltri[1]->v->co);
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r));
- glNormal3fv(ltri[2]->v->no);
+ if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[2])]);
+ else glNormal3fv(ltri[2]->v->no);
glVertex3fv(ltri[2]->v->co);
}
}
@@ -663,6 +727,7 @@ static void emDM_drawFacesTex_common(DerivedMesh *dm,
BMesh *bm = em->bm;
struct BMLoop *(*looptris)[3] = em->looptris;
BMFace *efa;
+ const float (*lnors)[3] = dm->getLoopDataArray(dm, CD_NORMAL);
MLoopUV *luv[3], dummyluv = {{0}};
MLoopCol *lcol[3] = {NULL} /* , dummylcol = {0} */;
const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV);
@@ -702,14 +767,14 @@ static void emDM_drawFacesTex_common(DerivedMesh *dm,
vertexNos = bmdm->vertexNos;
polyNos = bmdm->polyNos;
- BM_mesh_elem_index_ensure(bm, BM_VERT);
+ BM_mesh_elem_index_ensure(bm, lnors ? BM_LOOP | BM_VERT : BM_VERT);
for (i = 0; i < em->tottri; i++) {
BMLoop **ltri = looptris[i];
MTexPoly *tp = (cd_poly_tex_offset != -1) ? BM_ELEM_CD_GET_VOID_P(ltri[0]->f, cd_poly_tex_offset) : NULL;
MTFace mtf = {{{0}}};
/*unsigned char *cp = NULL;*/ /*UNUSED*/
- int drawSmooth = BM_elem_flag_test(ltri[0]->f, BM_ELEM_SMOOTH);
+ int drawSmooth = lnors || BM_elem_flag_test(ltri[0]->f, BM_ELEM_SMOOTH);
DMDrawOption draw_option;
efa = ltri[0]->f;
@@ -750,17 +815,20 @@ static void emDM_drawFacesTex_common(DerivedMesh *dm,
else {
glTexCoord2fv(luv[0]->uv);
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r));
- glNormal3fv(vertexNos[BM_elem_index_get(ltri[0]->v)]);
+ if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[0])]);
+ else glNormal3fv(vertexNos[BM_elem_index_get(ltri[0]->v)]);
glVertex3fv(vertexCos[BM_elem_index_get(ltri[0]->v)]);
glTexCoord2fv(luv[1]->uv);
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
- glNormal3fv(vertexNos[BM_elem_index_get(ltri[1]->v)]);
+ if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[1])]);
+ else glNormal3fv(vertexNos[BM_elem_index_get(ltri[1]->v)]);
glVertex3fv(vertexCos[BM_elem_index_get(ltri[1]->v)]);
glTexCoord2fv(luv[2]->uv);
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r));
- glNormal3fv(vertexNos[BM_elem_index_get(ltri[2]->v)]);
+ if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[2])]);
+ else glNormal3fv(vertexNos[BM_elem_index_get(ltri[2]->v)]);
glVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]);
}
glEnd();
@@ -768,14 +836,14 @@ static void emDM_drawFacesTex_common(DerivedMesh *dm,
}
}
else {
- BM_mesh_elem_index_ensure(bm, BM_VERT);
+ BM_mesh_elem_index_ensure(bm, lnors ? BM_LOOP | BM_VERT : BM_VERT);
for (i = 0; i < em->tottri; i++) {
BMLoop **ltri = looptris[i];
MTexPoly *tp = (cd_poly_tex_offset != -1) ? BM_ELEM_CD_GET_VOID_P(ltri[0]->f, cd_poly_tex_offset) : NULL;
MTFace mtf = {{{0}}};
/*unsigned char *cp = NULL;*/ /*UNUSED*/
- int drawSmooth = BM_elem_flag_test(ltri[0]->f, BM_ELEM_SMOOTH);
+ int drawSmooth = lnors || BM_elem_flag_test(ltri[0]->f, BM_ELEM_SMOOTH);
DMDrawOption draw_option;
efa = ltri[0]->f;
@@ -816,17 +884,20 @@ static void emDM_drawFacesTex_common(DerivedMesh *dm,
else {
glTexCoord2fv(luv[0]->uv);
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r));
- glNormal3fv(ltri[0]->v->no);
+ if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[0])]);
+ else glNormal3fv(ltri[0]->v->no);
glVertex3fv(ltri[0]->v->co);
glTexCoord2fv(luv[1]->uv);
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
- glNormal3fv(ltri[1]->v->no);
+ if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[1])]);
+ else glNormal3fv(ltri[1]->v->no);
glVertex3fv(ltri[1]->v->co);
glTexCoord2fv(luv[2]->uv);
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r));
- glNormal3fv(ltri[2]->v->no);
+ if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[2])]);
+ else glNormal3fv(ltri[2]->v->no);
glVertex3fv(ltri[2]->v->co);
}
glEnd();
@@ -927,6 +998,7 @@ static void emDM_drawMappedFacesGLSL(DerivedMesh *dm,
const float (*vertexCos)[3] = bmdm->vertexCos;
const float (*vertexNos)[3];
const float (*polyNos)[3];
+ const float (*lnors)[3] = dm->getLoopDataArray(dm, CD_NORMAL);
BMFace *efa;
DMVertexAttribs attribs;
@@ -947,7 +1019,7 @@ static void emDM_drawMappedFacesGLSL(DerivedMesh *dm,
/* always use smooth shading even for flat faces, else vertex colors wont interpolate */
glShadeModel(GL_SMOOTH);
- BM_mesh_elem_index_ensure(bm, BM_VERT | BM_FACE);
+ BM_mesh_elem_index_ensure(bm, lnors ? BM_VERT | BM_FACE | BM_LOOP : BM_VERT | BM_FACE);
for (i = 0; i < em->tottri; i++) {
BMLoop **ltri = looptris[i];
@@ -973,7 +1045,7 @@ static void emDM_drawMappedFacesGLSL(DerivedMesh *dm,
if (do_draw) {
/* draw face */
- drawSmooth = BM_elem_flag_test(efa, BM_ELEM_SMOOTH);
+ drawSmooth = lnors || BM_elem_flag_test(efa, BM_ELEM_SMOOTH);
if (!drawSmooth) {
if (vertexCos) {
@@ -996,14 +1068,16 @@ static void emDM_drawMappedFacesGLSL(DerivedMesh *dm,
for (fi = 0; fi < 3; fi++) {
const int j = BM_elem_index_get(ltri[fi]->v);
emdm_pass_attrib_vertex_glsl(&attribs, ltri[fi], fi);
- glNormal3fv(vertexNos[j]);
+ if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[fi])]);
+ else glNormal3fv(vertexNos[j]);
glVertex3fv(vertexCos[j]);
}
}
else {
for (fi = 0; fi < 3; fi++) {
emdm_pass_attrib_vertex_glsl(&attribs, ltri[fi], fi);
- glNormal3fv(ltri[fi]->v->no);
+ if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[fi])]);
+ else glNormal3fv(ltri[fi]->v->no);
glVertex3fv(ltri[fi]->v->co);
}
}
@@ -1017,13 +1091,13 @@ static void emDM_drawMappedFacesGLSL(DerivedMesh *dm,
}
static void emDM_drawFacesGLSL(DerivedMesh *dm,
- int (*setMaterial)(int, void *attribs))
+ int (*setMaterial)(int matnr, void *attribs))
{
dm->drawMappedFacesGLSL(dm, setMaterial, NULL, NULL);
}
static void emDM_drawMappedFacesMat(DerivedMesh *dm,
- void (*setMaterial)(void *userData, int, void *attribs),
+ void (*setMaterial)(void *userData, int matnr, void *attribs),
bool (*setFace)(void *userData, int index), void *userData)
{
EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
@@ -1033,6 +1107,7 @@ static void emDM_drawMappedFacesMat(DerivedMesh *dm,
const float (*vertexCos)[3] = bmdm->vertexCos;
const float (*vertexNos)[3];
const float (*polyNos)[3];
+ const float (*lnors)[3] = dm->getLoopDataArray(dm, CD_NORMAL);
BMFace *efa;
DMVertexAttribs attribs = {{{NULL}}};
GPUVertexAttribs gattribs;
@@ -1049,7 +1124,7 @@ static void emDM_drawMappedFacesMat(DerivedMesh *dm,
/* always use smooth shading even for flat faces, else vertex colors wont interpolate */
glShadeModel(GL_SMOOTH);
- BM_mesh_elem_index_ensure(bm, BM_VERT | BM_FACE);
+ BM_mesh_elem_index_ensure(bm, lnors ? BM_VERT | BM_FACE | BM_LOOP : BM_VERT | BM_FACE);
for (i = 0; i < em->tottri; i++) {
BMLoop **ltri = looptris[i];
@@ -1074,7 +1149,7 @@ static void emDM_drawMappedFacesMat(DerivedMesh *dm,
}
/* draw face */
- drawSmooth = BM_elem_flag_test(efa, BM_ELEM_SMOOTH);
+ drawSmooth = lnors || BM_elem_flag_test(efa, BM_ELEM_SMOOTH);
if (!drawSmooth) {
if (vertexCos) {
@@ -1097,14 +1172,16 @@ static void emDM_drawMappedFacesMat(DerivedMesh *dm,
for (fi = 0; fi < 3; fi++) {
const int j = BM_elem_index_get(ltri[fi]->v);
emdm_pass_attrib_vertex_glsl(&attribs, ltri[fi], fi);
- glNormal3fv(vertexNos[j]);
+ if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[fi])]);
+ else glNormal3fv(vertexNos[j]);
glVertex3fv(vertexCos[j]);
}
}
else {
for (fi = 0; fi < 3; fi++) {
emdm_pass_attrib_vertex_glsl(&attribs, ltri[fi], fi);
- glNormal3fv(ltri[fi]->v->no);
+ if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[fi])]);
+ else glNormal3fv(ltri[fi]->v->no);
glVertex3fv(ltri[fi]->v->co);
}
}
@@ -1178,7 +1255,7 @@ static int emDM_getNumPolys(DerivedMesh *dm)
static void bmvert_to_mvert(BMesh *bm, BMVert *ev, MVert *r_vert)
{
- float *f;
+ const float *f;
copy_v3_v3(r_vert->co, ev->co);
@@ -1288,7 +1365,7 @@ static void emDM_getEdge(DerivedMesh *dm, int index, MEdge *r_edge)
EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
BMesh *bm = bmdm->em->bm;
BMEdge *e;
- float *f;
+ const float *f;
if (UNLIKELY(index < 0 || index >= bm->totedge)) {
BLI_assert(!"error in emDM_getEdge");
@@ -1479,7 +1556,7 @@ static void *emDM_getTessFaceDataArray(DerivedMesh *dm, int type)
if (type == CD_MTFACE || type == CD_MCOL) {
const int type_from = (type == CD_MTFACE) ? CD_MTEXPOLY : CD_MLOOPCOL;
int index;
- char *data, *bmdata;
+ const char *data, *bmdata;
index = CustomData_get_layer_index(&bm->pdata, type_from);
if (index != -1) {
@@ -1525,6 +1602,31 @@ static void *emDM_getTessFaceDataArray(DerivedMesh *dm, int type)
}
}
+ /* Special handling for CD_TESSLOOPNORMAL, we generate it on demand as well. */
+ if (type == CD_TESSLOOPNORMAL) {
+ const float (*lnors)[3] = dm->getLoopDataArray(dm, CD_NORMAL);
+
+ if (lnors) {
+ BMLoop *(*looptris)[3] = bmdm->em->looptris;
+ short (*tlnors)[4][3], (*tlnor)[4][3];
+ int index, i, j;
+
+ DM_add_tessface_layer(dm, type, CD_CALLOC, NULL);
+ index = CustomData_get_layer_index(&dm->faceData, type);
+ dm->faceData.layers[index].flag |= CD_FLAG_TEMPORARY;
+
+ tlnor = tlnors = DM_get_tessface_data_layer(dm, type);
+
+ BM_mesh_elem_index_ensure(bm, BM_LOOP);
+
+ for (i = 0; i < bmdm->em->tottri; i++, tlnor++, looptris++) {
+ for (j = 0; j < 3; j++) {
+ normal_float_to_short_v3((*tlnor)[j], lnors[BM_elem_index_get((*looptris)[j])]);
+ }
+ }
+ }
+ }
+
return datalayer;
}
@@ -1654,9 +1756,11 @@ DerivedMesh *getEditDerivedBMesh(BMEditMesh *em,
bmdm->dm.getTessFaceDataArray = emDM_getTessFaceDataArray;
bmdm->dm.calcNormals = emDM_calcNormals;
+ bmdm->dm.calcLoopNormals = emDM_calcLoopNormals;
bmdm->dm.recalcTessellation = emDM_recalcTessellation;
bmdm->dm.foreachMappedVert = emDM_foreachMappedVert;
+ bmdm->dm.foreachMappedLoop = emDM_foreachMappedLoop;
bmdm->dm.foreachMappedEdge = emDM_foreachMappedEdge;
bmdm->dm.foreachMappedFaceCenter = emDM_foreachMappedFaceCenter;
diff --git a/source/blender/blenkernel/intern/editmesh.c b/source/blender/blenkernel/intern/editmesh.c
index 65faf59978a..2247b91df1d 100644
--- a/source/blender/blenkernel/intern/editmesh.c
+++ b/source/blender/blenkernel/intern/editmesh.c
@@ -36,8 +36,6 @@
#include "DNA_mesh_types.h"
#include "BLI_math.h"
-#include "BLI_memarena.h"
-#include "BLI_scanfill.h"
#include "BKE_editmesh.h"
#include "BKE_cdderivedmesh.h"
diff --git a/source/blender/blenkernel/intern/editmesh_bvh.c b/source/blender/blenkernel/intern/editmesh_bvh.c
index 943469eb4f0..76ea340ecbd 100644
--- a/source/blender/blenkernel/intern/editmesh_bvh.c
+++ b/source/blender/blenkernel/intern/editmesh_bvh.c
@@ -31,8 +31,6 @@
#include "MEM_guardedalloc.h"
-#include "DNA_object_types.h"
-
#include "BLI_math.h"
#include "BLI_kdopbvh.h"
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index 91d12d39af4..e28152dbc1a 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -37,15 +37,9 @@
#include "MEM_guardedalloc.h"
#include "DNA_curve_types.h"
-#include "DNA_effect_types.h"
#include "DNA_group_types.h"
-#include "DNA_ipo_types.h"
-#include "DNA_key_types.h"
-#include "DNA_lattice_types.h"
#include "DNA_listBase.h"
-#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
-#include "DNA_material_types.h"
#include "DNA_object_types.h"
#include "DNA_object_force.h"
#include "DNA_particle_types.h"
@@ -60,27 +54,13 @@
#include "PIL_time.h"
-#include "BKE_action.h"
#include "BKE_anim.h" /* needed for where_on_path */
-#include "BKE_armature.h"
-#include "BKE_blender.h"
#include "BKE_collision.h"
-#include "BKE_constraint.h"
#include "BKE_curve.h"
-#include "BKE_deform.h"
-#include "BKE_depsgraph.h"
#include "BKE_displist.h"
#include "BKE_DerivedMesh.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_effect.h"
-#include "BKE_global.h"
-#include "BKE_group.h"
-#include "BKE_ipo.h"
-#include "BKE_key.h"
-#include "BKE_lattice.h"
-#include "BKE_mesh.h"
-#include "BKE_material.h"
-#include "BKE_main.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_particle.h"
@@ -93,7 +73,6 @@
/* fluid sim particle import */
#ifdef WITH_MOD_FLUID
-#include "DNA_object_fluidsim.h"
#include "LBM_fluidsim.h"
#include <zlib.h>
#include <string.h>
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index 1810e41a39c..65b9d2159df 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -351,10 +351,6 @@ FCurve *rna_get_fcurve(PointerRNA *ptr, PropertyRNA *prop, int rnaindex, bAction
/* ----------------- Finding Keyframes/Extents -------------------------- */
-/* threshold for binary-searching keyframes - threshold here should be good enough for now, but should become userpref */
-#define BEZT_BINARYSEARCH_THRESH 0.01f /* was 0.00001, but giving errors */
-
-
/* Binary search algorithm for finding where to insert BezTriple, with optional argument for precision required.
* Returns the index to insert at (data already at that index will be offset if replace is 0)
*/
@@ -882,7 +878,7 @@ void testhandles_fcurve(FCurve *fcu, const bool use_handle)
*/
void sort_time_fcurve(FCurve *fcu)
{
- short ok = 1;
+ bool ok = true;
/* keep adjusting order of beztriples until nothing moves (bubble-sort) */
while (ok) {
@@ -1932,6 +1928,7 @@ static void berekenx(float *f, float *o, int b)
/* Calculate F-Curve value for 'evaltime' using BezTriple keyframes */
static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime)
{
+ const float eps = 1.e-8f;
BezTriple *bezt, *prevbezt, *lastbezt;
float v1[2], v2[2], v3[2], v4[2], opl[32], dx, fac;
unsigned int a;
@@ -2077,7 +2074,7 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
if (exact) {
cvalue = prevbezt->vec[1][1];
}
- else if (fabsf(bezt->vec[1][0] - evaltime) < SMALL_NUMBER) {
+ else if (fabsf(bezt->vec[1][0] - evaltime) < eps) {
cvalue = bezt->vec[1][1];
}
/* evaltime occurs within the interval defined by these two keyframes */
@@ -2086,7 +2083,7 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
const float change = bezt->vec[1][1] - prevbezt->vec[1][1];
const float duration = bezt->vec[1][0] - prevbezt->vec[1][0];
const float time = evaltime - prevbezt->vec[1][0];
- const float amplitude = prevbezt->amplitude + fabsf(change); /* see T39405 */
+ const float amplitude = prevbezt->amplitude;
const float period = prevbezt->period;
/* value depends on interpolation mode */
@@ -2142,6 +2139,10 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
case BEZT_IPO_EASE_IN_OUT:
cvalue = BLI_easing_back_ease_in_out(time, begin, change, duration, prevbezt->back);
break;
+
+ default: /* default/auto: same as ease out */
+ cvalue = BLI_easing_back_ease_out(time, begin, change, duration, prevbezt->back);
+ break;
}
break;
@@ -2156,6 +2157,10 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
case BEZT_IPO_EASE_IN_OUT:
cvalue = BLI_easing_bounce_ease_in_out(time, begin, change, duration);
break;
+
+ default: /* default/auto: same as ease out */
+ cvalue = BLI_easing_bounce_ease_out(time, begin, change, duration);
+ break;
}
break;
@@ -2170,6 +2175,10 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
case BEZT_IPO_EASE_IN_OUT:
cvalue = BLI_easing_circ_ease_in_out(time, begin, change, duration);
break;
+
+ default: /* default/auto: same as ease in */
+ cvalue = BLI_easing_circ_ease_in(time, begin, change, duration);
+ break;
}
break;
@@ -2184,6 +2193,10 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
case BEZT_IPO_EASE_IN_OUT:
cvalue = BLI_easing_cubic_ease_in_out(time, begin, change, duration);
break;
+
+ default: /* default/auto: same as ease in */
+ cvalue = BLI_easing_cubic_ease_in(time, begin, change, duration);
+ break;
}
break;
@@ -2198,6 +2211,10 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
case BEZT_IPO_EASE_IN_OUT:
cvalue = BLI_easing_elastic_ease_in_out(time, begin, change, duration, amplitude, period);
break;
+
+ default: /* default/auto: same as ease out */
+ cvalue = BLI_easing_elastic_ease_out(time, begin, change, duration, amplitude, period);
+ break;
}
break;
@@ -2212,6 +2229,10 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
case BEZT_IPO_EASE_IN_OUT:
cvalue = BLI_easing_expo_ease_in_out(time, begin, change, duration);
break;
+
+ default: /* default/auto: same as ease in */
+ cvalue = BLI_easing_expo_ease_in(time, begin, change, duration);
+ break;
}
break;
@@ -2226,6 +2247,10 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
case BEZT_IPO_EASE_IN_OUT:
cvalue = BLI_easing_quad_ease_in_out(time, begin, change, duration);
break;
+
+ default: /* default/auto: same as ease in */
+ cvalue = BLI_easing_quad_ease_in(time, begin, change, duration);
+ break;
}
break;
@@ -2240,6 +2265,10 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
case BEZT_IPO_EASE_IN_OUT:
cvalue = BLI_easing_quart_ease_in_out(time, begin, change, duration);
break;
+
+ default: /* default/auto: same as ease in */
+ cvalue = BLI_easing_quart_ease_in(time, begin, change, duration);
+ break;
}
break;
@@ -2254,6 +2283,10 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
case BEZT_IPO_EASE_IN_OUT:
cvalue = BLI_easing_quint_ease_in_out(time, begin, change, duration);
break;
+
+ default: /* default/auto: same as ease in */
+ cvalue = BLI_easing_quint_ease_in(time, begin, change, duration);
+ break;
}
break;
@@ -2268,6 +2301,10 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
case BEZT_IPO_EASE_IN_OUT:
cvalue = BLI_easing_sine_ease_in_out(time, begin, change, duration);
break;
+
+ default: /* default/auto: same as ease in */
+ cvalue = BLI_easing_sine_ease_in(time, begin, change, duration);
+ break;
}
break;
diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c
index efc9869c5ca..beb85b31847 100644
--- a/source/blender/blenkernel/intern/fluidsim.c
+++ b/source/blender/blenkernel/intern/fluidsim.c
@@ -44,7 +44,7 @@
#include "DNA_object_force.h" // for pointcache
#include "DNA_object_types.h"
#include "DNA_particle_types.h"
-#include "DNA_scene_types.h" // N_T
+#include "DNA_scene_types.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index 6bef88b7f43..ef861e2844c 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -52,7 +52,6 @@
#include "DNA_packedFile_types.h"
#include "DNA_curve_types.h"
#include "DNA_vfont_types.h"
-#include "DNA_scene_types.h"
#include "DNA_object_types.h"
#include "BKE_packedFile.h"
@@ -62,7 +61,6 @@
#include "BKE_main.h"
#include "BKE_anim.h"
#include "BKE_curve.h"
-#include "BKE_displist.h"
static ThreadRWMutex vfont_rwlock = BLI_RWLOCK_INITIALIZER;
diff --git a/source/blender/blenkernel/intern/freestyle.c b/source/blender/blenkernel/intern/freestyle.c
index f5a9ba4e241..495e99d61af 100644
--- a/source/blender/blenkernel/intern/freestyle.c
+++ b/source/blender/blenkernel/intern/freestyle.c
@@ -169,7 +169,7 @@ static FreestyleLineSet *alloc_lineset(void)
return (FreestyleLineSet *)MEM_callocN(sizeof(FreestyleLineSet), "Freestyle line set");
}
-FreestyleLineSet *BKE_freestyle_lineset_add(FreestyleConfig *config)
+FreestyleLineSet *BKE_freestyle_lineset_add(FreestyleConfig *config, const char *name)
{
int lineset_index = BLI_countlist(&config->linesets);
@@ -186,15 +186,36 @@ FreestyleLineSet *BKE_freestyle_lineset_add(FreestyleConfig *config)
lineset->edge_types = FREESTYLE_FE_SILHOUETTE | FREESTYLE_FE_BORDER | FREESTYLE_FE_CREASE;
lineset->exclude_edge_types = 0;
lineset->group = NULL;
- if (lineset_index > 0)
+ if (name) {
+ BLI_strncpy(lineset->name, name, sizeof(lineset->name));
+ }
+ else if (lineset_index > 0) {
sprintf(lineset->name, "LineSet %i", lineset_index + 1);
- else
+ }
+ else {
strcpy(lineset->name, "LineSet");
+ }
BKE_freestyle_lineset_unique_name(config, lineset);
return lineset;
}
+bool BKE_freestyle_lineset_delete(FreestyleConfig *config, FreestyleLineSet *lineset)
+{
+ if (BLI_findindex(&config->linesets, lineset) == -1)
+ return false;
+ if (lineset->group) {
+ lineset->group->id.us--;
+ }
+ if (lineset->linestyle) {
+ lineset->linestyle->id.us--;
+ }
+ BLI_remlink(&config->linesets, lineset);
+ MEM_freeN(lineset);
+ BKE_freestyle_lineset_set_active_index(config, 0);
+ return true;
+}
+
FreestyleLineSet *BKE_freestyle_lineset_get_active(FreestyleConfig *config)
{
FreestyleLineSet *lineset;
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 2eed25cde0e..c381084cfd2 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -48,8 +48,6 @@
#include "BKE_global.h"
#include "BKE_gpencil.h"
#include "BKE_library.h"
-#include "BKE_main.h"
-
/* ************************************************** */
diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c
index e84db7e1f82..6ea6bafaa14 100644
--- a/source/blender/blenkernel/intern/group.c
+++ b/source/blender/blenkernel/intern/group.c
@@ -39,7 +39,6 @@
#include "DNA_group_types.h"
#include "DNA_material_types.h"
#include "DNA_object_types.h"
-#include "DNA_nla_types.h"
#include "DNA_scene_types.h"
#include "DNA_particle_types.h"
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c
index 23d55ad90df..f12a0720692 100644
--- a/source/blender/blenkernel/intern/idprop.c
+++ b/source/blender/blenkernel/intern/idprop.c
@@ -35,6 +35,7 @@
#include "BLI_utildefines.h"
#include "BLI_string.h"
#include "BLI_listbase.h"
+#include "BLI_math.h"
#include "BKE_idprop.h"
#include "BKE_library.h"
@@ -820,6 +821,19 @@ bool IDP_EqualsProperties_ex(IDProperty *prop1, IDProperty *prop2, const bool is
case IDP_INT:
return (IDP_Int(prop1) == IDP_Int(prop2));
case IDP_FLOAT:
+#ifdef DEBUG
+ {
+ float p1 = IDP_Float(prop1);
+ float p2 = IDP_Float(prop2);
+ if ((p1 != p2) && ((fabsf(p1 - p2) / max_ff(p1, p2)) < 0.001f)) {
+ printf("WARNING: Comparing two float properties that have nearly the same value (%f vs. %f)\n", p1, p2);
+ printf(" p1: ");
+ IDP_spit(prop1);
+ printf(" p2: ");
+ IDP_spit(prop2);
+ }
+ }
+#endif
return (IDP_Float(prop1) == IDP_Float(prop2));
case IDP_DOUBLE:
return (IDP_Double(prop1) == IDP_Double(prop2));
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index c0c028632cf..440320e98fe 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -40,11 +40,6 @@
#include <time.h>
-#ifdef _WIN32
-# define open _open
-# define close _close
-#endif
-
#include "MEM_guardedalloc.h"
#include "IMB_colormanagement.h"
@@ -635,7 +630,7 @@ Image *BKE_image_load(Main *bmain, const char *filepath)
/* exists? */
file = BLI_open(str, O_BINARY | O_RDONLY, 0);
- if (file < 0)
+ if (file == -1)
return NULL;
close(file);
@@ -1580,7 +1575,7 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d
}
if (scene->r.stamp & R_STAMP_MARKER) {
- char *name = BKE_scene_find_last_marker_name(scene, CFRA);
+ const char *name = BKE_scene_find_last_marker_name(scene, CFRA);
if (name) BLI_strncpy(text, name, sizeof(text));
else BLI_strncpy(text, "<none>", sizeof(text));
@@ -1902,7 +1897,7 @@ bool BKE_imbuf_alpha_test(ImBuf *ibuf)
{
int tot;
if (ibuf->rect_float) {
- float *buf = ibuf->rect_float;
+ const float *buf = ibuf->rect_float;
for (tot = ibuf->x * ibuf->y; tot--; buf += 4) {
if (buf[3] < 1.0f) {
return true;
diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c
index cceb7925194..e28fb59cfe6 100644
--- a/source/blender/blenkernel/intern/implicit.c
+++ b/source/blender/blenkernel/intern/implicit.c
@@ -37,7 +37,6 @@
#include "DNA_object_force.h"
#include "DNA_meshdata_types.h"
-#include "BLI_threads.h"
#include "BLI_math.h"
#include "BLI_linklist.h"
#include "BLI_utildefines.h"
@@ -1400,7 +1399,7 @@ static void CalcFloat4( float *v1, float *v2, float *v3, float *v4, float *n)
n[2] = n1[0]*n2[1]-n1[1]*n2[0];
}
-static float calculateVertexWindForce(float wind[3], float vertexnormal[3])
+static float calculateVertexWindForce(const float wind[3], const float vertexnormal[3])
{
return dot_v3v3(wind, vertexnormal);
}
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index cf66d866c2c..7385322ddeb 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -60,7 +60,6 @@
#include "DNA_world_types.h"
#include "DNA_object_types.h"
-#include "BLI_math.h" /* windows needs for M_PI */
#include "BLI_blenlib.h"
#include "BLI_dynstr.h"
#include "BLI_utildefines.h"
@@ -78,6 +77,10 @@
#include "MEM_guardedalloc.h"
+#ifdef WIN32
+# include "BLI_math_base.h" /* M_PI */
+#endif
+
/* *************************************************** */
/* Old-Data Freeing Tools */
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index 11c00576b61..0f04c03688c 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -59,8 +59,6 @@
#include "BKE_lattice.h"
#include "BKE_library.h"
#include "BKE_editmesh.h"
-#include "BKE_main.h"
-#include "BKE_object.h"
#include "BKE_scene.h"
@@ -1681,7 +1679,7 @@ void BKE_key_convert_from_lattice(Lattice *lt, KeyBlock *kb)
void BKE_key_convert_to_lattice(KeyBlock *kb, Lattice *lt)
{
BPoint *bp;
- float *fp;
+ const float *fp;
int a, tot;
bp = lt->def;
@@ -1752,7 +1750,7 @@ void BKE_key_convert_to_curve(KeyBlock *kb, Curve *UNUSED(cu), ListBase *nurb)
Nurb *nu;
BezTriple *bezt;
BPoint *bp;
- float *fp;
+ const float *fp;
int a, tot;
nu = nurb->first;
@@ -1822,7 +1820,7 @@ void BKE_key_convert_from_mesh(Mesh *me, KeyBlock *kb)
void BKE_key_convert_to_mesh(KeyBlock *kb, Mesh *me)
{
MVert *mvert;
- float *fp;
+ const float *fp;
int a, tot;
mvert = me->mvert;
@@ -1839,7 +1837,7 @@ void BKE_key_convert_to_mesh(KeyBlock *kb, Mesh *me)
float (*BKE_key_convert_to_vertcos(Object *ob, KeyBlock *kb))[3]
{
float (*vertCos)[3], *co;
- float *fp = kb->data;
+ const float *fp = kb->data;
int tot = 0, a;
/* Count of vertex coords in array */
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index 55abd4b3f6c..51fbb86b38e 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -59,7 +59,6 @@
#include "BKE_lattice.h"
#include "BKE_library.h"
#include "BKE_main.h"
-#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "BKE_deform.h"
@@ -314,7 +313,7 @@ void BKE_lattice_make_local(Lattice *lt)
{
Main *bmain = G.main;
Object *ob;
- int is_local = false, is_lib = false;
+ bool is_local = false, is_lib = false;
/* - only lib users: do nothing
* - only local users: set flag
@@ -368,7 +367,7 @@ LatticeDeformData *init_latt_deform(Object *oblatt, Object *ob)
Lattice *lt = oblatt->data;
BPoint *bp;
DispList *dl = oblatt->curve_cache ? BKE_displist_find(&oblatt->curve_cache->disp, DL_VERTS) : NULL;
- float *co = dl ? dl->verts : NULL;
+ const float *co = dl ? dl->verts : NULL;
float *fp, imat[4][4];
float fu, fv, fw;
int u, v, w;
@@ -647,10 +646,17 @@ static bool calc_curve_deform(Scene *scene, Object *par, float co[3],
}
else {
index = axis;
- if (cu->flag & CU_STRETCH)
+ if (cu->flag & CU_STRETCH) {
fac = (co[index] - cd->dmin[index]) / (cd->dmax[index] - cd->dmin[index]);
- else
- fac = +(co[index] - cd->dmin[index]) / (par->curve_cache->path->totdist);
+ }
+ else {
+ if (LIKELY(par->curve_cache->path->totdist > FLT_EPSILON)) {
+ fac = +(co[index] - cd->dmin[index]) / (par->curve_cache->path->totdist);
+ }
+ else {
+ fac = 0.0f;
+ }
+ }
}
if (where_on_path_deform(par, fac, loc, dir, new_quat, &radius)) { /* returns OK */
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index f831378ca5a..fe2d1481581 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -52,12 +52,12 @@
#include "DNA_key_types.h"
#include "DNA_lamp_types.h"
#include "DNA_lattice_types.h"
+#include "DNA_linestyle_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meta_types.h"
#include "DNA_movieclip_types.h"
#include "DNA_mask_types.h"
-#include "DNA_nla_types.h"
#include "DNA_node_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
@@ -69,7 +69,6 @@
#include "DNA_world_types.h"
#include "BLI_blenlib.h"
-#include "BLI_dynstr.h"
#include "BLI_utildefines.h"
#include "BLF_translation.h"
@@ -89,7 +88,6 @@
#include "BKE_group.h"
#include "BKE_gpencil.h"
#include "BKE_idprop.h"
-#include "BKE_icons.h"
#include "BKE_image.h"
#include "BKE_ipo.h"
#include "BKE_key.h"
@@ -134,7 +132,7 @@
* also note that the id _must_ have a library - campbell */
void BKE_id_lib_local_paths(Main *bmain, Library *lib, ID *id)
{
- char *bpath_user_data[2] = {bmain->name, lib->filepath};
+ const char *bpath_user_data[2] = {bmain->name, lib->filepath};
BKE_bpath_traverse_id(bmain, id,
BKE_bpath_relocate_visitor,
@@ -283,7 +281,7 @@ bool id_make_local(ID *id, bool test)
case ID_GD:
return false; /* not implemented */
case ID_LS:
- return 0; /* not implemented */
+ return false; /* not implemented */
}
return false;
@@ -384,7 +382,7 @@ bool id_copy(ID *id, ID **newid, bool test)
return true;
case ID_LS:
if (!test) *newid = (ID *)BKE_copy_linestyle((FreestyleLineStyle *)id);
- return 1;
+ return true;
}
return false;
@@ -808,7 +806,7 @@ void *BKE_libblock_copy_ex(Main *bmain, ID *id)
return idn;
}
-void *BKE_libblock_copy_nolib(ID *id)
+void *BKE_libblock_copy_nolib(ID *id, const bool do_action)
{
ID *idn;
size_t idn_len;
@@ -829,7 +827,7 @@ void *BKE_libblock_copy_nolib(ID *id)
id->newid = idn;
idn->flag |= LIB_NEW;
- BKE_libblock_copy_data(idn, id, false);
+ BKE_libblock_copy_data(idn, id, do_action);
return idn;
}
@@ -1349,6 +1347,11 @@ void id_clear_lib_data(Main *bmain, ID *id)
BKE_id_lib_local_paths(bmain, id->lib, id);
+ if (id->flag & LIB_FAKEUSER) {
+ id->us--;
+ id->flag &= ~LIB_FAKEUSER;
+ }
+
id->lib = NULL;
id->flag = LIB_LOCAL;
new_id(which_libbase(bmain, GS(id->name)), id, NULL);
@@ -1362,6 +1365,7 @@ void id_clear_lib_data(Main *bmain, ID *id)
case ID_LA: ntree = ((Lamp *)id)->nodetree; break;
case ID_WO: ntree = ((World *)id)->nodetree; break;
case ID_TE: ntree = ((Tex *)id)->nodetree; break;
+ case ID_LS: ntree = ((FreestyleLineStyle *)id)->nodetree; break;
}
if (ntree)
ntree->id.lib = NULL;
diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c
index abc3a762372..e9bdc3679c1 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -29,7 +29,6 @@
#include <stdlib.h>
-#include "MEM_guardedalloc.h"
#include "DNA_anim_types.h"
#include "DNA_brush_types.h"
@@ -40,6 +39,7 @@
#include "DNA_key_types.h"
#include "DNA_lamp_types.h"
#include "DNA_lattice_types.h"
+#include "DNA_linestyle_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meta_types.h"
@@ -104,7 +104,7 @@ static void library_foreach_modifiersForeachIDLink(void *user_data, Object *UNUS
}
static void library_foreach_constraintObjectLooper(bConstraint *UNUSED(con), ID **id_pointer,
- short UNUSED(isReference), void *user_data)
+ bool UNUSED(is_reference), void *user_data)
{
LibraryForeachIDData *data = (LibraryForeachIDData *) user_data;
FOREACH_CALLBACK_INVOKE_ID_PP(data->self_id, id_pointer, data->flag, data->callback, data->user_data, IDWALK_NOP);
@@ -230,7 +230,7 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u
pose_channel = pose_channel->next)
{
CALLBACK_INVOKE(pose_channel->custom, IDWALK_NOP);
- BKE_id_loop_constraints(&pose_channel->constraints,
+ BKE_constraints_id_loop(&pose_channel->constraints,
library_foreach_constraintObjectLooper,
&data);
}
@@ -239,7 +239,7 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u
modifiers_foreachIDLink(object,
library_foreach_modifiersForeachIDLink,
&data);
- BKE_id_loop_constraints(&object->constraints,
+ BKE_constraints_id_loop(&object->constraints,
library_foreach_constraintObjectLooper,
&data);
break;
@@ -451,6 +451,19 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u
}
break;
}
+
+ case ID_LS:
+ {
+ FreestyleLineStyle *linestyle = (FreestyleLineStyle *) id;
+ for (i = 0; i < MAX_MTEX; i++) {
+ if (linestyle->mtex[i]) {
+ library_foreach_mtex(&data, linestyle->mtex[i]);
+ }
+ }
+ CALLBACK_INVOKE(linestyle->nodetree, IDWALK_NOP);
+ break;
+ }
+
}
#undef CALLBACK_INVOKE_ID
diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c
index 3622174975a..8028bdbc327 100644
--- a/source/blender/blenkernel/intern/linestyle.c
+++ b/source/blender/blenkernel/intern/linestyle.c
@@ -46,7 +46,7 @@
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_linestyle.h"
-#include "BKE_main.h"
+#include "BKE_node.h"
#include "BKE_texture.h"
#include "BKE_colortools.h"
#include "BKE_animsys.h"
@@ -81,7 +81,7 @@ static void default_linestyle_settings(FreestyleLineStyle *linestyle)
linestyle->thickness = 3.0f;
linestyle->thickness_position = LS_THICKNESS_CENTER;
linestyle->thickness_ratio = 0.5f;
- linestyle->flag = LS_SAME_OBJECT;
+ linestyle->flag = LS_SAME_OBJECT | LS_NO_SORTING | LS_TEXTURE;
linestyle->chaining = LS_CHAINING_PLAIN;
linestyle->rounds = 3;
linestyle->min_angle = DEG2RADF(0.0f);
@@ -89,6 +89,10 @@ static void default_linestyle_settings(FreestyleLineStyle *linestyle)
linestyle->min_length = 0.0f;
linestyle->max_length = 10000.0f;
linestyle->split_length = 100;
+ linestyle->sort_key = LS_SORT_KEY_DISTANCE_FROM_CAMERA;
+ linestyle->integration_type = LS_INTEGRATION_MEAN;
+ linestyle->texstep = 1.0f;
+ linestyle->pr_texture = TEX_PR_TEXTURE;
BLI_listbase_clear(&linestyle->color_modifiers);
BLI_listbase_clear(&linestyle->alpha_modifiers);
@@ -118,6 +122,19 @@ void BKE_free_linestyle(FreestyleLineStyle *linestyle)
{
LineStyleModifier *m;
+ MTex *mtex;
+ int a;
+
+ for (a = 0; a < MAX_MTEX; a++) {
+ mtex = linestyle->mtex[a];
+ if (mtex && mtex->tex) mtex->tex->id.us--;
+ if (mtex) MEM_freeN(mtex);
+ }
+ if (linestyle->nodetree) {
+ ntreeFreeTree(linestyle->nodetree);
+ MEM_freeN(linestyle->nodetree);
+ }
+
BKE_free_animdata(&linestyle->id);
while ((m = (LineStyleModifier *)linestyle->color_modifiers.first))
BKE_remove_linestyle_color_modifier(linestyle, m);
@@ -133,10 +150,22 @@ FreestyleLineStyle *BKE_copy_linestyle(FreestyleLineStyle *linestyle)
{
FreestyleLineStyle *new_linestyle;
LineStyleModifier *m;
+ int a;
new_linestyle = BKE_new_linestyle(linestyle->id.name + 2, NULL);
BKE_free_linestyle(new_linestyle);
+ for (a = 0; a < MAX_MTEX; a++) {
+ if (linestyle->mtex[a]) {
+ new_linestyle->mtex[a] = MEM_mallocN(sizeof(MTex), "BKE_copy_linestyle");
+ memcpy(new_linestyle->mtex[a], linestyle->mtex[a], sizeof(MTex));
+ id_us_plus((ID *)new_linestyle->mtex[a]->tex);
+ }
+ }
+ if (linestyle->nodetree) {
+ linestyle->nodetree = ntreeCopyTree(linestyle->nodetree);
+ }
+
new_linestyle->r = linestyle->r;
new_linestyle->g = linestyle->g;
new_linestyle->b = linestyle->b;
@@ -166,6 +195,8 @@ FreestyleLineStyle *BKE_copy_linestyle(FreestyleLineStyle *linestyle)
new_linestyle->dash3 = linestyle->dash3;
new_linestyle->gap3 = linestyle->gap3;
new_linestyle->panel = linestyle->panel;
+ new_linestyle->texstep = linestyle->texstep;
+ new_linestyle->pr_texture = linestyle->pr_texture;
for (m = (LineStyleModifier *)linestyle->color_modifiers.first; m; m = m->next)
BKE_copy_linestyle_color_modifier(new_linestyle, m);
for (m = (LineStyleModifier *)linestyle->alpha_modifiers.first; m; m = m->next)
@@ -1024,7 +1055,7 @@ void BKE_list_modifier_color_ramps(FreestyleLineStyle *linestyle, ListBase *list
default:
continue;
}
- link = (LinkData *) MEM_callocN( sizeof(LinkData), "link to color ramp");
+ link = (LinkData *) MEM_callocN(sizeof(LinkData), "link to color ramp");
link->data = color_ramp;
BLI_addtail(listbase, link);
}
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c
index b303243b66a..8c1cc4b0279 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -50,7 +50,6 @@
#include "DNA_sequence_types.h"
#include "BKE_curve.h"
-#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_mask.h"
@@ -1687,8 +1686,8 @@ void BKE_mask_layer_shape_to_mask_interp(MaskLayer *masklay,
{
int tot = BKE_mask_layer_shape_totvert(masklay);
if (masklay_shape_a->tot_vert == tot && masklay_shape_b->tot_vert == tot) {
- float *fp_a = masklay_shape_a->data;
- float *fp_b = masklay_shape_b->data;
+ const float *fp_a = masklay_shape_a->data;
+ const float *fp_b = masklay_shape_b->data;
const float ifac = 1.0f - fac;
MaskSpline *spline;
@@ -2105,7 +2104,7 @@ void BKE_mask_clipboard_paste_to_layer(Main *bmain, MaskLayer *mask_layer)
for (i = 0; i < spline_new->tot_point; i++) {
MaskSplinePoint *point = &spline_new->points[i];
if (point->parent.id) {
- char *id_name = BLI_ghash_lookup(mask_clipboard.id_hash, point->parent.id);
+ const char *id_name = BLI_ghash_lookup(mask_clipboard.id_hash, point->parent.id);
ListBase *listbase;
BLI_assert(id_name != NULL);
diff --git a/source/blender/blenkernel/intern/mask_evaluate.c b/source/blender/blenkernel/intern/mask_evaluate.c
index 33e74582750..3ed6148054c 100644
--- a/source/blender/blenkernel/intern/mask_evaluate.c
+++ b/source/blender/blenkernel/intern/mask_evaluate.c
@@ -37,30 +37,14 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
-#include "BLI_path_util.h"
-#include "BLI_string.h"
-#include "BLI_listbase.h"
#include "BLI_math.h"
#include "DNA_mask_types.h"
#include "DNA_node_types.h"
#include "DNA_scene_types.h"
-#include "DNA_object_types.h"
-#include "DNA_screen_types.h"
-#include "DNA_space_types.h"
-#include "DNA_movieclip_types.h"
-#include "DNA_tracking_types.h"
-#include "DNA_sequence_types.h"
#include "BKE_curve.h"
-#include "BKE_global.h"
-#include "BKE_library.h"
-#include "BKE_main.h"
#include "BKE_mask.h"
-#include "BKE_node.h"
-#include "BKE_sequencer.h"
-#include "BKE_tracking.h"
-#include "BKE_movieclip.h"
unsigned int BKE_mask_spline_resolution(MaskSpline *spline, int width, int height)
@@ -258,15 +242,15 @@ static void feather_bucket_check_intersect(
{
int i;
- float *v1 = (float *) feather_points[cur_a];
- float *v2 = (float *) feather_points[cur_b];
+ const float *v1 = (float *) feather_points[cur_a];
+ const float *v2 = (float *) feather_points[cur_b];
for (i = 0; i < bucket->tot_segment; i++) {
int check_a = bucket->segments[i][0];
int check_b = bucket->segments[i][1];
- float *v3 = (float *) feather_points[check_a];
- float *v4 = (float *) feather_points[check_b];
+ const float *v3 = (float *) feather_points[check_a];
+ const float *v4 = (float *) feather_points[check_b];
if (check_a >= cur_a - 1 || cur_b == check_a)
continue;
diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c
index 92628387dc6..35207595103 100644
--- a/source/blender/blenkernel/intern/mask_rasterize.c
+++ b/source/blender/blenkernel/intern/mask_rasterize.c
@@ -841,8 +841,8 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mas
open_spline_ranges[open_spline_index].vertex_total_cap_tail = 0;
if (!is_cyclic) {
- float *fp_cent;
- float *fp_turn;
+ const float *fp_cent;
+ const float *fp_turn;
unsigned int k;
@@ -1434,6 +1434,10 @@ void BKE_maskrasterize_buffer(MaskRasterHandle *mr_handle,
const unsigned int width, const unsigned int height,
float *buffer)
{
+ const float x_inv = 1.0f / (float)width;
+ const float y_inv = 1.0f / (float)height;
+ const float x_px_ofs = x_inv * 0.5f;
+ const float y_px_ofs = y_inv * 0.5f;
#ifdef _MSC_VER
int y; /* msvc requires signed for some reason */
@@ -1449,9 +1453,9 @@ void BKE_maskrasterize_buffer(MaskRasterHandle *mr_handle,
unsigned int i = y * width;
unsigned int x;
float xy[2];
- xy[1] = (float)y / (float)height;
+ xy[1] = ((float)y * y_inv) + y_px_ofs;
for (x = 0; x < width; x++, i++) {
- xy[0] = (float)x / (float)width;
+ xy[0] = ((float)x * x_inv) + x_px_ofs;
buffer[i] = BKE_maskrasterize_handle_sample(mr_handle, xy);
}
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 01bbd1db003..de3aea9267f 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -203,6 +203,7 @@ void init_material(Material *ma)
ma->game.face_orientation = 0;
ma->mode = MA_TRACEBLE | MA_SHADBUF | MA_SHADOW | MA_RAYBIAS | MA_TANGENT_STR | MA_ZTRANSP;
+ ma->mode2 = MA_CASTSHADOW;
ma->shade_flag = MA_APPROX_OCCLUSION;
ma->preview = NULL;
}
@@ -256,7 +257,7 @@ Material *localize_material(Material *ma)
Material *man;
int a;
- man = BKE_libblock_copy_nolib(&ma->id);
+ man = BKE_libblock_copy_nolib(&ma->id, false);
/* no increment for texture ID users, in previewrender.c it prevents decrement */
for (a = 0; a < MAX_MTEX; a++) {
@@ -668,7 +669,7 @@ void BKE_material_clear_id(struct ID *id, bool update_data)
Material *give_current_material(Object *ob, short act)
{
Material ***matarar, *ma;
- short *totcolp;
+ const short *totcolp;
if (ob == NULL) return NULL;
@@ -773,7 +774,7 @@ void test_object_materials(Main *bmain, ID *id)
{
/* make the ob mat-array same size as 'ob->data' mat-array */
Object *ob;
- short *totcol;
+ const short *totcol;
if (id == NULL || (totcol = give_totcolp_id(id)) == NULL) {
return;
@@ -1009,16 +1010,6 @@ static void do_init_render_material(Material *ma, int r_mode, float *amb)
ma->ambg = ma->amb * amb[1];
ma->ambb = ma->amb * amb[2];
}
- /* will become or-ed result of all node modes */
- ma->mode_l = ma->mode;
- ma->mode_l &= ~MA_SHLESS;
-
- if (ma->strand_surfnor > 0.0f)
- ma->mode_l |= MA_STR_SURFDIFF;
-
- /* parses the geom+tex nodes */
- if (ma->nodetree && ma->use_nodes)
- ntreeShaderGetTexcoMode(ma->nodetree, r_mode, &ma->texco, &ma->mode_l);
/* local group override */
if ((ma->shade_flag & MA_GROUP_LOCAL) && ma->id.lib && ma->group && ma->group->id.lib) {
@@ -1043,8 +1034,16 @@ static void init_render_nodetree(bNodeTree *ntree, Material *basemat, int r_mode
if (ma != basemat) {
do_init_render_material(ma, r_mode, amb);
basemat->texco |= ma->texco;
- basemat->mode_l |= ma->mode_l & ~(MA_TRANSP | MA_ZTRANSP | MA_RAYTRANSP);
}
+
+ basemat->mode_l |= ma->mode & ~(MA_MODE_PIPELINE | MA_SHLESS);
+ basemat->mode2_l |= ma->mode2 & ~MA_MODE2_PIPELINE;
+ /* basemat only considered shadeless if all node materials are too */
+ if (!(ma->mode & MA_SHLESS))
+ basemat->mode_l &= ~MA_SHLESS;
+
+ if (ma->strand_surfnor > 0.0f)
+ basemat->mode_l |= MA_STR_SURFDIFF;
}
else if (node->type == NODE_GROUP)
init_render_nodetree((bNodeTree *)node->id, basemat, r_mode, amb);
@@ -1058,11 +1057,27 @@ void init_render_material(Material *mat, int r_mode, float *amb)
do_init_render_material(mat, r_mode, amb);
if (mat->nodetree && mat->use_nodes) {
+ /* mode_l will take the pipeline options from the main material, and the or-ed
+ * result of non-pipeline options from the nodes. shadeless is an exception,
+ * mode_l will have it set when all node materials are shadeless. */
+ mat->mode_l = (mat->mode & MA_MODE_PIPELINE) | MA_SHLESS;
+ mat->mode2_l = mat->mode2 & MA_MODE2_PIPELINE;
+
+ /* parses the geom+tex nodes */
+ ntreeShaderGetTexcoMode(mat->nodetree, r_mode, &mat->texco, &mat->mode_l);
+
init_render_nodetree(mat->nodetree, mat, r_mode, amb);
if (!mat->nodetree->execdata)
mat->nodetree->execdata = ntreeShaderBeginExecTree(mat->nodetree);
}
+ else {
+ mat->mode_l = mat->mode;
+ mat->mode2_l = mat->mode2;
+
+ if (mat->strand_surfnor > 0.0f)
+ mat->mode_l |= MA_STR_SURFDIFF;
+ }
}
void init_render_materials(Main *bmain, int r_mode, float *amb)
@@ -1087,7 +1102,7 @@ void init_render_materials(Main *bmain, int r_mode, float *amb)
init_render_material(ma, r_mode, amb);
}
- do_init_render_material(&defmaterial, r_mode, amb);
+ init_render_material(&defmaterial, r_mode, amb);
}
/* only needed for nodes now */
@@ -1344,12 +1359,9 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3])
r_col[2] = facm * (r_col[2]) + fac * fabsf(r_col[2] - col[2]);
break;
case MA_RAMP_DARK:
- tmp = col[0] + ((1 - col[0]) * facm);
- if (tmp < r_col[0]) r_col[0] = tmp;
- tmp = col[1] + ((1 - col[1]) * facm);
- if (tmp < r_col[1]) r_col[1] = tmp;
- tmp = col[2] + ((1 - col[2]) * facm);
- if (tmp < r_col[2]) r_col[2] = tmp;
+ r_col[0] = min_ff(r_col[0], col[0]) * fac + r_col[0] * facm;
+ r_col[1] = min_ff(r_col[1], col[1]) * fac + r_col[1] * facm;
+ r_col[2] = min_ff(r_col[2], col[2]) * fac + r_col[2] * facm;
break;
case MA_RAMP_LIGHT:
tmp = fac * col[0];
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index 9efd0dee19a..fc6f9149841 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -356,7 +356,8 @@ void BKE_mball_texspace_calc(Object *ob)
DispList *dl;
BoundBox *bb;
float *data, min[3], max[3] /*, loc[3], size[3] */;
- int tot, do_it = false;
+ int tot;
+ bool do_it = false;
if (ob->bb == NULL) ob->bb = MEM_callocN(sizeof(BoundBox), "mb boundbox");
bb = ob->bb;
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 7d8d98a4573..f0566a7f473 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -40,7 +40,6 @@
#include "BLI_math.h"
#include "BLI_listbase.h"
#include "BLI_edgehash.h"
-#include "BLI_string_utf8.h"
#include "BLI_string.h"
#include "BKE_animsys.h"
@@ -54,6 +53,8 @@
#include "BKE_modifier.h"
#include "BKE_multires.h"
#include "BKE_key.h"
+#include "BKE_mball.h"
+#include "BKE_depsgraph.h"
/* these 2 are only used by conversion functions */
#include "BKE_curve.h"
/* -- */
@@ -423,11 +424,12 @@ void BKE_mesh_unlink(Mesh *me)
int a;
if (me == NULL) return;
-
- if (me->mat)
- for (a = 0; a < me->totcol; a++) {
- if (me->mat[a]) me->mat[a]->id.us--;
- me->mat[a] = NULL;
+
+ if (me->mat) {
+ for (a = 0; a < me->totcol; a++) {
+ if (me->mat[a]) me->mat[a]->id.us--;
+ me->mat[a] = NULL;
+ }
}
if (me->key) {
@@ -1023,7 +1025,7 @@ void BKE_mesh_from_metaball(ListBase *lb, Mesh *me)
MVert *mvert;
MLoop *mloop, *allloop;
MPoly *mpoly;
- float *nors, *verts;
+ const float *nors, *verts;
int a, *index;
dl = lb->first;
@@ -1194,7 +1196,7 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob, ListBase *dispbase,
MLoop *mloop;
MLoopUV *mloopuv = NULL;
MEdge *medge;
- float *data;
+ const float *data;
int a, b, ofs, vertcount, startvert, totvert = 0, totedge = 0, totloop = 0, totvlak = 0;
int p1, p2, p3, p4, *index;
const bool conv_polys = ((CU_DO_2DFILL(cu) == false) || /* 2d polys are filled with DL_INDEX3 displists */
@@ -2086,3 +2088,220 @@ void BKE_mesh_mselect_active_set(Mesh *me, int index, int type)
BLI_assert((me->mselect[me->totselect - 1].index == index) &&
(me->mselect[me->totselect - 1].type == type));
}
+
+/* settings: 1 - preview, 2 - render */
+Mesh *BKE_mesh_new_from_object(
+ Main *bmain, Scene *sce, Object *ob,
+ int apply_modifiers, int settings, int calc_tessface, int calc_undeformed)
+{
+ Mesh *tmpmesh;
+ Curve *tmpcu = NULL, *copycu;
+ Object *tmpobj = NULL;
+ int render = settings == eModifierMode_Render, i;
+ int cage = !apply_modifiers;
+
+ /* perform the mesh extraction based on type */
+ switch (ob->type) {
+ case OB_FONT:
+ case OB_CURVE:
+ case OB_SURF:
+ {
+ ListBase dispbase = {NULL, NULL};
+ DerivedMesh *derivedFinal = NULL;
+ int uv_from_orco;
+
+ /* copies object and modifiers (but not the data) */
+ tmpobj = BKE_object_copy_ex(bmain, ob, true);
+ tmpcu = (Curve *)tmpobj->data;
+ tmpcu->id.us--;
+
+ /* if getting the original caged mesh, delete object modifiers */
+ if (cage)
+ BKE_object_free_modifiers(tmpobj);
+
+ /* copies the data */
+ copycu = tmpobj->data = BKE_curve_copy((Curve *) ob->data);
+
+ /* temporarily set edit so we get updates from edit mode, but
+ * also because for text datablocks copying it while in edit
+ * mode gives invalid data structures */
+ copycu->editfont = tmpcu->editfont;
+ copycu->editnurb = tmpcu->editnurb;
+
+ /* get updated display list, and convert to a mesh */
+ BKE_displist_make_curveTypes_forRender(sce, tmpobj, &dispbase, &derivedFinal, false, render);
+
+ copycu->editfont = NULL;
+ copycu->editnurb = NULL;
+
+ tmpobj->derivedFinal = derivedFinal;
+
+ /* convert object type to mesh */
+ uv_from_orco = (tmpcu->flag & CU_UV_ORCO) != 0;
+ BKE_mesh_from_nurbs_displist(tmpobj, &dispbase, uv_from_orco);
+
+ tmpmesh = tmpobj->data;
+
+ BKE_displist_free(&dispbase);
+
+ /* BKE_mesh_from_nurbs changes the type to a mesh, check it worked.
+ * 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(G.main, tmpobj);
+ return NULL;
+ }
+
+ BKE_mesh_texspace_copy_from_object(tmpmesh, ob);
+
+ BKE_libblock_free_us(bmain, tmpobj);
+ break;
+ }
+
+ case OB_MBALL:
+ {
+ /* metaballs don't have modifiers, so just convert to mesh */
+ Object *basis_ob = BKE_mball_basis_find(sce, ob);
+ /* todo, re-generatre for render-res */
+ /* metaball_polygonize(scene, ob) */
+
+ if (ob != basis_ob)
+ return NULL; /* only do basis metaball */
+
+ tmpmesh = BKE_mesh_add(bmain, "Mesh");
+ /* BKE_mesh_add gives us a user count we don't need */
+ tmpmesh->id.us--;
+
+ if (render) {
+ ListBase disp = {NULL, NULL};
+ /* TODO(sergey): This is gonna to work for until EvaluationContext
+ * only contains for_render flag. As soon as CoW is
+ * implemented, this is to be rethinked.
+ */
+ EvaluationContext eval_ctx = {0};
+ eval_ctx.for_render = render;
+ BKE_displist_make_mball_forRender(&eval_ctx, sce, ob, &disp);
+ BKE_mesh_from_metaball(&disp, tmpmesh);
+ BKE_displist_free(&disp);
+ }
+ else {
+ ListBase disp = {NULL, NULL};
+ if (ob->curve_cache) {
+ disp = ob->curve_cache->disp;
+ }
+ BKE_mesh_from_metaball(&disp, tmpmesh);
+ }
+
+ BKE_mesh_texspace_copy_from_object(tmpmesh, ob);
+
+ break;
+
+ }
+ case OB_MESH:
+ /* copies object and modifiers (but not the data) */
+ if (cage) {
+ /* copies the data */
+ tmpmesh = BKE_mesh_copy_ex(bmain, ob->data);
+ /* if not getting the original caged mesh, get final derived mesh */
+ }
+ else {
+ /* Make a dummy mesh, saves copying */
+ DerivedMesh *dm;
+ /* CustomDataMask mask = CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL; */
+ CustomDataMask mask = CD_MASK_MESH; /* this seems more suitable, exporter,
+ * for example, needs CD_MASK_MDEFORMVERT */
+
+ if (calc_undeformed)
+ mask |= CD_MASK_ORCO;
+
+ /* Write the display mesh into the dummy mesh */
+ if (render)
+ dm = mesh_create_derived_render(sce, ob, mask);
+ else
+ dm = mesh_create_derived_view(sce, ob, mask);
+
+ tmpmesh = BKE_mesh_add(bmain, "Mesh");
+ DM_to_mesh(dm, tmpmesh, ob, mask);
+ dm->release(dm);
+ }
+
+ /* BKE_mesh_add/copy gives us a user count we don't need */
+ tmpmesh->id.us--;
+
+ break;
+ default:
+ /* "Object does not have geometry data") */
+ return NULL;
+ }
+
+ /* Copy materials to new mesh */
+ switch (ob->type) {
+ case OB_SURF:
+ case OB_FONT:
+ case OB_CURVE:
+ tmpmesh->totcol = tmpcu->totcol;
+
+ /* free old material list (if it exists) and adjust user counts */
+ if (tmpcu->mat) {
+ for (i = tmpcu->totcol; i-- > 0; ) {
+ /* are we an object material or data based? */
+
+ tmpmesh->mat[i] = ob->matbits[i] ? ob->mat[i] : tmpcu->mat[i];
+
+ if (tmpmesh->mat[i]) {
+ tmpmesh->mat[i]->id.us++;
+ }
+ }
+ }
+ break;
+
+#if 0
+ /* Crashes when assigning the new material, not sure why */
+ case OB_MBALL:
+ tmpmb = (MetaBall *)ob->data;
+ tmpmesh->totcol = tmpmb->totcol;
+
+ /* free old material list (if it exists) and adjust user counts */
+ if (tmpmb->mat) {
+ for (i = tmpmb->totcol; i-- > 0; ) {
+ tmpmesh->mat[i] = tmpmb->mat[i]; /* CRASH HERE ??? */
+ if (tmpmesh->mat[i]) {
+ tmpmb->mat[i]->id.us++;
+ }
+ }
+ }
+ break;
+#endif
+
+ case OB_MESH:
+ if (!cage) {
+ Mesh *origmesh = ob->data;
+ tmpmesh->flag = origmesh->flag;
+ tmpmesh->mat = MEM_dupallocN(origmesh->mat);
+ tmpmesh->totcol = origmesh->totcol;
+ tmpmesh->smoothresh = origmesh->smoothresh;
+ if (origmesh->mat) {
+ for (i = origmesh->totcol; i-- > 0; ) {
+ /* are we an object material or data based? */
+ tmpmesh->mat[i] = ob->matbits[i] ? ob->mat[i] : origmesh->mat[i];
+
+ if (tmpmesh->mat[i]) {
+ tmpmesh->mat[i]->id.us++;
+ }
+ }
+ }
+ }
+ break;
+ } /* end copy materials */
+
+ if (calc_tessface) {
+ /* cycles and exporters rely on this still */
+ BKE_mesh_tessface_ensure(tmpmesh);
+ }
+
+ /* make sure materials get updated in objects */
+ test_object_materials(bmain, &tmpmesh->id);
+
+ return tmpmesh;
+}
+
diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c
index 5d10c12b8e0..74e380c7d50 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.c
+++ b/source/blender/blenkernel/intern/mesh_evaluate.c
@@ -172,8 +172,8 @@ static void mesh_calc_normals_poly_accum(MPoly *mp, MLoop *ml,
/* inline version of #BKE_mesh_calc_poly_normal, also does edge-vectors */
{
int i_prev = nverts - 1;
- float const *v_prev = mvert[ml[i_prev].v].co;
- float const *v_curr;
+ const float *v_prev = mvert[ml[i_prev].v].co;
+ const float *v_curr;
zero_v3(polyno);
/* Newell's Method */
@@ -287,7 +287,7 @@ void BKE_mesh_calc_normals_tessface(MVert *mverts, int numVerts, MFace *mfaces,
MFace *mf = &mfaces[i];
float *f_no = fnors[i];
float *n4 = (mf->v4) ? tnorms[mf->v4] : NULL;
- float *c4 = (mf->v4) ? mverts[mf->v4].co : NULL;
+ const float *c4 = (mf->v4) ? mverts[mf->v4].co : NULL;
if (mf->v4)
normal_quad_v3(f_no, mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, mverts[mf->v4].co);
@@ -574,6 +574,7 @@ void BKE_mesh_normals_loop_split(MVert *mverts, const int UNUSED(numVerts), MEdg
#undef IS_EDGE_SHARP
}
+
/** \} */
@@ -737,8 +738,8 @@ static void mesh_calc_ngon_normal(MPoly *mpoly, MLoop *loopstart,
MVert *mvert, float normal[3])
{
const int nverts = mpoly->totloop;
- float const *v_prev = mvert[loopstart[nverts - 1].v].co;
- float const *v_curr;
+ const float *v_prev = mvert[loopstart[nverts - 1].v].co;
+ const float *v_curr;
int i;
zero_v3(normal);
@@ -787,8 +788,8 @@ static void mesh_calc_ngon_normal_coords(MPoly *mpoly, MLoop *loopstart,
const float (*vertex_coords)[3], float normal[3])
{
const int nverts = mpoly->totloop;
- float const *v_prev = vertex_coords[loopstart[nverts - 1].v];
- float const *v_curr;
+ const float *v_prev = vertex_coords[loopstart[nverts - 1].v];
+ const float *v_curr;
int i;
zero_v3(normal);
@@ -871,7 +872,7 @@ void BKE_mesh_calc_poly_center(MPoly *mpoly, MLoop *loopstart,
/* note, passing polynormal is only a speedup so we can skip calculating it */
float BKE_mesh_calc_poly_area(MPoly *mpoly, MLoop *loopstart,
- MVert *mvarray, const float polynormal[3])
+ MVert *mvarray)
{
if (mpoly->totloop == 3) {
return area_tri_v3(mvarray[loopstart[0].v].co,
@@ -889,22 +890,16 @@ float BKE_mesh_calc_poly_area(MPoly *mpoly, MLoop *loopstart,
else {
int i;
MLoop *l_iter = loopstart;
- float area, polynorm_local[3];
+ float area;
float (*vertexcos)[3] = BLI_array_alloca(vertexcos, (size_t)mpoly->totloop);
- const float *no = polynormal ? polynormal : polynorm_local;
/* pack vertex cos into an array for area_poly_v3 */
for (i = 0; i < mpoly->totloop; i++, l_iter++) {
copy_v3_v3(vertexcos[i], mvarray[l_iter->v].co);
}
- /* need normal for area_poly_v3 as well */
- if (polynormal == NULL) {
- BKE_mesh_calc_poly_normal(mpoly, loopstart, mvarray, polynorm_local);
- }
-
/* finally calculate the area */
- area = area_poly_v3((const float (*)[3])vertexcos, (unsigned int)mpoly->totloop, no);
+ area = area_poly_v3((const float (*)[3])vertexcos, (unsigned int)mpoly->totloop);
return area;
}
@@ -1103,7 +1098,8 @@ void BKE_mesh_loops_to_mface_corners(
const int numTex, /* CustomData_number_of_layers(pdata, CD_MTEXPOLY) */
const int numCol, /* CustomData_number_of_layers(ldata, CD_MLOOPCOL) */
const bool hasPCol, /* CustomData_has_layer(ldata, CD_PREVIEW_MLOOPCOL) */
- const bool hasOrigSpace /* CustomData_has_layer(ldata, CD_ORIGSPACE_MLOOP) */
+ const bool hasOrigSpace, /* CustomData_has_layer(ldata, CD_ORIGSPACE_MLOOP) */
+ const bool hasLNor /* CustomData_has_layer(ldata, CD_NORMAL) */
)
{
MTFace *texface;
@@ -1152,6 +1148,14 @@ void BKE_mesh_loops_to_mface_corners(
copy_v2_v2(of->uv[j], lof->uv);
}
}
+
+ if (hasLNor) {
+ short (*tlnors)[3] = CustomData_get(fdata, findex, CD_TESSLOOPNORMAL);
+
+ for (j = 0; j < mf_len; j++) {
+ normal_float_to_short_v3(tlnors[j], CustomData_get(ldata, (int)lindex[j], CD_NORMAL));
+ }
+ }
}
/**
@@ -1172,8 +1176,9 @@ void BKE_mesh_loops_to_tessdata(CustomData *fdata, CustomData *ldata, CustomData
const int numCol = CustomData_number_of_layers(ldata, CD_MLOOPCOL);
const bool hasPCol = CustomData_has_layer(ldata, CD_PREVIEW_MLOOPCOL);
const bool hasOrigSpace = CustomData_has_layer(ldata, CD_ORIGSPACE_MLOOP);
+ const bool hasLoopNormal = CustomData_has_layer(ldata, CD_NORMAL);
int findex, i, j;
- int *pidx;
+ const int *pidx;
unsigned int (*lidx)[4];
for (i = 0; i < numTex; i++) {
@@ -1225,6 +1230,17 @@ void BKE_mesh_loops_to_tessdata(CustomData *fdata, CustomData *ldata, CustomData
}
}
}
+
+ if (hasLoopNormal) {
+ short (*fnors)[4][3] = CustomData_get_layer(fdata, CD_TESSLOOPNORMAL);
+ float (*lnors)[3] = CustomData_get_layer(ldata, CD_NORMAL);
+
+ for (findex = 0, lidx = loopindices; findex < num_faces; lidx++, findex++, fnors++) {
+ for (j = (mface ? mface[findex].v4 : (*lidx)[3]) ? 4 : 3; j--;) {
+ normal_float_to_short_v3((*fnors)[j], lnors[(*lidx)[j]]);
+ }
+ }
+ }
}
/**
@@ -1516,6 +1532,7 @@ int BKE_mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata,
const int numCol = CustomData_number_of_layers(ldata, CD_MLOOPCOL);
const bool hasPCol = CustomData_has_layer(ldata, CD_PREVIEW_MLOOPCOL);
const bool hasOrigSpace = CustomData_has_layer(ldata, CD_ORIGSPACE_MLOOP);
+ const bool hasLNor = CustomData_has_layer(ldata, CD_NORMAL);
/* over-alloc, ngons will be skipped */
mface = MEM_mallocN(sizeof(*mface) * (size_t)totpoly, __func__);
@@ -1575,7 +1592,7 @@ int BKE_mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata,
BKE_mesh_loops_to_mface_corners(fdata, ldata, pdata,
lindex, k, i, 3,
- numTex, numCol, hasPCol, hasOrigSpace);
+ numTex, numCol, hasPCol, hasOrigSpace, hasLNor);
test_index_face(mf, fdata, k, 3);
}
else {
@@ -1595,7 +1612,7 @@ int BKE_mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata,
BKE_mesh_loops_to_mface_corners(fdata, ldata, pdata,
lindex, k, i, 4,
- numTex, numCol, hasPCol, hasOrigSpace);
+ numTex, numCol, hasPCol, hasOrigSpace, hasLNor);
test_index_face(mf, fdata, k, 4);
}
@@ -1651,6 +1668,16 @@ static void bm_corners_to_loops_ex(ID *id, CustomData *fdata, CustomData *ldata,
}
}
+ if (CustomData_has_layer(fdata, CD_TESSLOOPNORMAL)) {
+ float (*lnors)[3] = CustomData_get(ldata, loopstart, CD_NORMAL);
+ short (*tlnors)[3] = CustomData_get(fdata, findex, CD_TESSLOOPNORMAL);
+ const int max = mf->v4 ? 4 : 3;
+
+ for (i = 0; i < max; i++, lnors++, tlnors++) {
+ normal_short_to_float_v3(*lnors, *tlnors);
+ }
+ }
+
if (CustomData_has_layer(fdata, CD_MDISPS)) {
MDisps *ld = CustomData_get(ldata, loopstart, CD_MDISPS);
MDisps *fd = CustomData_get(fdata, findex, CD_MDISPS);
diff --git a/source/blender/blenkernel/intern/mesh_mapping.c b/source/blender/blenkernel/intern/mesh_mapping.c
index 94f29b5b1a4..65c576dd6a0 100644
--- a/source/blender/blenkernel/intern/mesh_mapping.c
+++ b/source/blender/blenkernel/intern/mesh_mapping.c
@@ -29,7 +29,6 @@
#include "MEM_guardedalloc.h"
-#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "BLI_utildefines.h"
@@ -426,7 +425,7 @@ int *BKE_mesh_calc_smoothgroups(const MEdge *medge, const int totedge,
for (ml = &mloop[mp->loopstart], j = mp->totloop; j--; ml++) {
/* loop over poly users */
const MeshElemMap *map_ele = &edge_poly_map[ml->e];
- int *p = map_ele->indices;
+ const int *p = map_ele->indices;
int i = map_ele->count;
if (!(medge[ml->e].flag & ME_SHARP)) {
for (; i--; p++) {
diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c
index 848483d2877..858fe83b43f 100644
--- a/source/blender/blenkernel/intern/mesh_validate.c
+++ b/source/blender/blenkernel/intern/mesh_validate.c
@@ -283,7 +283,7 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
}
for (i = 0, me = medges; i < totedge; i++, me++) {
- int remove = false;
+ bool remove = false;
if (me->v1 == me->v2) {
PRINT_ERR("\tEdge %u: has matching verts, both %u\n", i, me->v1);
remove = do_fixes;
@@ -336,7 +336,7 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
PRINT_ERR("No Polys, only tesselated Faces\n");
for (i = 0, mf = mfaces, sf = sort_faces; i < totface; i++, mf++) {
- int remove = false;
+ bool remove = false;
int fidx;
unsigned int fv[4];
@@ -411,7 +411,7 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
sf++;
for (i = 1; i < totsortface; i++, sf++) {
- int remove = false;
+ bool remove = false;
/* on a valid mesh, code below will never run */
if (memcmp(sf->es, sf_prev->es, sizeof(sf_prev->es)) == 0) {
@@ -565,7 +565,7 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
/* Now check that that poly does not use a same vertex more than once! */
if (!sp->invalid) {
- int *prev_v = v = sp->verts;
+ const int *prev_v = v = sp->verts;
j = sp->numverts;
qsort(sp->verts, j, sizeof(int), int_cmp);
@@ -598,7 +598,7 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
for (i = 1; i < totpoly; i++, sp++) {
int p1_nv = sp->numverts, p2_nv = prev_sp->numverts;
- int *p1_v = sp->verts, *p2_v = prev_sp->verts;
+ const int *p1_v = sp->verts, *p2_v = prev_sp->verts;
short p1_sub = true, p2_sub = true;
if (sp->invalid)
break;
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index a3801fa29fe..563831616de 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -57,7 +57,6 @@
#include "BLF_translation.h"
-#include "BKE_cloth.h"
#include "BKE_key.h"
#include "BKE_multires.h"
#include "BKE_DerivedMesh.h"
diff --git a/source/blender/blenkernel/intern/modifiers_bmesh.c b/source/blender/blenkernel/intern/modifiers_bmesh.c
index 8c79dee7a8b..c1726da32ae 100644
--- a/source/blender/blenkernel/intern/modifiers_bmesh.c
+++ b/source/blender/blenkernel/intern/modifiers_bmesh.c
@@ -33,9 +33,6 @@
#include "BLI_math.h"
#include "BLI_alloca.h"
-#include "DNA_object_types.h"
-
-
#include "BKE_DerivedMesh.h"
#include "BKE_editmesh.h"
@@ -104,8 +101,8 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm, const bool calc_face_normal)
totedge = dm->getNumEdges(dm);
/* totface = dm->getNumPolys(dm); */ /* UNUSED */
- vtable = MEM_callocN(sizeof(void **) * totvert, __func__);
- etable = MEM_callocN(sizeof(void **) * totedge, __func__);
+ vtable = MEM_mallocN(sizeof(*vtable) * totvert, __func__);
+ etable = MEM_mallocN(sizeof(*etable) * totedge, __func__);
/*do verts*/
mv = mvert = is_cddm ? dm->getVertArray(dm) : dm->dupVertArray(dm);
@@ -176,7 +173,8 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm, const bool calc_face_normal)
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
do {
/* Save index of correspsonding MLoop */
- CustomData_to_bmesh_block(&dm->loopData, &bm->ldata, j++, &l_iter->head.data, true);
+ CustomData_to_bmesh_block(&dm->loopData, &bm->ldata, j, &l_iter->head.data, true);
+ BM_elem_index_set(l_iter, j++); /* set_inline */
} while ((l_iter = l_iter->next) != l_first);
CustomData_to_bmesh_block(&dm->polyData, &bm->pdata, i, &f->head.data, true);
@@ -195,7 +193,7 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm, const bool calc_face_normal)
*orig_index = ORIGINDEX_NONE;
}
}
- if (is_init) bm->elem_index_dirty &= ~BM_FACE;
+ if (is_init) bm->elem_index_dirty &= ~(BM_FACE | BM_LOOP);
MEM_freeN(vtable);
MEM_freeN(etable);
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index f9cd1b2a6c5..35bf453c328 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -41,11 +41,6 @@
#include <time.h>
-#ifdef _WIN32
-# define open _open
-# define close _close
-#endif
-
#include "MEM_guardedalloc.h"
#include "DNA_constraint_types.h"
@@ -65,7 +60,6 @@
#include "BLI_threads.h"
#include "BKE_animsys.h"
-#include "BKE_constraint.h"
#include "BKE_colortools.h"
#include "BKE_library.h"
#include "BKE_global.h"
@@ -74,7 +68,6 @@
#include "BKE_node.h"
#include "BKE_image.h" /* openanim */
#include "BKE_tracking.h"
-#include "BKE_sequencer.h"
#include "IMB_colormanagement.h"
#include "IMB_imbuf_types.h"
@@ -335,7 +328,9 @@ typedef struct MovieClipCache {
/* cache for undistorted shot */
float principal[2];
- float k1, k2, k3;
+ float polynomial_k1, polynomial_k2, polynomial_k3;
+ float division_k1, division_k2;
+ short distortion_model;
bool undistortion_used;
int proxy;
@@ -624,7 +619,7 @@ MovieClip *BKE_movieclip_file_add(Main *bmain, const char *name)
/* exists? */
file = BLI_open(str, O_BINARY | O_RDONLY, 0);
- if (file < 0)
+ if (file == -1)
return NULL;
close(file);
@@ -732,11 +727,21 @@ static bool check_undistortion_cache_flags(MovieClip *clip)
MovieTrackingCamera *camera = &clip->tracking.camera;
/* check for distortion model changes */
- if (!equals_v2v2(camera->principal, cache->postprocessed.principal))
+ if (!equals_v2v2(camera->principal, cache->postprocessed.principal)) {
return false;
+ }
- if (!equals_v3v3(&camera->k1, &cache->postprocessed.k1))
+ if (camera->distortion_model != cache->postprocessed.distortion_model) {
return false;
+ }
+
+ if (!equals_v3v3(&camera->k1, &cache->postprocessed.polynomial_k1)) {
+ return false;
+ }
+
+ if (!equals_v2v2(&camera->division_k1, &cache->postprocessed.division_k1)) {
+ return false;
+ }
return true;
}
@@ -823,8 +828,10 @@ static void put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *use
}
if (need_undistortion_postprocess(user)) {
+ cache->postprocessed.distortion_model = camera->distortion_model;
copy_v2_v2(cache->postprocessed.principal, camera->principal);
- copy_v3_v3(&cache->postprocessed.k1, &camera->k1);
+ copy_v3_v3(&cache->postprocessed.polynomial_k1, &camera->k1);
+ copy_v2_v2(&cache->postprocessed.division_k1, &camera->division_k1);
cache->postprocessed.undistortion_used = true;
}
else {
@@ -1243,7 +1250,6 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip
scopes->track_disabled = false;
if (ibuf && (ibuf->rect || ibuf->rect_float)) {
- ImBuf *search_ibuf;
MovieTrackingMarker undist_marker = *marker;
if (user->render_flag & MCLIP_PROXY_RENDER_UNDISTORT) {
@@ -1261,16 +1267,7 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip
undist_marker.pos[1] /= height * aspy;
}
- search_ibuf = BKE_tracking_get_search_imbuf(ibuf, track, &undist_marker, true, true);
-
- if (search_ibuf) {
- if (!search_ibuf->rect_float) {
- /* sampling happens in float buffer */
- IMB_float_from_rect(search_ibuf);
- }
-
- scopes->track_search = search_ibuf;
- }
+ scopes->track_search = BKE_tracking_get_search_imbuf(ibuf, track, &undist_marker, true, true);
scopes->undist_marker = undist_marker;
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index 06a12bdade1..0c244e8a40b 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -157,8 +157,10 @@ void free_nladata(ListBase *tracks)
/* Copying ------------------------------------------- */
-/* Copy NLA strip */
-NlaStrip *copy_nlastrip(NlaStrip *strip)
+/* Copy NLA strip
+ * < use_same_action: if true, the existing action is used (instead of being duplicated)
+ */
+NlaStrip *copy_nlastrip(NlaStrip *strip, const bool use_same_action)
{
NlaStrip *strip_d;
NlaStrip *cs, *cs_d;
@@ -171,9 +173,17 @@ NlaStrip *copy_nlastrip(NlaStrip *strip)
strip_d = MEM_dupallocN(strip);
strip_d->next = strip_d->prev = NULL;
- /* increase user-count of action */
- if (strip_d->act)
- id_us_plus(&strip_d->act->id);
+ /* handle action */
+ if (strip_d->act) {
+ if (use_same_action) {
+ /* increase user-count of action */
+ id_us_plus(&strip_d->act->id);
+ }
+ else {
+ /* use a copy of the action instead (user count shouldn't have changed yet) */
+ strip_d->act = BKE_action_copy(strip_d->act);
+ }
+ }
/* copy F-Curves and modifiers */
copy_fcurves(&strip_d->fcurves, &strip->fcurves);
@@ -183,7 +193,7 @@ NlaStrip *copy_nlastrip(NlaStrip *strip)
BLI_listbase_clear(&strip_d->strips);
for (cs = strip->strips.first; cs; cs = cs->next) {
- cs_d = copy_nlastrip(cs);
+ cs_d = copy_nlastrip(cs, use_same_action);
BLI_addtail(&strip_d->strips, cs_d);
}
@@ -192,7 +202,7 @@ NlaStrip *copy_nlastrip(NlaStrip *strip)
}
/* Copy NLA Track */
-NlaTrack *copy_nlatrack(NlaTrack *nlt)
+NlaTrack *copy_nlatrack(NlaTrack *nlt, const bool use_same_actions)
{
NlaStrip *strip, *strip_d;
NlaTrack *nlt_d;
@@ -209,7 +219,7 @@ NlaTrack *copy_nlatrack(NlaTrack *nlt)
BLI_listbase_clear(&nlt_d->strips);
for (strip = nlt->strips.first; strip; strip = strip->next) {
- strip_d = copy_nlastrip(strip);
+ strip_d = copy_nlastrip(strip, use_same_actions);
BLI_addtail(&nlt_d->strips, strip_d);
}
@@ -232,7 +242,8 @@ void copy_nladata(ListBase *dst, ListBase *src)
/* copy each NLA-track, one at a time */
for (nlt = src->first; nlt; nlt = nlt->next) {
/* make a copy, and add the copy to the destination list */
- nlt_d = copy_nlatrack(nlt);
+ // XXX: we need to fix this sometime
+ nlt_d = copy_nlatrack(nlt, true);
BLI_addtail(dst, nlt_d);
}
}
@@ -626,10 +637,10 @@ void BKE_nlastrips_sort_strips(ListBase *strips)
/* Add the given NLA-Strip to the given list of strips, assuming that it
* isn't currently a member of another list
*/
-short BKE_nlastrips_add_strip(ListBase *strips, NlaStrip *strip)
+bool BKE_nlastrips_add_strip(ListBase *strips, NlaStrip *strip)
{
NlaStrip *ns;
- short not_added = 1;
+ bool not_added = true;
/* sanity checks */
if (ELEM(NULL, strips, strip))
@@ -664,7 +675,7 @@ short BKE_nlastrips_add_strip(ListBase *strips, NlaStrip *strip)
* contained within 'Meta-Strips' which act as strips which contain strips.
* temp: are the meta-strips to be created 'temporary' ones used for transforms?
*/
-void BKE_nlastrips_make_metas(ListBase *strips, short temp)
+void BKE_nlastrips_make_metas(ListBase *strips, bool is_temp)
{
NlaStrip *mstrip = NULL;
NlaStrip *strip, *stripn;
@@ -689,7 +700,7 @@ void BKE_nlastrips_make_metas(ListBase *strips, short temp)
mstrip->flag = NLASTRIP_FLAG_SELECT;
/* set temp flag if appropriate (i.e. for transform-type editing) */
- if (temp)
+ if (is_temp)
mstrip->flag |= NLASTRIP_FLAG_TEMP_META;
/* set default repeat/scale values to prevent warnings */
@@ -741,7 +752,7 @@ void BKE_nlastrips_clear_metastrip(ListBase *strips, NlaStrip *strip)
* sel: only consider selected meta-strips, otherwise all meta-strips are removed
* onlyTemp: only remove the 'temporary' meta-strips used for transforms
*/
-void BKE_nlastrips_clear_metas(ListBase *strips, short onlySel, short onlyTemp)
+void BKE_nlastrips_clear_metas(ListBase *strips, bool only_sel, bool only_temp)
{
NlaStrip *strip, *stripn;
@@ -756,8 +767,8 @@ void BKE_nlastrips_clear_metas(ListBase *strips, short onlySel, short onlyTemp)
/* check if strip is a meta-strip */
if (strip->type == NLASTRIP_TYPE_META) {
/* if check if selection and 'temporary-only' considerations are met */
- if ((onlySel == 0) || (strip->flag & NLASTRIP_FLAG_SELECT)) {
- if ((!onlyTemp) || (strip->flag & NLASTRIP_FLAG_TEMP_META)) {
+ if ((!only_sel) || (strip->flag & NLASTRIP_FLAG_SELECT)) {
+ if ((!only_temp) || (strip->flag & NLASTRIP_FLAG_TEMP_META)) {
BKE_nlastrips_clear_metastrip(strips, strip);
}
}
@@ -768,7 +779,7 @@ void BKE_nlastrips_clear_metas(ListBase *strips, short onlySel, short onlyTemp)
/* Add the given NLA-Strip to the given Meta-Strip, assuming that the
* strip isn't attached to any list of strips
*/
-short BKE_nlameta_add_strip(NlaStrip *mstrip, NlaStrip *strip)
+bool BKE_nlameta_add_strip(NlaStrip *mstrip, NlaStrip *strip)
{
/* sanity checks */
if (ELEM(NULL, mstrip, strip))
@@ -1002,7 +1013,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
*/
-short BKE_nlatrack_add_strip(NlaTrack *nlt, NlaStrip *strip)
+bool BKE_nlatrack_add_strip(NlaTrack *nlt, NlaStrip *strip)
{
/* sanity checks */
if (ELEM(NULL, nlt, strip))
@@ -1015,7 +1026,7 @@ short BKE_nlatrack_add_strip(NlaTrack *nlt, NlaStrip *strip)
/* Get the extents of the given NLA-Track including gaps between strips,
* returning whether this succeeded or not
*/
-short BKE_nlatrack_get_bounds(NlaTrack *nlt, float bounds[2])
+bool BKE_nlatrack_get_bounds(NlaTrack *nlt, float bounds[2])
{
NlaStrip *strip;
@@ -1085,7 +1096,7 @@ void BKE_nlastrip_set_active(AnimData *adt, NlaStrip *strip)
/* Does the given NLA-strip fall within the given bounds (times)? */
-short BKE_nlastrip_within_bounds(NlaStrip *strip, float min, float max)
+bool BKE_nlastrip_within_bounds(NlaStrip *strip, float min, float max)
{
const float stripLen = (strip) ? strip->end - strip->start : 0.0f;
const float boundsLen = fabsf(max - min);
@@ -1220,7 +1231,7 @@ static bool nlastrip_is_first(AnimData *adt, NlaStrip *strip)
/* Animated Strips ------------------------------------------- */
/* Check if the given NLA-Track has any strips with own F-Curves */
-short BKE_nlatrack_has_animated_strips(NlaTrack *nlt)
+bool BKE_nlatrack_has_animated_strips(NlaTrack *nlt)
{
NlaStrip *strip;
@@ -1239,7 +1250,7 @@ short BKE_nlatrack_has_animated_strips(NlaTrack *nlt)
}
/* Check if given NLA-Tracks have any strips with own F-Curves */
-short BKE_nlatracks_have_animated_strips(ListBase *tracks)
+bool BKE_nlatracks_have_animated_strips(ListBase *tracks)
{
NlaTrack *nlt;
@@ -1567,7 +1578,7 @@ void BKE_nla_action_pushdown(AnimData *adt)
/* Find the active strip + track combo, and set them up as the tweaking track,
* and return if successful or not.
*/
-short BKE_nla_tweakmode_enter(AnimData *adt)
+bool BKE_nla_tweakmode_enter(AnimData *adt)
{
NlaTrack *nlt, *activeTrack = NULL;
NlaStrip *strip, *activeStrip = NULL;
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 47ef03093b1..c11611a1f65 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -44,6 +44,7 @@
#include "DNA_scene_types.h"
#include "DNA_texture_types.h"
#include "DNA_world_types.h"
+#include "DNA_linestyle_types.h"
#include "BLI_string.h"
#include "BLI_math.h"
@@ -54,11 +55,8 @@
#include "BLF_translation.h"
#include "BKE_animsys.h"
-#include "BKE_action.h"
-#include "BKE_fcurve.h"
#include "BKE_global.h"
#include "BKE_idprop.h"
-#include "BKE_image.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_node.h"
@@ -174,6 +172,12 @@ static void ntree_set_typeinfo(bNodeTree *ntree, bNodeTreeType *typeinfo)
static void node_set_typeinfo(const struct bContext *C, bNodeTree *ntree, bNode *node, bNodeType *typeinfo)
{
+ /* for nodes saved in older versions storage can get lost, make undefined then */
+ if (node->flag & NODE_INIT) {
+ if (typeinfo && typeinfo->storagename[0] && !node->storage)
+ typeinfo = NULL;
+ }
+
if (typeinfo) {
node->typeinfo = typeinfo;
@@ -1119,7 +1123,7 @@ static bNodeTree *ntreeCopyTree_internal(bNodeTree *ntree, Main *bmain, bool do_
newtree = BKE_libblock_copy(&ntree->id);
}
else {
- newtree = BKE_libblock_copy_nolib(&ntree->id);
+ newtree = BKE_libblock_copy_nolib(&ntree->id, true);
newtree->id.lib = NULL; /* same as owning datablock id.lib */
}
@@ -1869,6 +1873,7 @@ bNodeTree *ntreeFromID(ID *id)
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;
default: return NULL;
}
}
@@ -3591,9 +3596,9 @@ static void registerTextureNodes(void)
void init_nodesystem(void)
{
- nodetreetypes_hash = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "nodetreetypes_hash gh");
- nodetypes_hash = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "nodetypes_hash gh");
- nodesockettypes_hash = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "nodesockettypes_hash gh");
+ nodetreetypes_hash = BLI_ghash_str_new("nodetreetypes_hash gh");
+ nodetypes_hash = BLI_ghash_str_new("nodetypes_hash gh");
+ nodesockettypes_hash = BLI_ghash_str_new("nodesockettypes_hash gh");
register_undefined_types();
@@ -3664,6 +3669,7 @@ void BKE_node_tree_iter_init(struct NodeTreeIterStore *ntreeiter, struct Main *b
ntreeiter->tex = bmain->tex.first;
ntreeiter->lamp = bmain->lamp.first;
ntreeiter->world = bmain->world.first;
+ ntreeiter->linestyle = bmain->linestyle.first;
}
bool BKE_node_tree_iter_step(struct NodeTreeIterStore *ntreeiter,
bNodeTree **r_nodetree, struct ID **r_id)
@@ -3698,6 +3704,11 @@ bool BKE_node_tree_iter_step(struct NodeTreeIterStore *ntreeiter,
*r_id = (ID *)ntreeiter->world;
ntreeiter->world = ntreeiter->world->id.next;
}
+ else if (ntreeiter->linestyle) {
+ *r_nodetree = ntreeiter->linestyle->nodetree;
+ *r_id = (ID *)ntreeiter->linestyle;
+ ntreeiter->linestyle = ntreeiter->linestyle->id.next;
+ }
else {
return false;
}
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 23af5bdf7ba..d99086a626a 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -52,7 +52,6 @@
#include "DNA_screen_types.h"
#include "DNA_sequence_types.h"
#include "DNA_smoke_types.h"
-#include "DNA_sound_types.h"
#include "DNA_space_types.h"
#include "DNA_view3d_types.h"
#include "DNA_world_types.h"
@@ -76,7 +75,6 @@
#include "BKE_armature.h"
#include "BKE_action.h"
#include "BKE_bullet.h"
-#include "BKE_colortools.h"
#include "BKE_deform.h"
#include "BKE_depsgraph.h"
#include "BKE_DerivedMesh.h"
@@ -88,7 +86,6 @@
#include "BKE_effect.h"
#include "BKE_fcurve.h"
#include "BKE_group.h"
-#include "BKE_icons.h"
#include "BKE_key.h"
#include "BKE_lamp.h"
#include "BKE_lattice.h"
@@ -98,7 +95,6 @@
#include "BKE_editmesh.h"
#include "BKE_mball.h"
#include "BKE_modifier.h"
-#include "BKE_node.h"
#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_particle.h"
@@ -394,7 +390,7 @@ void BKE_object_free_ex(Object *ob, bool do_id_user)
free_controllers(&ob->controllers);
free_actuators(&ob->actuators);
- BKE_free_constraints(&ob->constraints);
+ BKE_constraints_free(&ob->constraints);
free_partdeflect(ob->pd);
BKE_rigidbody_free_object(ob);
@@ -404,7 +400,7 @@ void BKE_object_free_ex(Object *ob, bool do_id_user)
if (ob->bsoft) bsbFree(ob->bsoft);
if (ob->gpulamp.first) GPU_lamp_free(ob);
- free_sculptsession(ob);
+ BKE_free_sculptsession(ob);
if (ob->pc_ids.first) BLI_freelistN(&ob->pc_ids);
@@ -500,7 +496,7 @@ void BKE_object_unlink(Object *ob)
bPoseChannel *pchan;
for (pchan = obt->pose->chanbase.first; pchan; pchan = pchan->next) {
for (con = pchan->constraints.first; con; con = con->next) {
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
@@ -531,7 +527,7 @@ void BKE_object_unlink(Object *ob)
sca_remove_ob_poin(obt, ob);
for (con = obt->constraints.first; con; con = con->next) {
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
@@ -1006,8 +1002,6 @@ Object *BKE_object_add_only_object(Main *bmain, int type, const char *name)
ob->margin = 0.04f;
ob->init_state = 1;
ob->state = 1;
- /* ob->pad3 == Contact Processing Threshold */
- ob->m_contactProcessingThreshold = 1.0f;
ob->obstacleRad = 1.0f;
ob->step_height = 0.15f;
ob->jump_speed = 10.0f;
@@ -1049,6 +1043,9 @@ Object *BKE_object_add(Main *bmain, Scene *scene, int type)
return ob;
}
+
+#ifdef WITH_GAMEENGINE
+
void BKE_object_lod_add(Object *ob)
{
LodLevel *lod = MEM_callocN(sizeof(LodLevel), "LoD Level");
@@ -1110,21 +1107,19 @@ bool BKE_object_lod_remove(Object *ob, int level)
return true;
}
-static LodLevel *lod_level_select(Object *ob, const float cam_loc[3])
+static LodLevel *lod_level_select(Object *ob, const float camera_position[3])
{
LodLevel *current = ob->currentlod;
- float ob_loc[3], delta[3];
- float dist_sq;
+ float dist_sq, dist_sq_curr;
if (!current) return NULL;
- copy_v3_v3(ob_loc, ob->obmat[3]);
- sub_v3_v3v3(delta, ob_loc, cam_loc);
- dist_sq = len_squared_v3(delta);
+ dist_sq = len_squared_v3v3(ob->obmat[3], camera_position);
+ dist_sq_curr = current->distance * current->distance;
- if (dist_sq < current->distance * current->distance) {
+ if (dist_sq < dist_sq_curr) {
/* check for higher LoD */
- while (current->prev && dist_sq < (current->distance * current->distance)) {
+ while (current->prev && dist_sq < dist_sq_curr) {
current = current->prev;
}
}
@@ -1144,17 +1139,14 @@ bool BKE_object_lod_is_usable(Object *ob, Scene *scene)
return (ob->mode == OB_MODE_OBJECT || !active);
}
-bool BKE_object_lod_update(Object *ob, float camera_position[3])
+void BKE_object_lod_update(Object *ob, const float camera_position[3])
{
LodLevel *cur_level = ob->currentlod;
LodLevel *new_level = lod_level_select(ob, camera_position);
if (new_level != cur_level) {
ob->currentlod = new_level;
- return true;
}
-
- return false;
}
static Object *lod_ob_get(Object *ob, Scene *scene, int flag)
@@ -1181,6 +1173,9 @@ struct Object *BKE_object_lod_matob_get(Object *ob, Scene *scene)
return lod_ob_get(ob, scene, OB_LOD_USE_MAT);
}
+#endif /* WITH_GAMEENGINE */
+
+
SoftBody *copy_softbody(SoftBody *sb, bool copy_caches)
{
SoftBody *sbn;
@@ -1369,12 +1364,8 @@ static void copy_object_pose(Object *obn, Object *ob)
chan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SIZE);
- if (chan->custom) {
- id_us_plus(&chan->custom->id);
- }
-
for (con = chan->constraints.first; con; con = con->next) {
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
@@ -1486,7 +1477,7 @@ Object *BKE_object_copy_ex(Main *bmain, Object *ob, bool copy_caches)
BKE_pose_rebuild(obn, obn->data);
}
defgroup_copy_list(&obn->defbase, &ob->defbase);
- BKE_copy_constraints(&obn->constraints, &ob->constraints, true);
+ BKE_constraints_copy(&obn->constraints, &ob->constraints, true);
obn->mode = 0;
obn->sculpt = NULL;
@@ -2216,7 +2207,7 @@ static void ob_get_parent_matrix(Scene *scene, Object *ob, Object *par, float pa
{
float tmat[4][4];
float vec[3];
- int ok;
+ bool ok;
switch (ob->partype & PARTYPE) {
case PAROBJECT:
@@ -2322,7 +2313,7 @@ void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime,
if (ob->parent) {
Object *par = ob->parent;
- float slowmat[4][4] = MAT4_UNITY;
+ float slowmat[4][4];
/* calculate parent matrix */
solve_parenting(scene, ob, par, ob->obmat, slowmat, r_originmat, true);
@@ -2348,7 +2339,7 @@ void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime,
if (ob->constraints.first && !(ob->transflag & OB_NO_CONSTRAINTS)) {
bConstraintOb *cob;
cob = BKE_constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
- BKE_solve_constraints(&ob->constraints, cob, ctime);
+ BKE_constraints_solve(&ob->constraints, cob, ctime);
BKE_constraints_clear_evalob(cob);
}
@@ -2368,9 +2359,10 @@ void BKE_object_where_is_calc_time(Scene *scene, Object *ob, float ctime)
* 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])
{
- float slowmat[4][4] = MAT4_UNITY;
if (ob->parent) {
+ float slowmat[4][4];
+
Object *par = ob->parent;
solve_parenting(scene, ob, par, obmat, slowmat, NULL, false);
@@ -2723,7 +2715,7 @@ void BKE_object_foreach_display_point(
DispList *dl;
for (dl = ob->curve_cache->disp.first; dl; dl = dl->next) {
- float *v3 = dl->verts;
+ const float *v3 = dl->verts;
int totvert = dl->nr;
int i;
@@ -3068,7 +3060,7 @@ void BKE_object_sculpt_modifiers_changed(Object *ob)
ss->pbvh = NULL;
}
- free_sculptsession_deformMats(ob->sculpt);
+ BKE_free_sculptsession_deformMats(ob->sculpt);
}
else {
PBVHNode **nodes;
@@ -3438,11 +3430,11 @@ void BKE_object_relink(Object *ob)
if (ob->id.lib)
return;
- BKE_relink_constraints(&ob->constraints);
+ BKE_constraints_relink(&ob->constraints);
if (ob->pose) {
bPoseChannel *chan;
for (chan = ob->pose->chanbase.first; chan; chan = chan->next) {
- BKE_relink_constraints(&chan->constraints);
+ BKE_constraints_relink(&chan->constraints);
}
}
modifiers_foreachIDLink(ob, copy_object__forwardModifierLinks, NULL);
@@ -3655,7 +3647,7 @@ KDTree *BKE_object_as_kdtree(Object *ob, int *r_tot)
unsigned int i;
DerivedMesh *dm = ob->derivedDeform ? ob->derivedDeform : ob->derivedFinal;
- int *index;
+ const int *index;
if (dm && (index = CustomData_get_layer(&dm->vertData, CD_ORIGINDEX))) {
MVert *mvert = dm->getVertArray(dm);
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index b3726ebc8da..84e626a3104 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -301,6 +301,18 @@ static void make_duplis_group(const DupliContext *ctx)
if (go->ob != ob) {
float mat[4][4];
+ /* Special case for instancing dupli-groups, see: T40051
+ * this object may be instanced via dupli-verts/faces, in this case we don't want to render
+ * (blender convention), but _do_ show in the viewport.
+ *
+ * Regular objects work fine but not if we're instancing dupli-groups,
+ * because the rules for rendering aren't applied to objects they instance.
+ * We could recursively pass down the 'hide' flag instead, but that seems unnecessary.
+ */
+ if (for_render && go->ob->parent && go->ob->parent->transflag & (OB_DUPLIVERTS | OB_DUPLIFACES)) {
+ continue;
+ }
+
/* group dupli offset, should apply after everything else */
mul_m4_m4m4(mat, group_mat, go->ob->obmat);
@@ -684,7 +696,7 @@ static void get_dupliface_transform(MPoly *mpoly, MLoop *mloop, MVert *mvert,
BKE_mesh_calc_poly_center(mpoly, mloop, mvert, loc);
/* rotation */
{
- float *v1, *v2, *v3;
+ const float *v1, *v2, *v3;
BKE_mesh_calc_poly_normal(mpoly, mloop, mvert, f_no);
v1 = mvert[mloop[0].v].co;
v2 = mvert[mloop[1].v].co;
@@ -693,7 +705,7 @@ static void get_dupliface_transform(MPoly *mpoly, MLoop *mloop, MVert *mvert,
}
/* scale */
if (use_scale) {
- float area = BKE_mesh_calc_poly_area(mpoly, mloop, mvert, f_no);
+ float area = BKE_mesh_calc_poly_area(mpoly, mloop, mvert);
scale = sqrtf(area) * scale_fac;
}
else
@@ -1245,3 +1257,42 @@ int count_duplilist(Object *ob)
}
return 1;
}
+
+DupliApplyData *duplilist_apply_matrix(ListBase *duplilist)
+{
+ DupliApplyData *apply_data = NULL;
+ int num_objects = BLI_countlist(duplilist);
+ if (num_objects > 0) {
+ DupliObject *dob;
+ int i;
+ apply_data = MEM_mallocN(sizeof(DupliApplyData), "DupliObject apply data");
+ apply_data->num_objects = num_objects;
+ apply_data->extra = MEM_mallocN(sizeof(DupliExtraData) * (size_t) num_objects,
+ "DupliObject apply extra data");
+
+ for (dob = duplilist->first, i = 0; dob; dob = dob->next, ++i) {
+ copy_m4_m4(apply_data->extra[i].obmat, dob->ob->obmat);
+ copy_m4_m4(dob->ob->obmat, dob->mat);
+ }
+ }
+ return apply_data;
+}
+
+void duplilist_restore_matrix(ListBase *duplilist, DupliApplyData *apply_data)
+{
+ DupliObject *dob;
+ int i;
+ /* Restore object matrices.
+ * NOTE: this has to happen in reverse order, since nested
+ * dupli objects can repeatedly override the obmat.
+ */
+ for (dob = duplilist->last, i = apply_data->num_objects - 1; dob; dob = dob->prev, --i) {
+ copy_m4_m4(dob->ob->obmat, apply_data->extra[i].obmat);
+ }
+}
+
+void duplilist_free_apply_data(DupliApplyData *apply_data)
+{
+ MEM_freeN(apply_data->extra);
+ MEM_freeN(apply_data);
+}
diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c
index 6f278ae1244..373ad34e7bd 100644
--- a/source/blender/blenkernel/intern/ocean.c
+++ b/source/blender/blenkernel/intern/ocean.c
@@ -41,7 +41,6 @@
#include "BLI_math.h"
#include "BLI_path_util.h"
#include "BLI_rand.h"
-#include "BLI_string.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c
index 71504bb9fbe..dafe5ca55ff 100644
--- a/source/blender/blenkernel/intern/packedFile.c
+++ b/source/blender/blenkernel/intern/packedFile.c
@@ -59,14 +59,6 @@
#include "BKE_report.h"
#include "BKE_sound.h"
-#ifdef _WIN32
-#define open _open
-#define close _close
-#define read _read
-#define write _write
-#endif
-
-
int seekPackedFile(PackedFile *pf, int offset, int whence)
{
int oldseek = -1, seek = 0;
@@ -202,7 +194,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char
* and create a PackedFile structure */
file = BLI_open(name, O_BINARY | O_RDONLY, 0);
- if (file < 0) {
+ if (file == -1) {
BKE_reportf(reports, RPT_ERROR, "Unable to pack file, source path '%s' not found", name);
}
else {
@@ -331,7 +323,7 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i
BLI_make_existing_file(name);
file = BLI_open(name, O_BINARY + O_WRONLY + O_CREAT + O_TRUNC, 0666);
- if (file < 0) {
+ if (file == -1) {
BKE_reportf(reports, RPT_ERROR, "Error creating file '%s'", name);
ret_value = RET_ERROR;
}
@@ -394,7 +386,7 @@ int checkPackedFile(const char *filename, PackedFile *pf)
/* we'll have to compare the two... */
file = BLI_open(name, O_BINARY | O_RDONLY, 0);
- if (file < 0) {
+ if (file == -1) {
ret_val = PF_NOFILE;
}
else {
@@ -627,21 +619,27 @@ void unpackAll(Main *bmain, ReportList *reports, int how)
/* ID should be not NULL, return 1 if there's a packed file */
bool BKE_pack_check(ID *id)
{
- if (GS(id->name) == ID_IM) {
- Image *ima = (Image *)id;
- return ima->packedfile != NULL;
- }
- if (GS(id->name) == ID_VF) {
- VFont *vf = (VFont *)id;
- return vf->packedfile != NULL;
- }
- if (GS(id->name) == ID_SO) {
- bSound *snd = (bSound *)id;
- return snd->packedfile != NULL;
- }
- if (GS(id->name) == ID_LI) {
- Library *li = (Library *)id;
- return li->packedfile != NULL;
+ switch (GS(id->name)) {
+ case ID_IM:
+ {
+ Image *ima = (Image *)id;
+ return ima->packedfile != NULL;
+ }
+ case ID_VF:
+ {
+ VFont *vf = (VFont *)id;
+ return vf->packedfile != NULL;
+ }
+ case ID_SO:
+ {
+ bSound *snd = (bSound *)id;
+ return snd->packedfile != NULL;
+ }
+ case ID_LI:
+ {
+ Library *li = (Library *)id;
+ return li->packedfile != NULL;
+ }
}
return false;
}
@@ -649,23 +647,36 @@ bool BKE_pack_check(ID *id)
/* ID should be not NULL */
void BKE_unpack_id(Main *bmain, ID *id, ReportList *reports, int how)
{
- if (GS(id->name) == ID_IM) {
- Image *ima = (Image *)id;
- if (ima->packedfile)
- unpackImage(reports, ima, how);
- }
- if (GS(id->name) == ID_VF) {
- VFont *vf = (VFont *)id;
- if (vf->packedfile)
- unpackVFont(reports, vf, how);
- }
- if (GS(id->name) == ID_SO) {
- bSound *snd = (bSound *)id;
- if (snd->packedfile)
- unpackSound(bmain, reports, snd, how);
- }
- if (GS(id->name) == ID_LI) {
- Library *li = (Library *)id;
- BKE_reportf(reports, RPT_ERROR, "Cannot unpack individual Library file, '%s'", li->name);
+ switch (GS(id->name)) {
+ case ID_IM:
+ {
+ Image *ima = (Image *)id;
+ if (ima->packedfile) {
+ unpackImage(reports, ima, how);
+ }
+ break;
+ }
+ case ID_VF:
+ {
+ VFont *vf = (VFont *)id;
+ if (vf->packedfile) {
+ unpackVFont(reports, vf, how);
+ }
+ break;
+ }
+ case ID_SO:
+ {
+ bSound *snd = (bSound *)id;
+ if (snd->packedfile) {
+ unpackSound(bmain, reports, snd, how);
+ }
+ break;
+ }
+ case ID_LI:
+ {
+ Library *li = (Library *)id;
+ BKE_reportf(reports, RPT_ERROR, "Cannot unpack individual Library file, '%s'", li->name);
+ break;
+ }
}
}
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index d7ae8e30698..1b8c4e084cf 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -37,6 +37,7 @@
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
+#include "DNA_modifier_types.h"
#include "DNA_scene_types.h"
#include "DNA_brush_types.h"
#include "DNA_space_types.h"
@@ -47,10 +48,14 @@
#include "BKE_brush.h"
#include "BKE_context.h"
+#include "BKE_crazyspace.h"
#include "BKE_depsgraph.h"
#include "BKE_global.h"
#include "BKE_image.h"
+#include "BKE_key.h"
#include "BKE_library.h"
+#include "BKE_mesh.h"
+#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_pbvh.h"
@@ -392,7 +397,7 @@ void paint_calculate_rake_rotation(UnifiedPaintSettings *ups, const float mouse_
}
}
-void free_sculptsession_deformMats(SculptSession *ss)
+void BKE_free_sculptsession_deformMats(SculptSession *ss)
{
if (ss->orig_cos) MEM_freeN(ss->orig_cos);
if (ss->deform_cos) MEM_freeN(ss->deform_cos);
@@ -413,8 +418,7 @@ static void sculptsession_bm_to_me_update_data_only(Object *ob, bool reorder)
BMIter iter;
BMFace *efa;
BM_ITER_MESH (efa, &iter, ss->bm, BM_FACES_OF_MESH) {
- BM_elem_flag_set(efa, BM_ELEM_SMOOTH,
- ss->bm_smooth_shading);
+ BM_elem_flag_set(efa, BM_ELEM_SMOOTH, ss->bm_smooth_shading);
}
if (reorder)
BM_log_mesh_elems_reorder(ss->bm, ss->bm_log);
@@ -423,7 +427,7 @@ static void sculptsession_bm_to_me_update_data_only(Object *ob, bool reorder)
}
}
-void sculptsession_bm_to_me(Object *ob, bool reorder)
+void BKE_sculptsession_bm_to_me(Object *ob, bool reorder)
{
if (ob && ob->sculpt) {
sculptsession_bm_to_me_update_data_only(ob, reorder);
@@ -433,7 +437,7 @@ void sculptsession_bm_to_me(Object *ob, bool reorder)
}
}
-void sculptsession_bm_to_me_for_render(Object *object)
+void BKE_sculptsession_bm_to_me_for_render(Object *object)
{
if (object && object->sculpt) {
if (object->sculpt->bm) {
@@ -460,14 +464,14 @@ void sculptsession_bm_to_me_for_render(Object *object)
}
}
-void free_sculptsession(Object *ob)
+void BKE_free_sculptsession(Object *ob)
{
if (ob && ob->sculpt) {
SculptSession *ss = ob->sculpt;
DerivedMesh *dm = ob->derivedFinal;
if (ss->bm) {
- sculptsession_bm_to_me(ob, true);
+ BKE_sculptsession_bm_to_me(ob, true);
BM_mesh_free(ss->bm);
}
@@ -500,3 +504,239 @@ void free_sculptsession(Object *ob)
ob->sculpt = NULL;
}
}
+
+/* Sculpt mode handles multires differently from regular meshes, but only if
+ * it's the last modifier on the stack and it is not on the first level */
+MultiresModifierData *BKE_sculpt_multires_active(Scene *scene, Object *ob)
+{
+ Mesh *me = (Mesh *)ob->data;
+ ModifierData *md;
+ VirtualModifierData virtualModifierData;
+
+ if (ob->sculpt && ob->sculpt->bm) {
+ /* can't combine multires and dynamic topology */
+ return NULL;
+ }
+
+ if (!CustomData_get_layer(&me->ldata, CD_MDISPS)) {
+ /* multires can't work without displacement layer */
+ return NULL;
+ }
+
+ for (md = modifiers_getVirtualModifierList(ob, &virtualModifierData); md; md = md->next) {
+ if (md->type == eModifierType_Multires) {
+ MultiresModifierData *mmd = (MultiresModifierData *)md;
+
+ if (!modifier_isEnabled(scene, md, eModifierMode_Realtime))
+ continue;
+
+ if (mmd->sculptlvl > 0) return mmd;
+ else return NULL;
+ }
+ }
+
+ return NULL;
+}
+
+
+/* Checks if there are any supported deformation modifiers active */
+static bool sculpt_modifiers_active(Scene *scene, Sculpt *sd, Object *ob)
+{
+ ModifierData *md;
+ Mesh *me = (Mesh *)ob->data;
+ MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, ob);
+ VirtualModifierData virtualModifierData;
+
+ if (mmd || ob->sculpt->bm)
+ return 0;
+
+ /* non-locked shape keys could be handled in the same way as deformed mesh */
+ if ((ob->shapeflag & OB_SHAPE_LOCK) == 0 && me->key && ob->shapenr)
+ return 1;
+
+ md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
+
+ /* exception for shape keys because we can edit those */
+ for (; md; md = md->next) {
+ ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+ if (!modifier_isEnabled(scene, md, eModifierMode_Realtime)) continue;
+ if (ELEM(md->type, eModifierType_ShapeKey, eModifierType_Multires)) continue;
+
+ if (mti->type == eModifierTypeType_OnlyDeform) return 1;
+ else if ((sd->flags & SCULPT_ONLY_DEFORM) == 0) return 1;
+ }
+
+ return 0;
+}
+
+/**
+ * \param need_mask So the DerivedMesh thats returned has mask data
+ */
+void BKE_sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob,
+ bool need_pmap, bool need_mask)
+{
+ DerivedMesh *dm;
+ SculptSession *ss = ob->sculpt;
+ Mesh *me = ob->data;
+ MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, ob);
+
+ ss->modifiers_active = sculpt_modifiers_active(scene, sd, ob);
+ ss->show_diffuse_color = (sd->flags & SCULPT_SHOW_DIFFUSE) != 0;
+
+ if (need_mask) {
+ if (mmd == NULL) {
+ if (!CustomData_has_layer(&me->vdata, CD_PAINT_MASK)) {
+ BKE_sculpt_mask_layers_ensure(ob, NULL);
+ }
+ }
+ else {
+ if (!CustomData_has_layer(&me->ldata, CD_GRID_PAINT_MASK)) {
+#if 1
+ BKE_sculpt_mask_layers_ensure(ob, mmd);
+#else /* if we wanted to support adding mask data while multi-res painting, we would need to do this */
+ if ((ED_sculpt_mask_layers_ensure(ob, mmd) & ED_SCULPT_MASK_LAYER_CALC_LOOP)) {
+ /* remake the derived mesh */
+ ob->recalc |= OB_RECALC_DATA;
+ BKE_object_handle_update(scene, ob);
+ }
+#endif
+ }
+ }
+ }
+
+ /* BMESH ONLY --- at some point we should move sculpt code to use polygons only - but for now it needs tessfaces */
+ BKE_mesh_tessface_ensure(me);
+
+ if (!mmd) ss->kb = BKE_keyblock_from_object(ob);
+ else ss->kb = NULL;
+
+ /* needs to be called after we ensure tessface */
+ dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
+
+ if (mmd) {
+ ss->multires = mmd;
+ ss->totvert = dm->getNumVerts(dm);
+ ss->totpoly = dm->getNumPolys(dm);
+ ss->mvert = NULL;
+ ss->mpoly = NULL;
+ ss->mloop = NULL;
+ ss->face_normals = NULL;
+ }
+ else {
+ ss->totvert = me->totvert;
+ ss->totpoly = me->totpoly;
+ ss->mvert = me->mvert;
+ ss->mpoly = me->mpoly;
+ ss->mloop = me->mloop;
+ ss->face_normals = NULL;
+ ss->multires = NULL;
+ 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_show_diffuse_color_set(ss->pbvh, ss->show_diffuse_color);
+
+ if (ss->modifiers_active) {
+ if (!ss->orig_cos) {
+ int a;
+
+ BKE_free_sculptsession_deformMats(ss);
+
+ ss->orig_cos = (ss->kb) ? BKE_key_convert_to_vertcos(ob, ss->kb) : BKE_mesh_vertexCos_get(me, NULL);
+
+ BKE_crazyspace_build_sculpt(scene, ob, &ss->deform_imats, &ss->deform_cos);
+ BKE_pbvh_apply_vertCos(ss->pbvh, ss->deform_cos);
+
+ for (a = 0; a < me->totvert; ++a) {
+ invert_m3(ss->deform_imats[a]);
+ }
+ }
+ }
+ else {
+ BKE_free_sculptsession_deformMats(ss);
+ }
+
+ /* if pbvh is deformed, key block is already applied to it */
+ if (ss->kb && !BKE_pbvh_isDeformed(ss->pbvh)) {
+ float (*vertCos)[3] = BKE_key_convert_to_vertcos(ob, ss->kb);
+
+ if (vertCos) {
+ /* apply shape keys coordinates to PBVH */
+ BKE_pbvh_apply_vertCos(ss->pbvh, vertCos);
+ MEM_freeN(vertCos);
+ }
+ }
+}
+
+int BKE_sculpt_mask_layers_ensure(Object *ob, MultiresModifierData *mmd)
+{
+ const float *paint_mask;
+ Mesh *me = ob->data;
+ int ret = 0;
+
+ paint_mask = CustomData_get_layer(&me->vdata, CD_PAINT_MASK);
+
+ /* if multires is active, create a grid paint mask layer if there
+ * isn't one already */
+ if (mmd && !CustomData_has_layer(&me->ldata, CD_GRID_PAINT_MASK)) {
+ GridPaintMask *gmask;
+ int level = max_ii(1, mmd->sculptlvl);
+ int gridsize = BKE_ccg_gridsize(level);
+ int gridarea = gridsize * gridsize;
+ int i, j;
+
+ gmask = CustomData_add_layer(&me->ldata, CD_GRID_PAINT_MASK,
+ CD_CALLOC, NULL, me->totloop);
+
+ for (i = 0; i < me->totloop; i++) {
+ GridPaintMask *gpm = &gmask[i];
+
+ gpm->level = level;
+ gpm->data = MEM_callocN(sizeof(float) * gridarea,
+ "GridPaintMask.data");
+ }
+
+ /* if vertices already have mask, copy into multires data */
+ if (paint_mask) {
+ for (i = 0; i < me->totpoly; i++) {
+ const MPoly *p = &me->mpoly[i];
+ float avg = 0;
+
+ /* mask center */
+ for (j = 0; j < p->totloop; j++) {
+ const MLoop *l = &me->mloop[p->loopstart + j];
+ avg += paint_mask[l->v];
+ }
+ avg /= (float)p->totloop;
+
+ /* fill in multires mask corner */
+ for (j = 0; j < p->totloop; j++) {
+ GridPaintMask *gpm = &gmask[p->loopstart + j];
+ const MLoop *l = &me->mloop[p->loopstart + j];
+ const MLoop *prev = ME_POLY_LOOP_PREV(me->mloop, p, j);
+ const MLoop *next = ME_POLY_LOOP_NEXT(me->mloop, p, j);
+
+ gpm->data[0] = avg;
+ gpm->data[1] = (paint_mask[l->v] +
+ paint_mask[next->v]) * 0.5f;
+ gpm->data[2] = (paint_mask[l->v] +
+ paint_mask[prev->v]) * 0.5f;
+ gpm->data[3] = paint_mask[l->v];
+ }
+ }
+ }
+
+ ret |= SCULPT_MASK_LAYER_CALC_LOOP;
+ }
+
+ /* create vertex paint mask layer if there isn't one already */
+ if (!paint_mask) {
+ CustomData_add_layer(&me->vdata, CD_PAINT_MASK,
+ CD_CALLOC, NULL, me->totvert);
+ ret |= SCULPT_MASK_LAYER_CALC_VERT;
+ }
+
+ return ret;
+}
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index df7de5be6b6..eb657bac312 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -71,7 +71,6 @@
#include "BKE_displist.h"
#include "BKE_particle.h"
-#include "BKE_object.h"
#include "BKE_material.h"
#include "BKE_key.h"
#include "BKE_library.h"
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 846ab10412e..d213a88f8b1 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -54,12 +54,9 @@
#include "DNA_modifier_types.h"
#include "DNA_object_force.h"
#include "DNA_object_types.h"
-#include "DNA_material_types.h"
#include "DNA_curve_types.h"
-#include "DNA_group_types.h"
#include "DNA_scene_types.h"
#include "DNA_texture_types.h"
-#include "DNA_ipo_types.h" // XXX old animation system stuff... to be removed!
#include "DNA_listBase.h"
#include "BLI_utildefines.h"
@@ -74,12 +71,10 @@
#include "BLI_threads.h"
#include "BLI_linklist.h"
-#include "BKE_main.h"
#include "BKE_animsys.h"
#include "BKE_boids.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_collision.h"
-#include "BKE_displist.h"
#include "BKE_effect.h"
#include "BKE_particle.h"
#include "BKE_global.h"
@@ -88,7 +83,6 @@
#include "BKE_object.h"
#include "BKE_material.h"
#include "BKE_cloth.h"
-#include "BKE_depsgraph.h"
#include "BKE_lattice.h"
#include "BKE_pointcache.h"
#include "BKE_mesh.h"
@@ -495,15 +489,19 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys)
int totvert=dm->getNumVerts(dm), from=psys->part->from;
int i, j, k, p, res=psys->part->grid_res, size[3], axis;
- mv=mvert;
-
/* find bounding box of dm */
- copy_v3_v3(min, mv->co);
- copy_v3_v3(max, mv->co);
- mv++;
-
- for (i=1; i<totvert; i++, mv++) {
- minmax_v3v3_v3(min, max, mv->co);
+ if (totvert > 0) {
+ mv=mvert;
+ copy_v3_v3(min, mv->co);
+ copy_v3_v3(max, mv->co);
+ mv++;
+ for (i = 1; i < totvert; i++, mv++) {
+ minmax_v3v3_v3(min, max, mv->co);
+ }
+ }
+ else {
+ zero_v3(min);
+ zero_v3(max);
}
sub_v3_v3v3(delta, max, min);
@@ -1964,10 +1962,21 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
}
}
}
+
+/* recursively evaluate emitter parent anim at cfra */
+static void evaluate_emitter_anim(Scene *scene, Object *ob, float cfra)
+{
+ if (ob->parent)
+ evaluate_emitter_anim(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_object_where_is_calc_time(scene, ob, cfra);
+}
+
/* sets particle to the emitter surface with initial velocity & rotation */
void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, float cfra)
{
- Object *ob = sim->ob;
ParticleSystem *psys = sim->psys;
ParticleSettings *part;
ParticleTexture ptex;
@@ -1976,13 +1985,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
/* get precise emitter matrix if particle is born */
if (part->type!=PART_HAIR && dtime > 0.f && pa->time < cfra && pa->time >= sim->psys->cfra) {
- /* we have to force RECALC_ANIM here since where_is_objec_time only does drivers */
- while (ob) {
- BKE_animsys_evaluate_animdata(sim->scene, &ob->id, ob->adt, pa->time, ADT_RECALC_ANIM);
- BKE_object_where_is_calc_time(sim->scene, ob, pa->time);
- ob = ob->parent;
- }
- ob = sim->ob;
+ evaluate_emitter_anim(sim->scene, sim->ob, pa->time);
psys->flag |= PSYS_OB_ANIM_RESTORE;
}
@@ -5100,13 +5103,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
/* make sure emitter is left at correct time (particle emission can change this) */
if (psys->flag & PSYS_OB_ANIM_RESTORE) {
- while (ob) {
- BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, cfra, ADT_RECALC_ANIM);
- BKE_object_where_is_calc_time(scene, ob, cfra);
- ob = ob->parent;
- }
- ob = sim.ob;
-
+ evaluate_emitter_anim(scene, ob, cfra);
psys->flag &= ~PSYS_OB_ANIM_RESTORE;
}
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index c595ee56633..45de1449027 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -34,10 +34,9 @@
#include "BKE_pbvh.h"
#include "BKE_ccg.h"
#include "BKE_DerivedMesh.h"
+#include "BKE_global.h"
#include "BKE_mesh.h" /* for BKE_mesh_calc_normals */
-#include "BKE_global.h" /* for BKE_mesh_calc_normals */
#include "BKE_paint.h"
-#include "BKE_subsurf.h"
#include "GPU_buffers.h"
@@ -276,6 +275,7 @@ static void build_mesh_leaf_node(PBVH *bvh, PBVHNode *node)
GHashIterator *iter;
GHash *map;
int i, j, totface;
+ bool has_visible = false;
node->uniq_verts = node->face_verts = 0;
totface = node->totprim;
@@ -295,6 +295,9 @@ static void build_mesh_leaf_node(PBVH *bvh, PBVHNode *node)
map_insert_vert(bvh, map, &node->face_verts,
&node->uniq_verts, (&f->v1)[j]);
}
+
+ if (!paint_is_face_hidden(f, bvh->verts))
+ has_visible = true;
}
node->vert_indices = MEM_callocN(sizeof(int) *
@@ -332,6 +335,8 @@ static void build_mesh_leaf_node(PBVH *bvh, PBVHNode *node)
BKE_pbvh_node_mark_rebuild_draw(node);
+ BKE_pbvh_node_fully_hidden_set(node, !has_visible);
+
BLI_ghash_free(map, NULL, NULL);
}
@@ -347,6 +352,45 @@ static void update_vb(PBVH *bvh, PBVHNode *node, BBC *prim_bbc,
node->orig_vb = node->vb;
}
+/* Returns the number of visible quads in the nodes' grids. */
+int BKE_pbvh_count_grid_quads(BLI_bitmap **grid_hidden,
+ int *grid_indices, int totgrid,
+ int gridsize)
+{
+ int gridarea = (gridsize - 1) * (gridsize - 1);
+ int i, x, y, totquad;
+
+ /* grid hidden layer is present, so have to check each grid for
+ * visibility */
+
+ for (i = 0, totquad = 0; i < totgrid; i++) {
+ const BLI_bitmap *gh = grid_hidden[grid_indices[i]];
+
+ if (gh) {
+ /* grid hidden are present, have to check each element */
+ for (y = 0; y < gridsize - 1; y++) {
+ for (x = 0; x < gridsize - 1; x++) {
+ if (!paint_is_grid_face_hidden(gh, gridsize, x, y))
+ totquad++;
+ }
+ }
+ }
+ else
+ totquad += gridarea;
+ }
+
+ return totquad;
+}
+
+static void build_grid_leaf_node(PBVH *bvh, PBVHNode *node)
+{
+ int totquads = BKE_pbvh_count_grid_quads(bvh->grid_hidden, node->prim_indices,
+ node->totprim, bvh->gridkey.grid_size);
+ BKE_pbvh_node_fully_hidden_set(node, (totquads == 0));
+ BKE_pbvh_node_mark_rebuild_draw(node);
+}
+
+
static void build_leaf(PBVH *bvh, int node_index, BBC *prim_bbc,
int offset, int count)
{
@@ -360,8 +404,9 @@ static void build_leaf(PBVH *bvh, int node_index, BBC *prim_bbc,
if (bvh->faces)
build_mesh_leaf_node(bvh, bvh->nodes + node_index);
- else
- BKE_pbvh_node_mark_rebuild_draw(bvh->nodes + node_index);
+ else {
+ build_grid_leaf_node(bvh, bvh->nodes + node_index);
+ }
}
/* Return zero if all primitives in the node can be drawn with the
@@ -594,7 +639,7 @@ void BKE_pbvh_free(PBVH *bvh)
BKE_pbvh_node_layer_disp_free(node);
if (node->bm_faces)
- BLI_ghash_free(node->bm_faces, NULL, NULL);
+ BLI_gset_free(node->bm_faces, NULL);
if (node->bm_unique_verts)
BLI_gset_free(node->bm_unique_verts, NULL);
if (node->bm_other_verts)
@@ -618,11 +663,6 @@ void BKE_pbvh_free(PBVH *bvh)
if (bvh->prim_indices)
MEM_freeN(bvh->prim_indices);
- if (bvh->bm_vert_to_node)
- BLI_ghash_free(bvh->bm_vert_to_node, NULL, NULL);
- if (bvh->bm_face_to_node)
- BLI_ghash_free(bvh->bm_face_to_node, NULL, NULL);
-
MEM_freeN(bvh);
}
@@ -1043,7 +1083,7 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode)
break;
case PBVH_FACES:
node->draw_buffers =
- GPU_build_pbvh_mesh_buffers(node->face_vert_indices,
+ GPU_build_mesh_pbvh_buffers(node->face_vert_indices,
bvh->faces, bvh->verts,
node->prim_indices,
node->totprim);
@@ -1095,6 +1135,22 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode)
}
}
+static void pbvh_draw_BB(PBVH *bvh)
+{
+ PBVHNode *node;
+ int a;
+
+ GPU_init_draw_pbvh_BB();
+
+ for (a = 0; a < bvh->totnode; a++) {
+ node = &bvh->nodes[a];
+
+ GPU_draw_pbvh_BB(node->vb.bmin, node->vb.bmax, ((node->flag & PBVH_Leaf) != 0));
+ }
+
+ GPU_end_draw_pbvh_BB();
+}
+
static int pbvh_flush_bb(PBVH *bvh, PBVHNode *node, int flag)
{
int update = 0;
@@ -1169,17 +1225,17 @@ void BKE_pbvh_redraw_BB(PBVH *bvh, float bb_min[3], float bb_max[3])
copy_v3_v3(bb_max, bb.bmax);
}
-void BKE_pbvh_get_grid_updates(PBVH *bvh, int clear, void ***gridfaces, int *totface)
+void BKE_pbvh_get_grid_updates(PBVH *bvh, int clear, void ***r_gridfaces, int *r_totface)
{
PBVHIter iter;
PBVHNode *node;
- GHashIterator *hiter;
- GHash *map;
+ GSetIterator gs_iter;
+ GSet *face_set;
void *face, **faces;
unsigned i;
int tot;
- map = BLI_ghash_ptr_new("pbvh_get_grid_updates gh");
+ face_set = BLI_gset_ptr_new(__func__);
pbvh_iter_begin(&iter, bvh, NULL, NULL);
@@ -1187,8 +1243,8 @@ void BKE_pbvh_get_grid_updates(PBVH *bvh, int clear, void ***gridfaces, int *tot
if (node->flag & PBVH_UpdateNormals) {
for (i = 0; i < node->totprim; ++i) {
face = bvh->gridfaces[node->prim_indices[i]];
- if (!BLI_ghash_lookup(map, face))
- BLI_ghash_insert(map, face, face);
+ if (!BLI_gset_haskey(face_set, face))
+ BLI_gset_insert(face_set, face);
}
if (clear)
@@ -1198,29 +1254,24 @@ void BKE_pbvh_get_grid_updates(PBVH *bvh, int clear, void ***gridfaces, int *tot
pbvh_iter_end(&iter);
- tot = BLI_ghash_size(map);
+ tot = BLI_gset_size(face_set);
if (tot == 0) {
- *totface = 0;
- *gridfaces = NULL;
- BLI_ghash_free(map, NULL, NULL);
+ *r_totface = 0;
+ *r_gridfaces = NULL;
+ BLI_gset_free(face_set, NULL);
return;
}
- faces = MEM_callocN(sizeof(void *) * tot, "PBVH Grid Faces");
+ faces = MEM_mallocN(sizeof(*faces) * tot, "PBVH Grid Faces");
- for (hiter = BLI_ghashIterator_new(map), i = 0;
- BLI_ghashIterator_done(hiter) == false;
- BLI_ghashIterator_step(hiter), ++i)
- {
- faces[i] = BLI_ghashIterator_getKey(hiter);
+ GSET_ITER_INDEX (gs_iter, face_set, i) {
+ faces[i] = BLI_gsetIterator_getKey(&gs_iter);
}
- BLI_ghashIterator_free(hiter);
-
- BLI_ghash_free(map, NULL, NULL);
+ BLI_gset_free(face_set, NULL);
- *totface = tot;
- *gridfaces = faces;
+ *r_totface = tot;
+ *r_gridfaces = faces;
}
/***************************** PBVH Access ***********************************/
@@ -1703,6 +1754,9 @@ void BKE_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*face_nors)[3],
else {
BKE_pbvh_search_callback(bvh, NULL, NULL, BKE_pbvh_node_draw, &draw_data);
}
+
+ if (G.debug_value == 14)
+ pbvh_draw_BB(bvh);
}
void BKE_pbvh_grids_update(PBVH *bvh, CCGElem **grids, DMGridAdjacency *gridadj, void **gridfaces,
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index 98efc112125..83e0d1a4740 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -32,8 +32,6 @@
#include "BKE_ccg.h"
#include "BKE_DerivedMesh.h"
-#include "BKE_global.h"
-#include "BKE_paint.h"
#include "BKE_pbvh.h"
#include "GPU_buffers.h"
@@ -46,10 +44,11 @@
/****************************** Building ******************************/
/* Update node data after splitting */
-static void pbvh_bmesh_node_finalize(PBVH *bvh, int node_index)
+static void pbvh_bmesh_node_finalize(PBVH *bvh, int node_index, const int cd_vert_node_offset, const int cd_face_node_offset)
{
- GHashIterator gh_iter;
+ GSetIterator gs_iter;
PBVHNode *n = &bvh->nodes[node_index];
+ bool has_visible = false;
/* Create vert hash sets */
n->bm_unique_verts = BLI_gset_ptr_new("bm_unique_verts");
@@ -57,32 +56,34 @@ static void pbvh_bmesh_node_finalize(PBVH *bvh, int node_index)
BB_reset(&n->vb);
- GHASH_ITER (gh_iter, n->bm_faces) {
- BMFace *f = BLI_ghashIterator_getKey(&gh_iter);
+ GSET_ITER (gs_iter, n->bm_faces) {
+ BMFace *f = BLI_gsetIterator_getKey(&gs_iter);
BMLoop *l_iter;
BMLoop *l_first;
BMVert *v;
- void *node_val = SET_INT_IN_POINTER(node_index);
/* Update ownership of faces */
- BLI_ghash_insert(bvh->bm_face_to_node, f, node_val);
+ BM_ELEM_CD_SET_INT(f, cd_face_node_offset, node_index);
- /* Update vertices */
+ /* Update vertices */
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
do {
v = l_iter->v;
if (!BLI_gset_haskey(n->bm_unique_verts, v)) {
- if (BLI_ghash_haskey(bvh->bm_vert_to_node, v)) {
+ if (BM_ELEM_CD_GET_INT(v, cd_vert_node_offset) != DYNTOPO_NODE_NONE) {
BLI_gset_reinsert(n->bm_other_verts, v, NULL);
}
else {
BLI_gset_insert(n->bm_unique_verts, v);
- BLI_ghash_insert(bvh->bm_vert_to_node, v, node_val);
+ BM_ELEM_CD_SET_INT(v, cd_vert_node_offset, node_index);
}
}
/* Update node bounding box */
BB_expand(&n->vb, v->co);
} while ((l_iter = l_iter->next) != l_first);
+
+ if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN))
+ has_visible = true;
}
BLI_assert(n->vb.bmin[0] <= n->vb.bmax[0] &&
@@ -93,32 +94,34 @@ static void pbvh_bmesh_node_finalize(PBVH *bvh, int node_index)
/* Build GPU buffers for new node and update vertex normals */
BKE_pbvh_node_mark_rebuild_draw(n);
+
+ BKE_pbvh_node_fully_hidden_set(n, !has_visible);
n->flag |= PBVH_UpdateNormals;
}
/* Recursively split the node if it exceeds the leaf_limit */
static void pbvh_bmesh_node_split(PBVH *bvh, GHash *prim_bbc, int node_index)
{
- GHash *empty, *other;
- GHashIterator gh_iter;
+ GSet *empty, *other;
GSetIterator gs_iter;
PBVHNode *n, *c1, *c2;
BB cb;
float mid;
int axis, children;
-
+ const int cd_vert_node_offset = bvh->cd_vert_node_offset;
+ const int cd_face_node_offset = bvh->cd_face_node_offset;
n = &bvh->nodes[node_index];
- if (BLI_ghash_size(n->bm_faces) <= bvh->leaf_limit) {
+ if (BLI_gset_size(n->bm_faces) <= bvh->leaf_limit) {
/* Node limit not exceeded */
- pbvh_bmesh_node_finalize(bvh, node_index);
+ pbvh_bmesh_node_finalize(bvh, node_index, cd_vert_node_offset, cd_face_node_offset);
return;
}
/* Calculate bounding box around primitive centroids */
BB_reset(&cb);
- GHASH_ITER (gh_iter, n->bm_faces) {
- const BMFace *f = BLI_ghashIterator_getKey(&gh_iter);
+ GSET_ITER (gs_iter, n->bm_faces) {
+ const BMFace *f = BLI_gsetIterator_getKey(&gs_iter);
const BBC *bbc = BLI_ghash_lookup(prim_bbc, f);
BB_expand(&cb, bbc->bcentroid);
@@ -141,35 +144,35 @@ static void pbvh_bmesh_node_split(PBVH *bvh, GHash *prim_bbc, int node_index)
c2 = &bvh->nodes[children + 1];
c1->flag |= PBVH_Leaf;
c2->flag |= PBVH_Leaf;
- c1->bm_faces = BLI_ghash_ptr_new_ex("bm_faces", BLI_ghash_size(n->bm_faces) / 2);
- c2->bm_faces = BLI_ghash_ptr_new_ex("bm_faces", BLI_ghash_size(n->bm_faces) / 2);
+ c1->bm_faces = BLI_gset_ptr_new_ex("bm_faces", BLI_gset_size(n->bm_faces) / 2);
+ c2->bm_faces = BLI_gset_ptr_new_ex("bm_faces", BLI_gset_size(n->bm_faces) / 2);
/* Partition the parent node's faces between the two children */
- GHASH_ITER (gh_iter, n->bm_faces) {
- BMFace *f = BLI_ghashIterator_getKey(&gh_iter);
+ GSET_ITER (gs_iter, n->bm_faces) {
+ BMFace *f = BLI_gsetIterator_getKey(&gs_iter);
const BBC *bbc = BLI_ghash_lookup(prim_bbc, f);
if (bbc->bcentroid[axis] < mid)
- BLI_ghash_insert(c1->bm_faces, f, NULL);
+ BLI_gset_insert(c1->bm_faces, f);
else
- BLI_ghash_insert(c2->bm_faces, f, NULL);
+ BLI_gset_insert(c2->bm_faces, f);
}
/* Enforce at least one primitive in each node */
empty = NULL;
- if (BLI_ghash_size(c1->bm_faces) == 0) {
+ if (BLI_gset_size(c1->bm_faces) == 0) {
empty = c1->bm_faces;
other = c2->bm_faces;
}
- else if (BLI_ghash_size(c2->bm_faces) == 0) {
+ else if (BLI_gset_size(c2->bm_faces) == 0) {
empty = c2->bm_faces;
other = c1->bm_faces;
}
if (empty) {
- GHASH_ITER (gh_iter, other) {
- void *key = BLI_ghashIterator_getKey(&gh_iter);
- BLI_ghash_insert(empty, key, NULL);
- BLI_ghash_remove(other, key, NULL, NULL);
+ GSET_ITER (gs_iter, other) {
+ void *key = BLI_gsetIterator_getKey(&gs_iter);
+ BLI_gset_insert(empty, key);
+ BLI_gset_remove(other, key, NULL);
break;
}
}
@@ -180,17 +183,17 @@ static void pbvh_bmesh_node_split(PBVH *bvh, GHash *prim_bbc, int node_index)
if (n->bm_unique_verts) {
GSET_ITER (gs_iter, n->bm_unique_verts) {
BMVert *v = BLI_gsetIterator_getKey(&gs_iter);
- BLI_ghash_remove(bvh->bm_vert_to_node, v, NULL, NULL);
+ BM_ELEM_CD_SET_INT(v, cd_vert_node_offset, DYNTOPO_NODE_NONE);
}
BLI_gset_free(n->bm_unique_verts, NULL);
}
/* Unclaim faces */
- GHASH_ITER (gh_iter, n->bm_faces) {
- BMFace *f = BLI_ghashIterator_getKey(&gh_iter);
- BLI_ghash_remove(bvh->bm_face_to_node, f, NULL, NULL);
+ GSET_ITER (gs_iter, n->bm_faces) {
+ BMFace *f = BLI_gsetIterator_getKey(&gs_iter);
+ BM_ELEM_CD_SET_INT(f, cd_face_node_offset, DYNTOPO_NODE_NONE);
}
- BLI_ghash_free(n->bm_faces, NULL, NULL);
+ BLI_gset_free(n->bm_faces, NULL);
if (n->bm_other_verts)
BLI_gset_free(n->bm_other_verts, NULL);
@@ -228,14 +231,14 @@ static void pbvh_bmesh_node_split(PBVH *bvh, GHash *prim_bbc, int node_index)
static bool pbvh_bmesh_node_limit_ensure(PBVH *bvh, int node_index)
{
GHash *prim_bbc;
- GHash *bm_faces;
+ GSet *bm_faces;
int bm_faces_size;
- GHashIterator gh_iter;
+ GSetIterator gs_iter;
BBC *bbc_array;
unsigned int i;
bm_faces = bvh->nodes[node_index].bm_faces;
- bm_faces_size = BLI_ghash_size(bm_faces);
+ bm_faces_size = BLI_gset_size(bm_faces);
if (bm_faces_size <= bvh->leaf_limit) {
/* Node limit not exceeded */
return false;
@@ -245,8 +248,8 @@ static bool pbvh_bmesh_node_limit_ensure(PBVH *bvh, int node_index)
prim_bbc = BLI_ghash_ptr_new_ex("prim_bbc", bm_faces_size);
bbc_array = MEM_callocN(sizeof(BBC) * bm_faces_size, "BBC");
- GHASH_ITER_INDEX (gh_iter, bm_faces, i) {
- BMFace *f = BLI_ghashIterator_getKey(&gh_iter);
+ GSET_ITER_INDEX (gs_iter, bm_faces, i) {
+ BMFace *f = BLI_gsetIterator_getKey(&gs_iter);
BBC *bbc = &bbc_array[i];
BMLoop *l_iter;
BMLoop *l_first;
@@ -271,13 +274,12 @@ static bool pbvh_bmesh_node_limit_ensure(PBVH *bvh, int node_index)
/**********************************************************************/
-static PBVHNode *pbvh_bmesh_node_lookup(PBVH *bvh, GHash *map, void *key)
+static PBVHNode *pbvh_bmesh_node_lookup(PBVH *bvh, void *key, const int cd_node_offset)
{
- int node_index;
+ int node_index = BM_ELEM_CD_GET_INT((BMElem *)key, cd_node_offset);
- BLI_assert(BLI_ghash_haskey(map, key));
+ BLI_assert(node_index != DYNTOPO_NODE_NONE);
- node_index = GET_INT_FROM_POINTER(BLI_ghash_lookup(map, key));
BLI_assert(node_index < bvh->totnode);
return &bvh->nodes[node_index];
@@ -285,51 +287,54 @@ static PBVHNode *pbvh_bmesh_node_lookup(PBVH *bvh, GHash *map, void *key)
static BMVert *pbvh_bmesh_vert_create(PBVH *bvh, int node_index,
const float co[3],
- const BMVert *example)
+ const BMVert *example,
+ const int cd_vert_mask_offset,
+ const int cd_vert_node_offset)
{
BMVert *v = BM_vert_create(bvh->bm, co, example, BM_CREATE_NOP);
- void *val = SET_INT_IN_POINTER(node_index);
+ PBVHNode *node = &bvh->nodes[node_index];
BLI_assert((bvh->totnode == 1 || node_index) && node_index <= bvh->totnode);
- BLI_gset_insert(bvh->nodes[node_index].bm_unique_verts, v);
- BLI_ghash_insert(bvh->bm_vert_to_node, v, val);
+ BLI_gset_insert(node->bm_unique_verts, v);
+ BM_ELEM_CD_SET_INT(v, cd_vert_node_offset, node_index);
+
+ node->flag |= PBVH_UpdateDrawBuffers | PBVH_UpdateBB;
/* Log the new vertex */
- BM_log_vert_added(bvh->bm, bvh->bm_log, v);
+ BM_log_vert_added(bvh->bm_log, v, cd_vert_mask_offset);
return v;
}
static BMFace *pbvh_bmesh_face_create(PBVH *bvh, int node_index,
BMVert *v_tri[3], BMEdge *e_tri[3],
- const BMFace *f_example)
+ const BMFace *f_example, const int cd_face_node_offset)
{
BMFace *f;
- void *val = SET_INT_IN_POINTER(node_index);
+ PBVHNode *node = &bvh->nodes[node_index];
/* ensure we never add existing face */
BLI_assert(BM_face_exists(v_tri, 3, NULL) == false);
f = BM_face_create(bvh->bm, v_tri, e_tri, 3, f_example, BM_CREATE_NOP);
+ f->head.hflag = f_example->head.hflag;
- if (!BLI_ghash_haskey(bvh->bm_face_to_node, f)) {
-
- BLI_ghash_insert(bvh->nodes[node_index].bm_faces, f, NULL);
- BLI_ghash_insert(bvh->bm_face_to_node, f, val);
+ BLI_gset_insert(node->bm_faces, f);
+ BM_ELEM_CD_SET_INT(f, cd_face_node_offset, node_index);
- /* mark node for update */
- bvh->nodes[node_index].flag |= PBVH_UpdateDrawBuffers | PBVH_UpdateNormals | PBVH_UpdateBB;
+ /* mark node for update */
+ node->flag |= PBVH_UpdateDrawBuffers | PBVH_UpdateNormals;
+ node->flag &= ~PBVH_FullyHidden;
- /* Log the new face */
- BM_log_face_added(bvh->bm_log, f);
- }
+ /* Log the new face */
+ BM_log_face_added(bvh->bm_log, f);
return f;
}
/* Return the number of faces in 'node' that use vertex 'v' */
-static int pbvh_bmesh_node_vert_use_count(PBVH *bvh, PBVHNode *node, BMVert *v)
+static int pbvh_bmesh_node_vert_use_count(PBVH *bvh, PBVHNode *node, BMVert *v, const int cd_face_node_offset)
{
BMIter bm_iter;
BMFace *f;
@@ -338,7 +343,7 @@ static int pbvh_bmesh_node_vert_use_count(PBVH *bvh, PBVHNode *node, BMVert *v)
BM_ITER_ELEM (f, &bm_iter, v, BM_FACES_OF_VERT) {
PBVHNode *f_node;
- f_node = pbvh_bmesh_node_lookup(bvh, bvh->bm_face_to_node, f);
+ f_node = pbvh_bmesh_node_lookup(bvh, f, cd_face_node_offset);
if (f_node == node)
count++;
@@ -348,18 +353,20 @@ static int pbvh_bmesh_node_vert_use_count(PBVH *bvh, PBVHNode *node, BMVert *v)
}
/* Return a node that uses vertex 'v' other than its current owner */
-static PBVHNode *pbvh_bmesh_vert_other_node_find(PBVH *bvh, BMVert *v)
+static PBVHNode *pbvh_bmesh_vert_other_node_find(PBVH *bvh, BMVert *v,
+ const int cd_vert_node_offset,
+ const int cd_face_node_offset)
{
BMIter bm_iter;
BMFace *f;
PBVHNode *current_node;
- current_node = pbvh_bmesh_node_lookup(bvh, bvh->bm_vert_to_node, v);
+ current_node = pbvh_bmesh_node_lookup(bvh, v, cd_vert_node_offset);
BM_ITER_ELEM (f, &bm_iter, v, BM_FACES_OF_VERT) {
PBVHNode *f_node;
- f_node = pbvh_bmesh_node_lookup(bvh, bvh->bm_face_to_node, f);
+ f_node = pbvh_bmesh_node_lookup(bvh, f, cd_face_node_offset);
if (f_node != current_node)
return f_node;
@@ -369,13 +376,13 @@ static PBVHNode *pbvh_bmesh_vert_other_node_find(PBVH *bvh, BMVert *v)
}
static void pbvh_bmesh_vert_ownership_transfer(PBVH *bvh, PBVHNode *new_owner,
- BMVert *v)
+ BMVert *v, const int cd_vert_node_offset)
{
PBVHNode *current_owner;
- current_owner = pbvh_bmesh_node_lookup(bvh, bvh->bm_vert_to_node, v);
+ current_owner = pbvh_bmesh_node_lookup(bvh, v, cd_vert_node_offset);
/* mark node for update */
- current_owner->flag |= PBVH_UpdateDrawBuffers | PBVH_UpdateNormals | PBVH_UpdateBB;
+ current_owner->flag |= PBVH_UpdateDrawBuffers | PBVH_UpdateBB;
BLI_assert(current_owner != new_owner);
@@ -384,34 +391,32 @@ static void pbvh_bmesh_vert_ownership_transfer(PBVH *bvh, PBVHNode *new_owner,
BLI_gset_remove(current_owner->bm_unique_verts, v, NULL);
/* Set new ownership */
- BLI_ghash_reinsert(bvh->bm_vert_to_node, v,
- SET_INT_IN_POINTER(new_owner - bvh->nodes), NULL, NULL);
+ BM_ELEM_CD_SET_INT(v, cd_vert_node_offset, new_owner - bvh->nodes);
BLI_gset_insert(new_owner->bm_unique_verts, v);
BLI_gset_remove(new_owner->bm_other_verts, v, NULL);
BLI_assert(!BLI_gset_haskey(new_owner->bm_other_verts, v));
/* mark node for update */
- new_owner->flag |= PBVH_UpdateDrawBuffers | PBVH_UpdateNormals | PBVH_UpdateBB;
+ new_owner->flag |= PBVH_UpdateDrawBuffers | PBVH_UpdateBB;
}
-static void pbvh_bmesh_vert_remove(PBVH *bvh, BMVert *v)
+static void pbvh_bmesh_vert_remove(PBVH *bvh, BMVert *v, const int cd_vert_node_offset, const int cd_face_node_offset)
{
PBVHNode *v_node;
BMIter bm_iter;
BMFace *f;
- BLI_assert(BLI_ghash_haskey(bvh->bm_vert_to_node, v));
- v_node = pbvh_bmesh_node_lookup(bvh, bvh->bm_vert_to_node, v);
+ v_node = pbvh_bmesh_node_lookup(bvh, v, cd_vert_node_offset);
BLI_gset_remove(v_node->bm_unique_verts, v, NULL);
- BLI_ghash_remove(bvh->bm_vert_to_node, v, NULL, NULL);
+ BM_ELEM_CD_SET_INT(v, cd_vert_node_offset, DYNTOPO_NODE_NONE);
/* Have to check each neighboring face's node */
BM_ITER_ELEM (f, &bm_iter, v, BM_FACES_OF_VERT) {
- PBVHNode *f_node = pbvh_bmesh_node_lookup(bvh, bvh->bm_face_to_node, f);
+ PBVHNode *f_node = pbvh_bmesh_node_lookup(bvh, f, cd_face_node_offset);
+
+ f_node->flag |= PBVH_UpdateDrawBuffers | PBVH_UpdateBB;
/* Remove current ownership */
- /* Should be handled above by vert_to_node removal, leaving just in case - psy-fi */
- //BLI_ghash_remove(f_node->bm_unique_verts, v, NULL, NULL);
BLI_gset_remove(f_node->bm_other_verts, v, NULL);
BLI_assert(!BLI_gset_haskey(f_node->bm_unique_verts, v));
@@ -419,7 +424,7 @@ static void pbvh_bmesh_vert_remove(PBVH *bvh, BMVert *v)
}
}
-static void pbvh_bmesh_face_remove(PBVH *bvh, BMFace *f)
+static void pbvh_bmesh_face_remove(PBVH *bvh, BMFace *f, const int cd_vert_node_offset, const int cd_face_node_offset)
{
PBVHNode *f_node;
BMVert *v;
@@ -427,23 +432,23 @@ static void pbvh_bmesh_face_remove(PBVH *bvh, BMFace *f)
BMLoop *l_iter;
BMLoop *l_first;
- f_node = pbvh_bmesh_node_lookup(bvh, bvh->bm_face_to_node, f);
+ f_node = pbvh_bmesh_node_lookup(bvh, f, cd_face_node_offset);
/* Check if any of this face's vertices need to be removed
* from the node */
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
do {
v = l_iter->v;
- if (pbvh_bmesh_node_vert_use_count(bvh, f_node, v) == 1) {
+ if (pbvh_bmesh_node_vert_use_count(bvh, f_node, v, cd_face_node_offset) == 1) {
if (BLI_gset_haskey(f_node->bm_unique_verts, v)) {
/* Find a different node that uses 'v' */
PBVHNode *new_node;
- new_node = pbvh_bmesh_vert_other_node_find(bvh, v);
+ new_node = pbvh_bmesh_vert_other_node_find(bvh, v, cd_vert_node_offset, cd_face_node_offset);
BLI_assert(new_node || BM_vert_face_count(v) == 1);
if (new_node) {
- pbvh_bmesh_vert_ownership_transfer(bvh, new_node, v);
+ pbvh_bmesh_vert_ownership_transfer(bvh, new_node, v, cd_vert_node_offset);
}
}
else {
@@ -454,14 +459,14 @@ static void pbvh_bmesh_face_remove(PBVH *bvh, BMFace *f)
} while ((l_iter = l_iter->next) != l_first);
/* Remove face from node and top level */
- BLI_ghash_remove(f_node->bm_faces, f, NULL, NULL);
- BLI_ghash_remove(bvh->bm_face_to_node, f, NULL, NULL);
+ BLI_gset_remove(f_node->bm_faces, f, NULL);
+ BM_ELEM_CD_SET_INT(f, cd_face_node_offset, DYNTOPO_NODE_NONE);
/* Log removed face */
BM_log_face_removed(bvh->bm_log, f);
/* mark node for update */
- f_node->flag |= PBVH_UpdateDrawBuffers | PBVH_UpdateNormals | PBVH_UpdateBB;
+ f_node->flag |= PBVH_UpdateDrawBuffers | PBVH_UpdateNormals;
}
static void pbvh_bmesh_edge_loops(BLI_Buffer *buf, BMEdge *e)
@@ -505,6 +510,8 @@ typedef struct {
BLI_mempool *pool;
BMesh *bm;
int cd_vert_mask_offset;
+ int cd_vert_node_offset;
+ int cd_face_node_offset;
} EdgeQueueContext;
static bool edge_queue_tri_in_sphere(const EdgeQueue *q, BMFace *f)
@@ -539,7 +546,10 @@ static void edge_queue_insert(EdgeQueueContext *eq_ctx, BMEdge *e,
* should already make the brush move the vertices only 50%, which means
* that topology updates will also happen less frequent, that should be
* enough. */
- if (check_mask(eq_ctx, e->v1) || check_mask(eq_ctx, e->v2)) {
+ if ((check_mask(eq_ctx, e->v1) || check_mask(eq_ctx, e->v2)) &&
+ !(BM_elem_flag_test_bool(e->v1, BM_ELEM_HIDDEN) ||
+ BM_elem_flag_test_bool(e->v2, BM_ELEM_HIDDEN)))
+ {
pair = BLI_mempool_alloc(eq_ctx->pool);
pair[0] = e->v1;
pair[1] = e->v2;
@@ -618,13 +628,14 @@ static void long_edge_queue_create(EdgeQueueContext *eq_ctx,
/* Check leaf nodes marked for topology update */
if ((node->flag & PBVH_Leaf) &&
- (node->flag & PBVH_UpdateTopology))
+ (node->flag & PBVH_UpdateTopology) &&
+ !(node->flag & PBVH_FullyHidden))
{
- GHashIterator gh_iter;
+ GSetIterator gs_iter;
/* Check each face */
- GHASH_ITER (gh_iter, node->bm_faces) {
- BMFace *f = BLI_ghashIterator_getKey(&gh_iter);
+ GSET_ITER (gs_iter, node->bm_faces) {
+ BMFace *f = BLI_gsetIterator_getKey(&gs_iter);
long_edge_queue_face_add(eq_ctx, f);
}
@@ -657,13 +668,14 @@ static void short_edge_queue_create(EdgeQueueContext *eq_ctx,
/* Check leaf nodes marked for topology update */
if ((node->flag & PBVH_Leaf) &&
- (node->flag & PBVH_UpdateTopology))
+ (node->flag & PBVH_UpdateTopology) &&
+ !(node->flag & PBVH_FullyHidden))
{
- GHashIterator gh_iter;
+ GSetIterator gs_iter;
/* Check each face */
- GHASH_ITER (gh_iter, node->bm_faces) {
- BMFace *f = BLI_ghashIterator_getKey(&gh_iter);
+ GSET_ITER (gs_iter, node->bm_faces) {
+ BMFace *f = BLI_gsetIterator_getKey(&gs_iter);
short_edge_queue_face_add(eq_ctx, f);
}
@@ -693,9 +705,8 @@ static void pbvh_bmesh_split_edge(EdgeQueueContext *eq_ctx, PBVH *bvh,
/* Create a new vertex in current node at the edge's midpoint */
mid_v3_v3v3(mid, e->v1->co, e->v2->co);
- node_index = GET_INT_FROM_POINTER(BLI_ghash_lookup(bvh->bm_vert_to_node,
- e->v1));
- v_new = pbvh_bmesh_vert_create(bvh, node_index, mid, e->v1);
+ node_index = BM_ELEM_CD_GET_INT(e->v1, eq_ctx->cd_vert_node_offset);
+ v_new = pbvh_bmesh_vert_create(bvh, node_index, mid, e->v1, eq_ctx->cd_vert_mask_offset, eq_ctx->cd_vert_node_offset);
/* update paint mask */
if (eq_ctx->cd_vert_mask_offset != -1) {
@@ -714,12 +725,10 @@ static void pbvh_bmesh_split_edge(EdgeQueueContext *eq_ctx, PBVH *bvh,
BMVert *v_opp, *v1, *v2;
BMVert *v_tri[3];
BMEdge *e_tri[3];
- void *nip;
int ni;
BLI_assert(f_adj->len == 3);
- nip = BLI_ghash_lookup(bvh->bm_face_to_node, f_adj);
- ni = GET_INT_FROM_POINTER(nip);
+ ni = BM_ELEM_CD_GET_INT(f_adj, eq_ctx->cd_face_node_offset);
/* Find the vertex not in the edge */
v_opp = l_adj->prev->v;
@@ -731,14 +740,14 @@ static void pbvh_bmesh_split_edge(EdgeQueueContext *eq_ctx, PBVH *bvh,
v2 = l_adj->next->v;
if (ni != node_index && i == 0)
- pbvh_bmesh_vert_ownership_transfer(bvh, &bvh->nodes[ni], v_new);
+ pbvh_bmesh_vert_ownership_transfer(bvh, &bvh->nodes[ni], v_new, eq_ctx->cd_vert_node_offset);
/* Create two new faces */
v_tri[0] = v1;
v_tri[1] = v_new;
v_tri[2] = v_opp;
bm_edges_from_tri(bvh->bm, v_tri, e_tri);
- f_new = pbvh_bmesh_face_create(bvh, ni, v_tri, e_tri, f_adj);
+ f_new = pbvh_bmesh_face_create(bvh, ni, v_tri, e_tri, f_adj, eq_ctx->cd_face_node_offset);
long_edge_queue_face_add(eq_ctx, f_new);
v_tri[0] = v_new;
@@ -747,11 +756,11 @@ static void pbvh_bmesh_split_edge(EdgeQueueContext *eq_ctx, PBVH *bvh,
e_tri[0] = BM_edge_create(bvh->bm, v_tri[0], v_tri[1], NULL, BM_CREATE_NO_DOUBLE);
e_tri[2] = e_tri[1]; /* switched */
e_tri[1] = BM_edge_create(bvh->bm, v_tri[1], v_tri[2], NULL, BM_CREATE_NO_DOUBLE);
- f_new = pbvh_bmesh_face_create(bvh, ni, v_tri, e_tri, f_adj);
+ f_new = pbvh_bmesh_face_create(bvh, ni, v_tri, e_tri, f_adj, eq_ctx->cd_face_node_offset);
long_edge_queue_face_add(eq_ctx, f_new);
/* Delete original */
- pbvh_bmesh_face_remove(bvh, f_adj);
+ pbvh_bmesh_face_remove(bvh, f_adj, eq_ctx->cd_vert_node_offset, eq_ctx->cd_face_node_offset);
BM_face_kill(bvh->bm, f_adj);
/* Ensure new vertex is in the node */
@@ -799,8 +808,8 @@ static bool pbvh_bmesh_subdivide_long_edges(EdgeQueueContext *eq_ctx, PBVH *bvh,
* possible that an edge collapse has deleted adjacent faces
* and the node has been split, thus leaving wire edges and
* associated vertices. */
- if (!BLI_ghash_haskey(bvh->bm_vert_to_node, e->v1) ||
- !BLI_ghash_haskey(bvh->bm_vert_to_node, e->v2))
+ if ((BM_ELEM_CD_GET_INT(e->v1, eq_ctx->cd_vert_node_offset) == DYNTOPO_NODE_NONE) ||
+ (BM_ELEM_CD_GET_INT(e->v2, eq_ctx->cd_vert_node_offset) == DYNTOPO_NODE_NONE))
{
continue;
}
@@ -813,17 +822,18 @@ static bool pbvh_bmesh_subdivide_long_edges(EdgeQueueContext *eq_ctx, PBVH *bvh,
return any_subdivided;
}
-static void pbvh_bmesh_collapse_edge(PBVH *bvh, BMEdge *e, BMVert *v1,
- BMVert *v2, GHash *deleted_verts,
+static void pbvh_bmesh_collapse_edge(PBVH *bvh, BMEdge *e,
+ BMVert *v1, BMVert *v2,
+ GSet *deleted_verts,
BLI_Buffer *edge_loops,
BLI_Buffer *deleted_faces,
- int cd_vert_mask_offset)
+ EdgeQueueContext *eq_ctx)
{
BMIter bm_iter;
BMFace *f;
BMVert *v_del, *v_conn;
int i;
- float mask_v1 = BM_ELEM_CD_GET_FLOAT(v1, cd_vert_mask_offset);
+ float mask_v1 = BM_ELEM_CD_GET_FLOAT(v1, eq_ctx->cd_vert_mask_offset);
/* one of the two vertices may be masked, select the correct one for deletion */
if (mask_v1 < 1.0f) {
@@ -839,19 +849,19 @@ static void pbvh_bmesh_collapse_edge(PBVH *bvh, BMEdge *e, BMVert *v1,
pbvh_bmesh_edge_loops(edge_loops, e);
/* Remove the merge vertex from the PBVH */
- pbvh_bmesh_vert_remove(bvh, v_del);
+ pbvh_bmesh_vert_remove(bvh, v_del, eq_ctx->cd_vert_node_offset, eq_ctx->cd_face_node_offset);
/* Remove all faces adjacent to the edge */
for (i = 0; i < edge_loops->count; i++) {
BMLoop *l_adj = BLI_buffer_at(edge_loops, BMLoop *, i);
BMFace *f_adj = l_adj->f;
- pbvh_bmesh_face_remove(bvh, f_adj);
+ pbvh_bmesh_face_remove(bvh, f_adj, eq_ctx->cd_vert_node_offset, eq_ctx->cd_face_node_offset);
BM_face_kill(bvh->bm, f_adj);
}
/* Kill the edge */
- BLI_assert(BM_edge_face_count(e) == 0);
+ BLI_assert(BM_edge_is_wire(e));
BM_edge_kill(bvh->bm, e);
/* For all remaining faces of v_del, create a new face that is the
@@ -885,10 +895,10 @@ static void pbvh_bmesh_collapse_edge(PBVH *bvh, BMEdge *e, BMVert *v1,
}
else {
BMEdge *e_tri[3];
- n = pbvh_bmesh_node_lookup(bvh, bvh->bm_face_to_node, f);
+ n = pbvh_bmesh_node_lookup(bvh, f, eq_ctx->cd_face_node_offset);
ni = n - bvh->nodes;
bm_edges_from_tri(bvh->bm, v_tri, e_tri);
- pbvh_bmesh_face_create(bvh, ni, v_tri, e_tri, f);
+ pbvh_bmesh_face_create(bvh, ni, v_tri, e_tri, f, eq_ctx->cd_face_node_offset);
/* Ensure that v_conn is in the new face's node */
if (!BLI_gset_haskey(n->bm_unique_verts, v_conn) &&
@@ -920,8 +930,8 @@ static void pbvh_bmesh_collapse_edge(PBVH *bvh, BMEdge *e, BMVert *v1,
* remove them from the PBVH */
for (j = 0; j < 3; j++) {
if (v_tri[j] != v_del && BM_vert_face_count(v_tri[j]) == 1) {
- BLI_ghash_insert(deleted_verts, v_tri[j], NULL);
- pbvh_bmesh_vert_remove(bvh, v_tri[j]);
+ BLI_gset_insert(deleted_verts, v_tri[j]);
+ pbvh_bmesh_vert_remove(bvh, v_tri[j], eq_ctx->cd_vert_node_offset, eq_ctx->cd_face_node_offset);
}
else {
v_tri[j] = NULL;
@@ -929,20 +939,20 @@ static void pbvh_bmesh_collapse_edge(PBVH *bvh, BMEdge *e, BMVert *v1,
}
/* Remove the face */
- pbvh_bmesh_face_remove(bvh, f_del);
+ pbvh_bmesh_face_remove(bvh, f_del, eq_ctx->cd_vert_node_offset, eq_ctx->cd_face_node_offset);
BM_face_kill(bvh->bm, f_del);
/* Check if any of the face's edges are now unused by any
* face, if so delete them */
for (j = 0; j < 3; j++) {
- if (BM_edge_face_count(e_tri[j]) == 0)
+ if (BM_edge_is_wire(e_tri[j]))
BM_edge_kill(bvh->bm, e_tri[j]);
}
/* Delete unused vertices */
for (j = 0; j < 3; j++) {
if (v_tri[j]) {
- BM_log_vert_removed(bvh->bm, bvh->bm_log, v_tri[j]);
+ BM_log_vert_removed(bvh->bm_log, v_tri[j], eq_ctx->cd_vert_mask_offset);
BM_vert_kill(bvh->bm, v_tri[j]);
}
}
@@ -950,15 +960,15 @@ static void pbvh_bmesh_collapse_edge(PBVH *bvh, BMEdge *e, BMVert *v1,
/* Move v_conn to the midpoint of v_conn and v_del (if v_conn still exists, it
* may have been deleted above) */
- if (!BLI_ghash_haskey(deleted_verts, v_conn)) {
- BM_log_vert_before_modified(bvh->bm, bvh->bm_log, v_conn);
+ if (!BLI_gset_haskey(deleted_verts, v_conn)) {
+ BM_log_vert_before_modified(bvh->bm_log, v_conn, eq_ctx->cd_vert_mask_offset);
mid_v3_v3v3(v_conn->co, v_conn->co, v_del->co);
}
/* Delete v_del */
BLI_assert(BM_vert_face_count(v_del) == 0);
- BLI_ghash_insert(deleted_verts, v_del, NULL);
- BM_log_vert_removed(bvh->bm, bvh->bm_log, v_del);
+ BLI_gset_insert(deleted_verts, v_del);
+ BM_log_vert_removed(bvh->bm_log, v_del, eq_ctx->cd_vert_mask_offset);
BM_vert_kill(bvh->bm, v_del);
}
@@ -968,10 +978,10 @@ static bool pbvh_bmesh_collapse_short_edges(EdgeQueueContext *eq_ctx,
BLI_Buffer *deleted_faces)
{
float min_len_squared = bvh->bm_min_edge_len * bvh->bm_min_edge_len;
- GHash *deleted_verts;
+ GSet *deleted_verts;
bool any_collapsed = false;
- deleted_verts = BLI_ghash_ptr_new("deleted_verts");
+ deleted_verts = BLI_gset_ptr_new("deleted_verts");
while (!BLI_heap_is_empty(eq_ctx->q->heap)) {
BMVert **pair = BLI_heap_popmin(eq_ctx->q->heap);
@@ -982,8 +992,8 @@ static bool pbvh_bmesh_collapse_short_edges(EdgeQueueContext *eq_ctx,
pair = NULL;
/* Check the verts still exist */
- if (BLI_ghash_haskey(deleted_verts, v1) ||
- BLI_ghash_haskey(deleted_verts, v2))
+ if (BLI_gset_haskey(deleted_verts, v1) ||
+ BLI_gset_haskey(deleted_verts, v2))
{
continue;
}
@@ -1000,8 +1010,8 @@ static bool pbvh_bmesh_collapse_short_edges(EdgeQueueContext *eq_ctx,
* possible that an edge collapse has deleted adjacent faces
* and the node has been split, thus leaving wire edges and
* associated vertices. */
- if (!BLI_ghash_haskey(bvh->bm_vert_to_node, e->v1) ||
- !BLI_ghash_haskey(bvh->bm_vert_to_node, e->v2))
+ if ((BM_ELEM_CD_GET_INT(e->v1, eq_ctx->cd_vert_node_offset) == DYNTOPO_NODE_NONE) ||
+ (BM_ELEM_CD_GET_INT(e->v2, eq_ctx->cd_vert_node_offset) == DYNTOPO_NODE_NONE))
{
continue;
}
@@ -1010,22 +1020,21 @@ static bool pbvh_bmesh_collapse_short_edges(EdgeQueueContext *eq_ctx,
pbvh_bmesh_collapse_edge(bvh, e, v1, v2,
deleted_verts, edge_loops,
- deleted_faces, eq_ctx->cd_vert_mask_offset);
+ deleted_faces, eq_ctx);
}
- BLI_ghash_free(deleted_verts, NULL, NULL);
+ BLI_gset_free(deleted_verts, NULL);
return any_collapsed;
}
/************************* Called from pbvh.c *************************/
-int pbvh_bmesh_node_raycast(PBVHNode *node, const float ray_start[3],
+bool pbvh_bmesh_node_raycast(PBVHNode *node, const float ray_start[3],
const float ray_normal[3], float *dist,
- int use_original)
+ bool use_original)
{
- GHashIterator gh_iter;
- int hit = 0;
+ bool hit = false;
if (use_original && node->bm_tot_ortri) {
int i;
@@ -1039,11 +1048,13 @@ int pbvh_bmesh_node_raycast(PBVHNode *node, const float ray_start[3],
}
}
else {
- GHASH_ITER (gh_iter, node->bm_faces) {
- BMFace *f = BLI_ghashIterator_getKey(&gh_iter);
+ GSetIterator gs_iter;
+
+ GSET_ITER (gs_iter, node->bm_faces) {
+ BMFace *f = BLI_gsetIterator_getKey(&gs_iter);
BLI_assert(f->len == 3);
- if (f->len == 3 && !paint_is_bmesh_face_hidden(f)) {
+ if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
BMVert *v_tri[3];
BM_face_as_array_vert_tri(f, v_tri);
@@ -1064,18 +1075,18 @@ bool BKE_pbvh_bmesh_node_raycast_detail(
const float ray_start[3], const float ray_normal[3],
float *detail, float *dist)
{
- GHashIterator gh_iter;
+ GSetIterator gs_iter;
bool hit = false;
BMFace *f_hit = NULL;
if (node->flag & PBVH_FullyHidden)
return 0;
- GHASH_ITER (gh_iter, node->bm_faces) {
- BMFace *f = BLI_ghashIterator_getKey(&gh_iter);
+ GSET_ITER (gs_iter, node->bm_faces) {
+ BMFace *f = BLI_gsetIterator_getKey(&gs_iter);
BLI_assert(f->len == 3);
- if (f->len == 3 && !paint_is_bmesh_face_hidden(f)) {
+ if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
BMVert *v_tri[3];
bool hit_local;
BM_face_as_array_vert_tri(f, v_tri);
@@ -1117,11 +1128,10 @@ void pbvh_bmesh_normals_update(PBVHNode **nodes, int totnode)
PBVHNode *node = nodes[n];
if (node->flag & PBVH_UpdateNormals) {
- GHashIterator gh_iter;
GSetIterator gs_iter;
- GHASH_ITER (gh_iter, node->bm_faces) {
- BM_face_normal_update(BLI_ghashIterator_getKey(&gh_iter));
+ GSET_ITER (gs_iter, node->bm_faces) {
+ BM_face_normal_update(BLI_gsetIterator_getKey(&gs_iter));
}
GSET_ITER (gs_iter, node->bm_unique_verts) {
BM_vert_normal_update(BLI_gsetIterator_getKey(&gs_iter));
@@ -1137,22 +1147,42 @@ void pbvh_bmesh_normals_update(PBVHNode **nodes, int totnode)
/***************************** Public API *****************************/
+static void pbvh_bmesh_node_layers_reset(PBVH *bvh)
+{
+ BMFace *f;
+ BMVert *v;
+ BMIter iter;
+ BMesh *bm = bvh->bm;
+ int cd_vert_node_offset = bvh->cd_vert_node_offset;
+ int cd_face_node_offset = bvh->cd_face_node_offset;
+
+ /* clear the elements of the node information */
+ BM_ITER_MESH(v, &iter, bm, BM_VERTS_OF_MESH) {
+ BM_ELEM_CD_SET_INT(v, cd_vert_node_offset, DYNTOPO_NODE_NONE);
+ }
+
+ BM_ITER_MESH(f, &iter, bm, BM_FACES_OF_MESH) {
+ BM_ELEM_CD_SET_INT(f, cd_face_node_offset, DYNTOPO_NODE_NONE);
+ }
+}
+
+
/* Build a PBVH from a BMesh */
-void BKE_pbvh_build_bmesh(PBVH *bvh, BMesh *bm, int smooth_shading,
- BMLog *log)
+void BKE_pbvh_build_bmesh(PBVH *bvh, BMesh *bm, bool smooth_shading, BMLog *log,
+ const int cd_vert_node_offset, const int cd_face_node_offset)
{
BMIter iter;
BMFace *f;
PBVHNode *n;
int node_index = 0;
+ bvh->cd_vert_node_offset = cd_vert_node_offset;
+ bvh->cd_face_node_offset = cd_face_node_offset;
bvh->bm = bm;
BKE_pbvh_bmesh_detail_size_set(bvh, 0.75);
bvh->type = PBVH_BMESH;
- bvh->bm_face_to_node = BLI_ghash_ptr_new("bm_face_to_node");
- bvh->bm_vert_to_node = BLI_ghash_ptr_new("bm_vert_to_node");
bvh->bm_log = log;
/* TODO: choose leaf limit better */
@@ -1161,19 +1191,21 @@ void BKE_pbvh_build_bmesh(PBVH *bvh, BMesh *bm, int smooth_shading,
if (smooth_shading)
bvh->flags |= PBVH_DYNTOPO_SMOOTH_SHADING;
+ pbvh_bmesh_node_layers_reset(bvh);
+
/* Start with all faces in the root node */
n = bvh->nodes = MEM_callocN(sizeof(PBVHNode), "PBVHNode");
bvh->totnode = 1;
n->flag = PBVH_Leaf;
- n->bm_faces = BLI_ghash_ptr_new_ex("bm_faces", bvh->bm->totface);
+ n->bm_faces = BLI_gset_ptr_new_ex("bm_faces", bvh->bm->totface);
BM_ITER_MESH (f, &iter, bvh->bm, BM_FACES_OF_MESH) {
- BLI_ghash_insert(n->bm_faces, f, NULL);
+ BLI_gset_insert(n->bm_faces, f);
}
/* Recursively split the node until it is under the limit; if no
* splitting occurs then finalize the existing leaf node */
if (!pbvh_bmesh_node_limit_ensure(bvh, node_index))
- pbvh_bmesh_node_finalize(bvh, 0);
+ pbvh_bmesh_node_finalize(bvh, 0, cd_vert_node_offset, cd_face_node_offset);
}
/* Collapse short edges, subdivide long edges */
@@ -1184,14 +1216,16 @@ bool BKE_pbvh_bmesh_update_topology(PBVH *bvh, PBVHTopologyUpdateMode mode,
BLI_buffer_declare_static(BMFace *, edge_loops, BLI_BUFFER_NOP, 2);
BLI_buffer_declare_static(BMFace *, deleted_faces, BLI_BUFFER_NOP, 32);
const int cd_vert_mask_offset = CustomData_get_offset(&bvh->bm->vdata, CD_PAINT_MASK);
+ const int cd_vert_node_offset = bvh->cd_vert_node_offset;
+ const int cd_face_node_offset = bvh->cd_face_node_offset;
bool modified = false;
int n;
if (mode & PBVH_Collapse) {
EdgeQueue q;
- BLI_mempool *queue_pool = BLI_mempool_create(sizeof(BMVert *[2]), 128, 128, BLI_MEMPOOL_NOP);
- EdgeQueueContext eq_ctx = {&q, queue_pool, bvh->bm, cd_vert_mask_offset};
+ BLI_mempool *queue_pool = BLI_mempool_create(sizeof(BMVert *[2]), 0, 128, BLI_MEMPOOL_NOP);
+ EdgeQueueContext eq_ctx = {&q, queue_pool, bvh->bm, cd_vert_mask_offset, cd_vert_node_offset, cd_face_node_offset};
short_edge_queue_create(&eq_ctx, bvh, center, radius);
modified |= !BLI_heap_is_empty(q.heap);
@@ -1203,8 +1237,8 @@ bool BKE_pbvh_bmesh_update_topology(PBVH *bvh, PBVHTopologyUpdateMode mode,
if (mode & PBVH_Subdivide) {
EdgeQueue q;
- BLI_mempool *queue_pool = BLI_mempool_create(sizeof(BMVert *[2]), 128, 128, BLI_MEMPOOL_NOP);
- EdgeQueueContext eq_ctx = {&q, queue_pool, bvh->bm, cd_vert_mask_offset};
+ BLI_mempool *queue_pool = BLI_mempool_create(sizeof(BMVert *[2]), 0, 128, BLI_MEMPOOL_NOP);
+ EdgeQueueContext eq_ctx = {&q, queue_pool, bvh->bm, cd_vert_mask_offset, cd_vert_node_offset, cd_face_node_offset};
long_edge_queue_create(&eq_ctx, bvh, center, radius);
modified |= !BLI_heap_is_empty(q.heap);
@@ -1246,7 +1280,6 @@ BLI_INLINE void bm_face_as_array_index_tri(BMFace *f, int r_index[3])
* Skips triangles that are hidden. */
void BKE_pbvh_bmesh_node_save_orig(PBVHNode *node)
{
- GHashIterator gh_iter;
GSetIterator gs_iter;
int i, totvert, tottri;
@@ -1257,7 +1290,7 @@ void BKE_pbvh_bmesh_node_save_orig(PBVHNode *node)
totvert = (BLI_gset_size(node->bm_unique_verts) +
BLI_gset_size(node->bm_other_verts));
- tottri = BLI_ghash_size(node->bm_faces);
+ tottri = BLI_gset_size(node->bm_faces);
node->bm_orco = MEM_mallocN(sizeof(*node->bm_orco) * totvert, __func__);
node->bm_ortri = MEM_mallocN(sizeof(*node->bm_ortri) * tottri, __func__);
@@ -1279,10 +1312,10 @@ void BKE_pbvh_bmesh_node_save_orig(PBVHNode *node)
/* Copy the triangles */
i = 0;
- GHASH_ITER (gh_iter, node->bm_faces) {
- BMFace *f = BLI_ghashIterator_getKey(&gh_iter);
+ GSET_ITER (gs_iter, node->bm_faces) {
+ BMFace *f = BLI_gsetIterator_getKey(&gs_iter);
- if (paint_is_bmesh_face_hidden(f))
+ if (BM_elem_flag_test(f, BM_ELEM_HIDDEN))
continue;
#if 0
@@ -1304,6 +1337,7 @@ void BKE_pbvh_bmesh_node_save_orig(PBVHNode *node)
void BKE_pbvh_bmesh_after_stroke(PBVH *bvh)
{
int i;
+
for (i = 0; i < bvh->totnode; i++) {
PBVHNode *n = &bvh->nodes[i];
if (n->flag & PBVH_Leaf) {
@@ -1338,29 +1372,14 @@ GSet *BKE_pbvh_bmesh_node_other_verts(PBVHNode *node)
return node->bm_other_verts;
}
-/****************************** Debugging *****************************/
-
-#if 0
-void bli_ghash_duplicate_key_check(GHash *gh)
+struct GSet *BKE_pbvh_bmesh_node_faces(PBVHNode *node)
{
- GHashIterator gh_iter1, gh_iter2;
-
- GHASH_ITER (gh_iter1, gh) {
- void *key1 = BLI_ghashIterator_getKey(&gh_iter1);
- int dup = -1;
+ return node->bm_faces;
+}
- GHASH_ITER (gh_iter2, gh) {
- void *key2 = BLI_ghashIterator_getKey(&gh_iter2);
+/****************************** Debugging *****************************/
- if (key1 == key2) {
- dup++;
- if (dup > 0) {
- BLI_assert(!"duplicate in hash");
- }
- }
- }
- }
-}
+#if 0
void bli_gset_duplicate_key_check(GSet *gs)
{
@@ -1515,7 +1534,7 @@ void pbvh_bmesh_verify(PBVH *bvh)
BLI_assert(n->flag & PBVH_Leaf);
/* Check that the face's node knows it owns the face */
- BLI_assert(BLI_ghash_haskey(n->bm_faces, f));
+ BLI_assert(BLI_gset_haskey(n->bm_faces, f));
/* Check the face's vertices... */
BM_ITER_ELEM (v, &bm_iter, f, BM_VERTS_OF_FACE) {
@@ -1603,7 +1622,7 @@ void pbvh_bmesh_verify(PBVH *bvh)
/* Check for duplicate entries */
/* Slow */
#if 0
- bli_ghash_duplicate_key_check(n->bm_faces);
+ bli_gset_duplicate_key_check(n->bm_faces);
bli_gset_duplicate_key_check(n->bm_unique_verts);
bli_gset_duplicate_key_check(n->bm_other_verts);
#endif
diff --git a/source/blender/blenkernel/intern/pbvh_intern.h b/source/blender/blenkernel/intern/pbvh_intern.h
index 1230d3a90b6..6b3ef8eb5da 100644
--- a/source/blender/blenkernel/intern/pbvh_intern.h
+++ b/source/blender/blenkernel/intern/pbvh_intern.h
@@ -104,7 +104,7 @@ struct PBVHNode {
PBVHProxyNode *proxies;
/* Dyntopo */
- GHash *bm_faces;
+ GSet *bm_faces;
GSet *bm_unique_verts;
GSet *bm_other_verts;
float (*bm_orco)[3];
@@ -160,10 +160,10 @@ struct PBVH {
/* Dynamic topology */
BMesh *bm;
- GHash *bm_face_to_node;
- GHash *bm_vert_to_node;
float bm_max_edge_len;
float bm_min_edge_len;
+ int cd_vert_node_offset;
+ int cd_face_node_offset;
struct BMLog *bm_log;
};
@@ -181,14 +181,10 @@ bool ray_face_intersection(const float ray_start[3], const float ray_normal[3],
void pbvh_update_BB_redraw(PBVH *bvh, PBVHNode **nodes, int totnode, int flag);
/* pbvh_bmesh.c */
-int pbvh_bmesh_node_raycast(
+bool pbvh_bmesh_node_raycast(
PBVHNode *node, const float ray_start[3],
const float ray_normal[3], float *dist,
- int use_original);
-
-int pbvh_bmesh_node_raycast_detail(
- PBVHNode *node, const float ray_start[3],
- const float ray_normal[3], float *detail, float *dist);
+ bool use_original);
void pbvh_bmesh_normals_update(PBVHNode **nodes, int totnode);
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 7458b4a4fa0..c8042171a94 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -37,7 +37,6 @@
#include "MEM_guardedalloc.h"
#include "DNA_ID.h"
-#include "DNA_cloth_types.h"
#include "DNA_dynamicpaint_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
@@ -63,10 +62,8 @@
#include "BKE_anim.h"
#include "BKE_blender.h"
#include "BKE_cloth.h"
-#include "BKE_depsgraph.h"
#include "BKE_dynamicpaint.h"
#include "BKE_global.h"
-#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
@@ -1059,7 +1056,7 @@ static void ptcache_rigidbody_interpolate(int index, void *rb_v, void **data, fl
if (rbo->type == RBO_TYPE_ACTIVE) {
copy_v3_v3(keys[1].co, rbo->pos);
- copy_v3_v3(keys[1].rot, rbo->orn);
+ copy_qt_qt(keys[1].rot, rbo->orn);
if (old_data) {
memcpy(keys[2].co, data, 3 * sizeof(float));
@@ -1075,7 +1072,7 @@ static void ptcache_rigidbody_interpolate(int index, void *rb_v, void **data, fl
interp_qt_qtqt(keys->rot, keys[1].rot, keys[2].rot, (cfra - cfra1) / dfra);
copy_v3_v3(rbo->pos, keys->co);
- copy_v3_v3(rbo->orn, keys->rot);
+ copy_qt_qt(rbo->orn, keys->rot);
}
}
}
@@ -1493,7 +1490,7 @@ static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_p
idname = (pid->ob->id.name + 2);
/* convert chars to hex so they are always a valid filename */
while ('\0' != *idname) {
- BLI_snprintf(newname, MAX_PTCACHE_FILE, "%02X", (char)(*idname++));
+ BLI_snprintf(newname, MAX_PTCACHE_FILE, "%02X", (unsigned int)(*idname++));
newname+=2;
len += 2;
}
@@ -3000,7 +2997,7 @@ PointCache *BKE_ptcache_add(ListBase *ptcaches)
cache= MEM_callocN(sizeof(PointCache), "PointCache");
cache->startframe= 1;
cache->endframe= 250;
- cache->step= 10;
+ cache->step = 1;
cache->index = -1;
BLI_addtail(ptcaches, cache);
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 3f92f5881e4..8e5b67404ac 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -46,26 +46,20 @@
# include "RBI_api.h"
#endif
-#include "DNA_anim_types.h"
#include "DNA_group_types.h"
-#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_object_force.h"
#include "DNA_rigidbody_types.h"
#include "DNA_scene_types.h"
-#include "BKE_animsys.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_effect.h"
#include "BKE_global.h"
-#include "BKE_group.h"
#include "BKE_library.h"
-#include "BKE_mesh.h"
#include "BKE_object.h"
#include "BKE_pointcache.h"
#include "BKE_rigidbody.h"
-#include "BKE_utildefines.h"
#include "RNA_access.h"
@@ -941,10 +935,7 @@ void BKE_rigidbody_remove_object(Scene *scene, Object *ob)
Object *obt = go->ob;
if (obt && obt->rigidbody_constraint) {
rbc = obt->rigidbody_constraint;
- if (rbc->ob1 == ob) {
- BKE_rigidbody_remove_constraint(scene, obt);
- }
- if (rbc->ob2 == ob) {
+ if (ELEM(ob, rbc->ob1, rbc->ob2)) {
BKE_rigidbody_remove_constraint(scene, obt);
}
}
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 269a367b530..0e95cf1d418 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -34,12 +34,6 @@
#include <stdio.h>
#include <string.h>
-#ifndef WIN32
-# include <unistd.h>
-#else
-# include <io.h>
-#endif
-
#include "MEM_guardedalloc.h"
#include "DNA_anim_types.h"
@@ -80,7 +74,6 @@
#include "BKE_node.h"
#include "BKE_object.h"
#include "BKE_paint.h"
-#include "BKE_pointcache.h"
#include "BKE_rigidbody.h"
#include "BKE_scene.h"
#include "BKE_sequencer.h"
@@ -476,6 +469,23 @@ Scene *BKE_scene_add(Main *bmain, const char *name)
sce->r.bake_normal_space = R_BAKE_SPACE_TANGENT;
sce->r.bake_samples = 256;
sce->r.bake_biasdist = 0.001;
+
+ sce->r.bake.flag = R_BAKE_CLEAR;
+ sce->r.bake.width = 512;
+ sce->r.bake.height = 512;
+ sce->r.bake.margin = 16;
+ sce->r.bake.normal_space = R_BAKE_SPACE_TANGENT;
+ sce->r.bake.normal_swizzle[0] = R_BAKE_POSX;
+ sce->r.bake.normal_swizzle[1] = R_BAKE_POSY;
+ sce->r.bake.normal_swizzle[2] = R_BAKE_POSZ;
+ BLI_strncpy(sce->r.bake.filepath, U.renderdir, sizeof(sce->r.bake.filepath));
+
+ sce->r.bake.im_format.planes = R_IMF_PLANES_RGBA;
+ sce->r.bake.im_format.imtype = R_IMF_IMTYPE_PNG;
+ sce->r.bake.im_format.depth = R_IMF_CHAN_DEPTH_8;
+ sce->r.bake.im_format.quality = 90;
+ sce->r.bake.im_format.compress = 15;
+
sce->r.scemode = R_DOCOMP | R_DOSEQ | R_EXTENSION;
sce->r.stamp = R_STAMP_TIME | R_STAMP_FRAME | R_STAMP_DATE | R_STAMP_CAMERA | R_STAMP_SCENE | R_STAMP_FILENAME | R_STAMP_RENDERTIME;
sce->r.stamp_font_id = 12;
@@ -638,9 +648,6 @@ Scene *BKE_scene_add(Main *bmain, const char *name)
sce->gm.exitkey = 218; // Blender key code for ESC
- sce->omp_threads_mode = SCE_OMP_AUTO;
- sce->omp_threads = 1;
-
sound_create_scene(sce);
/* color management */
@@ -743,6 +750,13 @@ static void scene_unlink_space_node(SpaceNode *snode, Scene *sce)
}
}
+static void scene_unlink_space_buts(SpaceButs *sbuts, Scene *sce)
+{
+ if (sbuts->pinid == &sce->id) {
+ sbuts->pinid = NULL;
+ }
+}
+
void BKE_scene_unlink(Main *bmain, Scene *sce, Scene *newsce)
{
Scene *sce1;
@@ -775,8 +789,14 @@ void BKE_scene_unlink(Main *bmain, Scene *sce, Scene *newsce)
for (area = screen->areabase.first; area; area = area->next) {
SpaceLink *space_link;
for (space_link = area->spacedata.first; space_link; space_link = space_link->next) {
- if (space_link->spacetype == SPACE_NODE)
- scene_unlink_space_node((SpaceNode *)space_link, sce);
+ switch (space_link->spacetype) {
+ case SPACE_NODE:
+ scene_unlink_space_node((SpaceNode *)space_link, sce);
+ break;
+ case SPACE_BUTS:
+ scene_unlink_space_buts((SpaceButs *)space_link, sce);
+ break;
+ }
}
}
}
@@ -1561,10 +1581,10 @@ void BKE_scene_update_tagged(EvaluationContext *eval_ctx, Main *bmain, Scene *sc
BKE_animsys_evaluate_animdata(scene, &scene->id, adt, ctime, 0);
}
- /* Extra call here to recalc aterial animation.
+ /* Extra call here to recalc material animation.
*
* Need to do this so changing material settings from the graph/dopesheet
- * will update suff in the viewport.
+ * will update stuff in the viewport.
*/
if (DAG_id_type_tagged(bmain, ID_MA)) {
Material *material;
@@ -1870,11 +1890,3 @@ int BKE_scene_num_threads(const Scene *scene)
{
return BKE_render_num_threads(&scene->r);
}
-
-int BKE_scene_num_omp_threads(const struct Scene *scene)
-{
- if (scene->omp_threads_mode == SCE_OMP_AUTO)
- return BLI_omp_thread_count();
- else
- return scene->omp_threads;
-}
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index ef5507a649f..9d40ee6e667 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -193,7 +193,10 @@ ARegion *BKE_area_region_copy(SpaceType *st, ARegion *ar)
BLI_listbase_clear(&newar->panels);
BLI_duplicatelist(&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;
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index b5d4c00dca6..7ed9af8b87f 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -35,20 +35,16 @@
#include <stdlib.h>
#include "MEM_guardedalloc.h"
-#include "BLI_dynlib.h"
#include "BLI_math.h" /* windows needs for M_PI */
#include "BLI_utildefines.h"
-#include "BLI_string.h"
#include "DNA_scene_types.h"
#include "DNA_sequence_types.h"
#include "DNA_anim_types.h"
#include "BKE_fcurve.h"
-#include "BKE_main.h"
#include "BKE_sequencer.h"
-#include "BKE_texture.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
diff --git a/source/blender/blenkernel/intern/seqmodifier.c b/source/blender/blenkernel/intern/seqmodifier.c
index 2b5bc884315..b78529f51b4 100644
--- a/source/blender/blenkernel/intern/seqmodifier.c
+++ b/source/blender/blenkernel/intern/seqmodifier.c
@@ -214,7 +214,7 @@ static void curves_apply_threaded(int width, int height, unsigned char *rect, fl
curvemapping_evaluate_premulRGBF(curve_mapping, result, pixel);
if (mask_rect_float) {
- float *m = mask_rect_float + pixel_index;
+ const float *m = mask_rect_float + pixel_index;
pixel[0] = pixel[0] * (1.0f - m[0]) + result[0] * m[0];
pixel[1] = pixel[1] * (1.0f - m[1]) + result[1] * m[1];
@@ -454,7 +454,7 @@ static void brightcontrast_apply_threaded(int width, int height, unsigned char *
v = a * i + b;
if (mask_rect_float) {
- float *m = mask_rect_float + pixel_index;
+ const float *m = mask_rect_float + pixel_index;
pixel[c] = pixel[c] * (1.0f - m[c]) + v * m[c];
}
@@ -518,7 +518,7 @@ static void maskmodifier_apply_threaded(int width, int height, unsigned char *re
else if (rect_float) {
int c;
float *pixel = rect_float + pixel_index;
- float *mask_pixel = mask_rect_float + pixel_index;
+ const float *mask_pixel = mask_rect_float + pixel_index;
float mask = min_fff(mask_pixel[0], mask_pixel[1], mask_pixel[2]);
/* float buffers are premultiplied, so need to premul color
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index e834c017ea0..cf15b235b45 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -35,7 +35,6 @@
#include <math.h>
#include "MEM_guardedalloc.h"
-#include "MEM_CacheLimiterC-Api.h"
#include "DNA_sequence_types.h"
#include "DNA_movieclip_types.h"
@@ -948,8 +947,9 @@ static void seqbase_unique_name(ListBase *seqbasep, SeqUniqueInfo *sui)
Sequence *seq;
for (seq = seqbasep->first; seq; seq = seq->next) {
if ((sui->seq != seq) && STREQ(sui->name_dest, seq->name + 2)) {
- /* SEQ_NAME_MAXSTR - 2 for prefix, -1 for \0, -4 for the number */
- BLI_snprintf(sui->name_dest, sizeof(sui->name_dest), "%.59s.%03d", sui->name_src, sui->count++);
+ /* SEQ_NAME_MAXSTR -4 for the number, -1 for \0, - 2 for prefix */
+ BLI_snprintf(sui->name_dest, sizeof(sui->name_dest), "%.*s.%03d", SEQ_NAME_MAXSTR - 4 - 1 - 2,
+ sui->name_src, sui->count++);
sui->match = 1; /* be sure to re-scan */
}
}
@@ -1156,7 +1156,7 @@ StripElem *BKE_sequencer_give_stripelem(Sequence *seq, int cfra)
return se;
}
-static int evaluate_seq_frame_gen(Sequence **seq_arr, ListBase *seqbase, int cfra)
+static int evaluate_seq_frame_gen(Sequence **seq_arr, ListBase *seqbase, int cfra, int chanshown)
{
Sequence *seq;
Sequence *effect_inputs[MAXSEQ + 1];
@@ -1188,11 +1188,24 @@ static int evaluate_seq_frame_gen(Sequence **seq_arr, ListBase *seqbase, int cfr
}
/* Drop strips which are used for effect inputs, we don't want
- *them to blend into render stack in any other way than effect
+ * them to blend into render stack in any other way than effect
* string rendering.
*/
for (i = 0; i < num_effect_inputs; i++) {
seq = effect_inputs[i];
+ /* It's possible that effetc strip would be placed to the same
+ * 'machine' as it's inputs. We don't want to clear such strips
+ * from the stack.
+ */
+ if (seq_arr[seq->machine] && seq_arr[seq->machine]->type & SEQ_TYPE_EFFECT) {
+ continue;
+ }
+ /* If we're shown a specified channel, then we want to see the stirps
+ * which belongs to this machine.
+ */
+ if (chanshown != 0 && chanshown <= seq->machine) {
+ continue;
+ }
seq_arr[seq->machine] = NULL;
}
@@ -1207,7 +1220,7 @@ int BKE_sequencer_evaluate_frame(Scene *scene, int cfra)
if (ed == NULL)
return 0;
- return evaluate_seq_frame_gen(seq_arr, ed->seqbasep, cfra);
+ return evaluate_seq_frame_gen(seq_arr, ed->seqbasep, cfra, 0);
}
static bool video_seq_is_rendered(Sequence *seq)
@@ -1225,7 +1238,7 @@ static int get_shown_sequences(ListBase *seqbasep, int cfra, int chanshown, Sequ
return 0;
}
- if (evaluate_seq_frame_gen(seq_arr, seqbasep, cfra)) {
+ if (evaluate_seq_frame_gen(seq_arr, seqbasep, cfra, chanshown)) {
if (b == 0) {
b = MAXSEQ;
}
@@ -1753,8 +1766,8 @@ static void color_balance_byte_float(StripColorBalance *cb_, unsigned char *rect
static void color_balance_float_float(StripColorBalance *cb_, float *rect_float, float *mask_rect_float, int width, int height, float mul)
{
float *p = rect_float;
- float *e = rect_float + width * 4 * height;
- float *m = mask_rect_float;
+ const float *e = rect_float + width * 4 * height;
+ const float *m = mask_rect_float;
StripColorBalance cb = calc_cb(cb_);
while (p < e) {
@@ -2401,7 +2414,7 @@ static ImBuf *seq_render_mask(const SeqRenderData *context, Mask *mask, float nr
if (make_float) {
/* pixels */
- float *fp_src;
+ const float *fp_src;
float *fp_dst;
ibuf = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rectfloat);
@@ -2419,7 +2432,7 @@ static ImBuf *seq_render_mask(const SeqRenderData *context, Mask *mask, float nr
}
else {
/* pixels */
- float *fp_src;
+ const float *fp_src;
unsigned char *ub_dst;
ibuf = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect);
@@ -2539,6 +2552,9 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context, Sequence *seq
if ((sequencer_view3d_cb && do_seq_gl && camera) && is_thread_main) {
char err_out[256] = "unknown";
+ int width = (scene->r.xsch * scene->r.size) / 100;
+ int height = (scene->r.ysch * scene->r.size) / 100;
+
/* for old scened this can be uninitialized,
* should probably be added to do_versions at some point if the functionality stays */
if (context->scene->r.seq_prev_type == 0)
@@ -2546,7 +2562,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context, Sequence *seq
/* opengl offscreen render */
BKE_scene_update_for_newframe(context->eval_ctx, context->bmain, scene, scene->lay);
- ibuf = sequencer_view3d_cb(scene, camera, context->rectx, context->recty, IB_rect,
+ ibuf = sequencer_view3d_cb(scene, camera, width, height, IB_rect,
context->scene->r.seq_prev_type,
(context->scene->r.seq_flag & R_SEQ_SOLID_TEX) != 0,
true, scene->r.alphamode, err_out);
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index 275bd693518..e2cc7b84f95 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -41,7 +41,6 @@
#include "DNA_modifier_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_mesh_types.h"
-#include "DNA_scene_types.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index f993d74959d..74edd1902d8 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -42,11 +42,8 @@
#include <stdio.h>
#include <string.h> /* memset */
-#include "BLI_linklist.h"
-#include "BLI_rand.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
-#include "BLI_edgehash.h"
#include "BLI_kdtree.h"
#include "BLI_kdopbvh.h"
#include "BLI_threads.h"
@@ -57,9 +54,7 @@
#include "DNA_armature_types.h"
#include "DNA_constraint_types.h"
#include "DNA_customdata_types.h"
-#include "DNA_group_types.h"
#include "DNA_lamp_types.h"
-#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
@@ -933,7 +928,7 @@ static void update_obstacles(Scene *scene, Object *ob, SmokeDomainSettings *sds,
**********************************************************/
/* set "ignore cache" flag for all caches on this object */
-static void object_cacheIgnoreClear(Object *ob, int state)
+static void object_cacheIgnoreClear(Object *ob, bool state)
{
ListBase pidlist;
PTCacheID *pid;
@@ -951,7 +946,7 @@ static void object_cacheIgnoreClear(Object *ob, int state)
BLI_freelistN(&pidlist);
}
-static int subframe_updateObject(Scene *scene, Object *ob, int update_mesh, int parent_recursion, float frame, bool for_render)
+static bool subframe_updateObject(Scene *scene, Object *ob, int update_mesh, int parent_recursion, float frame, bool for_render)
{
SmokeModifierData *smd = (SmokeModifierData *)modifiers_findByType(ob, eModifierType_Smoke);
bConstraint *con;
@@ -963,9 +958,9 @@ static int subframe_updateObject(Scene *scene, Object *ob, int update_mesh, int
/* if object has parents, update them too */
if (parent_recursion) {
int recursion = parent_recursion - 1;
- int is_domain = 0;
- if (ob->parent) is_domain += subframe_updateObject(scene, ob->parent, 0, recursion, frame, for_render);
- if (ob->track) is_domain += subframe_updateObject(scene, ob->track, 0, recursion, frame, for_render);
+ bool is_domain = false;
+ if (ob->parent) is_domain |= subframe_updateObject(scene, ob->parent, 0, recursion, frame, for_render);
+ if (ob->track) is_domain |= subframe_updateObject(scene, ob->track, 0, recursion, frame, for_render);
/* skip subframe if object is parented
* to vertex of a dynamic paint canvas */
@@ -974,7 +969,7 @@ static int subframe_updateObject(Scene *scene, Object *ob, int update_mesh, int
/* also update constraint targets */
for (con = ob->constraints.first; con; con = con->next) {
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
if (cti && cti->get_constraint_targets) {
@@ -1073,7 +1068,7 @@ static void clampBoundsInDomain(SmokeDomainSettings *sds, int min[3], int max[3]
}
}
-static void em_allocateData(EmissionMap *em, int use_velocity, int hires_mul)
+static void em_allocateData(EmissionMap *em, bool use_velocity, int hires_mul)
{
int i, res[3];
@@ -1427,8 +1422,11 @@ static void emit_from_particles(Object *flow_ob, SmokeDomainSettings *sds, Smoke
}
}
-static void sample_derivedmesh(SmokeFlowSettings *sfs, MVert *mvert, MTFace *tface, MFace *mface, float *influence_map, float *velocity_map, int index, int base_res[3], float flow_center[3], BVHTreeFromMesh *treeData, float ray_start[3],
- float *vert_vel, int has_velocity, int defgrp_index, MDeformVert *dvert, float x, float y, float z)
+static void sample_derivedmesh(
+ SmokeFlowSettings *sfs, MVert *mvert, MTFace *tface, MFace *mface,
+ float *influence_map, float *velocity_map, int index, int base_res[3], float flow_center[3],
+ BVHTreeFromMesh *treeData, const float ray_start[3], const float *vert_vel,
+ bool has_velocity, int defgrp_index, MDeformVert *dvert, float x, float y, float z)
{
float ray_dir[3] = {1.0f, 0.0f, 0.0f};
BVHTreeRayHit hit = {0};
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index a2fb66eb926..9c411142566 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -75,7 +75,6 @@ variables on the UI for now
#include "BKE_global.h"
#include "BKE_modifier.h"
#include "BKE_softbody.h"
-#include "BKE_DerivedMesh.h"
#include "BKE_pointcache.h"
#include "BKE_deform.h"
#include "BKE_mesh.h"
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index 1fe73a1f692..6ba843c8a8f 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -53,15 +53,13 @@
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_sound.h"
-#include "BKE_context.h"
#include "BKE_library.h"
#include "BKE_packedFile.h"
-#include "BKE_animsys.h"
#include "BKE_sequencer.h"
#include "BKE_scene.h"
#ifdef WITH_AUDASPACE
-// evil global ;-)
+/* evil global ;-) */
static int sound_cfra;
#endif
@@ -70,7 +68,7 @@ bSound *sound_new_file(struct Main *bmain, const char *filename)
bSound *sound = NULL;
char str[FILE_MAX];
- char *path;
+ const char *path;
size_t len;
@@ -86,7 +84,7 @@ bSound *sound_new_file(struct Main *bmain, const char *filename)
sound = BKE_libblock_alloc(bmain, ID_SO, filename + len);
BLI_strncpy(sound->name, filename, FILE_MAX);
-// XXX unused currently sound->type = SOUND_TYPE_FILE;
+ /* sound->type = SOUND_TYPE_FILE; */ /* XXX unused currently */
sound_load(bmain, sound);
@@ -118,7 +116,7 @@ void BKE_sound_free(bSound *sound)
}
sound_free_waveform(sound);
-#endif // WITH_AUDASPACE
+#endif /* WITH_AUDASPACE */
}
#ifdef WITH_AUDASPACE
@@ -223,7 +221,7 @@ void sound_exit_once(void)
AUD_exitOnce();
}
-// XXX unused currently
+/* XXX unused currently */
#if 0
bSound *sound_new_buffer(struct Main *bmain, bSound *source)
{
@@ -330,7 +328,7 @@ void sound_load(struct Main *bmain, bSound *sound)
sound_free_waveform(sound);
-// XXX unused currently
+/* XXX unused currently */
#if 0
switch (sound->type)
{
@@ -353,7 +351,7 @@ void sound_load(struct Main *bmain, bSound *sound)
else
sound->handle = AUD_load(fullpath);
}
-// XXX unused currently
+/* XXX unused currently */
#if 0
break;
}
@@ -437,10 +435,14 @@ void sound_update_scene_listener(struct Scene *scene)
scene->audio.doppler_factor, scene->audio.distance_model);
}
-void *sound_scene_add_scene_sound(struct Scene *scene, struct Sequence *sequence, int startframe, int endframe, int frameskip)
+void *sound_scene_add_scene_sound(struct Scene *scene, struct Sequence *sequence,
+ int startframe, int endframe, int frameskip)
{
- if (scene != sequence->scene)
- return AUD_addSequence(scene->sound_scene, sequence->scene->sound_scene, startframe / FPS, endframe / FPS, frameskip / FPS);
+ if (scene != sequence->scene) {
+ const double fps = FPS;
+ return AUD_addSequence(scene->sound_scene, sequence->scene->sound_scene,
+ startframe / fps, endframe / fps, frameskip / fps);
+ }
return NULL;
}
@@ -453,7 +455,9 @@ void *sound_scene_add_scene_sound_defaults(struct Scene *scene, struct Sequence
void *sound_add_scene_sound(struct Scene *scene, struct Sequence *sequence, int startframe, int endframe, int frameskip)
{
- void *handle = AUD_addSequence(scene->sound_scene, sequence->sound->playback_handle, startframe / FPS, endframe / FPS, frameskip / FPS);
+ const double fps = FPS;
+ void *handle = AUD_addSequence(scene->sound_scene, sequence->sound->playback_handle,
+ startframe / fps, endframe / fps, frameskip / fps);
AUD_muteSequence(handle, (sequence->flag & SEQ_MUTE) != 0);
AUD_setSequenceAnimData(handle, AUD_AP_VOLUME, CFRA, &sequence->volume, 0);
AUD_setSequenceAnimData(handle, AUD_AP_PITCH, CFRA, &sequence->pitch, 0);
@@ -480,7 +484,8 @@ void sound_mute_scene_sound(void *handle, char mute)
void sound_move_scene_sound(struct Scene *scene, void *handle, int startframe, int endframe, int frameskip)
{
- AUD_moveSequence(handle, startframe / FPS, endframe / FPS, frameskip / FPS);
+ const double fps = FPS;
+ AUD_moveSequence(handle, startframe / fps, endframe / fps, frameskip / fps);
}
void sound_move_scene_sound_defaults(struct Scene *scene, struct Sequence *sequence)
@@ -504,7 +509,8 @@ void sound_set_cfra(int cfra)
void sound_set_scene_volume(struct Scene *scene, float volume)
{
- AUD_setSequencerAnimData(scene->sound_scene, AUD_AP_VOLUME, CFRA, &volume, (scene->audio.flag & AUDIO_VOLUME_ANIMATED) != 0);
+ AUD_setSequencerAnimData(scene->sound_scene, AUD_AP_VOLUME, CFRA, &volume,
+ (scene->audio.flag & AUDIO_VOLUME_ANIMATED) != 0);
}
void sound_set_scene_sound_volume(void *handle, float volume, char animated)
@@ -545,20 +551,23 @@ static void sound_start_play_scene(struct Scene *scene)
void sound_play_scene(struct Scene *scene)
{
AUD_Status status;
+ const float cur_time = (float)((double)CFRA / FPS);
+
AUD_lock();
status = scene->sound_scene_handle ? AUD_getStatus(scene->sound_scene_handle) : AUD_STATUS_INVALID;
- if (status == AUD_STATUS_INVALID)
+ if (status == AUD_STATUS_INVALID) {
sound_start_play_scene(scene);
- if (!scene->sound_scene_handle) {
- AUD_unlock();
- return;
+ if (!scene->sound_scene_handle) {
+ AUD_unlock();
+ return;
+ }
}
if (status != AUD_STATUS_PLAYING) {
- AUD_seek(scene->sound_scene_handle, CFRA / FPS);
+ AUD_seek(scene->sound_scene_handle, cur_time);
AUD_resume(scene->sound_scene_handle);
}
@@ -584,6 +593,9 @@ void sound_seek_scene(struct Main *bmain, struct Scene *scene)
bScreen *screen;
int animation_playing;
+ const float one_frame = (float)(1.0 / FPS);
+ const float cur_time = (float)((double)CFRA / FPS);
+
AUD_lock();
status = scene->sound_scene_handle ? AUD_getStatus(scene->sound_scene_handle) : AUD_STATUS_INVALID;
@@ -608,26 +620,31 @@ void sound_seek_scene(struct Main *bmain, struct Scene *scene)
if (scene->audio.flag & AUDIO_SCRUB && !animation_playing) {
if (scene->audio.flag & AUDIO_SYNC) {
- AUD_seek(scene->sound_scene_handle, CFRA / FPS);
- AUD_seekSequencer(scene->sound_scene_handle, CFRA / FPS);
+ AUD_seek(scene->sound_scene_handle, cur_time);
+ AUD_seekSequencer(scene->sound_scene_handle, cur_time);
+ }
+ else {
+ AUD_seek(scene->sound_scene_handle, cur_time);
}
- else
- AUD_seek(scene->sound_scene_handle, CFRA / FPS);
AUD_resume(scene->sound_scene_handle);
- if (scene->sound_scrub_handle && AUD_getStatus(scene->sound_scrub_handle) != AUD_STATUS_INVALID)
+ if (scene->sound_scrub_handle && AUD_getStatus(scene->sound_scrub_handle) != AUD_STATUS_INVALID) {
AUD_seek(scene->sound_scrub_handle, 0);
+ }
else {
- if (scene->sound_scrub_handle)
+ if (scene->sound_scrub_handle) {
AUD_stop(scene->sound_scrub_handle);
- scene->sound_scrub_handle = AUD_pauseAfter(scene->sound_scene_handle, 1 / FPS);
+ }
+ scene->sound_scrub_handle = AUD_pauseAfter(scene->sound_scene_handle, one_frame);
}
}
else {
- if (scene->audio.flag & AUDIO_SYNC)
- AUD_seekSequencer(scene->sound_scene_handle, CFRA / FPS);
+ if (scene->audio.flag & AUDIO_SYNC) {
+ AUD_seekSequencer(scene->sound_scene_handle, cur_time);
+ }
else {
- if (status == AUD_STATUS_PLAYING)
- AUD_seek(scene->sound_scene_handle, CFRA / FPS);
+ if (status == AUD_STATUS_PLAYING) {
+ AUD_seek(scene->sound_scene_handle, cur_time);
+ }
}
}
@@ -695,62 +712,59 @@ void sound_update_scene(Main *bmain, struct Scene *scene)
float quat[4];
/* cheap test to skip looping over all objects (no speakers is a common case) */
- if (BLI_listbase_is_empty(&bmain->speaker)) {
- goto skip_speakers;
- }
+ if (!BLI_listbase_is_empty(&bmain->speaker)) {
+ for (SETLOOPER(scene, sce_it, base)) {
+ ob = base->object;
+ if ((ob->type != OB_SPEAKER) || !ob->adt) {
+ continue;
+ }
+ for (track = ob->adt->nla_tracks.first; track; track = track->next) {
+ for (strip = track->strips.first; strip; strip = strip->next) {
+ if (strip->type != NLASTRIP_TYPE_SOUND) {
+ continue;
+ }
+ speaker = (Speaker *)ob->data;
- for (SETLOOPER(scene, sce_it, base)) {
- ob = base->object;
- if (ob->type == OB_SPEAKER) {
- if (ob->adt) {
- for (track = ob->adt->nla_tracks.first; track; track = track->next) {
- for (strip = track->strips.first; strip; strip = strip->next) {
- if (strip->type == NLASTRIP_TYPE_SOUND) {
- speaker = (Speaker *)ob->data;
-
- if (AUD_removeSet(scene->speaker_handles, strip->speaker_handle)) {
- if (speaker->sound)
- AUD_moveSequence(strip->speaker_handle, (double)strip->start / FPS, -1, 0);
- else {
- AUD_removeSequence(scene->sound_scene, strip->speaker_handle);
- strip->speaker_handle = NULL;
- }
- }
- else {
- if (speaker->sound) {
- strip->speaker_handle = AUD_addSequence(scene->sound_scene,
- speaker->sound->playback_handle,
- (double)strip->start / FPS, -1, 0);
- AUD_setRelativeSequence(strip->speaker_handle, 0);
- }
- }
-
- if (strip->speaker_handle) {
- AUD_addSet(new_set, strip->speaker_handle);
- AUD_updateSequenceData(strip->speaker_handle, speaker->volume_max,
- speaker->volume_min, speaker->distance_max,
- speaker->distance_reference, speaker->attenuation,
- speaker->cone_angle_outer, speaker->cone_angle_inner,
- speaker->cone_volume_outer);
-
- mat4_to_quat(quat, ob->obmat);
- AUD_setSequenceAnimData(strip->speaker_handle, AUD_AP_LOCATION, CFRA, ob->obmat[3], 1);
- AUD_setSequenceAnimData(strip->speaker_handle, AUD_AP_ORIENTATION, CFRA, quat, 1);
- AUD_setSequenceAnimData(strip->speaker_handle, AUD_AP_VOLUME, CFRA, &speaker->volume, 1);
- AUD_setSequenceAnimData(strip->speaker_handle, AUD_AP_PITCH, CFRA, &speaker->pitch, 1);
- AUD_updateSequenceSound(strip->speaker_handle, speaker->sound->playback_handle);
- AUD_muteSequence(strip->speaker_handle, ((strip->flag & NLASTRIP_FLAG_MUTED) != 0) || ((speaker->flag & SPK_MUTED) != 0));
- }
+ if (AUD_removeSet(scene->speaker_handles, strip->speaker_handle)) {
+ if (speaker->sound) {
+ AUD_moveSequence(strip->speaker_handle, (double)strip->start / FPS, -1, 0);
+ }
+ else {
+ AUD_removeSequence(scene->sound_scene, strip->speaker_handle);
+ strip->speaker_handle = NULL;
}
}
+ else {
+ if (speaker->sound) {
+ strip->speaker_handle = AUD_addSequence(scene->sound_scene,
+ speaker->sound->playback_handle,
+ (double)strip->start / FPS, -1, 0);
+ AUD_setRelativeSequence(strip->speaker_handle, 0);
+ }
+ }
+
+ if (strip->speaker_handle) {
+ const bool mute = ((strip->flag & NLASTRIP_FLAG_MUTED) || (speaker->flag & SPK_MUTED));
+ AUD_addSet(new_set, strip->speaker_handle);
+ AUD_updateSequenceData(strip->speaker_handle, speaker->volume_max,
+ speaker->volume_min, speaker->distance_max,
+ speaker->distance_reference, speaker->attenuation,
+ speaker->cone_angle_outer, speaker->cone_angle_inner,
+ speaker->cone_volume_outer);
+
+ mat4_to_quat(quat, ob->obmat);
+ AUD_setSequenceAnimData(strip->speaker_handle, AUD_AP_LOCATION, CFRA, ob->obmat[3], 1);
+ AUD_setSequenceAnimData(strip->speaker_handle, AUD_AP_ORIENTATION, CFRA, quat, 1);
+ AUD_setSequenceAnimData(strip->speaker_handle, AUD_AP_VOLUME, CFRA, &speaker->volume, 1);
+ AUD_setSequenceAnimData(strip->speaker_handle, AUD_AP_PITCH, CFRA, &speaker->pitch, 1);
+ AUD_updateSequenceSound(strip->speaker_handle, speaker->sound->playback_handle);
+ AUD_muteSequence(strip->speaker_handle, mute);
+ }
}
}
}
}
-
-skip_speakers:
-
while ((handle = AUD_getSet(scene->speaker_handles))) {
AUD_removeSequence(scene->sound_scene, handle);
}
@@ -767,7 +781,7 @@ skip_speakers:
void *sound_get_factory(void *sound)
{
- return ((bSound *) sound)->playback_handle;
+ return ((bSound *)sound)->playback_handle;
}
/* stupid wrapper because AUD_C-API.h includes Python.h which makesrna doesn't like */
@@ -778,52 +792,56 @@ float sound_get_length(bSound *sound)
return info.length;
}
-int sound_is_jack_supported(void)
+bool sound_is_jack_supported(void)
{
- return AUD_isJackSupported();
+ return (bool)AUD_isJackSupported();
}
-#else // WITH_AUDASPACE
+#else /* WITH_AUDASPACE */
#include "BLI_utildefines.h"
-int sound_define_from_str(const char *UNUSED(str)) { return -1;}
+int sound_define_from_str(const char *UNUSED(str)) { return -1; }
void sound_force_device(int UNUSED(device)) {}
void sound_init_once(void) {}
void sound_init(struct Main *UNUSED(bmain)) {}
void sound_exit(void) {}
void sound_exit_once(void) {}
-void sound_cache(struct bSound *UNUSED(sound)) { }
+void sound_cache(struct bSound *UNUSED(sound)) {}
void sound_delete_cache(struct bSound *UNUSED(sound)) {}
void sound_load(struct Main *UNUSED(bmain), struct bSound *UNUSED(sound)) {}
void sound_create_scene(struct Scene *UNUSED(scene)) {}
void sound_destroy_scene(struct Scene *UNUSED(scene)) {}
void sound_mute_scene(struct Scene *UNUSED(scene), int UNUSED(muted)) {}
-void *sound_scene_add_scene_sound(struct Scene *UNUSED(scene), struct Sequence *UNUSED(sequence), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) { return NULL; }
-void *sound_scene_add_scene_sound_defaults(struct Scene *UNUSED(scene), struct Sequence *UNUSED(sequence)) { return NULL; }
-void *sound_add_scene_sound(struct Scene *UNUSED(scene), struct Sequence *UNUSED(sequence), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) { return NULL; }
+void *sound_scene_add_scene_sound(struct Scene *UNUSED(scene), struct Sequence *UNUSED(sequence),
+ int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) { return NULL; }
+void *sound_scene_add_scene_sound_defaults(struct Scene *UNUSED(scene),
+ struct Sequence *UNUSED(sequence)) { return NULL; }
+void *sound_add_scene_sound(struct Scene *UNUSED(scene), struct Sequence *UNUSED(sequence), int UNUSED(startframe),
+ int UNUSED(endframe), int UNUSED(frameskip)) { return NULL; }
void *sound_add_scene_sound_defaults(struct Scene *UNUSED(scene), struct Sequence *UNUSED(sequence)) { return NULL; }
void sound_remove_scene_sound(struct Scene *UNUSED(scene), void *UNUSED(handle)) {}
void sound_mute_scene_sound(void *UNUSED(handle), char UNUSED(mute)) {}
-void sound_move_scene_sound(struct Scene *UNUSED(scene), void *UNUSED(handle), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) {}
+void sound_move_scene_sound(struct Scene *UNUSED(scene), void *UNUSED(handle), int UNUSED(startframe),
+ int UNUSED(endframe), int UNUSED(frameskip)) {}
void sound_move_scene_sound_defaults(struct Scene *UNUSED(scene), struct Sequence *UNUSED(sequence)) {}
void sound_play_scene(struct Scene *UNUSED(scene)) {}
void sound_stop_scene(struct Scene *UNUSED(scene)) {}
void sound_seek_scene(struct Main *UNUSED(bmain), struct Scene *UNUSED(scene)) {}
float sound_sync_scene(struct Scene *UNUSED(scene)) { return NAN_FLT; }
int sound_scene_playing(struct Scene *UNUSED(scene)) { return -1; }
-void sound_read_waveform(struct bSound *sound) { (void)sound; }
-void sound_init_main(struct Main *bmain) { (void)bmain; }
-void sound_set_cfra(int cfra) { (void)cfra; }
-void sound_update_sequencer(struct Main *main, struct bSound *sound) { (void)main; (void)sound; }
-void sound_update_scene(struct Main *UNUSED(bmain), struct Scene *UNUSED(scene)) { }
-void sound_update_scene_sound(void *handle, struct bSound *sound) { (void)handle; (void)sound; }
-void sound_update_scene_listener(struct Scene *scene) { (void)scene; }
-void sound_update_fps(struct Scene *scene) { (void)scene; }
-void sound_set_scene_sound_volume(void *handle, float volume, char animated) { (void)handle; (void)volume; (void)animated; }
-void sound_set_scene_sound_pan(void *handle, float pan, char animated) { (void)handle; (void)pan; (void)animated; }
-void sound_set_scene_volume(struct Scene *scene, float volume) { (void)scene; (void)volume; }
-void sound_set_scene_sound_pitch(void *handle, float pitch, char animated) { (void)handle; (void)pitch; (void)animated; }
-float sound_get_length(struct bSound *sound) { (void)sound; return 0; }
-int sound_is_jack_supported(void) { return 0; }
-#endif // WITH_AUDASPACE
+void sound_read_waveform(struct bSound *UNUSED(sound)) {}
+void sound_init_main(struct Main *UNUSED(bmain)) {}
+void sound_set_cfra(int UNUSED(cfra)) {}
+void sound_update_sequencer(struct Main *UNUSED(main), struct bSound *UNUSED(sound)) {}
+void sound_update_scene(struct Main *UNUSED(bmain), struct Scene *UNUSED(scene)) {}
+void sound_update_scene_sound(void *UNUSED(handle), struct bSound *UNUSED(sound)) {}
+void sound_update_scene_listener(struct Scene *UNUSED(scene)) {}
+void sound_update_fps(struct Scene *UNUSED(scene)) {}
+void sound_set_scene_sound_volume(void *UNUSED(handle), float UNUSED(volume), char UNUSED(animated)) {}
+void sound_set_scene_sound_pan(void *UNUSED(handle), float UNUSED(pan), char UNUSED(animated)) {}
+void sound_set_scene_volume(struct Scene *UNUSED(scene), float UNUSED(volume)) {}
+void sound_set_scene_sound_pitch(void *UNUSED(handle), float UNUSED(pitch), char UNUSED(animated)) {}
+float sound_get_length(struct bSound *UNUSED(sound)) { return 0; }
+bool sound_is_jack_supported(void) { return false; }
+#endif /* WITH_AUDASPACE */
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index 87de748eace..a9eba54128a 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -53,19 +53,17 @@
#include "BLI_edgehash.h"
#include "BLI_math.h"
#include "BLI_memarena.h"
+#include "BLI_threads.h"
#include "BKE_pbvh.h"
#include "BKE_ccg.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_global.h"
-#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
-#include "BKE_modifier.h"
#include "BKE_multires.h"
#include "BKE_paint.h"
#include "BKE_scene.h"
#include "BKE_subsurf.h"
-#include "BKE_editmesh.h"
#include "PIL_time.h"
@@ -83,6 +81,9 @@
extern GLubyte stipple_quarttone[128]; /* glutil.c, bad level data */
+static ThreadRWMutex loops_cache_rwlock = BLI_RWLOCK_INITIALIZER;
+static ThreadRWMutex origindex_cache_rwlock = BLI_RWLOCK_INITIALIZER;
+
static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
int drawInteriorEdges,
int useSubsurfUv,
@@ -1329,16 +1330,21 @@ static void ccgDM_copyFinalLoopArray(DerivedMesh *dm, MLoop *mloop)
/* DMFlagMat *faceFlags = ccgdm->faceFlags; */ /* UNUSED */
if (!ccgdm->ehash) {
- MEdge *medge;
+ BLI_rw_mutex_lock(&loops_cache_rwlock, THREAD_LOCK_WRITE);
+ if (!ccgdm->ehash) {
+ MEdge *medge;
- ccgdm->ehash = BLI_edgehash_new_ex(__func__, ccgdm->dm.numEdgeData);
- medge = ccgdm->dm.getEdgeArray((DerivedMesh *)ccgdm);
+ ccgdm->ehash = BLI_edgehash_new_ex(__func__, ccgdm->dm.numEdgeData);
+ medge = ccgdm->dm.getEdgeArray((DerivedMesh *)ccgdm);
- for (i = 0; i < ccgdm->dm.numEdgeData; i++) {
- BLI_edgehash_insert(ccgdm->ehash, medge[i].v1, medge[i].v2, SET_INT_IN_POINTER(i));
+ for (i = 0; i < ccgdm->dm.numEdgeData; i++) {
+ BLI_edgehash_insert(ccgdm->ehash, medge[i].v1, medge[i].v2, SET_INT_IN_POINTER(i));
+ }
}
+ BLI_rw_mutex_unlock(&loops_cache_rwlock);
}
+ BLI_rw_mutex_lock(&loops_cache_rwlock, THREAD_LOCK_READ);
totface = ccgSubSurf_getNumFaces(ss);
mv = mloop;
for (index = 0; index < totface; index++) {
@@ -1381,6 +1387,7 @@ static void ccgDM_copyFinalLoopArray(DerivedMesh *dm, MLoop *mloop)
}
}
}
+ BLI_rw_mutex_unlock(&loops_cache_rwlock);
}
static void ccgDM_copyFinalPolyArray(DerivedMesh *dm, MPoly *mpoly)
@@ -1554,6 +1561,35 @@ static void ccgDM_foreachMappedEdge(
ccgEdgeIterator_free(ei);
}
+static void ccgDM_foreachMappedLoop(
+ DerivedMesh *dm,
+ void (*func)(void *userData, int vertex_index, int face_index, const float co[3], const float no[3]),
+ void *userData,
+ DMForeachFlag flag)
+{
+ /* We can't use dm->getLoopDataLayout(dm) here, we want to always access dm->loopData, EditDerivedBMesh would
+ * return loop data from bmesh itself. */
+ const float (*lnors)[3] = (flag & DM_FOREACH_USE_NORMAL) ? DM_get_loop_data_layer(dm, CD_NORMAL) : NULL;
+
+ MVert *mv = dm->getVertArray(dm);
+ MLoop *ml = dm->getLoopArray(dm);
+ MPoly *mp = dm->getPolyArray(dm);
+ const int *v_index = dm->getVertDataArray(dm, CD_ORIGINDEX);
+ const int *f_index = dm->getPolyDataArray(dm, CD_ORIGINDEX);
+ int p_idx, i;
+
+ for (p_idx = 0; p_idx < dm->numPolyData; ++p_idx, ++mp) {
+ for (i = 0; i < mp->totloop; ++i, ++ml) {
+ const int v_idx = v_index ? v_index[ml->v] : ml->v;
+ const int f_idx = f_index ? f_index[p_idx] : p_idx;
+ const float *no = lnors ? *lnors++ : NULL;
+ if (!ELEM(ORIGINDEX_NONE, v_idx, f_idx)) {
+ func(userData, v_idx, f_idx, mv[ml->v].co, no);
+ }
+ }
+ }
+}
+
static void ccgDM_drawVerts(DerivedMesh *dm)
{
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
@@ -1612,7 +1648,7 @@ static void ccgdm_pbvh_update(CCGDerivedMesh *ccgdm)
}
}
-static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges)
+static void ccgDM_drawEdges(DerivedMesh *dm, bool drawLooseEdges, bool drawAllEdges)
{
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
CCGSubSurf *ss = ccgdm->ss;
@@ -1725,12 +1761,14 @@ static void ccgDM_glNormalFast(float *a, float *b, float *c, float *d)
}
/* Only used by non-editmesh types */
-static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)[4], int fast, DMSetMaterial setMaterial)
+static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)[4], bool fast, DMSetMaterial setMaterial)
{
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
CCGSubSurf *ss = ccgdm->ss;
CCGKey key;
+ short (*lnors)[4][3] = dm->getTessFaceDataArray(dm, CD_TESSLOOPNORMAL);
int gridSize = ccgSubSurf_getGridSize(ss);
+ int gridFaces = gridSize - 1;
DMFlagMat *faceFlags = ccgdm->faceFlags;
int step = (fast) ? gridSize - 1 : 1;
int i, totface = ccgSubSurf_getNumFaces(ss);
@@ -1754,9 +1792,10 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)
int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f);
int index = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
int new_matnr, new_shademodel;
+ short (*ln)[4][3] = NULL;
if (faceFlags) {
- new_shademodel = (faceFlags[index].flag & ME_SMOOTH) ? GL_SMOOTH : GL_FLAT;
+ new_shademodel = (lnors || (faceFlags[index].flag & ME_SMOOTH)) ? GL_SMOOTH : GL_FLAT;
new_matnr = faceFlags[index].mat_nr;
}
else {
@@ -1764,6 +1803,11 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)
new_matnr = 0;
}
+ if (lnors) {
+ ln = lnors;
+ lnors += gridFaces * gridFaces * numVerts;
+ }
+
if (shademodel != new_shademodel || matnr != new_matnr) {
matnr = new_matnr;
shademodel = new_shademodel;
@@ -1782,8 +1826,31 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)
for (S = 0; S < numVerts; S++) {
CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
- if (shademodel == GL_SMOOTH) {
- for (y = 0; y < gridSize - 1; y += step) {
+ if (ln) {
+ /* Can't use quad strips here... */
+ glBegin(GL_QUADS);
+ for (y = 0; y < gridFaces; y += step) {
+ for (x = 0; x < gridFaces; x += step) {
+ float *a = CCG_grid_elem_co(&key, faceGridData, x, y + 0);
+ float *b = CCG_grid_elem_co(&key, faceGridData, x + step, y + 0);
+ float *c = CCG_grid_elem_co(&key, faceGridData, x + step, y + step);
+ float *d = CCG_grid_elem_co(&key, faceGridData, x, y + step);
+
+ glNormal3sv(ln[0][1]);
+ glVertex3fv(d);
+ glNormal3sv(ln[0][2]);
+ glVertex3fv(c);
+ glNormal3sv(ln[0][3]);
+ glVertex3fv(b);
+ glNormal3sv(ln[0][0]);
+ glVertex3fv(a);
+ ln += step;
+ }
+ }
+ glEnd();
+ }
+ else if (shademodel == GL_SMOOTH) {
+ for (y = 0; y < gridFaces; y += step) {
glBegin(GL_QUAD_STRIP);
for (x = 0; x < gridSize; x += step) {
CCGElem *a = CCG_grid_elem(&key, faceGridData, x, y + 0);
@@ -1799,8 +1866,8 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)
}
else {
glBegin(GL_QUADS);
- for (y = 0; y < gridSize - 1; y += step) {
- for (x = 0; x < gridSize - 1; x += step) {
+ for (y = 0; y < gridFaces; y += step) {
+ for (x = 0; x < gridFaces; x += step) {
float *a = CCG_grid_elem_co(&key, faceGridData, x, y + 0);
float *b = CCG_grid_elem_co(&key, faceGridData, x + step, y + 0);
float *c = CCG_grid_elem_co(&key, faceGridData, x + step, y + step);
@@ -1894,6 +1961,7 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
int gridFaces = gridSize - 1;
int edgeSize = ccgSubSurf_getEdgeSize(ss);
DMFlagMat *faceFlags = ccgdm->faceFlags;
+ short (*lnors)[4][3] = dm->getTessFaceDataArray(dm, CD_TESSLOOPNORMAL);
int a, i, do_draw, numVerts, matnr, new_matnr, totface;
CCG_key_top_level(&key, ss);
@@ -1913,6 +1981,7 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
totface = ccgSubSurf_getNumFaces(ss);
for (a = 0, i = 0; i < totface; i++) {
CCGFace *f = ccgdm->faceMap[i].face;
+ short (*ln)[4][3] = NULL;
int S, x, y, drawSmooth;
int index = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
int origIndex = ccgDM_getFaceMapIndex(ss, f);
@@ -1920,7 +1989,7 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
numVerts = ccgSubSurf_getFaceNumVerts(f);
if (faceFlags) {
- drawSmooth = (faceFlags[index].flag & ME_SMOOTH);
+ drawSmooth = (lnors || (faceFlags[index].flag & ME_SMOOTH));
new_matnr = faceFlags[index].mat_nr + 1;
}
else {
@@ -1928,6 +1997,11 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
new_matnr = 1;
}
+ if (lnors) {
+ ln = lnors;
+ lnors += gridFaces * gridFaces * numVerts;
+ }
+
if (new_matnr != matnr) {
do_draw = setMaterial(matnr = new_matnr, &gattribs);
if (do_draw)
@@ -1946,7 +2020,35 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
CCGElem *vda, *vdb;
- if (drawSmooth) {
+ if (ln) {
+ glBegin(GL_QUADS);
+ for (y = 0; y < gridFaces; y++) {
+ for (x = 0; x < gridFaces; x++) {
+ float *aco = CCG_grid_elem_co(&key, faceGridData, x, y);
+ float *bco = CCG_grid_elem_co(&key, faceGridData, x + 1, y);
+ float *cco = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 1);
+ float *dco = CCG_grid_elem_co(&key, faceGridData, x, y + 1);
+
+ PASSATTRIB(0, 1, 1);
+ glNormal3sv(ln[0][1]);
+ glVertex3fv(dco);
+ PASSATTRIB(1, 1, 2);
+ glNormal3sv(ln[0][2]);
+ glVertex3fv(cco);
+ PASSATTRIB(1, 0, 3);
+ glNormal3sv(ln[0][3]);
+ glVertex3fv(bco);
+ PASSATTRIB(0, 0, 0);
+ glNormal3sv(ln[0][0]);
+ glVertex3fv(aco);
+
+ ln++;
+ a++;
+ }
+ }
+ glEnd();
+ }
+ else if (drawSmooth) {
for (y = 0; y < gridFaces; y++) {
glBegin(GL_QUAD_STRIP);
for (x = 0; x < gridFaces; x++) {
@@ -2019,7 +2121,7 @@ static void ccgDM_drawFacesGLSL(DerivedMesh *dm, DMSetMaterial setMaterial)
/* Only used by non-editmesh types */
static void ccgDM_drawMappedFacesMat(DerivedMesh *dm,
- void (*setMaterial)(void *userData, int, void *attribs),
+ void (*setMaterial)(void *userData, int matnr, void *attribs),
bool (*setFace)(void *userData, int index), void *userData)
{
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
@@ -2031,6 +2133,7 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm,
int gridFaces = gridSize - 1;
int edgeSize = ccgSubSurf_getEdgeSize(ss);
DMFlagMat *faceFlags = ccgdm->faceFlags;
+ short (*lnors)[4][3] = dm->getTessFaceDataArray(dm, CD_TESSLOOPNORMAL);
int a, i, numVerts, matnr, new_matnr, totface;
CCG_key_top_level(&key, ss);
@@ -2049,6 +2152,7 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm,
totface = ccgSubSurf_getNumFaces(ss);
for (a = 0, i = 0; i < totface; i++) {
CCGFace *f = ccgdm->faceMap[i].face;
+ short (*ln)[4][3] = NULL;
int S, x, y, drawSmooth;
int index = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
int origIndex = ccgDM_getFaceMapIndex(ss, f);
@@ -2057,7 +2161,7 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm,
/* get flags */
if (faceFlags) {
- drawSmooth = (faceFlags[index].flag & ME_SMOOTH);
+ drawSmooth = (lnors || (faceFlags[index].flag & ME_SMOOTH));
new_matnr = faceFlags[index].mat_nr + 1;
}
else {
@@ -2065,6 +2169,11 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm,
new_matnr = 1;
}
+ if (lnors) {
+ ln = lnors;
+ lnors += gridFaces * gridFaces * numVerts;
+ }
+
/* material */
if (new_matnr != matnr) {
setMaterial(userData, matnr = new_matnr, &gattribs);
@@ -2083,7 +2192,35 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm,
CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
CCGElem *vda, *vdb;
- if (drawSmooth) {
+ if (ln) {
+ glBegin(GL_QUADS);
+ for (y = 0; y < gridFaces; y++) {
+ for (x = 0; x < gridFaces; x++) {
+ float *aco = CCG_grid_elem_co(&key, faceGridData, x, y + 0);
+ float *bco = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 0);
+ float *cco = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 1);
+ float *dco = CCG_grid_elem_co(&key, faceGridData, x, y + 1);
+
+ PASSATTRIB(0, 1, 1);
+ glNormal3sv(ln[0][1]);
+ glVertex3fv(dco);
+ PASSATTRIB(1, 1, 2);
+ glNormal3sv(ln[0][2]);
+ glVertex3fv(cco);
+ PASSATTRIB(1, 0, 3);
+ glNormal3sv(ln[0][3]);
+ glVertex3fv(bco);
+ PASSATTRIB(0, 0, 0);
+ glNormal3sv(ln[0][0]);
+ glVertex3fv(aco);
+
+ ln++;
+ a++;
+ }
+ }
+ glEnd();
+ }
+ else if (drawSmooth) {
for (y = 0; y < gridFaces; y++) {
glBegin(GL_QUAD_STRIP);
for (x = 0; x < gridFaces; x++) {
@@ -2160,6 +2297,7 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
CCGKey key;
MCol *mcol = dm->getTessFaceDataArray(dm, CD_PREVIEW_MCOL);
MTFace *tf = DM_get_tessface_data_layer(dm, CD_MTFACE);
+ short (*lnors)[4][3] = dm->getTessFaceDataArray(dm, CD_TESSLOOPNORMAL);
DMFlagMat *faceFlags = ccgdm->faceFlags;
DMDrawOption draw_option;
int i, totface, gridSize = ccgSubSurf_getGridSize(ss);
@@ -2183,10 +2321,11 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
int drawSmooth, index = ccgDM_getFaceMapIndex(ss, f);
int origIndex = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
unsigned char *cp = NULL;
+ short (*ln)[4][3] = NULL;
int mat_nr;
if (faceFlags) {
- drawSmooth = (faceFlags[origIndex].flag & ME_SMOOTH);
+ drawSmooth = (lnors || (faceFlags[origIndex].flag & ME_SMOOTH));
mat_nr = faceFlags[origIndex].mat_nr;
}
else {
@@ -2201,6 +2340,10 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
else
draw_option = GPU_enable_material(mat_nr, NULL) ? DM_DRAW_OPTION_NORMAL : DM_DRAW_OPTION_SKIP;
+ if (lnors) {
+ ln = lnors;
+ lnors += gridFaces * gridFaces * numVerts;
+ }
if (draw_option == DM_DRAW_OPTION_SKIP) {
if (tf) tf += gridFaces * gridFaces * numVerts;
@@ -2219,7 +2362,44 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
CCGElem *a, *b;
- if (drawSmooth) {
+ if (ln) {
+ glShadeModel(GL_SMOOTH);
+ glBegin(GL_QUADS);
+ for (y = 0; y < gridFaces; y++) {
+ for (x = 0; x < gridFaces; x++) {
+ float *a_co = CCG_grid_elem_co(&key, faceGridData, x, y + 0);
+ float *b_co = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 0);
+ float *c_co = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 1);
+ float *d_co = CCG_grid_elem_co(&key, faceGridData, x, y + 1);
+
+ if (tf) glTexCoord2fv(tf->uv[1]);
+ if (cp) glColor3ub(cp[7], cp[6], cp[5]);
+ glNormal3sv(ln[0][1]);
+ glVertex3fv(d_co);
+
+ if (tf) glTexCoord2fv(tf->uv[2]);
+ if (cp) glColor3ub(cp[11], cp[10], cp[9]);
+ glNormal3sv(ln[0][2]);
+ glVertex3fv(c_co);
+
+ if (tf) glTexCoord2fv(tf->uv[3]);
+ if (cp) glColor3ub(cp[15], cp[14], cp[13]);
+ glNormal3sv(ln[0][3]);
+ glVertex3fv(b_co);
+
+ if (tf) glTexCoord2fv(tf->uv[0]);
+ if (cp) glColor3ub(cp[3], cp[2], cp[1]);
+ glNormal3sv(ln[0][0]);
+ glVertex3fv(a_co);
+
+ if (tf) tf++;
+ if (cp) cp += 16;
+ ln++;
+ }
+ }
+ glEnd();
+ }
+ else if (drawSmooth) {
glShadeModel(GL_SMOOTH);
for (y = 0; y < gridFaces; y++) {
glBegin(GL_QUAD_STRIP);
@@ -2360,6 +2540,7 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
CCGSubSurf *ss = ccgdm->ss;
CCGKey key;
MCol *mcol = NULL;
+ short (*lnors)[4][3] = dm->getTessFaceDataArray(dm, CD_TESSLOOPNORMAL);
int i, gridSize = ccgSubSurf_getGridSize(ss);
DMFlagMat *faceFlags = ccgdm->faceFlags;
int useColors = flag & DM_DRAW_USE_COLORS;
@@ -2383,11 +2564,12 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
int drawSmooth, index = ccgDM_getFaceMapIndex(ss, f);
int origIndex;
unsigned char *cp = NULL;
+ short (*ln)[4][3] = NULL;
origIndex = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
if (flag & DM_DRAW_ALWAYS_SMOOTH) drawSmooth = 1;
- else if (faceFlags) drawSmooth = (faceFlags[origIndex].flag & ME_SMOOTH);
+ else if (faceFlags) drawSmooth = (lnors || (faceFlags[origIndex].flag & ME_SMOOTH));
else drawSmooth = 1;
if (mcol) {
@@ -2395,6 +2577,11 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
mcol += gridFaces * gridFaces * numVerts * 4;
}
+ if (lnors) {
+ ln = lnors;
+ lnors += gridFaces * gridFaces * numVerts;
+ }
+
{
DMDrawOption draw_option = DM_DRAW_OPTION_NORMAL;
@@ -2415,7 +2602,35 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
for (S = 0; S < numVerts; S++) {
CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
- if (drawSmooth) {
+ if (ln) {
+ glBegin(GL_QUADS);
+ for (y = 0; y < gridFaces; y++) {
+ for (x = 0; x < gridFaces; x++) {
+ float *a = CCG_grid_elem_co(&key, faceGridData, x, y + 0);
+ float *b = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 0);
+ float *c = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 1);
+ float *d = CCG_grid_elem_co(&key, faceGridData, x, y + 1);
+
+ if (cp) glColor3ub(cp[7], cp[6], cp[5]);
+ glNormal3sv(ln[0][1]);
+ glVertex3fv(d);
+ if (cp) glColor3ub(cp[11], cp[10], cp[9]);
+ glNormal3sv(ln[0][2]);
+ glVertex3fv(c);
+ if (cp) glColor3ub(cp[15], cp[14], cp[13]);
+ glNormal3sv(ln[0][3]);
+ glVertex3fv(b);
+ if (cp) glColor3ub(cp[3], cp[2], cp[1]);
+ glNormal3sv(ln[0][0]);
+ glVertex3fv(a);
+
+ if (cp) cp += 16;
+ ln++;
+ }
+ }
+ glEnd();
+ }
+ else if (drawSmooth) {
for (y = 0; y < gridFaces; y++) {
CCGElem *a, *b;
glBegin(GL_QUAD_STRIP);
@@ -2698,11 +2913,14 @@ static void *ccgDM_get_vert_data_layer(DerivedMesh *dm, int type)
int a, index, totnone, totorig;
/* Avoid re-creation if the layer exists already */
+ BLI_rw_mutex_lock(&origindex_cache_rwlock, THREAD_LOCK_READ);
origindex = DM_get_vert_data_layer(dm, CD_ORIGINDEX);
+ BLI_rw_mutex_unlock(&origindex_cache_rwlock);
if (origindex) {
return origindex;
}
+ BLI_rw_mutex_lock(&origindex_cache_rwlock, THREAD_LOCK_WRITE);
DM_add_vert_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
origindex = DM_get_vert_data_layer(dm, CD_ORIGINDEX);
@@ -2717,6 +2935,7 @@ static void *ccgDM_get_vert_data_layer(DerivedMesh *dm, int type)
CCGVert *v = ccgdm->vertMap[index].vert;
origindex[a] = ccgDM_getVertMapIndex(ccgdm->ss, v);
}
+ BLI_rw_mutex_unlock(&origindex_cache_rwlock);
return origindex;
}
@@ -2786,6 +3005,39 @@ static void *ccgDM_get_tessface_data_layer(DerivedMesh *dm, int type)
return origindex;
}
+ if (type == CD_TESSLOOPNORMAL) {
+ /* Create tessloopnormal on demand to save memory. */
+ /* Note that since tessellated face corners are the same a loops in CCGDM, and since all faces have four
+ * loops/corners, we can simplify the code here by converting tessloopnormals from 'short (*)[4][3]'
+ * to 'short (*)[3]'.
+ */
+ short (*tlnors)[3];
+
+ /* Avoid re-creation if the layer exists already */
+ tlnors = DM_get_tessface_data_layer(dm, CD_TESSLOOPNORMAL);
+ if (!tlnors) {
+ float (*lnors)[3];
+ short (*tlnors_it)[3];
+ const int numLoops = ccgDM_getNumLoops(dm);
+ int i;
+
+ lnors = dm->getLoopDataArray(dm, CD_NORMAL);
+ if (!lnors) {
+ return NULL;
+ }
+
+ DM_add_tessface_layer(dm, CD_TESSLOOPNORMAL, CD_CALLOC, NULL);
+ tlnors = tlnors_it = (short (*)[3])DM_get_tessface_data_layer(dm, CD_TESSLOOPNORMAL);
+
+ /* With ccgdm, we have a simple one to one mapping between loops and tessellated face corners. */
+ for (i = 0; i < numLoops; ++i, ++tlnors_it, ++lnors) {
+ normal_float_to_short_v3(*tlnors_it, *lnors);
+ }
+ }
+
+ return tlnors;
+ }
+
return DM_get_tessface_data_layer(dm, type);
}
@@ -2847,8 +3099,8 @@ static void *ccgDM_get_edge_data(DerivedMesh *dm, int index, int type)
static void *ccgDM_get_tessface_data(DerivedMesh *dm, int index, int type)
{
- if (type == CD_ORIGINDEX) {
- /* ensure creation of CD_ORIGINDEX layer */
+ if (ELEM(type, CD_ORIGINDEX, CD_TESSLOOPNORMAL)) {
+ /* ensure creation of CD_ORIGINDEX/CD_TESSLOOPNORMAL layers */
ccgDM_get_tessface_data_layer(dm, type);
}
@@ -3147,7 +3399,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
int index, totvert, totedge, totface;
int i;
int vertNum, edgeNum, faceNum;
- int *vertOrigIndex, *faceOrigIndex, *polyOrigIndex, *base_polyOrigIndex; /* *edgeOrigIndex - as yet, unused */
+ int *vertOrigIndex, *faceOrigIndex, *polyOrigIndex, *base_polyOrigIndex, *edgeOrigIndex;
short *edgeFlags;
DMFlagMat *faceFlags;
int *polyidx = NULL;
@@ -3157,7 +3409,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
BLI_array_declare(vertidx);
#endif
int loopindex, loopindex2;
- int edgeSize, has_edge_origindex;
+ int edgeSize;
int gridSize;
int gridFaces, gridCuts;
/*int gridSideVerts;*/
@@ -3170,6 +3422,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
MEdge *medge = NULL;
/* MFace *mface = NULL; */
MPoly *mpoly = NULL;
+ bool has_edge_cd;
DM_from_template(&ccgdm->dm, dm, DM_TYPE_CCGDM,
ccgSubSurf_getNumFinalVerts(ss),
@@ -3243,11 +3496,13 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
ccgdm->dm.getPBVH = ccgDM_getPBVH;
ccgdm->dm.calcNormals = ccgDM_calcNormals;
+ ccgdm->dm.calcLoopNormals = CDDM_calc_loop_normals;
ccgdm->dm.recalcTessellation = ccgDM_recalcTessellation;
ccgdm->dm.getVertCos = ccgdm_getVertCos;
ccgdm->dm.foreachMappedVert = ccgDM_foreachMappedVert;
ccgdm->dm.foreachMappedEdge = ccgDM_foreachMappedEdge;
+ ccgdm->dm.foreachMappedLoop = ccgDM_foreachMappedLoop;
ccgdm->dm.foreachMappedFaceCenter = ccgDM_foreachMappedFaceCenter;
ccgdm->dm.drawVerts = ccgDM_drawVerts;
@@ -3323,11 +3578,13 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
faceFlags = ccgdm->faceFlags = MEM_callocN(sizeof(DMFlagMat) * totface, "faceFlags");
vertOrigIndex = DM_get_vert_data_layer(&ccgdm->dm, CD_ORIGINDEX);
- /*edgeOrigIndex = DM_get_edge_data_layer(&ccgdm->dm, CD_ORIGINDEX);*/
+ edgeOrigIndex = DM_get_edge_data_layer(&ccgdm->dm, CD_ORIGINDEX);
faceOrigIndex = DM_get_tessface_data_layer(&ccgdm->dm, CD_ORIGINDEX);
polyOrigIndex = DM_get_poly_data_layer(&ccgdm->dm, CD_ORIGINDEX);
+ has_edge_cd = ((ccgdm->dm.edgeData.totlayer - (edgeOrigIndex ? 1 : 0)) != 0);
+
#if 0
/* this is not in trunk, can gives problems because colors initialize
* as black, just don't do it!, it works fine - campbell */
@@ -3336,9 +3593,6 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
mcol = DM_get_tessface_data_layer(&ccgdm->dm, CD_MCOL);
#endif
- has_edge_origindex = CustomData_has_layer(&ccgdm->dm.edgeData, CD_ORIGINDEX);
-
-
loopindex = loopindex2 = 0; /* current loop index */
for (index = 0; index < totface; index++) {
CCGFace *f = ccgdm->faceMap[index].face;
@@ -3428,10 +3682,10 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
}
}
- if (has_edge_origindex) {
- for (i = 0; i < numFinalEdges; ++i)
- *(int *)DM_get_edge_data(&ccgdm->dm, edgeNum + i,
- CD_ORIGINDEX) = ORIGINDEX_NONE;
+ if (edgeOrigIndex) {
+ for (i = 0; i < numFinalEdges; ++i) {
+ edgeOrigIndex[edgeNum + i] = ORIGINDEX_NONE;
+ }
}
for (s = 0; s < numVerts; s++) {
@@ -3525,9 +3779,15 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
vertNum++;
}
- for (i = 0; i < numFinalEdges; ++i) {
- if (has_edge_origindex) {
- *(int *)DM_get_edge_data(&ccgdm->dm, edgeNum + i, CD_ORIGINDEX) = mapIndex;
+ if (has_edge_cd) {
+ for (i = 0; i < numFinalEdges; ++i) {
+ CustomData_copy_data(&dm->edgeData, &ccgdm->dm.edgeData, mapIndex, edgeNum + i, 1);
+ }
+ }
+
+ if (edgeOrigIndex) {
+ for (i = 0; i < numFinalEdges; ++i) {
+ edgeOrigIndex[edgeNum + i] = mapIndex;
}
}
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index 22267c93680..b6d7e8922c4 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -1367,7 +1367,7 @@ char *txt_to_buf(Text *text)
int txt_find_string(Text *text, const char *findstr, int wrap, int match_case)
{
TextLine *tl, *startl;
- char *s = NULL;
+ const char *s = NULL;
if (!text || !text->curl || !text->sell) return 0;
@@ -2537,7 +2537,7 @@ void txt_backspace_char(Text *text)
}
else { /* Just backspacing a char */
size_t c_len = 0;
- char *prev = BLI_str_prev_char_utf8(text->curl->line + text->curc);
+ const char *prev = BLI_str_prev_char_utf8(text->curl->line + text->curc);
c = BLI_str_utf8_as_unicode_and_size(prev, &c_len);
/* source and destination overlap, don't use memcpy() */
@@ -2574,7 +2574,7 @@ static void txt_convert_tab_to_spaces(Text *text)
* is added so that the indention of the line is the right width (i.e. aligned
* to multiples of TXT_TABSIZE)
*/
- char *sb = &tab_to_spaces[text->curc % TXT_TABSIZE];
+ const char *sb = &tab_to_spaces[text->curc % TXT_TABSIZE];
txt_insert_buf(text, sb);
}
@@ -2775,23 +2775,21 @@ void txt_unindent(Text *text)
}
while (true) {
- int i = 0;
-
- if (BLI_strncasecmp(text->curl->line, remove, indentlen) == 0) {
+ bool changed = false;
+ if (strncmp(text->curl->line, remove, indentlen) == 0) {
if (num == 0)
unindented_first = true;
- while (i < text->curl->len) {
- text->curl->line[i] = text->curl->line[i + indentlen];
- i++;
- }
text->curl->len -= indentlen;
+ memmove(text->curl->line, text->curl->line + indentlen, text->curl->len + 1);
+ changed = true;
}
txt_make_dirty(text);
txt_clean_text(text);
if (text->curl == text->sell) {
- if (i > 0) text->selc = MAX2(text->selc - indentlen, 0);
+ if (changed)
+ text->selc = MAX2(text->selc - indentlen, 0);
break;
}
else {
@@ -2801,7 +2799,8 @@ void txt_unindent(Text *text)
}
- if (unindented_first) text->curc = MAX2(text->curc - indentlen, 0);
+ if (unindented_first)
+ text->curc = MAX2(text->curc - indentlen, 0);
while (num > 0) {
text->curl = text->curl->prev;
@@ -2963,7 +2962,8 @@ int txt_setcurr_tab_spaces(Text *text, int space)
* 2) within an identifier
* 3) after the cursor (text->curc), i.e. when creating space before a function def [#25414]
*/
- int a, is_indent = 0;
+ int a;
+ bool is_indent = false;
for (a = 0; (a < text->curc) && (text->curl->line[a] != '\0'); a++) {
char ch = text->curl->line[a];
if (ch == '#') {
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index d7248c521c4..4fff50153ef 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -38,7 +38,6 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
-#include "BLI_dynlib.h"
#include "BLI_math.h"
#include "BLI_kdopbvh.h"
#include "BLI_utildefines.h"
@@ -52,12 +51,12 @@
#include "DNA_node_types.h"
#include "DNA_color_types.h"
#include "DNA_particle_types.h"
+#include "DNA_linestyle_types.h"
#include "IMB_imbuf.h"
#include "BKE_global.h"
#include "BKE_main.h"
-#include "BKE_ocean.h"
#include "BKE_library.h"
#include "BKE_image.h"
@@ -789,6 +788,7 @@ void BKE_texture_make_local(Tex *tex)
Lamp *la;
Brush *br;
ParticleSettings *pa;
+ FreestyleLineStyle *ls;
int a;
bool is_local = false, is_lib = false;
@@ -857,6 +857,16 @@ void BKE_texture_make_local(Tex *tex)
}
pa = pa->id.next;
}
+ ls = bmain->linestyle.first;
+ while (ls) {
+ for (a = 0; a < MAX_MTEX; a++) {
+ if (ls->mtex[a] && ls->mtex[a]->tex == tex) {
+ if (ls->id.lib) is_lib = true;
+ else is_local = true;
+ }
+ }
+ ls = ls->id.next;
+ }
if (is_local && is_lib == false) {
id_clear_lib_data(bmain, &tex->id);
@@ -940,6 +950,19 @@ void BKE_texture_make_local(Tex *tex)
}
pa = pa->id.next;
}
+ ls = bmain->linestyle.first;
+ while (ls) {
+ for (a = 0; a < MAX_MTEX; a++) {
+ if (ls->mtex[a] && ls->mtex[a]->tex == tex) {
+ if (ls->id.lib == NULL) {
+ ls->mtex[a]->tex = tex_new;
+ tex_new->id.us++;
+ tex->id.us--;
+ }
+ }
+ }
+ ls = ls->id.next;
+ }
}
}
@@ -1001,6 +1024,41 @@ void set_current_lamp_texture(Lamp *la, Tex *newtex)
}
}
+Tex *give_current_linestyle_texture(FreestyleLineStyle *linestyle)
+{
+ MTex *mtex = NULL;
+ Tex *tex = NULL;
+
+ if (linestyle) {
+ mtex = linestyle->mtex[(int)(linestyle->texact)];
+ if (mtex) tex = mtex->tex;
+ }
+
+ return tex;
+}
+
+void set_current_linestyle_texture(FreestyleLineStyle *linestyle, Tex *newtex)
+{
+ int act = linestyle->texact;
+
+ if (linestyle->mtex[act] && linestyle->mtex[act]->tex)
+ id_us_min(&linestyle->mtex[act]->tex->id);
+
+ if (newtex) {
+ if (!linestyle->mtex[act]) {
+ linestyle->mtex[act] = add_mtex();
+ linestyle->mtex[act]->texco = TEXCO_STROKE;
+ }
+
+ linestyle->mtex[act]->tex = newtex;
+ id_us_plus(&newtex->id);
+ }
+ else if (linestyle->mtex[act]) {
+ MEM_freeN(linestyle->mtex[act]);
+ linestyle->mtex[act] = NULL;
+ }
+}
+
bNode *give_current_material_texture_node(Material *ma)
{
if (ma && ma->use_nodes && ma->nodetree)
@@ -1050,6 +1108,10 @@ bool give_active_mtex(ID *id, MTex ***mtex_ar, short *act)
*mtex_ar = ((Lamp *)id)->mtex;
if (act) *act = (((Lamp *)id)->texact);
break;
+ case ID_LS:
+ *mtex_ar = ((FreestyleLineStyle *)id)->mtex;
+ if (act) *act = (((FreestyleLineStyle *)id)->texact);
+ break;
case ID_PA:
*mtex_ar = ((ParticleSettings *)id)->mtex;
if (act) *act = (((ParticleSettings *)id)->texact);
@@ -1078,6 +1140,9 @@ void set_active_mtex(ID *id, short act)
case ID_LA:
((Lamp *)id)->texact = act;
break;
+ case ID_LS:
+ ((FreestyleLineStyle *)id)->texact = act;
+ break;
case ID_PA:
((ParticleSettings *)id)->texact = act;
break;
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index a96960c0345..22005892535 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -47,7 +47,6 @@
#include "BLI_math.h"
#include "BLI_math_base.h"
#include "BLI_listbase.h"
-#include "BLI_ghash.h"
#include "BLI_path_util.h"
#include "BLI_string.h"
#include "BLI_threads.h"
@@ -55,7 +54,6 @@
#include "BLF_translation.h"
#include "BKE_fcurve.h"
-#include "BKE_global.h"
#include "BKE_tracking.h"
#include "BKE_movieclip.h"
#include "BKE_object.h"
@@ -1733,32 +1731,19 @@ void BKE_tracking_camera_get_reconstructed_interpolate(MovieTracking *tracking,
/*********************** Distortion/Undistortion *************************/
-static void cameraIntrinscisOptionsFromTracking(libmv_CameraIntrinsicsOptions *camera_intrinsics_options,
- MovieTracking *tracking, int calibration_width, int calibration_height)
-{
- MovieTrackingCamera *camera = &tracking->camera;
- float aspy = 1.0f / tracking->camera.pixel_aspect;
-
- camera_intrinsics_options->focal_length = camera->focal;
-
- camera_intrinsics_options->principal_point_x = camera->principal[0];
- camera_intrinsics_options->principal_point_y = camera->principal[1] * aspy;
-
- camera_intrinsics_options->k1 = camera->k1;
- camera_intrinsics_options->k2 = camera->k2;
- camera_intrinsics_options->k3 = camera->k3;
-
- camera_intrinsics_options->image_width = calibration_width;
- camera_intrinsics_options->image_height = (int) (calibration_height * aspy);
-}
-
-MovieDistortion *BKE_tracking_distortion_new(void)
+MovieDistortion *BKE_tracking_distortion_new(MovieTracking *tracking,
+ int calibration_width, int calibration_height)
{
MovieDistortion *distortion;
+ libmv_CameraIntrinsicsOptions camera_intrinsics_options;
- distortion = MEM_callocN(sizeof(MovieDistortion), "BKE_tracking_distortion_create");
+ tracking_cameraIntrinscisOptionsFromTracking(tracking,
+ calibration_width,
+ calibration_height,
+ &camera_intrinsics_options);
- distortion->intrinsics = libmv_cameraIntrinsicsNewEmpty();
+ distortion = MEM_callocN(sizeof(MovieDistortion), "BKE_tracking_distortion_create");
+ distortion->intrinsics = libmv_cameraIntrinsicsNew(&camera_intrinsics_options);
return distortion;
}
@@ -1768,8 +1753,10 @@ void BKE_tracking_distortion_update(MovieDistortion *distortion, MovieTracking *
{
libmv_CameraIntrinsicsOptions camera_intrinsics_options;
- cameraIntrinscisOptionsFromTracking(&camera_intrinsics_options, tracking,
- calibration_width, calibration_height);
+ tracking_cameraIntrinscisOptionsFromTracking(tracking,
+ calibration_width,
+ calibration_height,
+ &camera_intrinsics_options);
libmv_cameraIntrinsicsUpdate(&camera_intrinsics_options, distortion->intrinsics);
}
@@ -1845,7 +1832,9 @@ void BKE_tracking_distort_v2(MovieTracking *tracking, const float co[2], float r
double x, y;
float aspy = 1.0f / tracking->camera.pixel_aspect;
- cameraIntrinscisOptionsFromTracking(&camera_intrinsics_options, tracking, 0, 0);
+ tracking_cameraIntrinscisOptionsFromTracking(tracking,
+ 0, 0,
+ &camera_intrinsics_options);
/* normalize coords */
x = (co[0] - camera->principal[0]) / camera->focal;
@@ -1866,7 +1855,9 @@ void BKE_tracking_undistort_v2(MovieTracking *tracking, const float co[2], float
double x = co[0], y = co[1];
float aspy = 1.0f / tracking->camera.pixel_aspect;
- cameraIntrinscisOptionsFromTracking(&camera_intrinsics_options, tracking, 0, 0);
+ tracking_cameraIntrinscisOptionsFromTracking(tracking,
+ 0, 0,
+ &camera_intrinsics_options);
libmv_cameraIntrinsicsInvert(&camera_intrinsics_options, x, y, &x, &y);
@@ -1879,8 +1870,9 @@ ImBuf *BKE_tracking_undistort_frame(MovieTracking *tracking, ImBuf *ibuf, int ca
{
MovieTrackingCamera *camera = &tracking->camera;
- if (camera->intrinsics == NULL)
- camera->intrinsics = BKE_tracking_distortion_new();
+ if (camera->intrinsics == NULL) {
+ camera->intrinsics = BKE_tracking_distortion_new(tracking, calibration_width, calibration_height);
+ }
return BKE_tracking_distortion_exec(camera->intrinsics, tracking, ibuf, calibration_width,
calibration_height, overscan, true);
@@ -1891,8 +1883,9 @@ ImBuf *BKE_tracking_distort_frame(MovieTracking *tracking, ImBuf *ibuf, int cali
{
MovieTrackingCamera *camera = &tracking->camera;
- if (camera->intrinsics == NULL)
- camera->intrinsics = BKE_tracking_distortion_new();
+ if (camera->intrinsics == NULL) {
+ camera->intrinsics = BKE_tracking_distortion_new(tracking, calibration_width, calibration_height);
+ }
return BKE_tracking_distortion_exec(camera->intrinsics, tracking, ibuf, calibration_width,
calibration_height, overscan, false);
@@ -1981,11 +1974,9 @@ ImBuf *BKE_tracking_sample_pattern(int frame_width, int frame_height, ImBuf *sea
if (num_samples_x <= 0 || num_samples_y <= 0)
return NULL;
- pattern_ibuf = IMB_allocImBuf(num_samples_x, num_samples_y, 32, IB_rectfloat);
-
- if (!search_ibuf->rect_float) {
- IMB_float_from_rect(search_ibuf);
- }
+ pattern_ibuf = IMB_allocImBuf(num_samples_x, num_samples_y,
+ 32,
+ search_ibuf->rect_float ? IB_rectfloat : IB_rect);
tracking_get_marker_coords_for_tracking(frame_width, frame_height, marker, src_pixel_x, src_pixel_y);
@@ -2015,10 +2006,26 @@ ImBuf *BKE_tracking_sample_pattern(int frame_width, int frame_height, ImBuf *sea
mask = BKE_tracking_track_get_mask(frame_width, frame_height, track, marker);
}
- libmv_samplePlanarPatch(search_ibuf->rect_float, search_ibuf->x, search_ibuf->y, 4,
- src_pixel_x, src_pixel_y, num_samples_x,
- num_samples_y, mask, pattern_ibuf->rect_float,
- &warped_position_x, &warped_position_y);
+ if (search_ibuf->rect_float) {
+ libmv_samplePlanarPatch(search_ibuf->rect_float,
+ search_ibuf->x, search_ibuf->y, 4,
+ src_pixel_x, src_pixel_y,
+ num_samples_x, num_samples_y,
+ mask,
+ pattern_ibuf->rect_float,
+ &warped_position_x,
+ &warped_position_y);
+ }
+ else {
+ libmv_samplePlanarPatchByte((unsigned char *) search_ibuf->rect,
+ search_ibuf->x, search_ibuf->y, 4,
+ src_pixel_x, src_pixel_y,
+ num_samples_x, num_samples_y,
+ mask,
+ (unsigned char *) pattern_ibuf->rect,
+ &warped_position_x,
+ &warped_position_y);
+ }
if (pos) {
pos[0] = warped_position_x;
diff --git a/source/blender/blenkernel/intern/tracking_detect.c b/source/blender/blenkernel/intern/tracking_detect.c
index a5a8ec87721..62039b761e8 100644
--- a/source/blender/blenkernel/intern/tracking_detect.c
+++ b/source/blender/blenkernel/intern/tracking_detect.c
@@ -31,8 +31,6 @@
* This file contains blender-side implementation of feature detection.
*/
-#include "MEM_guardedalloc.h"
-
#include "DNA_gpencil_types.h"
#include "DNA_movieclip_types.h"
#include "DNA_object_types.h" /* SELECT */
diff --git a/source/blender/blenkernel/intern/tracking_solver.c b/source/blender/blenkernel/intern/tracking_solver.c
index 44a4c11ec92..056220e27d8 100644
--- a/source/blender/blenkernel/intern/tracking_solver.c
+++ b/source/blender/blenkernel/intern/tracking_solver.c
@@ -66,11 +66,7 @@ typedef struct MovieReconstructContext {
bool is_camera;
short motion_flag;
- float focal_length;
- float principal_point[2];
- float k1, k2, k3;
-
- int width, height;
+ libmv_CameraIntrinsicsOptions camera_intrinsics_options;
float reprojection_error;
@@ -134,22 +130,11 @@ static void reconstruct_retrieve_libmv_intrinsics(MovieReconstructContext *conte
struct libmv_Reconstruction *libmv_reconstruction = context->reconstruction;
struct libmv_CameraIntrinsics *libmv_intrinsics = libmv_reconstructionExtractIntrinsics(libmv_reconstruction);
- float aspy = 1.0f / tracking->camera.pixel_aspect;
-
- double focal_length, principal_x, principal_y, k1, k2, k3;
- int width, height;
-
- libmv_cameraIntrinsicsExtract(libmv_intrinsics, &focal_length, &principal_x, &principal_y,
- &k1, &k2, &k3, &width, &height);
-
- tracking->camera.focal = focal_length;
-
- tracking->camera.principal[0] = principal_x;
- tracking->camera.principal[1] = principal_y / (double)aspy;
+ libmv_CameraIntrinsicsOptions camera_intrinsics_options;
+ libmv_cameraIntrinsicsExtractOptions(libmv_intrinsics, &camera_intrinsics_options);
- tracking->camera.k1 = k1;
- tracking->camera.k2 = k2;
- tracking->camera.k3 = k3;
+ tracking_trackingCameraFromIntrinscisOptions(tracking,
+ &camera_intrinsics_options);
}
/* Retrieve reconstructed tracks from libmv to blender.
@@ -369,7 +354,6 @@ MovieReconstructContext *BKE_tracking_reconstruction_context_new(MovieClip *clip
{
MovieTracking *tracking = &clip->tracking;
MovieReconstructContext *context = MEM_callocN(sizeof(MovieReconstructContext), "MovieReconstructContext data");
- MovieTrackingCamera *camera = &tracking->camera;
ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
float aspy = 1.0f / tracking->camera.pixel_aspect;
int num_tracks = BLI_countlist(tracksbase);
@@ -383,16 +367,9 @@ MovieReconstructContext *BKE_tracking_reconstruction_context_new(MovieClip *clip
context->select_keyframes =
(tracking->settings.reconstruction_flag & TRACKING_USE_KEYFRAME_SELECTION) != 0;
- context->focal_length = camera->focal;
- context->principal_point[0] = camera->principal[0];
- context->principal_point[1] = camera->principal[1] * aspy;
-
- context->width = width;
- context->height = height;
-
- context->k1 = camera->k1;
- context->k2 = camera->k2;
- context->k3 = camera->k3;
+ tracking_cameraIntrinscisOptionsFromTracking(tracking,
+ width, height,
+ &context->camera_intrinsics_options);
context->tracks_map = tracks_map_new(context->object_name, context->is_camera, num_tracks, 0);
@@ -461,22 +438,6 @@ static void reconstruct_update_solve_cb(void *customdata, double progress, const
BLI_snprintf(progressdata->stats_message, progressdata->message_size, "Solving camera | %s", message);
}
-/* FIll in camera intrinsics structure from reconstruction context. */
-static void camraIntrincicsOptionsFromContext(libmv_CameraIntrinsicsOptions *camera_intrinsics_options,
- MovieReconstructContext *context)
-{
- camera_intrinsics_options->focal_length = context->focal_length;
-
- camera_intrinsics_options->principal_point_x = context->principal_point[0];
- camera_intrinsics_options->principal_point_y = context->principal_point[1];
-
- camera_intrinsics_options->k1 = context->k1;
- camera_intrinsics_options->k2 = context->k2;
- camera_intrinsics_options->k3 = context->k3;
-
- camera_intrinsics_options->image_width = context->width;
- camera_intrinsics_options->image_height = context->height;
-}
/* Fill in reconstruction options structure from reconstruction context. */
static void reconstructionOptionsFromContext(libmv_ReconstructionOptions *reconstruction_options,
@@ -506,7 +467,6 @@ void BKE_tracking_reconstruction_solve(MovieReconstructContext *context, short *
ReconstructProgressData progressdata;
- libmv_CameraIntrinsicsOptions camera_intrinsics_options;
libmv_ReconstructionOptions reconstruction_options;
progressdata.stop = stop;
@@ -515,18 +475,17 @@ void BKE_tracking_reconstruction_solve(MovieReconstructContext *context, short *
progressdata.stats_message = stats_message;
progressdata.message_size = message_size;
- camraIntrincicsOptionsFromContext(&camera_intrinsics_options, context);
reconstructionOptionsFromContext(&reconstruction_options, context);
if (context->motion_flag & TRACKING_MOTION_MODAL) {
context->reconstruction = libmv_solveModal(context->tracks,
- &camera_intrinsics_options,
+ &context->camera_intrinsics_options,
&reconstruction_options,
reconstruct_update_solve_cb, &progressdata);
}
else {
context->reconstruction = libmv_solveReconstruction(context->tracks,
- &camera_intrinsics_options,
+ &context->camera_intrinsics_options,
&reconstruction_options,
reconstruct_update_solve_cb, &progressdata);
@@ -576,7 +535,7 @@ bool BKE_tracking_reconstruction_finish(MovieReconstructContext *context, MovieT
}
static void tracking_scale_reconstruction(ListBase *tracksbase, MovieTrackingReconstruction *reconstruction,
- float scale[3])
+ const float scale[3])
{
MovieTrackingTrack *track;
int i;
diff --git a/source/blender/blenkernel/intern/tracking_stabilize.c b/source/blender/blenkernel/intern/tracking_stabilize.c
index f198f686b52..8cdb547612c 100644
--- a/source/blender/blenkernel/intern/tracking_stabilize.c
+++ b/source/blender/blenkernel/intern/tracking_stabilize.c
@@ -33,8 +33,6 @@
#include <limits.h>
-#include "MEM_guardedalloc.h"
-
#include "DNA_movieclip_types.h"
#include "BLI_utildefines.h"
diff --git a/source/blender/blenkernel/intern/tracking_util.c b/source/blender/blenkernel/intern/tracking_util.c
index 4b3c354dd12..4ebe8494101 100644
--- a/source/blender/blenkernel/intern/tracking_util.c
+++ b/source/blender/blenkernel/intern/tracking_util.c
@@ -51,6 +51,8 @@
#include "tracking_private.h"
+#include "libmv-capi.h"
+
/*********************** Tracks map *************************/
TracksMap *tracks_map_new(const char *object_name, bool is_camera, int num_tracks, int customdata_size)
@@ -386,3 +388,68 @@ void tracking_marker_insert_disabled(MovieTrackingTrack *track, const MovieTrack
if (overwrite || !BKE_tracking_track_has_marker_at_frame(track, marker_new.framenr))
BKE_tracking_marker_insert(track, &marker_new);
}
+
+
+/* Fill in Libmv C-API camera intrinsics options from tracking structure.
+ */
+void tracking_cameraIntrinscisOptionsFromTracking(MovieTracking *tracking,
+ int calibration_width, int calibration_height,
+ libmv_CameraIntrinsicsOptions *camera_intrinsics_options)
+{
+ MovieTrackingCamera *camera = &tracking->camera;
+ float aspy = 1.0f / tracking->camera.pixel_aspect;
+
+ camera_intrinsics_options->focal_length = camera->focal;
+
+ camera_intrinsics_options->principal_point_x = camera->principal[0];
+ camera_intrinsics_options->principal_point_y = camera->principal[1] * aspy;
+
+ switch (camera->distortion_model) {
+ case TRACKING_DISTORTION_MODEL_POLYNOMIAL:
+ camera_intrinsics_options->distortion_model = LIBMV_DISTORTION_MODEL_POLYNOMIAL;
+ camera_intrinsics_options->polynomial_k1 = camera->k1;
+ camera_intrinsics_options->polynomial_k2 = camera->k2;
+ camera_intrinsics_options->polynomial_k3 = camera->k3;
+ camera_intrinsics_options->polynomial_p1 = 0.0;
+ camera_intrinsics_options->polynomial_p2 = 0.0;
+ break;
+ case TRACKING_DISTORTION_MODEL_DIVISION:
+ camera_intrinsics_options->distortion_model = LIBMV_DISTORTION_MODEL_DIVISION;
+ camera_intrinsics_options->division_k1 = camera->division_k1;
+ camera_intrinsics_options->division_k2 = camera->division_k2;
+ break;
+ default:
+ BLI_assert(!"Unknown distortion model");
+ }
+
+ camera_intrinsics_options->image_width = calibration_width;
+ camera_intrinsics_options->image_height = (int) (calibration_height * aspy);
+}
+
+void tracking_trackingCameraFromIntrinscisOptions(MovieTracking *tracking,
+ const libmv_CameraIntrinsicsOptions *camera_intrinsics_options)
+{
+ float aspy = 1.0f / tracking->camera.pixel_aspect;
+ MovieTrackingCamera *camera = &tracking->camera;
+
+ camera->focal = camera_intrinsics_options->focal_length;
+
+ camera->principal[0] = camera_intrinsics_options->principal_point_x;
+ camera->principal[1] = camera_intrinsics_options->principal_point_y / (double) aspy;
+
+ switch (camera_intrinsics_options->distortion_model) {
+ case LIBMV_DISTORTION_MODEL_POLYNOMIAL:
+ camera->distortion_model = TRACKING_DISTORTION_MODEL_POLYNOMIAL;
+ camera->k1 = camera_intrinsics_options->polynomial_k1;
+ camera->k2 = camera_intrinsics_options->polynomial_k2;
+ camera->k3 = camera_intrinsics_options->polynomial_k3;
+ break;
+ case LIBMV_DISTORTION_MODEL_DIVISION:
+ camera->distortion_model = TRACKING_DISTORTION_MODEL_DIVISION;
+ camera->division_k1 = camera_intrinsics_options->division_k1;
+ camera->division_k2 = camera_intrinsics_options->division_k2;
+ break;
+ default:
+ BLI_assert(!"Unknown distortion model");
+ }
+}
diff --git a/source/blender/blenkernel/intern/treehash.c b/source/blender/blenkernel/intern/treehash.c
index d1e9da72208..fb55e3d2137 100644
--- a/source/blender/blenkernel/intern/treehash.c
+++ b/source/blender/blenkernel/intern/treehash.c
@@ -76,11 +76,19 @@ static void tse_group_free(TseGroup *tse_group)
static unsigned int tse_hash(const void *ptr)
{
const TreeStoreElem *tse = ptr;
- unsigned int hash;
+ union {
+ short h_pair[2];
+ unsigned int u_int;
+ } hash;
+
BLI_assert(tse->type || !tse->nr);
- hash = BLI_ghashutil_inthash(SET_INT_IN_POINTER((tse->nr << 16) + tse->type));
- hash ^= BLI_ghashutil_inthash(tse->id);
- return hash;
+
+ hash.h_pair[0] = tse->type;
+ hash.h_pair[1] = tse->nr;
+
+ hash.u_int ^= BLI_ghashutil_ptrhash(tse->id);
+
+ return hash.u_int;
}
static int tse_cmp(const void *a, const void *b)
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c
index 6a05014385d..de6424f3145 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -680,7 +680,7 @@ int bUnit_ReplaceString(char *str, int len_max, const char *str_prev, double sca
* */
{
char *str_found = str;
- char *ch = str;
+ const char *ch = str;
while ((str_found = strchr(str_found, SEP_CHR))) {
diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c
index fcfd4f9dd85..dbceba288c7 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -1438,20 +1438,26 @@ static void ffmpeg_set_expert_options(RenderData *rd)
BKE_ffmpeg_property_add_string(rd, "video", "bf:3");
BKE_ffmpeg_property_add_string(rd, "video", "refs:2");
BKE_ffmpeg_property_add_string(rd, "video", "qcomp:0.6");
- BKE_ffmpeg_property_add_string(rd, "video", "directpred:3"); // Deprecated.
BKE_ffmpeg_property_add_string(rd, "video", "trellis:0");
- BKE_ffmpeg_property_add_string(rd, "video", "flags2:wpred"); // Deprecated.
BKE_ffmpeg_property_add_string(rd, "video", "weightb:1");
- BKE_ffmpeg_property_add_string(rd, "video", "flags2:dct8x8"); // Deprecated.
+#ifdef FFMPEG_HAVE_DEPRECATED_FLAGS2
+ BKE_ffmpeg_property_add_string(rd, "video", "flags2:dct8x8");
+ BKE_ffmpeg_property_add_string(rd, "video", "directpred:3");
+ BKE_ffmpeg_property_add_string(rd, "video", "flags2:fastpskip");
+ BKE_ffmpeg_property_add_string(rd, "video", "flags2:wpred");
+#else
BKE_ffmpeg_property_add_string(rd, "video", "8x8dct:1");
- BKE_ffmpeg_property_add_string(rd, "video", "flags2:fastpskip"); // Deprecated.
BKE_ffmpeg_property_add_string(rd, "video", "fast-pskip:1");
BKE_ffmpeg_property_add_string(rd, "video", "wpredp:2");
+#endif
if (rd->ffcodecdata.flags & FFMPEG_LOSSLESS_OUTPUT) {
- BKE_ffmpeg_property_add_string(rd, "video", "cqp:0"); // Deprecated.
+#ifdef FFMPEG_HAVE_DEPRECATED_FLAGS2
+ BKE_ffmpeg_property_add_string(rd, "video", "cqp:0");
+#else
BKE_ffmpeg_property_add_string(rd, "video", "qp:0");
+#endif
}
}
else if (codec_id == AV_CODEC_ID_DNXHD) {
diff --git a/source/blender/blenkernel/tracking_private.h b/source/blender/blenkernel/tracking_private.h
index 981b7951097..6efa1533e3e 100644
--- a/source/blender/blenkernel/tracking_private.h
+++ b/source/blender/blenkernel/tracking_private.h
@@ -41,6 +41,8 @@ struct GHash;
struct MovieTracking;
struct MovieTrackingMarker;
+struct libmv_CameraIntrinsicsOptions;
+
/*********************** Tracks map *************************/
typedef struct TracksMap {
@@ -86,4 +88,11 @@ void tracking_set_marker_coords_from_tracking(int frame_width, int frame_height,
void tracking_marker_insert_disabled(struct MovieTrackingTrack *track, const struct MovieTrackingMarker *ref_marker,
bool before, bool overwrite);
+void tracking_cameraIntrinscisOptionsFromTracking(struct MovieTracking *tracking,
+ int calibration_width, int calibration_height,
+ struct libmv_CameraIntrinsicsOptions *camera_intrinsics_options);
+
+void tracking_trackingCameraFromIntrinscisOptions(struct MovieTracking *tracking,
+ const struct libmv_CameraIntrinsicsOptions *camera_intrinsics_options);
+
#endif /* __TRACKING_PRIVATE_H__ */
diff --git a/source/blender/blenlib/BLI_alloca.h b/source/blender/blenlib/BLI_alloca.h
index 06c3e8d8996..fd814940624 100644
--- a/source/blender/blenlib/BLI_alloca.h
+++ b/source/blender/blenlib/BLI_alloca.h
@@ -28,9 +28,6 @@
*/
/* BLI_array_alloca / alloca */
-#ifdef _MSC_VER
-# define alloca _alloca
-#endif
#if defined(__MINGW32__)
# include <malloc.h> /* mingw needs for alloca() */
diff --git a/source/blender/blenlib/BLI_compiler_attrs.h b/source/blender/blenlib/BLI_compiler_attrs.h
index 0a93ae2566b..f0d32670229 100644
--- a/source/blender/blenlib/BLI_compiler_attrs.h
+++ b/source/blender/blenlib/BLI_compiler_attrs.h
@@ -42,7 +42,7 @@
/* hint to mark function arguments expected to be non-null
* if no arguments are given to the macro, all of pointer
- * arguments owuld be expected to be non-null
+ * arguments would be expected to be non-null
*/
#ifdef __GNUC__
# define ATTR_NONNULL(args ...) __attribute__((nonnull(args)))
diff --git a/source/blender/compositor/nodes/COM_CombineRGBANode.h b/source/blender/blenlib/BLI_compiler_compat.h
index 5cc0b1ea6da..60a7d8dbd02 100644
--- a/source/blender/compositor/nodes/COM_CombineRGBANode.h
+++ b/source/blender/blenlib/BLI_compiler_compat.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011, Blender Foundation.
+ * ***** 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
@@ -15,23 +15,21 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
- * Monique Dewanchand
+ * ***** END GPL LICENSE BLOCK *****
*/
-#ifndef _COM_CombineRGBANode_h_
-#define _COM_CombineRGBANode_h_
+#ifndef __BLI_COMPILER_COMPAT_H__
+#define __BLI_COMPILER_COMPAT_H__
-#include "COM_Node.h"
-#include "DNA_node_types.h"
-/**
- * @brief CombineRGBANode
- * @ingroup Node
+/** \file BLI_compiler_compat.h
+ * \ingroup bli
+ *
+ * Use to help with cross platform portability.
*/
-class CombineRGBANode : public Node {
-public:
- CombineRGBANode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
-};
+
+#if defined(_MSC_VER)
+# define __func__ __FUNCTION__
+# define alloca _alloca
#endif
+
+#endif /* __BLI_COMPILER_COMPAT_H__ */
diff --git a/source/blender/blenlib/BLI_edgehash.h b/source/blender/blenlib/BLI_edgehash.h
index fccbda4b4db..8e74ce3a9e3 100644
--- a/source/blender/blenlib/BLI_edgehash.h
+++ b/source/blender/blenlib/BLI_edgehash.h
@@ -32,9 +32,13 @@
#include "BLI_compiler_attrs.h"
struct EdgeHash;
-struct EdgeHashIterator;
typedef struct EdgeHash EdgeHash;
-typedef struct EdgeHashIterator EdgeHashIterator;
+
+typedef struct EdgeHashIterator {
+ EdgeHash *eh;
+ struct EdgeEntry *curEntry;
+ unsigned int curBucket;
+} EdgeHashIterator;
typedef void (*EdgeHashFreeFP)(void *key);
@@ -49,6 +53,7 @@ void BLI_edgehash_free(EdgeHash *eh, EdgeHashFreeFP valfreefp);
void BLI_edgehash_insert(EdgeHash *eh, unsigned int v0, unsigned int v1, void *val);
bool BLI_edgehash_reinsert(EdgeHash *eh, unsigned int v0, unsigned int v1, void *val);
void *BLI_edgehash_lookup(EdgeHash *eh, unsigned int v0, unsigned int v1) ATTR_WARN_UNUSED_RESULT;
+void *BLI_edgehash_lookup_default(EdgeHash *eh, unsigned int v0, unsigned int v1, void *val_default) ATTR_WARN_UNUSED_RESULT;
void **BLI_edgehash_lookup_p(EdgeHash *eh, unsigned int v0, unsigned int v1) ATTR_WARN_UNUSED_RESULT;
bool BLI_edgehash_haskey(EdgeHash *eh, unsigned int v0, unsigned int v1) ATTR_WARN_UNUSED_RESULT;
int BLI_edgehash_size(EdgeHash *eh) ATTR_WARN_UNUSED_RESULT;
@@ -59,13 +64,29 @@ void BLI_edgehash_flag_set(EdgeHash *eh, unsigned int flag);
void BLI_edgehash_flag_clear(EdgeHash *eh, unsigned int flag);
EdgeHashIterator *BLI_edgehashIterator_new(EdgeHash *eh) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT;
+void BLI_edgehashIterator_init(EdgeHashIterator *ehi, EdgeHash *eh);
void BLI_edgehashIterator_free(EdgeHashIterator *ehi);
-void BLI_edgehashIterator_getKey(EdgeHashIterator *ehi, unsigned int *r_v0, unsigned int *r_v1);
-void *BLI_edgehashIterator_getValue(EdgeHashIterator *ehi) ATTR_WARN_UNUSED_RESULT;
-void **BLI_edgehashIterator_getValue_p(EdgeHashIterator *ehi) ATTR_WARN_UNUSED_RESULT;
-void BLI_edgehashIterator_setValue(EdgeHashIterator *ehi, void *val);
void BLI_edgehashIterator_step(EdgeHashIterator *ehi);
-bool BLI_edgehashIterator_isDone(EdgeHashIterator *ehi) ATTR_WARN_UNUSED_RESULT;
+
+BLI_INLINE bool BLI_edgehashIterator_isDone(EdgeHashIterator *ehi) ATTR_WARN_UNUSED_RESULT;
+BLI_INLINE void BLI_edgehashIterator_getKey(EdgeHashIterator *ehi, unsigned int *r_v0, unsigned int *r_v1);
+BLI_INLINE void *BLI_edgehashIterator_getValue(EdgeHashIterator *ehi) ATTR_WARN_UNUSED_RESULT;
+BLI_INLINE void **BLI_edgehashIterator_getValue_p(EdgeHashIterator *ehi) ATTR_WARN_UNUSED_RESULT;
+BLI_INLINE void BLI_edgehashIterator_setValue(EdgeHashIterator *ehi, void *val);
+
+struct _eh_Entry { void *next; unsigned int v0, v1; void *val; };
+BLI_INLINE void BLI_edgehashIterator_getKey(EdgeHashIterator *ehi, unsigned int *r_v0, unsigned int *r_v1)
+{ *r_v0 = ((struct _eh_Entry *)ehi->curEntry)->v0; *r_v1 = ((struct _eh_Entry *)ehi->curEntry)->v1; }
+BLI_INLINE void *BLI_edgehashIterator_getValue(EdgeHashIterator *ehi) { return ((struct _eh_Entry *)ehi->curEntry)->val; }
+BLI_INLINE void **BLI_edgehashIterator_getValue_p(EdgeHashIterator *ehi) { return &((struct _eh_Entry *)ehi->curEntry)->val; }
+BLI_INLINE void BLI_edgehashIterator_setValue(EdgeHashIterator *ehi, void *val) { ((struct _eh_Entry *)ehi->curEntry)->val = val; }
+BLI_INLINE bool BLI_edgehashIterator_isDone(EdgeHashIterator *ehi) { return (((struct _eh_Entry *)ehi->curEntry) == NULL); }
+/* disallow further access */
+#ifdef __GNUC__
+# pragma GCC poison _eh_Entry
+#else
+# define _eh_Entry void
+#endif
#define BLI_EDGEHASH_SIZE_GUESS_FROM_LOOPS(totloop) ((totloop) / 2)
#define BLI_EDGEHASH_SIZE_GUESS_FROM_POLYS(totpoly) ((totpoly) * 2)
diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h
index e5a93691ad0..2aa79d6da8d 100644
--- a/source/blender/blenlib/BLI_ghash.h
+++ b/source/blender/blenlib/BLI_ghash.h
@@ -66,6 +66,7 @@ void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfre
void BLI_ghash_insert(GHash *gh, void *key, void *val);
bool BLI_ghash_reinsert(GHash *gh, void *key, void *val, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp);
void *BLI_ghash_lookup(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT;
+void *BLI_ghash_lookup_default(GHash *gh, const void *key, void *val_default) ATTR_WARN_UNUSED_RESULT;
void **BLI_ghash_lookup_p(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT;
bool BLI_ghash_remove(GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp);
void BLI_ghash_clear(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp);
@@ -83,13 +84,24 @@ GHashIterator *BLI_ghashIterator_new(GHash *gh) ATTR_MALLOC ATTR_WARN_UNUSED_RES
void BLI_ghashIterator_init(GHashIterator *ghi, GHash *gh);
void BLI_ghashIterator_free(GHashIterator *ghi);
-
-void *BLI_ghashIterator_getKey(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT;
-void *BLI_ghashIterator_getValue(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT;
-void **BLI_ghashIterator_getValue_p(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT;
-
void BLI_ghashIterator_step(GHashIterator *ghi);
-bool BLI_ghashIterator_done(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT;
+
+BLI_INLINE void *BLI_ghashIterator_getKey(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT;
+BLI_INLINE void *BLI_ghashIterator_getValue(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT;
+BLI_INLINE void **BLI_ghashIterator_getValue_p(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT;
+BLI_INLINE bool BLI_ghashIterator_done(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT;
+
+struct _gh_Entry { void *next, *key, *val; };
+BLI_INLINE void *BLI_ghashIterator_getKey(GHashIterator *ghi) { return ((struct _gh_Entry *)ghi->curEntry)->key; }
+BLI_INLINE void *BLI_ghashIterator_getValue(GHashIterator *ghi) { return ((struct _gh_Entry *)ghi->curEntry)->val; }
+BLI_INLINE void **BLI_ghashIterator_getValue_p(GHashIterator *ghi) { return &((struct _gh_Entry *)ghi->curEntry)->val; }
+BLI_INLINE bool BLI_ghashIterator_done(GHashIterator *ghi) { return !ghi->curEntry; }
+/* disallow further access */
+#ifdef __GNUC__
+# pragma GCC poison _gh_Entry
+#else
+# define _gh_Entry void
+#endif
#define GHASH_ITER(gh_iter_, ghash_) \
for (BLI_ghashIterator_init(&gh_iter_, ghash_); \
@@ -101,17 +113,37 @@ bool BLI_ghashIterator_done(GHashIterator *ghi) ATTR_WARN_UNUSED_RESUL
BLI_ghashIterator_done(&gh_iter_) == false; \
BLI_ghashIterator_step(&gh_iter_), i_++)
-/* *** */
+/** \name Callbacks for GHash
+ *
+ * \note '_p' suffix denotes void pointer arg,
+ * so we can have functions that take correctly typed args too.
+ * \{ */
unsigned int BLI_ghashutil_ptrhash(const void *key);
int BLI_ghashutil_ptrcmp(const void *a, const void *b);
-unsigned int BLI_ghashutil_strhash(const void *key);
+unsigned int BLI_ghashutil_strhash_n(const char *key, size_t n);
+#define BLI_ghashutil_strhash(key) ( \
+ CHECK_TYPE_INLINE(key, char *), \
+ BLI_ghashutil_strhash_p(key))
+unsigned int BLI_ghashutil_strhash_p(const void *key);
int BLI_ghashutil_strcmp(const void *a, const void *b);
-unsigned int BLI_ghashutil_inthash(const void *ptr);
+#define BLI_ghashutil_inthash(key) ( \
+ CHECK_TYPE_INLINE(key, int), \
+ BLI_ghashutil_uinthash((unsigned int)key))
+unsigned int BLI_ghashutil_uinthash(unsigned int key);
+#define BLI_ghashutil_inthash_v4(key) ( \
+ CHECK_TYPE_INLINE(key, int *), \
+ BLI_ghashutil_uinthash_v4((const unsigned int *)key))
+unsigned int BLI_ghashutil_uinthash_v4(const unsigned int key[4]);
+#define BLI_ghashutil_inthash_v4_p \
+ ((GSetHashFP)BLI_ghashutil_uinthash_v4)
+unsigned int BLI_ghashutil_inthash_p(const void *ptr);
int BLI_ghashutil_intcmp(const void *a, const void *b);
+/** \} */
+
GHash *BLI_ghash_ptr_new_ex(const char *info,
const unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT;
GHash *BLI_ghash_ptr_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT;
diff --git a/source/blender/editors/include/ED_fluidsim.h b/source/blender/blenlib/BLI_link_utils.h
index 4790dc5e03d..d469b105f93 100644
--- a/source/blender/editors/include/ED_fluidsim.h
+++ b/source/blender/blenlib/BLI_link_utils.h
@@ -15,34 +15,32 @@
* 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) Blender Foundation.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file ED_fluidsim.h
- * \ingroup editors
- */
-
-#ifndef __ED_FLUIDSIM_H__
-#define __ED_FLUIDSIM_H__
-
-struct Object;
-struct FluidsimSettings;
+#ifndef __BLI_LINK_UTILS_H__
+#define __BLI_LINK_UTILS_H__
+/** \file BLI_link_utils.h
+ * \ingroup bli
+ * \brief Single link-list utility macros. (header only api).
+ *
+ * Use this api when the structure defines its own ``next`` pointer
+ * and a double linked list such as #ListBase isnt needed.
+ */
-/* allocates and initializes fluidsim data */
-struct FluidsimSettings *fluidsimSettingsNew(struct Object *srcob);
-
-/* frees internal data itself */
-void fluidsimSettingsFree(struct FluidsimSettings *sb);
-
-/* duplicate internal data */
-struct FluidsimSettings *fluidsimSettingsCopy(struct FluidsimSettings *sb);
-
-#endif /* __ED_FLUIDSIM_H__ */
+#define BLI_LINKS_PREPEND(list, link) { \
+ CHECK_TYPE_PAIR(list, link); \
+ (link)->next = list; \
+ list = link; \
+} (void)0
+
+#define BLI_LINKS_FREE(list) { \
+ while (list) { \
+ void *next = list->next; \
+ MEM_freeN(list); \
+ list = next; \
+ } \
+} (void)0
+
+#endif /* __BLI_LINK_UTILS_H__ */
diff --git a/source/blender/blenlib/BLI_linklist_stack.h b/source/blender/blenlib/BLI_linklist_stack.h
index c2aefc3f283..5f4f98c5a4f 100644
--- a/source/blender/blenlib/BLI_linklist_stack.h
+++ b/source/blender/blenlib/BLI_linklist_stack.h
@@ -56,7 +56,7 @@
#define BLI_LINKSTACK_INIT(var) { \
var = NULL; \
- _##var##_pool = BLI_mempool_create(sizeof(LinkNode), 1, 64, BLI_MEMPOOL_NOP); \
+ _##var##_pool = BLI_mempool_create(sizeof(LinkNode), 0, 64, BLI_MEMPOOL_NOP); \
} (void)0
#define BLI_LINKSTACK_SIZE(var) \
@@ -136,17 +136,32 @@
} (void)0
/* internal use, no null check */
+#define _BLI_SMALLSTACK_DEL_EX(var_src, var_dst) \
+ (void)((_##var_src##_temp = _##var_src##_stack->next), \
+ (_##var_src##_stack->next = _##var_dst##_free), \
+ (_##var_dst##_free = _##var_src##_stack), \
+ (_##var_src##_stack = _##var_src##_temp)) \
+
#define _BLI_SMALLSTACK_DEL(var) \
- (void)((_##var##_temp = _##var##_stack->next), \
- (_##var##_stack->next = _##var##_free), \
- (_##var##_free = _##var##_stack), \
- (_##var##_stack = _##var##_temp)) \
+ _BLI_SMALLSTACK_DEL_EX(var, var) \
/* check for typeof() */
#define BLI_SMALLSTACK_POP(var) \
(_BLI_SMALLSTACK_CAST(var) ((_##var##_stack) ? \
(_BLI_SMALLSTACK_DEL(var), (_##var##_free->link)) : NULL))
+/* support to put the free-node into another stack */
+#define BLI_SMALLSTACK_POP_EX(var_src, var_dst) \
+ (_BLI_SMALLSTACK_CAST(var_src) ((_##var_src##_stack) ? \
+ (_BLI_SMALLSTACK_DEL_EX(var_src, var_dst), (_##var_dst##_free->link)) : NULL))
+
+#define BLI_SMALLSTACK_LAST(var) \
+ (_BLI_SMALLSTACK_CAST(var) ((_##var##_stack) ? \
+ _##var##_stack->link : NULL))
+
+#define BLI_SMALLSTACK_IS_EMPTY(var) \
+ (_BLI_SMALLSTACK_CAST(var) (_##var##_stack != NULL))
+
/* loop over stack members last-added-first */
#define BLI_SMALLSTACK_ITER_BEGIN(var, item) \
{ \
@@ -158,6 +173,13 @@
} \
} (void)0
+#define BLI_SMALLSTACK_SWAP(var_a, var_b) \
+{ \
+ CHECK_TYPE_PAIR(_##var_a##_type, _##var_b##_type); \
+ SWAP(LinkNode *, _##var_a##_stack, _##var_b##_stack); \
+ SWAP(LinkNode *, _##var_a##_free, _##var_b##_free); \
+} (void)0
+
#define BLI_SMALLSTACK_FREE(var) { \
(void)&(_##var##_type); \
} (void)0
diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h
index 5458def8de1..5bd8490db6e 100644
--- a/source/blender/blenlib/BLI_math_base.h
+++ b/source/blender/blenlib/BLI_math_base.h
@@ -241,8 +241,6 @@ MINLINE int mod_i(int i, int n);
MINLINE unsigned int highest_order_bit_i(unsigned int n);
MINLINE unsigned short highest_order_bit_s(unsigned short n);
-MINLINE float shell_angle_to_dist(const float angle);
-
#if defined(_MSC_VER) && (_MSC_VER < 1800)
extern double copysign(double x, double y);
extern double round(double x);
@@ -274,23 +272,29 @@ double double_round(double x, int ndigits);
# 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) || \
- (fabsf(_test_unit) < BLI_ASSERT_UNIT_EPSILON)); \
+ 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) { \
- BLI_assert(dot_vn_vn((const float *)m, (const float *)m, 9) != 0.0); \
+ BLI_assert(dot_vn_vn((const float *)m, (const float *)m, 9) != 0.0); \
} (void)0
# define BLI_ASSERT_ZERO_M4(m) { \
BLI_assert(dot_vn_vn((const float *)m, (const float *)m, 16) != 0.0); \
} (void)0
+# define BLI_ASSERT_UNIT_M3(m) { \
+ BLI_ASSERT_UNIT_V3((m)[0]); \
+ BLI_ASSERT_UNIT_V3((m)[1]); \
+ BLI_ASSERT_UNIT_V3((m)[2]); \
+} (void)0
#else
# define BLI_ASSERT_UNIT_V2(v) (void)(v)
# define BLI_ASSERT_UNIT_V3(v) (void)(v)
# define BLI_ASSERT_UNIT_QUAT(v) (void)(v)
# define BLI_ASSERT_ZERO_M3(m) (void)(m)
# define BLI_ASSERT_ZERO_M4(m) (void)(m)
+# define BLI_ASSERT_UNIT_M3(m) (void)(m)
#endif
#endif /* __BLI_MATH_BASE_H__ */
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index 7dcee518287..f4bcc810846 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -49,13 +49,14 @@ void cent_quad_v3(float r[3], const float a[3], const float b[3], const float c[
float normal_tri_v3(float r[3], const float a[3], const float b[3], const float c[3]);
float normal_quad_v3(float r[3], const float a[3], const float b[3], const float c[3], const float d[3]);
+float normal_poly_v3(float r[3], const float verts[][3], unsigned int nr);
MINLINE float area_tri_v2(const float a[2], const float b[2], const float c[2]);
MINLINE float area_tri_signed_v2(const float v1[2], const float v2[2], const float v3[2]);
float area_tri_v3(const float a[3], const float b[3], const float c[3]);
float area_tri_signed_v3(const float v1[3], const float v2[3], const float v3[3], const float normal[3]);
float area_quad_v3(const float a[3], const float b[3], const float c[3], const float d[3]);
-float area_poly_v3(const float verts[][3], unsigned int nr, const float normal[3]);
+float area_poly_v3(const float verts[][3], unsigned int nr);
float area_poly_v2(const float verts[][2], unsigned int nr);
float cotangent_tri_weight_v3(const float v1[3], const float v2[3], const float v3[3]);
@@ -214,6 +215,8 @@ void barycentric_transform(float pt_tar[3], float const pt_src[3],
void barycentric_weights_v2(const float v1[2], const float v2[2], const float v3[2],
const float co[2], float w[3]);
+void barycentric_weights_v2_persp(const float v1[4], const float v2[4], const float v3[4],
+ const float co[2], float w[3]);
void barycentric_weights_v2_quad(const float v1[2], const float v2[2], const float v3[2], const float v4[2],
const float co[2], float w[4]);
@@ -302,7 +305,7 @@ bool form_factor_visible_quad(const float p[3], const float n[3],
float form_factor_hemi_poly(float p[3], float n[3],
float v1[3], float v2[3], float v3[3], float v4[3]);
-bool axis_dominant_v3_to_m3(float r_mat[3][3], const float normal[3]);
+void axis_dominant_v3_to_m3(float r_mat[3][3], const float normal[3]);
MINLINE void axis_dominant_v3(int *r_axis_a, int *r_axis_b, const float axis[3]);
MINLINE float axis_dominant_v3_max(int *r_axis_a, int *r_axis_b, const float axis[3]) ATTR_WARN_UNUSED_RESULT;
@@ -313,6 +316,12 @@ MINLINE int min_axis_v3(const float vec[3]);
MINLINE int poly_to_tri_count(const int poly_count, const int corner_count);
+MINLINE float shell_angle_to_dist(const float angle);
+MINLINE float shell_v3v3_normalized_to_dist(const float a[3], const float b[3]);
+MINLINE float shell_v2v2_normalized_to_dist(const float a[2], const float b[2]);
+MINLINE float shell_v3v3_mid_normalized_to_dist(const float a[3], const float b[3]);
+MINLINE float shell_v2v2_mid_normalized_to_dist(const float a[2], const float b[2]);
+
/**************************** Inline Definitions ******************************/
#if BLI_MATH_DO_INLINE
diff --git a/source/blender/blenlib/BLI_math_rotation.h b/source/blender/blenlib/BLI_math_rotation.h
index 25c9b5e468f..905889a33d7 100644
--- a/source/blender/blenlib/BLI_math_rotation.h
+++ b/source/blender/blenlib/BLI_math_rotation.h
@@ -84,6 +84,7 @@ void tri_to_quat_ex(float quat[4], const float v1[3], const float v2[3], const f
float tri_to_quat(float q[4], const float a[3], const float b[3], const float c[3]);
void vec_to_quat(float q[4], const float vec[3], short axis, const short upflag);
/* note: v1 and v2 must be normalized */
+void rotation_between_vecs_to_mat3(float m[3][3], const float v1[3], const float v2[3]);
void rotation_between_vecs_to_quat(float q[4], const float v1[3], const float v2[3]);
void rotation_between_quats_to_quat(float q[4], const float q1[4], const float q2[4]);
@@ -106,6 +107,8 @@ void print_qt(const char *str, const float q[4]);
void axis_angle_normalized_to_quat(float r[4], const float axis[3], const float angle);
void axis_angle_to_quat(float r[4], const float axis[3], const float angle);
void axis_angle_to_mat3(float R[3][3], const float axis[3], const float angle);
+void axis_angle_normalized_to_mat3_ex(float mat[3][3], const float axis[3],
+ const float angle_sin, const float angle_cos);
void axis_angle_normalized_to_mat3(float R[3][3], const float axis[3], const float angle);
void axis_angle_to_mat4(float R[4][4], const float axis[3], const float angle);
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index a9edfa0ccff..f816ad53d15 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -261,7 +261,7 @@ void project_v2_v2v2(float c[2], const float v1[2], const float v2[2]);
void project_v3_v3v3(float r[3], const float p[3], const float n[3]);
void project_v3_plane(float v[3], const float n[3], const float p[3]);
void reflect_v3_v3v3(float r[3], const float v[3], const float n[3]);
-void ortho_basis_v3v3_v3(float r1[3], float r2[3], const float a[3]);
+void ortho_basis_v3v3_v3(float r_n1[3], float r_n2[3], const float n[3]);
void ortho_v3_v3(float p[3], const float v[3]);
void ortho_v2_v2(float p[3], const float v[3]);
void bisect_v3_v3v3v3(float r[3], const float a[3], const float b[3], const float c[3]);
@@ -313,6 +313,7 @@ void msub_vn_vn(float *array_tar, const float *array_src, const float f, const i
void msub_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, const float f, const int size);
void interp_vn_vn(float *array_tar, const float *array_src, const float t, const int size);
void fill_vn_i(int *array_tar, const int size, const int val);
+void fill_vn_short(short *array_tar, const int size, const short val);
void fill_vn_ushort(unsigned short *array_tar, const int size, const unsigned short val);
void fill_vn_fl(float *array_tar, const int size, const float val);
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h
index efc5731c7cf..3e98e2ceeae 100644
--- a/source/blender/blenlib/BLI_path_util.h
+++ b/source/blender/blenlib/BLI_path_util.h
@@ -165,6 +165,14 @@ bool BLI_path_cwd(char *path) ATTR_NONNULL();
void BLI_path_rel(char *file, const char *relfile) ATTR_NONNULL();
bool BLI_path_is_rel(const char *path) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
+bool BLI_path_is_unc(const char *path);
+
+#if defined(WIN32)
+void BLI_cleanup_unc_16(wchar_t *path_16);
+void BLI_cleanup_unc(char *path_16, int maxlen);
+#endif
+
+bool BLI_path_suffix(char *string, size_t maxlen, const char *suffix, const char *sep) ATTR_NONNULL();
/* path string comparisons: case-insensitive for Windows, case-sensitive otherwise */
#if defined(WIN32)
diff --git a/source/blender/blenlib/BLI_sys_types.h b/source/blender/blenlib/BLI_sys_types.h
index 8d9ed07668f..b0a8adeef22 100644
--- a/source/blender/blenlib/BLI_sys_types.h
+++ b/source/blender/blenlib/BLI_sys_types.h
@@ -197,9 +197,8 @@ typedef uint64_t u_int64_t;
#endif /* ifdef platform for types */
+#include <stddef.h> /* size_t define */
-/* note: use of (int, TRUE / FALSE) is deprecated,
- * use (bool, true / false) instead */
#ifdef HAVE_STDBOOL_H
# include <stdbool.h>
#elif !defined(__bool_true_false_are_defined) && !defined(__BOOL_DEFINED)
diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h
index b522d95ddae..1c9e75d950a 100644
--- a/source/blender/blenlib/BLI_threads.h
+++ b/source/blender/blenlib/BLI_threads.h
@@ -75,7 +75,7 @@ int BLI_system_thread_count(void); /* gets the number of threads the system
void BLI_system_num_threads_override_set(int num);
int BLI_system_num_threads_override_get(void);
-int BLI_omp_thread_count(void); /* gets the number of openmp threads the system can make use of */
+int BLI_system_thread_count_omp(void);
/* Global Mutex Locks
*
diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h
index ef6edda1118..f70befddc4d 100644
--- a/source/blender/blenlib/BLI_utildefines.h
+++ b/source/blender/blenlib/BLI_utildefines.h
@@ -34,6 +34,7 @@
/* avoid many includes for now */
#include "BLI_sys_types.h"
+#include "BLI_compiler_compat.h"
#ifndef NDEBUG /* for BLI_assert */
#include <stdio.h>
@@ -211,8 +212,10 @@
} (void)0
-#define FTOCHAR(val) (char)(((val) <= 0.0f) ? 0 : (((val) > (1.0f - 0.5f / 255.0f)) ? 255 : ((255.0f * (val)) + 0.5f)))
-#define FTOUSHORT(val) ((val >= 1.0f - 0.5f / 65535) ? 65535 : (val <= 0.0f) ? 0 : (unsigned short)(val * 65535.0f + 0.5f))
+#define FTOCHAR(val) ((CHECK_TYPE_INLINE(val, float)), \
+ (char)(((val) <= 0.0f) ? 0 : (((val) > (1.0f - 0.5f / 255.0f)) ? 255 : ((255.0f * (val)) + 0.5f))))
+#define FTOUSHORT(val) ((CHECK_TYPE_INLINE(val, float)), \
+ ((val >= 1.0f - 0.5f / 65535) ? 65535 : (val <= 0.0f) ? 0 : (unsigned short)(val * 65535.0f + 0.5f)))
#define USHORTTOUCHAR(val) ((unsigned char)(((val) >= 65535 - 128) ? 255 : ((val) + 128) >> 8))
#define F3TOCHAR3(v2, v1) { \
(v1)[0] = FTOCHAR((v2[0])); \
@@ -260,9 +263,9 @@
*(v1 + 2) = *(v2 + 2) + *(v3 + 2) * (fac); \
} (void)0
#define VECMADD(v1, v2, v3, v4) { \
- *(v1) = *(v2) + *(v3) * (*(v4)); \
- *(v1 + 1) = *(v2 + 1) + *(v3 + 1) * (*(v4 + 1)); \
- *(v1 + 2) = *(v2 + 2) + *(v3 + 2) * (*(v4 + 2)); \
+ *(v1) = *(v2) + *(v3) * (*(v4)); \
+ *(v1 + 1) = *(v2 + 1) + *(v3 + 1) * (*(v4 + 1)); \
+ *(v1 + 2) = *(v2 + 2) + *(v3 + 2) * (*(v4 + 2)); \
} (void)0
#define VECSUBFAC(v1, v2, v3, fac) { \
*(v1) = *(v2) - *(v3) * (fac); \
@@ -384,16 +387,9 @@
#define STRCASEEQLEN(a, b, n) (strncasecmp(a, b, n) == 0)
#define STRPREFIX(a, b) (strncmp((a), (b), strlen(b)) == 0)
-
-
/* useful for debugging */
#define AT __FILE__ ":" STRINGIFY(__LINE__)
-/* so we can use __func__ everywhere */
-#if defined(_MSC_VER)
-# define __func__ __FUNCTION__
-#endif
-
/* UNUSED macro, for function argument */
#ifdef __GNUC__
@@ -464,7 +460,7 @@
# define BLI_STATIC_ASSERT(a, msg)
#endif
-/* hints for branch pradiction, only use in code that runs a _lot_ where */
+/* hints for branch prediction, only use in code that runs a _lot_ where */
#ifdef __GNUC__
# define LIKELY(x) __builtin_expect(!!(x), 1)
# define UNLIKELY(x) __builtin_expect(!!(x), 0)
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index 205935f3d14..9e360741b23 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -116,6 +116,7 @@ set(SRC
BLI_buffer.h
BLI_callbacks.h
BLI_compiler_attrs.h
+ BLI_compiler_compat.h
BLI_convexhull2d.h
BLI_dlrbTree.h
BLI_dynlib.h
@@ -135,6 +136,7 @@ set(SRC
BLI_kdopbvh.h
BLI_kdtree.h
BLI_lasso.h
+ BLI_link_utils.h
BLI_linklist.h
BLI_linklist_stack.h
BLI_listbase.h
diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c
index 169b98da267..7b48744bcdf 100644
--- a/source/blender/blenlib/intern/BLI_ghash.c
+++ b/source/blender/blenlib/intern/BLI_ghash.c
@@ -384,6 +384,16 @@ void *BLI_ghash_lookup(GHash *gh, const void *key)
}
/**
+ * A version of #BLI_ghash_lookup which accepts a fallback argument.
+ */
+void *BLI_ghash_lookup_default(GHash *gh, const void *key, void *val_default)
+{
+ Entry *e = ghash_lookup_entry(gh, key);
+ IS_GHASH_ASSERT(gh);
+ return e ? e->val : val_default;
+}
+
+/**
* Lookup a pointer to the value of \a key in \a gh.
*
* \param key The key to lookup.
@@ -559,11 +569,31 @@ void BLI_ghashIterator_init(GHashIterator *ghi, GHash *gh)
ghi->gh = gh;
ghi->curEntry = NULL;
ghi->curBucket = UINT_MAX; /* wraps to zero */
- while (!ghi->curEntry) {
- ghi->curBucket++;
- if (ghi->curBucket == ghi->gh->nbuckets)
- break;
- ghi->curEntry = ghi->gh->buckets[ghi->curBucket];
+ if (gh->nentries) {
+ while (!ghi->curEntry) {
+ ghi->curBucket++;
+ if (UNLIKELY(ghi->curBucket == ghi->gh->nbuckets))
+ break;
+ ghi->curEntry = ghi->gh->buckets[ghi->curBucket];
+ }
+ }
+}
+
+/**
+ * Steps the iterator to the next index.
+ *
+ * \param ghi The iterator.
+ */
+void BLI_ghashIterator_step(GHashIterator *ghi)
+{
+ if (ghi->curEntry) {
+ ghi->curEntry = ghi->curEntry->next;
+ while (!ghi->curEntry) {
+ ghi->curBucket++;
+ if (ghi->curBucket == ghi->gh->nbuckets)
+ break;
+ ghi->curEntry = ghi->gh->buckets[ghi->curBucket];
+ }
}
}
@@ -577,6 +607,8 @@ void BLI_ghashIterator_free(GHashIterator *ghi)
MEM_freeN(ghi);
}
+/* inline functions now */
+#if 0
/**
* Retrieve the key from an iterator.
*
@@ -586,7 +618,7 @@ void BLI_ghashIterator_free(GHashIterator *ghi)
*/
void *BLI_ghashIterator_getKey(GHashIterator *ghi)
{
- return ghi->curEntry ? ghi->curEntry->key : NULL;
+ return ghi->curEntry->key;
}
/**
@@ -598,7 +630,7 @@ void *BLI_ghashIterator_getKey(GHashIterator *ghi)
*/
void *BLI_ghashIterator_getValue(GHashIterator *ghi)
{
- return ghi->curEntry ? ghi->curEntry->val : NULL;
+ return ghi->curEntry->val;
}
/**
@@ -610,25 +642,7 @@ void *BLI_ghashIterator_getValue(GHashIterator *ghi)
*/
void **BLI_ghashIterator_getValue_p(GHashIterator *ghi)
{
- return ghi->curEntry ? &ghi->curEntry->val : NULL;
-}
-
-/**
- * Steps the iterator to the next index.
- *
- * \param ghi The iterator.
- */
-void BLI_ghashIterator_step(GHashIterator *ghi)
-{
- if (ghi->curEntry) {
- ghi->curEntry = ghi->curEntry->next;
- while (!ghi->curEntry) {
- ghi->curBucket++;
- if (ghi->curBucket == ghi->gh->nbuckets)
- break;
- ghi->curEntry = ghi->gh->buckets[ghi->curBucket];
- }
- }
+ return &ghi->curEntry->val;
}
/**
@@ -642,6 +656,7 @@ bool BLI_ghashIterator_done(GHashIterator *ghi)
{
return ghi->curEntry == NULL;
}
+#endif
/** \} */
@@ -676,7 +691,32 @@ int BLI_ghashutil_ptrcmp(const void *a, const void *b)
return (a < b) ? -1 : 1;
}
-unsigned int BLI_ghashutil_inthash(const void *ptr)
+unsigned int BLI_ghashutil_uinthash_v4(const unsigned int key[4])
+{
+ unsigned int hash;
+ hash = key[0];
+ hash *= 37;
+ hash += key[1];
+ hash *= 37;
+ hash += key[2];
+ hash *= 37;
+ hash += key[3];
+ return hash;
+}
+
+unsigned int BLI_ghashutil_uinthash(unsigned int key)
+{
+ key += ~(key << 16);
+ key ^= (key >> 5);
+ key += (key << 3);
+ key ^= (key >> 13);
+ key += ~(key << 9);
+ key ^= (key >> 17);
+
+ return key;
+}
+
+unsigned int BLI_ghashutil_inthash_p(const void *ptr)
{
uintptr_t key = (uintptr_t)ptr;
@@ -707,7 +747,18 @@ int BLI_ghashutil_intcmp(const void *a, const void *b)
*
* note: this is the same hash method that glib 2.34.0 uses.
*/
-unsigned int BLI_ghashutil_strhash(const void *ptr)
+unsigned int BLI_ghashutil_strhash_n(const char *key, size_t n)
+{
+ const signed char *p;
+ unsigned int h = 5381;
+
+ for (p = (const signed char *)key; n-- && *p != '\0'; p++) {
+ h = (h << 5) + h + (unsigned int)*p;
+ }
+
+ return h;
+}
+unsigned int BLI_ghashutil_strhash_p(const void *ptr)
{
const signed char *p;
unsigned int h = 5381;
@@ -774,7 +825,7 @@ GHash *BLI_ghash_ptr_new(const char *info)
GHash *BLI_ghash_str_new_ex(const char *info,
const unsigned int nentries_reserve)
{
- return BLI_ghash_new_ex(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, info,
+ return BLI_ghash_new_ex(BLI_ghashutil_strhash_p, BLI_ghashutil_strcmp, info,
nentries_reserve);
}
GHash *BLI_ghash_str_new(const char *info)
@@ -785,7 +836,7 @@ GHash *BLI_ghash_str_new(const char *info)
GHash *BLI_ghash_int_new_ex(const char *info,
const unsigned int nentries_reserve)
{
- return BLI_ghash_new_ex(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, info,
+ return BLI_ghash_new_ex(BLI_ghashutil_inthash_p, BLI_ghashutil_intcmp, info,
nentries_reserve);
}
GHash *BLI_ghash_int_new(const char *info)
diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c
index 6fdfac2e1cb..6b1fbe855a1 100644
--- a/source/blender/blenlib/intern/BLI_kdopbvh.c
+++ b/source/blender/blenlib/intern/BLI_kdopbvh.c
@@ -617,9 +617,7 @@ static void build_implicit_tree_helper(BVHTree *tree, BVHBuildHelper *data)
data->branches_on_level[0] = 1;
- /* We could stop the loop first (but I am lazy to find out when) */
- /* note: this often causes integer overflow, may be worth avoiding? - campbell */
- for (depth = 1; depth < 32; depth++) {
+ for (depth = 1; (depth < 32) && data->leafs_per_child[depth - 1]; depth++) {
data->branches_on_level[depth] = data->branches_on_level[depth - 1] * data->tree_type;
data->leafs_per_child[depth] = data->leafs_per_child[depth - 1] / data->tree_type;
}
diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c
index 673dfdefe8e..448fefa5979 100644
--- a/source/blender/blenlib/intern/BLI_mempool.c
+++ b/source/blender/blenlib/intern/BLI_mempool.c
@@ -56,6 +56,7 @@
#endif
#define FREEWORD MAKE_ID('f', 'r', 'e', 'e')
+#define USEDWORD MAKE_ID('u', 's', 'e', 'd')
/* currently totalloc isnt used */
// #define USE_TOTALLOC
@@ -97,7 +98,11 @@ typedef struct BLI_mempool_chunk {
* The mempool, stores and tracks memory \a chunks and elements within those chunks \a free.
*/
struct BLI_mempool {
- BLI_mempool_chunk *chunks;
+ BLI_mempool_chunk *chunks; /* single linked list of allocated chunks */
+ /* keep a pointer to the last, so we can append new chunks there
+ * this is needed for iteration so we can loop over chunks in the order added */
+ BLI_mempool_chunk *chunk_tail;
+
unsigned int esize; /* element size in bytes */
unsigned int csize; /* chunk size in bytes */
unsigned int pchunk; /* number of elements per chunk */
@@ -120,8 +125,11 @@ struct BLI_mempool {
# define CHUNK_DATA(chunk) (CHECK_TYPE_INLINE(chunk, BLI_mempool_chunk *), (void *)((chunk) + 1))
#endif
+#define NODE_STEP_NEXT(node) ((void *)((char *)(node) + esize))
+#define NODE_STEP_PREV(node) ((void *)((char *)(node) - esize))
+
/* extra bytes implicitly used for every chunk alloc */
-#ifdef USE_CHUNK_POW2
+#ifdef USE_DATA_PTR
# define CHUNK_OVERHEAD (unsigned int)(MEM_SIZE_OVERHEAD + sizeof(BLI_mempool_chunk))
#else
# define CHUNK_OVERHEAD (unsigned int)(MEM_SIZE_OVERHEAD)
@@ -135,7 +143,7 @@ static unsigned int power_of_2_max_u(unsigned int x)
x = x | (x >> 2);
x = x | (x >> 4);
x = x | (x >> 8);
- x = x | (x >>16);
+ x = x | (x >> 16);
return x + 1;
}
#endif
@@ -185,36 +193,45 @@ static BLI_mempool_chunk *mempool_chunk_alloc(BLI_mempool *pool)
static BLI_freenode *mempool_chunk_add(BLI_mempool *pool, BLI_mempool_chunk *mpchunk,
BLI_freenode *lasttail)
{
- BLI_freenode *curnode = NULL;
- const unsigned int pchunk_last = pool->pchunk - 1;
- char *addr;
+ const unsigned int esize = pool->esize;
+ BLI_freenode *curnode = CHUNK_DATA(mpchunk);
unsigned int j;
- /* prepend */
- mpchunk->next = pool->chunks;
- pool->chunks = mpchunk;
+ /* append */
+ if (pool->chunk_tail) {
+ pool->chunk_tail->next = mpchunk;
+ }
+ else {
+ BLI_assert(pool->chunks == NULL);
+ pool->chunks = mpchunk;
+ }
- if (pool->free == NULL) {
- pool->free = CHUNK_DATA(mpchunk); /* start of the list */
- if (pool->flag & BLI_MEMPOOL_ALLOW_ITER) {
- pool->free->freeword = FREEWORD;
- }
+ mpchunk->next = NULL;
+ pool->chunk_tail = mpchunk;
+
+ if (UNLIKELY(pool->free == NULL)) {
+ pool->free = curnode;
}
/* loop through the allocated data, building the pointer structures */
- for (addr = CHUNK_DATA(mpchunk), j = 0; j != pchunk_last; j++) {
- curnode = ((BLI_freenode *)addr);
- addr += pool->esize;
- curnode->next = (BLI_freenode *)addr;
- if (pool->flag & BLI_MEMPOOL_ALLOW_ITER) {
- if (j != pchunk_last)
- curnode->next->freeword = FREEWORD;
+ j = pool->pchunk;
+ if (pool->flag & BLI_MEMPOOL_ALLOW_ITER) {
+ while (j--) {
+ curnode->next = NODE_STEP_NEXT(curnode);
curnode->freeword = FREEWORD;
+ curnode = curnode->next;
+ }
+ }
+ else {
+ while (j--) {
+ curnode->next = NODE_STEP_NEXT(curnode);
+ curnode = curnode->next;
}
}
- /* terminate the list,
+ /* terminate the list (rewind one)
* will be overwritten if 'curnode' gets passed in again as 'lasttail' */
+ curnode = NODE_STEP_PREV(curnode);
curnode->next = NULL;
#ifdef USE_TOTALLOC
@@ -224,9 +241,6 @@ static BLI_freenode *mempool_chunk_add(BLI_mempool *pool, BLI_mempool_chunk *mpc
/* final pointer in the previously allocated chunk is wrong */
if (lasttail) {
lasttail->next = CHUNK_DATA(mpchunk);
- if (pool->flag & BLI_MEMPOOL_ALLOW_ITER) {
- lasttail->freeword = FREEWORD;
- }
}
return curnode;
@@ -273,6 +287,7 @@ BLI_mempool *BLI_mempool_create(unsigned int esize, unsigned int totelem,
maxchunks = mempool_maxchunks(totelem, pchunk);
pool->chunks = NULL;
+ pool->chunk_tail = NULL;
pool->esize = esize;
pool->csize = esize * pchunk;
@@ -296,10 +311,12 @@ BLI_mempool *BLI_mempool_create(unsigned int esize, unsigned int totelem,
#endif
pool->totused = 0;
- /* allocate the actual chunks */
- for (i = 0; i < maxchunks; i++) {
- BLI_mempool_chunk *mpchunk = mempool_chunk_alloc(pool);
- lasttail = mempool_chunk_add(pool, mpchunk, lasttail);
+ if (totelem) {
+ /* allocate the actual chunks */
+ for (i = 0; i < maxchunks; i++) {
+ BLI_mempool_chunk *mpchunk = mempool_chunk_alloc(pool);
+ lasttail = mempool_chunk_add(pool, mpchunk, lasttail);
+ }
}
#ifdef WITH_MEM_VALGRIND
@@ -311,9 +328,7 @@ BLI_mempool *BLI_mempool_create(unsigned int esize, unsigned int totelem,
void *BLI_mempool_alloc(BLI_mempool *pool)
{
- void *retval = NULL;
-
- pool->totused++;
+ BLI_freenode *free_pop;
if (UNLIKELY(pool->free == NULL)) {
/* need to allocate a new chunk */
@@ -321,19 +336,22 @@ void *BLI_mempool_alloc(BLI_mempool *pool)
mempool_chunk_add(pool, mpchunk, NULL);
}
- retval = pool->free;
+ free_pop = pool->free;
+
+ BLI_assert(pool->chunk_tail->next == NULL);
if (pool->flag & BLI_MEMPOOL_ALLOW_ITER) {
- pool->free->freeword = 0x7FFFFFFF;
+ free_pop->freeword = USEDWORD;
}
- pool->free = pool->free->next;
+ pool->free = free_pop->next;
+ pool->totused++;
#ifdef WITH_MEM_VALGRIND
- VALGRIND_MEMPOOL_ALLOC(pool, retval, pool->esize);
+ VALGRIND_MEMPOOL_ALLOC(pool, free_pop, pool->esize);
#endif
- return retval;
+ return (void *)free_pop;
}
void *BLI_mempool_calloc(BLI_mempool *pool)
@@ -392,14 +410,15 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr)
/* nothing is in use; free all the chunks except the first */
if (UNLIKELY(pool->totused == 0)) {
- BLI_freenode *curnode = NULL;
- char *tmpaddr = NULL;
- unsigned int i;
+ const unsigned int esize = pool->esize;
+ BLI_freenode *curnode;
+ unsigned int j;
BLI_mempool_chunk *first;
first = pool->chunks;
mempool_chunk_free_all(first->next);
first->next = NULL;
+ pool->chunk_tail = first;
#ifdef USE_TOTALLOC
pool->totalloc = pool->pchunk;
@@ -409,12 +428,16 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr)
#ifdef WITH_MEM_VALGRIND
VALGRIND_MEMPOOL_ALLOC(pool, CHUNK_DATA(first), pool->csize);
#endif
- pool->free = CHUNK_DATA(first); /* start of the list */
- for (tmpaddr = CHUNK_DATA(first), i = 0; i < pool->pchunk; i++) {
- curnode = ((BLI_freenode *)tmpaddr);
- tmpaddr += pool->esize;
- curnode->next = (BLI_freenode *)tmpaddr;
+
+ curnode = CHUNK_DATA(first);
+ pool->free = curnode;
+
+ j = pool->pchunk;
+ while (j--) {
+ curnode->next = NODE_STEP_NEXT(curnode);
+ curnode = curnode->next;
}
+ curnode = NODE_STEP_PREV(curnode);
curnode->next = NULL; /* terminate the list */
#ifdef WITH_MEM_VALGRIND
@@ -481,15 +504,16 @@ void **BLI_mempool_as_tableN(BLI_mempool *pool, const char *allocstr)
*/
void BLI_mempool_as_array(BLI_mempool *pool, void *data)
{
+ const unsigned int esize = pool->esize;
BLI_mempool_iter iter;
char *elem, *p = data;
BLI_assert(pool->flag & BLI_MEMPOOL_ALLOW_ITER);
BLI_mempool_iternew(pool, &iter);
while ((elem = BLI_mempool_iterstep(&iter))) {
- memcpy(p, elem, (size_t)pool->esize);
- p += pool->esize;
+ memcpy(p, elem, (size_t)esize);
+ p = NODE_STEP_NEXT(p);
}
- BLI_assert((unsigned int)(p - (char *)data) == pool->totused * pool->esize);
+ BLI_assert((unsigned int)(p - (char *)data) == pool->totused * esize);
}
/**
@@ -626,6 +650,7 @@ void BLI_mempool_clear_ex(BLI_mempool *pool, const int totelem_reserve)
chunks_temp = pool->chunks;
pool->chunks = NULL;
+ pool->chunk_tail = NULL;
while ((mpchunk = chunks_temp)) {
chunks_temp = mpchunk->next;
diff --git a/source/blender/blenlib/intern/boxpack2d.c b/source/blender/blenlib/intern/boxpack2d.c
index 4b51aefbd87..5d01706ebb1 100644
--- a/source/blender/blenlib/intern/boxpack2d.c
+++ b/source/blender/blenlib/intern/boxpack2d.c
@@ -25,16 +25,27 @@
*/
#include <stdlib.h> /* for qsort */
+#include <math.h> /* for fabsf */
#include "MEM_guardedalloc.h"
-#include "BLI_strict_flags.h"
+#include "BLI_utildefines.h"
#include "BLI_boxpack2d.h" /* own include */
+#include "BLI_strict_flags.h"
+
#ifdef __GNUC__
# pragma GCC diagnostic error "-Wpadded"
#endif
+/* de-duplicate as we pack */
+#define USE_MERGE
+/* use strip-free */
+#define USE_FREE_STRIP
+/* slight bias, needed when packing many boxes the _exact_ same size */
+#define USE_PACK_BIAS
+
+
/* BoxPacker for backing 2D rectangles into a square
*
* The defined Below are for internal use only */
@@ -42,7 +53,9 @@ typedef struct BoxVert {
float x;
float y;
- int free; /* could be a char */
+ int free : 8; /* vert status */
+ unsigned int used : 1;
+ unsigned int _pad : 23;
unsigned int index;
struct BoxPack *trb; /* top right box */
@@ -53,68 +66,156 @@ typedef struct BoxVert {
/* Store last intersecting boxes here
* speedup intersection testing */
struct BoxPack *isect_cache[4];
+
+#ifdef USE_PACK_BIAS
+ float bias;
+ int _pad2;
+#endif
} BoxVert;
+#ifdef __GNUC__
+# pragma GCC diagnostic ignored "-Wpadded"
+#endif
+
/* free vert flags */
#define EPSILON 0.0000001f
+#define EPSILON_MERGE 0.00001f
+#ifdef USE_PACK_BIAS
+# define EPSILON_BIAS 0.000001f
+#endif
#define BLF 1
#define TRF 2
#define TLF 4
#define BRF 8
#define CORNERFLAGS (BLF | TRF | TLF | BRF)
+BLI_INLINE int quad_flag(unsigned int q)
+{
+ BLI_assert(q < 4 && q >= 0);
+ return (1 << q);
+}
+
#define BL 0
#define TR 1
#define TL 2
#define BR 3
-#define BOXLEFT(b) ((b)->v[BL]->x)
-#define BOXRIGHT(b) ((b)->v[TR]->x)
-#define BOXBOTTOM(b) ((b)->v[BL]->y)
-#define BOXTOP(b) ((b)->v[TR]->y)
-#define BOXAREA(b) ((b)->w * (b)->h)
-
-#define UPDATE_V34X(b) ((b)->v[TL]->x = (b)->v[BL]->x); \
- ((b)->v[BR]->x = (b)->v[TR]->x)
-#define UPDATE_V34Y(b) ((b)->v[TL]->y = (b)->v[TR]->y); \
- ((b)->v[BR]->y = (b)->v[BL]->y)
-
-/* UNUSED */
-// #define UPDATE_V34(b) UPDATE_V34X(b); UPDATE_V34Y(b)
-
-#define SET_BOXLEFT(b, f) (b)->v[TR]->x = f + (b)->w; \
- (b)->v[BL]->x = f; \
- UPDATE_V34X(b)
-#define SET_BOXRIGHT(b, f) (b)->v[BL]->x = f - (b)->w; \
- (b)->v[TR]->x = f; \
- UPDATE_V34X(b)
-#define SET_BOXBOTTOM(b, f) (b)->v[TR]->y = f + (b)->h; \
- (b)->v[BL]->y = f; \
- UPDATE_V34Y(b)
-#define SET_BOXTOP(b, f) (b)->v[BL]->y = f - (b)->h; \
- (b)->v[TR]->y = f; \
- UPDATE_V34Y(b)
-#define BOXINTERSECT(b1, b2) \
- !(BOXLEFT(b1) + EPSILON >= BOXRIGHT(b2) || \
- BOXBOTTOM(b1) + EPSILON >= BOXTOP(b2) || \
- BOXRIGHT(b1) - EPSILON <= BOXLEFT(b2) || \
- BOXTOP(b1) - EPSILON <= BOXBOTTOM(b2))
+/** \name Box Accessor Functions
+ * \{ */
+
+static float box_xmin_get(const BoxPack *box)
+{
+ return box->v[BL]->x;
+}
+
+static float box_xmax_get(const BoxPack *box)
+{
+ return box->v[TR]->x;
+}
+
+static float box_ymin_get(const BoxPack *box)
+{
+ return box->v[BL]->y;
+}
+
+static float box_ymax_get(const BoxPack *box)
+{
+ return box->v[TR]->y;
+}
+/** \} */
+
+
+/** \name Box Placement
+ * \{ */
+
+BLI_INLINE void box_v34x_update(BoxPack *box)
+{
+ box->v[TL]->x = box->v[BL]->x;
+ box->v[BR]->x = box->v[TR]->x;
+}
+
+BLI_INLINE void box_v34y_update(BoxPack *box)
+{
+ box->v[TL]->y = box->v[TR]->y;
+ box->v[BR]->y = box->v[BL]->y;
+}
+
+static void box_xmin_set(BoxPack *box, const float f)
+{
+ box->v[TR]->x = f + box->w;
+ box->v[BL]->x = f;
+ box_v34x_update(box);
+}
+
+static void box_xmax_set(BoxPack *box, const float f)
+{
+ box->v[BL]->x = f - box->w;
+ box->v[TR]->x = f;
+ box_v34x_update(box);
+}
+
+static void box_ymin_set(BoxPack *box, const float f)
+{
+ box->v[TR]->y = f + box->h;
+ box->v[BL]->y = f;
+ box_v34y_update(box);
+}
+
+static void box_ymax_set(BoxPack *box, const float f)
+{
+ box->v[BL]->y = f - box->h;
+ box->v[TR]->y = f;
+ box_v34y_update(box);
+}
+/** \} */
+
+
+/** \name Box Utils
+ * \{ */
+
+static float box_area(const BoxPack *box)
+{
+ return box->w * box->h;
+}
+
+static bool box_isect(const BoxPack *box_a, const BoxPack *box_b)
+{
+ return !(box_xmin_get(box_a) + EPSILON >= box_xmax_get(box_b) ||
+ box_ymin_get(box_a) + EPSILON >= box_ymax_get(box_b) ||
+ box_xmax_get(box_a) - EPSILON <= box_xmin_get(box_b) ||
+ box_ymax_get(box_a) - EPSILON <= box_ymin_get(box_b));
+}
+
+/** \} */
+
/* compiler should inline */
static float max_ff(const float a, const float b) { return b > a ? b : a; }
+#ifdef USE_PACK_BIAS
+/* set when used is enabled */
+static void vert_bias_update(BoxVert *v)
+{
+ BLI_assert(v->used);
+ v->bias = (v->x * v->y) * EPSILON_BIAS;
+}
+#endif
+
#if 0
#define BOXDEBUG(b) \
printf("\tBox Debug i %i, w:%.3f h:%.3f x:%.3f y:%.3f\n", \
b->index, b->w, b->h, b->x, b->y)
#endif
+/** \name Box/Vert Sorting
+ * \{ */
+
/* qsort function - sort largest to smallest */
static int box_areasort(const void *p1, const void *p2)
{
const BoxPack *b1 = p1, *b2 = p2;
- const float a1 = BOXAREA(b1);
- const float a2 = BOXAREA(b2);
+ const float a1 = box_area(b1);
+ const float a2 = box_area(b2);
if (a1 < a2) return 1;
else if (a1 > a2) return -1;
@@ -122,7 +223,7 @@ static int box_areasort(const void *p1, const void *p2)
}
/* qsort vertex sorting function
- * sorts from lower left to top right It uses the current box's width and height
+ * sorts from lower left to top right It uses the current box's width and height
* as offsets when sorting, this has the result of not placing boxes outside
* the bounds of the existing backed area where possible
* */
@@ -138,40 +239,55 @@ static int vertex_sort(const void *p1, const void *p2)
v1 = vertarray + ((int *)p1)[0];
v2 = vertarray + ((int *)p2)[0];
+#ifdef USE_FREE_STRIP
+ /* push free verts to the end so we can strip */
+ if (UNLIKELY(v1->free == 0 && v2->free == 0)) return 0;
+ else if (UNLIKELY(v1->free == 0)) return 1;
+ else if (UNLIKELY(v2->free == 0)) return -1;
+#endif
+
a1 = max_ff(v1->x + box_width, v1->y + box_height);
a2 = max_ff(v2->x + box_width, v2->y + box_height);
+#ifdef USE_PACK_BIAS
+ a1 += v1->bias;
+ a2 += v2->bias;
+#endif
+
/* sort largest to smallest */
if (a1 > a2) return 1;
else if (a1 < a2) return -1;
return 0;
}
-/* Main boxpacking function accessed from other functions
+/** \} */
+
+/**
+ * Main boxpacking function accessed from other functions
* 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)
*
- * boxarray - a pre allocated array of boxes.
+ * \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
* is that the box array is sorted by area and programs need to be able
* to have some way of writing the boxes back to the original data.
- * len - the number of boxes in the array.
- * tot_width and tot_height are set so you can normalize the data.
+ * \param len: the number of boxes in the array.
+ * \param r_tot_x, r_tot_y: set so you can normalize the data.
* */
-void BLI_box_pack_2d(BoxPack *boxarray, const unsigned int len, float *tot_width, float *tot_height)
+void BLI_box_pack_2d(BoxPack *boxarray, const unsigned int len, float *r_tot_x, float *r_tot_y)
{
- const int quad_flags[4] = {BLF, TRF, TLF, BRF}; /* use for looping */
unsigned int box_index, verts_pack_len, i, j, k;
unsigned int *vertex_pack_indices; /* an array of indices used for sorting verts */
bool isect;
+ float tot_x = 0.0f, tot_y = 0.0f;
BoxPack *box, *box_test; /*current box and another for intersection tests*/
BoxVert *vert; /* the current vert */
if (!len) {
- *tot_width = 0.0f;
- *tot_height = 0.0f;
+ *r_tot_x = tot_x;
+ *r_tot_y = tot_y;
return;
}
@@ -189,32 +305,36 @@ void BLI_box_pack_2d(BoxPack *boxarray, const unsigned int len, float *tot_width
vert->isect_cache[2] = vert->isect_cache[3] = NULL;
vert->free = CORNERFLAGS & ~TRF;
vert->trb = box;
+ vert->used = false;
vert->index = i++;
- box->v[BL] = vert; vert++;
+ box->v[BL] = vert++;
vert->trb = vert->brb = vert->tlb =
vert->isect_cache[0] = vert->isect_cache[1] =
vert->isect_cache[2] = vert->isect_cache[3] = NULL;
vert->free = CORNERFLAGS & ~BLF;
vert->blb = box;
+ vert->used = false;
vert->index = i++;
- box->v[TR] = vert; vert++;
+ box->v[TR] = vert++;
vert->trb = vert->blb = vert->tlb =
vert->isect_cache[0] = vert->isect_cache[1] =
vert->isect_cache[2] = vert->isect_cache[3] = NULL;
vert->free = CORNERFLAGS & ~BRF;
vert->brb = box;
+ vert->used = false;
vert->index = i++;
- box->v[TL] = vert; vert++;
+ box->v[TL] = vert++;
vert->trb = vert->blb = vert->brb =
vert->isect_cache[0] = vert->isect_cache[1] =
vert->isect_cache[2] = vert->isect_cache[3] = NULL;
vert->free = CORNERFLAGS & ~TLF;
- vert->tlb = box;
+ vert->tlb = box;
+ vert->used = false;
vert->index = i++;
- box->v[BR] = vert; vert++;
+ box->v[BR] = vert++;
}
vert = NULL;
@@ -227,14 +347,21 @@ void BLI_box_pack_2d(BoxPack *boxarray, const unsigned int len, float *tot_width
box->v[BR]->free &= ~(BLF | BRF);
box->v[TL]->free &= ~(BLF | TLF);
- *tot_width = box->w;
- *tot_height = box->h;
+ tot_x = box->w;
+ tot_y = box->h;
/* This sets all the vertex locations */
- SET_BOXLEFT(box, 0.0f);
- SET_BOXBOTTOM(box, 0.0f);
+ box_xmin_set(box, 0.0f);
+ box_ymin_set(box, 0.0f);
box->x = box->y = 0.0f;
+ for (i = 0; i < 4; i++) {
+ box->v[i]->used = true;
+#ifdef USE_PACK_BIAS
+ vert_bias_update(box->v[i]);
+#endif
+ }
+
for (i = 0; i < 3; i++)
vertex_pack_indices[i] = box->v[i + 1]->index;
verts_pack_len = 3;
@@ -250,6 +377,15 @@ void BLI_box_pack_2d(BoxPack *boxarray, const unsigned int len, float *tot_width
qsort(vertex_pack_indices, (size_t)verts_pack_len, sizeof(int), vertex_sort);
+#ifdef USE_FREE_STRIP
+ /* strip free vertices */
+ i = verts_pack_len - 1;
+ while ((i != 0) && vertarray[vertex_pack_indices[i]].free == 0) {
+ i--;
+ }
+ verts_pack_len = i + 1;
+#endif
+
/* Pack the box in with the others */
/* sort the verts */
isect = true;
@@ -265,23 +401,23 @@ void BLI_box_pack_2d(BoxPack *boxarray, const unsigned int len, float *tot_width
* */
for (j = 0; (j < 4) && isect; j++) {
- if (vert->free & quad_flags[j]) {
+ if (vert->free & quad_flag(j)) {
switch (j) {
case BL:
- SET_BOXRIGHT(box, vert->x);
- SET_BOXTOP(box, vert->y);
+ box_xmax_set(box, vert->x);
+ box_ymax_set(box, vert->y);
break;
case TR:
- SET_BOXLEFT(box, vert->x);
- SET_BOXBOTTOM(box, vert->y);
+ box_xmin_set(box, vert->x);
+ box_ymin_set(box, vert->y);
break;
case TL:
- SET_BOXRIGHT(box, vert->x);
- SET_BOXBOTTOM(box, vert->y);
+ box_xmax_set(box, vert->x);
+ box_ymin_set(box, vert->y);
break;
case BR:
- SET_BOXLEFT(box, vert->x);
- SET_BOXTOP(box, vert->y);
+ box_xmin_set(box, vert->x);
+ box_ymax_set(box, vert->y);
break;
}
@@ -291,10 +427,10 @@ void BLI_box_pack_2d(BoxPack *boxarray, const unsigned int len, float *tot_width
isect = false;
if ( /* Constrain boxes to positive X/Y values */
- BOXLEFT(box) < 0.0f || BOXBOTTOM(box) < 0.0f ||
+ box_xmin_get(box) < 0.0f || box_ymin_get(box) < 0.0f ||
/* check for last intersected */
(vert->isect_cache[j] &&
- BOXINTERSECT(box, vert->isect_cache[j])))
+ box_isect(box, vert->isect_cache[j])))
{
/* Here we check that the last intersected
* box will intersect with this one using
@@ -308,7 +444,7 @@ void BLI_box_pack_2d(BoxPack *boxarray, const unsigned int len, float *tot_width
* this is really slow, some spatially divided
* data-structure would be better */
for (box_test = boxarray; box_test != box; box_test++) {
- if (BOXINTERSECT(box, box_test)) {
+ if (box_isect(box, box_test)) {
/* Store the last intersecting here as cache
* for faster checking next time around */
vert->isect_cache[j] = box_test;
@@ -321,11 +457,11 @@ void BLI_box_pack_2d(BoxPack *boxarray, const unsigned int len, float *tot_width
if (!isect) {
/* maintain the total width and height */
- (*tot_width) = max_ff(BOXRIGHT(box), (*tot_width));
- (*tot_height) = max_ff(BOXTOP(box), (*tot_height));
+ tot_x = max_ff(box_xmax_get(box), tot_x);
+ tot_y = max_ff(box_ymax_get(box), tot_y);
/* Place the box */
- vert->free &= ~quad_flags[j];
+ vert->free &= (signed char)(~quad_flag(j));
switch (j) {
case TR:
@@ -352,11 +488,11 @@ void BLI_box_pack_2d(BoxPack *boxarray, const unsigned int len, float *tot_width
*
* We can do an else/if here because only the first
* box can be at the very bottom left corner */
- if (BOXLEFT(box) <= 0) {
+ if (box_xmin_get(box) <= 0) {
box->v[TL]->free &= ~(TLF | BLF);
box->v[BL]->free &= ~(TLF | BLF);
}
- else if (BOXBOTTOM(box) <= 0) {
+ else if (box_ymin_get(box) <= 0) {
box->v[BL]->free &= ~(BRF | BLF);
box->v[BR]->free &= ~(BRF | BLF);
}
@@ -367,58 +503,139 @@ void BLI_box_pack_2d(BoxPack *boxarray, const unsigned int len, float *tot_width
* as being used by checking the width or
* height of both boxes */
if (vert->tlb && vert->trb && (box == vert->tlb || box == vert->trb)) {
- if (vert->tlb->h > vert->trb->h) {
+ if (UNLIKELY(fabsf(vert->tlb->h - vert->trb->h) < EPSILON_MERGE)) {
+#ifdef USE_MERGE
+# define A (vert->trb->v[TL])
+# define B (vert->tlb->v[TR])
+# define MASK (BLF | BRF)
+ BLI_assert(A->used != B->used);
+ if (A->used) {
+ A->free &= B->free & ~MASK;
+ B = A;
+ }
+ else {
+ B->free &= A->free & ~MASK;
+ A = B;
+ }
+ BLI_assert((A->free & MASK) == 0);
+# undef A
+# undef B
+# undef MASK
+#else
+ vert->tlb->v[TR]->free &= ~BLF;
+ vert->trb->v[TL]->free &= ~BRF;
+#endif
+ }
+ else if (vert->tlb->h > vert->trb->h) {
vert->trb->v[TL]->free &= ~(TLF | BLF);
}
- else if (vert->tlb->h < vert->trb->h) {
+ else /* if (vert->tlb->h < vert->trb->h) */ {
vert->tlb->v[TR]->free &= ~(TRF | BRF);
}
- else { /*same*/
- vert->tlb->v[TR]->free &= ~BLF;
- vert->trb->v[TL]->free &= ~BRF;
- }
}
else if (vert->blb && vert->brb && (box == vert->blb || box == vert->brb)) {
- if (vert->blb->h > vert->brb->h) {
+ if (UNLIKELY(fabsf(vert->blb->h - vert->brb->h) < EPSILON_MERGE)) {
+#ifdef USE_MERGE
+# define A (vert->blb->v[BR])
+# define B (vert->brb->v[BL])
+# define MASK (TRF | TLF)
+ BLI_assert(A->used != B->used);
+ if (A->used) {
+ A->free &= B->free & ~MASK;
+ B = A;
+ }
+ else {
+ B->free &= A->free & ~MASK;
+ A = B;
+ }
+ BLI_assert((A->free & MASK) == 0);
+# undef A
+# undef B
+# undef MASK
+#else
+ vert->blb->v[BR]->free &= ~TRF;
+ vert->brb->v[BL]->free &= ~TLF;
+#endif
+ }
+ else if (vert->blb->h > vert->brb->h) {
vert->brb->v[BL]->free &= ~(TLF | BLF);
}
- else if (vert->blb->h < vert->brb->h) {
+ else /* if (vert->blb->h < vert->brb->h) */ {
vert->blb->v[BR]->free &= ~(TRF | BRF);
}
- else { /*same*/
- vert->blb->v[BR]->free &= ~TRF;
- vert->brb->v[BL]->free &= ~TLF;
- }
}
/* Horizontal */
if (vert->tlb && vert->blb && (box == vert->tlb || box == vert->blb)) {
- if (vert->tlb->w > vert->blb->w) {
+ if (UNLIKELY(fabsf(vert->tlb->w - vert->blb->w) < EPSILON_MERGE)) {
+#ifdef USE_MERGE
+# define A (vert->blb->v[TL])
+# define B (vert->tlb->v[BL])
+# define MASK (TRF | BRF)
+ BLI_assert(A->used != B->used);
+ if (A->used) {
+ A->free &= B->free & ~MASK;
+ B = A;
+ }
+ else {
+ B->free &= A->free & ~MASK;
+ A = B;
+ }
+ BLI_assert((A->free & MASK) == 0);
+# undef A
+# undef B
+# undef MASK
+#else
+ vert->blb->v[TL]->free &= ~TRF;
+ vert->tlb->v[BL]->free &= ~BRF;
+#endif
+ }
+ else if (vert->tlb->w > vert->blb->w) {
vert->blb->v[TL]->free &= ~(TLF | TRF);
}
- else if (vert->tlb->w < vert->blb->w) {
+ else /* if (vert->tlb->w < vert->blb->w) */ {
vert->tlb->v[BL]->free &= ~(BLF | BRF);
}
- else { /*same*/
- vert->blb->v[TL]->free &= ~TRF;
- vert->tlb->v[BL]->free &= ~BRF;
- }
}
else if (vert->trb && vert->brb && (box == vert->trb || box == vert->brb)) {
- if (vert->trb->w > vert->brb->w) {
+ if (UNLIKELY(fabsf(vert->trb->w - vert->brb->w) < EPSILON_MERGE)) {
+
+#ifdef USE_MERGE
+# define A (vert->brb->v[TR])
+# define B (vert->trb->v[BR])
+# define MASK (TLF | BLF)
+ BLI_assert(A->used != B->used);
+ if (A->used) {
+ A->free &= B->free & ~MASK;
+ B = A;
+ }
+ else {
+ B->free &= A->free & ~MASK;
+ A = B;
+ }
+ BLI_assert((A->free & MASK) == 0);
+# undef A
+# undef B
+# undef MASK
+#else
+ vert->brb->v[TR]->free &= ~TLF;
+ vert->trb->v[BR]->free &= ~BLF;
+#endif
+ }
+ else if (vert->trb->w > vert->brb->w) {
vert->brb->v[TR]->free &= ~(TLF | TRF);
}
- else if (vert->trb->w < vert->brb->w) {
+ else /* if (vert->trb->w < vert->brb->w) */ {
vert->trb->v[BR]->free &= ~(BLF | BRF);
}
- else { /*same*/
- vert->brb->v[TR]->free &= ~TLF;
- vert->trb->v[BR]->free &= ~BLF;
- }
}
/* End logical check */
for (k = 0; k < 4; k++) {
- if (box->v[k] != vert) {
+ if (box->v[k]->used == false) {
+ box->v[k]->used = true;
+#ifdef USE_PACK_BIAS
+ vert_bias_update(box->v[k]);
+#endif
vertex_pack_indices[verts_pack_len] = box->v[k]->index;
verts_pack_len++;
}
@@ -426,14 +643,17 @@ void BLI_box_pack_2d(BoxPack *boxarray, const unsigned int len, float *tot_width
/* The Box verts are only used internally
* Update the box x and y since thats what external
* functions will see */
- box->x = BOXLEFT(box);
- box->y = BOXBOTTOM(box);
+ box->x = box_xmin_get(box);
+ box->y = box_ymin_get(box);
}
}
}
}
}
+ *r_tot_x = tot_x;
+ *r_tot_y = tot_y;
+
/* free all the verts, not really needed because they shouldn't be
* touched anymore but accessing the pointers would crash blender */
for (box_index = 0; box_index < len; box_index++) {
@@ -443,4 +663,3 @@ void BLI_box_pack_2d(BoxPack *boxarray, const unsigned int len, float *tot_width
MEM_freeN(vertex_pack_indices);
MEM_freeN(vertarray);
}
-
diff --git a/source/blender/blenlib/intern/convexhull2d.c b/source/blender/blenlib/intern/convexhull2d.c
index 9f509638e3b..34ee39d8a9b 100644
--- a/source/blender/blenlib/intern/convexhull2d.c
+++ b/source/blender/blenlib/intern/convexhull2d.c
@@ -167,21 +167,17 @@ struct PointRef {
const float *pt; /* 2d vector */
};
-static int pointref_cmp_x(const void *a_, const void *b_)
+static int pointref_cmp_yx(const void *a_, const void *b_)
{
const struct PointRef *a = a_;
const struct PointRef *b = b_;
- if (a->pt[0] > b->pt[0]) return 1;
- else if (a->pt[0] < b->pt[0]) return -1;
- else return 0;
-}
-static int pointref_cmp_y(const void *a_, const void *b_)
-{
- const struct PointRef *a = a_;
- const struct PointRef *b = b_;
if (a->pt[1] > b->pt[1]) return 1;
else if (a->pt[1] < b->pt[1]) return -1;
+
+ if (a->pt[0] > b->pt[0]) return 1;
+ else if (a->pt[0] < b->pt[0]) return -1;
+
else return 0;
}
@@ -207,8 +203,7 @@ int BLI_convexhull_2d(const float (*points)[2], const int n, int r_points[])
}
/* Sort the points by X, then by Y (required by the algorithm) */
- qsort(points_ref, (size_t)n, sizeof(struct PointRef), pointref_cmp_x);
- qsort(points_ref, (size_t)n, sizeof(struct PointRef), pointref_cmp_y);
+ qsort(points_ref, (size_t)n, sizeof(struct PointRef), pointref_cmp_yx);
for (i = 0; i < n; i++) {
memcpy(points_sort[i], points_ref[i].pt, sizeof(float[2]));
diff --git a/source/blender/blenlib/intern/easing.c b/source/blender/blenlib/intern/easing.c
index 2c7bb0a3abe..1f39c2f57b5 100644
--- a/source/blender/blenlib/intern/easing.c
+++ b/source/blender/blenlib/intern/easing.c
@@ -38,6 +38,8 @@
#include "BLI_strict_flags.h"
+/* blend if (amplitude < fabsf(change) */
+#define USE_ELASTIC_BLEND
float BLI_easing_back_ease_in(float time, float begin, float change, float duration, float overshoot)
{
@@ -141,73 +143,116 @@ float BLI_easing_cubic_ease_in_out(float time, float begin, float change, float
return change / 2 * (time * time * time + 2) + begin;
}
+#ifdef USE_ELASTIC_BLEND
+/**
+ * When the amplitude is less then the change, we need to blend
+ * \a f when we're close to the crossing point (int time), else we get an ugly sharp falloff.
+ */
+static float elastic_blend(float time, float change, float duration, float amplitude, float s, float f)
+{
+ if (change) {
+ /* Looks like a magic number,
+ * but this is a part of the sine curve we need to blend from */
+ const float t = fabsf(s);
+ if (amplitude) {
+ f *= amplitude / fabsf(change);
+ }
+ else {
+ f = 0.0f;
+ }
+
+ if (fabsf(time * duration) < t) {
+ float l = fabsf(time * duration) / t;
+ f = (f * l) + (1.0f - l);
+ }
+ }
+
+ return f;
+}
+#endif
+
float BLI_easing_elastic_ease_in(float time, float begin, float change, float duration, float amplitude, float period)
{
float s;
+ float f = 1.0f;
if (time == 0.0f)
return begin;
if ((time /= duration) == 1.0f)
return begin + change;
-
+ time -= 1.0f;
if (!period)
period = duration * 0.3f;
-
if (!amplitude || amplitude < fabsf(change)) {
- amplitude = change;
s = period / 4;
+#ifdef USE_ELASTIC_BLEND
+ f = elastic_blend(time, change, duration, amplitude, s, f);
+#endif
+ amplitude = change;
}
else
s = period / (2 * (float)M_PI) * asinf(change / amplitude);
- time -= 1.0f;
- return -(amplitude * powf(2, 10 * time) * sinf((time * duration - s) * (2 * (float)M_PI) / period)) + begin;
+ return (-f * (amplitude * powf(2, 10 * time) * sinf((time * duration - s) * (2 * (float)M_PI) / period))) + begin;
}
float BLI_easing_elastic_ease_out(float time, float begin, float change, float duration, float amplitude, float period)
{
float s;
+ float f = 1.0f;
if (time == 0.0f)
return begin;
if ((time /= duration) == 1.0f)
return begin + change;
+ time = -time;
if (!period)
period = duration * 0.3f;
if (!amplitude || amplitude < fabsf(change)) {
- amplitude = change;
s = period / 4;
+#ifdef USE_ELASTIC_BLEND
+ f = elastic_blend(time, change, duration, amplitude, s, f);
+#endif
+ amplitude = change;
}
else
s = period / (2 * (float)M_PI) * asinf(change / amplitude);
- return (amplitude * powf(2, -10 * time) * sinf((time * duration - s) * (2 * (float)M_PI) / period) + change + begin);
+ return (f * (amplitude * powf(2, 10 * time) * sinf((time * duration - s) * (2 * (float)M_PI) / period))) + change + begin;
}
float BLI_easing_elastic_ease_in_out(float time, float begin, float change, float duration, float amplitude, float period)
{
float s;
+ float f = 1.0f;
if (time == 0.0f)
return begin;
if ((time /= duration / 2) == 2.0f)
return begin + change;
+ time -= 1.0f;
if (!period)
period = duration * (0.3f * 1.5f);
if (!amplitude || amplitude < fabsf(change)) {
- amplitude = change;
s = period / 4;
+#ifdef USE_ELASTIC_BLEND
+ f = elastic_blend(time, change, duration, amplitude, s, f);
+#endif
+ amplitude = change;
}
else
s = period / (2 * (float)M_PI) * asinf(change / amplitude);
- if (time < 1.0f) {
- time -= 1.0f;
- return -0.5f * (amplitude * powf(2, 10 * time) * sinf((time * duration - s) * (2 * (float)M_PI) / period)) + begin;
- }
- time -= 1.0f;
- return amplitude * powf(2, -10 * time) * sinf((time * duration - s) * (2 * (float)M_PI) / period) * 0.5f + change + begin;
+ if (time < 0.0f) {
+ f *= -0.5f;
+ return (f * (amplitude * powf(2, 10 * time) * sinf((time * duration - s) * (2 * (float)M_PI) / period))) + begin;
+ }
+ else {
+ time = -time;
+ f *= 0.5f;
+ return (f * (amplitude * powf(2, 10 * time) * sinf((time * duration - s) * (2 * (float)M_PI) / period))) + change + begin;
+ }
}
float BLI_easing_expo_ease_in(float time, float begin, float change, float duration)
diff --git a/source/blender/blenlib/intern/edgehash.c b/source/blender/blenlib/intern/edgehash.c
index c191d8b5b55..51a22cc46ab 100644
--- a/source/blender/blenlib/intern/edgehash.c
+++ b/source/blender/blenlib/intern/edgehash.c
@@ -190,7 +190,7 @@ static EdgeHash *edgehash_new(const char *info,
}
eh->buckets = MEM_callocN(eh->nbuckets * sizeof(*eh->buckets), "eh buckets");
- eh->epool = BLI_mempool_create(entry_size, 512, 512, BLI_MEMPOOL_NOP);
+ eh->epool = BLI_mempool_create(entry_size, nentries_reserve, 512, BLI_MEMPOOL_NOP);
return eh;
}
@@ -356,6 +356,16 @@ void *BLI_edgehash_lookup(EdgeHash *eh, unsigned int v0, unsigned int v1)
}
/**
+ * A version of #BLI_edgehash_lookup which accepts a fallback argument.
+ */
+void *BLI_edgehash_lookup_default(EdgeHash *eh, unsigned int v0, unsigned int v1, void *val_default)
+{
+ EdgeEntry *e = edgehash_lookup_entry(eh, v0, v1);
+ IS_EDGEHASH_ASSERT(eh);
+ return e ? e->val : val_default;
+}
+
+/**
* Return boolean true/false if edge (v0,v1) in hash.
*/
bool BLI_edgehash_haskey(EdgeHash *eh, unsigned int v0, unsigned int v1)
@@ -427,13 +437,6 @@ void BLI_edgehash_flag_clear(EdgeHash *eh, unsigned int flag)
/** \name Iterator API
* \{ */
-struct EdgeHashIterator {
- EdgeHash *eh;
- unsigned int curBucket;
- EdgeEntry *curEntry;
-};
-
-
/**
* Create a new EdgeHashIterator. The hash table must not be mutated
* while the iterator is in use, and the iterator will step exactly
@@ -442,16 +445,51 @@ struct EdgeHashIterator {
EdgeHashIterator *BLI_edgehashIterator_new(EdgeHash *eh)
{
EdgeHashIterator *ehi = MEM_mallocN(sizeof(*ehi), "eh iter");
+ BLI_edgehashIterator_init(ehi, eh);
+ return ehi;
+}
+
+/**
+ * Init an already allocated EdgeHashIterator. The hash table must not
+ * be mutated while the iterator is in use, and the iterator will
+ * step exactly BLI_edgehash_size(eh) times before becoming done.
+ *
+ * \param ehi The EdgeHashIterator to initialize.
+ * \param eh The EdgeHash to iterate over.
+ */
+void BLI_edgehashIterator_init(EdgeHashIterator *ehi, EdgeHash *eh)
+{
ehi->eh = eh;
ehi->curEntry = NULL;
ehi->curBucket = UINT_MAX; /* wraps to zero */
- while (!ehi->curEntry) {
- ehi->curBucket++;
- if (ehi->curBucket == ehi->eh->nbuckets)
- break;
- ehi->curEntry = ehi->eh->buckets[ehi->curBucket];
+ if (eh->nentries) {
+ while (!ehi->curEntry) {
+ ehi->curBucket++;
+ if (UNLIKELY(ehi->curBucket == ehi->eh->nbuckets)) {
+ break;
+ }
+
+ ehi->curEntry = ehi->eh->buckets[ehi->curBucket];
+ }
+ }
+}
+
+/**
+ * Steps the iterator to the next index.
+ */
+void BLI_edgehashIterator_step(EdgeHashIterator *ehi)
+{
+ if (ehi->curEntry) {
+ ehi->curEntry = ehi->curEntry->next;
+ while (!ehi->curEntry) {
+ ehi->curBucket++;
+ if (UNLIKELY(ehi->curBucket == ehi->eh->nbuckets)) {
+ break;
+ }
+
+ ehi->curEntry = ehi->eh->buckets[ehi->curBucket];
+ }
}
- return ehi;
}
/**
@@ -462,15 +500,15 @@ void BLI_edgehashIterator_free(EdgeHashIterator *ehi)
MEM_freeN(ehi);
}
+/* inline functions now */
+#if 0
/**
* Retrieve the key from an iterator.
*/
void BLI_edgehashIterator_getKey(EdgeHashIterator *ehi, unsigned int *r_v0, unsigned int *r_v1)
{
- if (ehi->curEntry) {
- *r_v0 = ehi->curEntry->v0;
- *r_v1 = ehi->curEntry->v1;
- }
+ *r_v0 = ehi->curEntry->v0;
+ *r_v1 = ehi->curEntry->v1;
}
/**
@@ -478,7 +516,7 @@ void BLI_edgehashIterator_getKey(EdgeHashIterator *ehi, unsigned int *r_v0, unsi
*/
void *BLI_edgehashIterator_getValue(EdgeHashIterator *ehi)
{
- return ehi->curEntry ? ehi->curEntry->val : NULL;
+ return ehi->curEntry->val;
}
/**
@@ -486,7 +524,7 @@ void *BLI_edgehashIterator_getValue(EdgeHashIterator *ehi)
*/
void **BLI_edgehashIterator_getValue_p(EdgeHashIterator *ehi)
{
- return ehi->curEntry ? &ehi->curEntry->val : NULL;
+ return &ehi->curEntry->val;
}
/**
@@ -494,27 +532,7 @@ void **BLI_edgehashIterator_getValue_p(EdgeHashIterator *ehi)
*/
void BLI_edgehashIterator_setValue(EdgeHashIterator *ehi, void *val)
{
- if (ehi->curEntry) {
- ehi->curEntry->val = val;
- }
-}
-
-/**
- * Steps the iterator to the next index.
- */
-void BLI_edgehashIterator_step(EdgeHashIterator *ehi)
-{
- if (ehi->curEntry) {
- ehi->curEntry = ehi->curEntry->next;
- while (!ehi->curEntry) {
- ehi->curBucket++;
- if (ehi->curBucket == ehi->eh->nbuckets) {
- break;
- }
-
- ehi->curEntry = ehi->eh->buckets[ehi->curBucket];
- }
- }
+ ehi->curEntry->val = val;
}
/**
@@ -524,6 +542,7 @@ bool BLI_edgehashIterator_isDone(EdgeHashIterator *ehi)
{
return (ehi->curEntry == NULL);
}
+#endif
/** \} */
diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c
index 988979b5d0a..39475d73ee0 100644
--- a/source/blender/blenlib/intern/fileops.c
+++ b/source/blender/blenlib/intern/fileops.c
@@ -61,7 +61,6 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
-#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_path_util.h"
#include "BLI_fileops.h"
@@ -86,7 +85,7 @@ int BLI_file_gzip(const char *from, const char *to)
if (gzfile == NULL)
return -1;
file = BLI_open(from, O_BINARY | O_RDONLY, 0);
- if (file < 0)
+ if (file == -1)
return -2;
while (1) {
diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c
index 79f009e8aa3..b3392e28223 100644
--- a/source/blender/blenlib/intern/freetypefont.c
+++ b/source/blender/blenlib/intern/freetypefont.c
@@ -73,7 +73,7 @@ static VChar *freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *
FT_UInt glyph_index;
FT_Outline ftoutline;
float dx, dy;
- int j, k, l, m = 0;
+ int j, k, l, l_first = 0;
/*
* Generate the character 3D data
@@ -84,7 +84,8 @@ static VChar *freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *
/* If loading succeeded, convert the FT glyph to the internal format */
if (!err) {
- int *npoints;
+ /* initialize as -1 to add 1 on first loop each time */
+ int contour_prev;
int *onpoints;
/* First we create entry for the new character to the character list */
@@ -101,28 +102,24 @@ static VChar *freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *
BLI_ghash_insert(vfd->characters, SET_UINT_IN_POINTER(che->index), che);
/* Start converting the FT data */
- npoints = (int *)MEM_mallocN((ftoutline.n_contours) * sizeof(int), "endpoints");
onpoints = (int *)MEM_callocN((ftoutline.n_contours) * sizeof(int), "onpoints");
- /* calculate total points of each contour */
- for (j = 0; j < ftoutline.n_contours; j++) {
- if (j == 0)
- npoints[j] = ftoutline.contours[j] + 1;
- else
- npoints[j] = ftoutline.contours[j] - ftoutline.contours[j - 1];
- }
-
/* get number of on-curve points for beziertriples (including conic virtual on-points) */
- for (j = 0; j < ftoutline.n_contours; j++) {
- for (k = 0; k < npoints[j]; k++) {
+ for (j = 0, contour_prev = -1; j < ftoutline.n_contours; j++) {
+ const int n = ftoutline.contours[j] - contour_prev;
+ contour_prev = ftoutline.contours[j];
+
+ for (k = 0; k < n; k++) {
l = (j > 0) ? (k + ftoutline.contours[j - 1] + 1) : k;
+ if (k == 0) l_first = l;
if (ftoutline.tags[l] == FT_Curve_Tag_On)
onpoints[j]++;
- if (k < npoints[j] - 1) {
- if (ftoutline.tags[l] == FT_Curve_Tag_Conic &&
- ftoutline.tags[l + 1] == FT_Curve_Tag_Conic)
+ {
+ const int l_next = (k < n - 1) ? (l + 1) : l_first;
+ if (ftoutline.tags[l] == FT_Curve_Tag_Conic &&
+ ftoutline.tags[l_next] == FT_Curve_Tag_Conic)
{
onpoints[j]++;
}
@@ -131,7 +128,10 @@ static VChar *freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *
}
/* contour loop, bezier & conic styles merged */
- for (j = 0; j < ftoutline.n_contours; j++) {
+ for (j = 0, contour_prev = -1; j < ftoutline.n_contours; j++) {
+ const int n = ftoutline.contours[j] - contour_prev;
+ contour_prev = ftoutline.contours[j];
+
/* add new curve */
nu = (Nurb *)MEM_callocN(sizeof(struct Nurb), "objfnt_nurb");
bezt = (BezTriple *)MEM_callocN((onpoints[j]) * sizeof(BezTriple), "objfnt_bezt");
@@ -145,15 +145,18 @@ static VChar *freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *
nu->bezt = bezt;
/* individual curve loop, start-end */
- for (k = 0; k < npoints[j]; k++) {
- if (j > 0) l = k + ftoutline.contours[j - 1] + 1; else l = k;
- if (k == 0) m = l;
+ for (k = 0; k < n; k++) {
+ l = (j > 0) ? (k + ftoutline.contours[j - 1] + 1) : k;
+ if (k == 0) l_first = l;
/* virtual conic on-curve points */
- if (k < npoints[j] - 1) {
- if (ftoutline.tags[l] == FT_Curve_Tag_Conic && ftoutline.tags[l + 1] == FT_Curve_Tag_Conic) {
- dx = (ftoutline.points[l].x + ftoutline.points[l + 1].x) * scale / 2.0f;
- dy = (ftoutline.points[l].y + ftoutline.points[l + 1].y) * scale / 2.0f;
+ {
+ const int l_next = (k < n - 1) ? (l + 1) : l_first;
+ if (ftoutline.tags[l] == FT_Curve_Tag_Conic &&
+ ftoutline.tags[l_next] == FT_Curve_Tag_Conic)
+ {
+ dx = (ftoutline.points[l].x + ftoutline.points[l_next].x) * scale / 2.0f;
+ dy = (ftoutline.points[l].y + ftoutline.points[l_next].y) * scale / 2.0f;
/* left handle */
bezt->vec[0][0] = (dx + (2 * ftoutline.points[l].x) * scale) / 3.0f;
@@ -164,8 +167,8 @@ static VChar *freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *
bezt->vec[1][1] = dy;
/* right handle */
- bezt->vec[2][0] = (dx + (2 * ftoutline.points[l + 1].x) * scale) / 3.0f;
- bezt->vec[2][1] = (dy + (2 * ftoutline.points[l + 1].y) * scale) / 3.0f;
+ bezt->vec[2][0] = (dx + (2 * ftoutline.points[l_next].x) * scale) / 3.0f;
+ bezt->vec[2][1] = (dy + (2 * ftoutline.points[l_next].y) * scale) / 3.0f;
bezt->h1 = bezt->h2 = HD_ALIGN;
bezt->radius = 1.0f;
@@ -175,40 +178,24 @@ static VChar *freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *
/* on-curve points */
if (ftoutline.tags[l] == FT_Curve_Tag_On) {
+ const int l_prev = (k > 0) ? (l - 1) : ftoutline.contours[j];
+ const int l_next = (k < n - 1) ? (l + 1) : l_first;
+
/* left handle */
- if (k > 0) {
- if (ftoutline.tags[l - 1] == FT_Curve_Tag_Cubic) {
- bezt->vec[0][0] = ftoutline.points[l - 1].x * scale;
- bezt->vec[0][1] = ftoutline.points[l - 1].y * scale;
- bezt->h1 = HD_FREE;
- }
- else if (ftoutline.tags[l - 1] == FT_Curve_Tag_Conic) {
- bezt->vec[0][0] = (ftoutline.points[l].x + (2 * ftoutline.points[l - 1].x)) * scale / 3.0f;
- bezt->vec[0][1] = (ftoutline.points[l].y + (2 * ftoutline.points[l - 1].y)) * scale / 3.0f;
- bezt->h1 = HD_FREE;
- }
- else {
- bezt->vec[0][0] = ftoutline.points[l].x * scale - (ftoutline.points[l].x - ftoutline.points[l - 1].x) * scale / 3.0f;
- bezt->vec[0][1] = ftoutline.points[l].y * scale - (ftoutline.points[l].y - ftoutline.points[l - 1].y) * scale / 3.0f;
- bezt->h1 = HD_VECT;
- }
+ if (ftoutline.tags[l_prev] == FT_Curve_Tag_Cubic) {
+ bezt->vec[0][0] = ftoutline.points[l_prev].x * scale;
+ bezt->vec[0][1] = ftoutline.points[l_prev].y * scale;
+ bezt->h1 = HD_FREE;
+ }
+ else if (ftoutline.tags[l_prev] == FT_Curve_Tag_Conic) {
+ bezt->vec[0][0] = (ftoutline.points[l].x + (2 * ftoutline.points[l_prev].x)) * scale / 3.0f;
+ bezt->vec[0][1] = (ftoutline.points[l].y + (2 * ftoutline.points[l_prev].y)) * scale / 3.0f;
+ bezt->h1 = HD_FREE;
}
- else { /* first point on curve */
- if (ftoutline.tags[ftoutline.contours[j]] == FT_Curve_Tag_Cubic) {
- bezt->vec[0][0] = ftoutline.points[ftoutline.contours[j]].x * scale;
- bezt->vec[0][1] = ftoutline.points[ftoutline.contours[j]].y * scale;
- bezt->h1 = HD_FREE;
- }
- else if (ftoutline.tags[ftoutline.contours[j]] == FT_Curve_Tag_Conic) {
- bezt->vec[0][0] = (ftoutline.points[l].x + (2 * ftoutline.points[ftoutline.contours[j]].x)) * scale / 3.0f;
- bezt->vec[0][1] = (ftoutline.points[l].y + (2 * ftoutline.points[ftoutline.contours[j]].y)) * scale / 3.0f;
- bezt->h1 = HD_FREE;
- }
- else {
- bezt->vec[0][0] = ftoutline.points[l].x * scale - (ftoutline.points[l].x - ftoutline.points[ftoutline.contours[j]].x) * scale / 3.0f;
- bezt->vec[0][1] = ftoutline.points[l].y * scale - (ftoutline.points[l].y - ftoutline.points[ftoutline.contours[j]].y) * scale / 3.0f;
- bezt->h1 = HD_VECT;
- }
+ else {
+ bezt->vec[0][0] = ftoutline.points[l].x * scale - (ftoutline.points[l].x - ftoutline.points[l_prev].x) * scale / 3.0f;
+ bezt->vec[0][1] = ftoutline.points[l].y * scale - (ftoutline.points[l].y - ftoutline.points[l_prev].y) * scale / 3.0f;
+ bezt->h1 = HD_VECT;
}
/* midpoint (on-curve point) */
@@ -216,39 +203,20 @@ static VChar *freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *
bezt->vec[1][1] = ftoutline.points[l].y * scale;
/* right handle */
- if (k < (npoints[j] - 1)) {
- if (ftoutline.tags[l + 1] == FT_Curve_Tag_Cubic) {
- bezt->vec[2][0] = ftoutline.points[l + 1].x * scale;
- bezt->vec[2][1] = ftoutline.points[l + 1].y * scale;
- bezt->h2 = HD_FREE;
- }
- else if (ftoutline.tags[l + 1] == FT_Curve_Tag_Conic) {
- bezt->vec[2][0] = (ftoutline.points[l].x + (2 * ftoutline.points[l + 1].x)) * scale / 3.0f;
- bezt->vec[2][1] = (ftoutline.points[l].y + (2 * ftoutline.points[l + 1].y)) * scale / 3.0f;
- bezt->h2 = HD_FREE;
- }
- else {
- bezt->vec[2][0] = ftoutline.points[l].x * scale - (ftoutline.points[l].x - ftoutline.points[l + 1].x) * scale / 3.0f;
- bezt->vec[2][1] = ftoutline.points[l].y * scale - (ftoutline.points[l].y - ftoutline.points[l + 1].y) * scale / 3.0f;
- bezt->h2 = HD_VECT;
- }
+ if (ftoutline.tags[l_next] == FT_Curve_Tag_Cubic) {
+ bezt->vec[2][0] = ftoutline.points[l_next].x * scale;
+ bezt->vec[2][1] = ftoutline.points[l_next].y * scale;
+ bezt->h2 = HD_FREE;
}
- else { /* last point on curve */
- if (ftoutline.tags[m] == FT_Curve_Tag_Cubic) {
- bezt->vec[2][0] = ftoutline.points[m].x * scale;
- bezt->vec[2][1] = ftoutline.points[m].y * scale;
- bezt->h2 = HD_FREE;
- }
- else if (ftoutline.tags[m] == FT_Curve_Tag_Conic) {
- bezt->vec[2][0] = (ftoutline.points[l].x + (2 * ftoutline.points[m].x)) * scale / 3.0f;
- bezt->vec[2][1] = (ftoutline.points[l].y + (2 * ftoutline.points[m].y)) * scale / 3.0f;
- bezt->h2 = HD_FREE;
- }
- else {
- bezt->vec[2][0] = ftoutline.points[l].x * scale - (ftoutline.points[l].x - ftoutline.points[m].x) * scale / 3.0f;
- bezt->vec[2][1] = ftoutline.points[l].y * scale - (ftoutline.points[l].y - ftoutline.points[m].y) * scale / 3.0f;
- bezt->h2 = HD_VECT;
- }
+ else if (ftoutline.tags[l_next] == FT_Curve_Tag_Conic) {
+ bezt->vec[2][0] = (ftoutline.points[l].x + (2 * ftoutline.points[l_next].x)) * scale / 3.0f;
+ bezt->vec[2][1] = (ftoutline.points[l].y + (2 * ftoutline.points[l_next].y)) * scale / 3.0f;
+ bezt->h2 = HD_FREE;
+ }
+ else {
+ bezt->vec[2][0] = ftoutline.points[l].x * scale - (ftoutline.points[l].x - ftoutline.points[l_next].x) * scale / 3.0f;
+ bezt->vec[2][1] = ftoutline.points[l].y * scale - (ftoutline.points[l].y - ftoutline.points[l_next].y) * scale / 3.0f;
+ bezt->h2 = HD_VECT;
}
/* get the handles that are aligned, tricky...
@@ -273,8 +241,8 @@ static VChar *freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *
}
}
}
- if (npoints) MEM_freeN(npoints);
- if (onpoints) MEM_freeN(onpoints);
+
+ MEM_freeN(onpoints);
return che;
}
diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c
index 82c6e68ccc2..e6217329145 100644
--- a/source/blender/blenlib/intern/math_base_inline.c
+++ b/source/blender/blenlib/intern/math_base_inline.c
@@ -44,9 +44,6 @@
# define UNLIKELY(x) (x)
#endif
-/* A few small defines. Keep'em local! */
-#define SMALL_NUMBER 1.e-8f
-
MINLINE float sqrt3f(float f)
{
if (UNLIKELY(f == 0.0f)) return 0.0f;
@@ -111,15 +108,6 @@ MINLINE float interpf(float target, float origin, float fac)
return (fac * target) + (1.0f - fac) * origin;
}
-/* useful to calculate an even width shell, by taking the angle between 2 planes.
- * The return value is a scale on the offset.
- * no angle between planes is 1.0, as the angle between the 2 planes approaches 180d
- * the distance gets very high, 180d would be inf, but this case isn't valid */
-MINLINE float shell_angle_to_dist(const float angle)
-{
- return (UNLIKELY(angle < SMALL_NUMBER)) ? 1.0f : fabsf(1.0f / cosf(angle));
-}
-
/* used for zoom values*/
MINLINE float power_of_2(float val)
{
diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c
index 61d55c720b0..57a48bb5fa8 100644
--- a/source/blender/blenlib/intern/math_color.c
+++ b/source/blender/blenlib/intern/math_color.c
@@ -29,10 +29,8 @@
#include <assert.h>
-#include "MEM_guardedalloc.h"
#include "BLI_math.h"
-#include "BLI_rand.h"
#include "BLI_utildefines.h"
#include "BLI_strict_flags.h"
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 01dbe01d152..5f3ab5eb73e 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -30,7 +30,6 @@
#include "MEM_guardedalloc.h"
#include "BLI_math.h"
-#include "BLI_memarena.h"
#include "BLI_utildefines.h"
#include "BLI_strict_flags.h"
@@ -88,6 +87,27 @@ float normal_quad_v3(float n[3], const float v1[3], const float v2[3], const flo
return normalize_v3(n);
}
+/**
+ * Computes the normal of a planar
+ * polygon See Graphics Gems for
+ * computing newell normal.
+ */
+float normal_poly_v3(float n[3], const float verts[][3], unsigned int nr)
+{
+ const float *v_prev = verts[nr - 1];
+ const float *v_curr = verts[0];
+ unsigned int i;
+
+ zero_v3(n);
+
+ /* Newell's Method */
+ for (i = 0; i < nr; v_prev = v_curr, v_curr = verts[++i]) {
+ add_newell_cross_v3_v3v3(n, v_prev, v_curr);
+ }
+
+ return normalize_v3(n);
+}
+
/* only convex Quadrilaterals */
float area_quad_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3])
{
@@ -134,25 +154,10 @@ float area_tri_signed_v3(const float v1[3], const float v2[3], const float v3[3]
return area;
}
-float area_poly_v3(const float verts[][3], unsigned int nr, const float normal[3])
+float area_poly_v3(const float verts[][3], unsigned int nr)
{
- unsigned int a;
- int px, py;
- const float max = axis_dominant_v3_max(&px, &py, normal);
- float area;
- const float *co_curr, *co_prev;
-
- /* The Trapezium Area Rule */
- co_prev = verts[nr - 1];
- co_curr = verts[0];
- area = 0.0f;
- for (a = 0; a < nr; a++) {
- area += (co_curr[px] - co_prev[px]) * (co_curr[py] + co_prev[py]);
- co_prev = co_curr;
- co_curr += 3;
- }
-
- return fabsf(0.5f * area / max);
+ float n[3];
+ return normal_poly_v3(n, verts, nr) * 0.5f;
}
float cross_poly_v2(const float verts[][2], unsigned int nr)
@@ -2127,32 +2132,20 @@ void fill_poly_v2i_n(
* \param r_mat The matrix to return.
* \param normal A unit length vector.
*/
-bool axis_dominant_v3_to_m3(float r_mat[3][3], const float normal[3])
+void axis_dominant_v3_to_m3(float r_mat[3][3], const float normal[3])
{
- float up[3] = {0.0f, 0.0f, 1.0f};
- float axis[3];
- float angle;
-
- /* double check they are normalized */
BLI_ASSERT_UNIT_V3(normal);
- cross_v3_v3v3(axis, normal, up);
- angle = saacos(dot_v3v3(normal, up));
+ copy_v3_v3(r_mat[2], normal);
+ ortho_basis_v3v3_v3(r_mat[0], r_mat[1], r_mat[2]);
- if (angle >= FLT_EPSILON) {
- if (len_squared_v3(axis) < FLT_EPSILON) {
- axis[0] = 0.0f;
- axis[1] = 1.0f;
- axis[2] = 0.0f;
- }
+ BLI_ASSERT_UNIT_V3(r_mat[0]);
+ BLI_ASSERT_UNIT_V3(r_mat[1]);
- axis_angle_to_mat3(r_mat, axis, angle);
- return true;
- }
- else {
- unit_m3(r_mat);
- return false;
- }
+ transpose_m3(r_mat);
+
+ BLI_assert(!is_negative_m3(r_mat));
+ BLI_assert(fabsf(dot_m3_v3_row_z(r_mat, normal) - 1.0f) < BLI_ASSERT_UNIT_EPSILON);
}
/****************************** Interpolation ********************************/
@@ -2278,8 +2271,9 @@ bool barycentric_coords_v2(const float v1[2], const float v2[2], const float v3[
return false;
}
-/* used by projection painting
- * note: using area_tri_signed_v2 means locations outside the triangle are correctly weighted */
+/**
+ * \note: using #area_tri_signed_v2 means locations outside the triangle are correctly weighted
+ */
void barycentric_weights_v2(const float v1[2], const float v2[2], const float v3[2], const float co[2], float w[3])
{
float wtot;
@@ -2297,6 +2291,26 @@ void barycentric_weights_v2(const float v1[2], const float v2[2], const float v3
}
}
+/**
+ * still use 2D X,Y space but this works for verts transformed by a perspective matrix,
+ * using their 4th component as a weight
+ */
+void barycentric_weights_v2_persp(const float v1[4], const float v2[4], const float v3[4], const float co[2], float w[3])
+{
+ float wtot;
+
+ w[0] = area_tri_signed_v2(v2, v3, co) / v1[3];
+ w[1] = area_tri_signed_v2(v3, v1, co) / v2[3];
+ w[2] = area_tri_signed_v2(v1, v2, co) / v3[3];
+ wtot = w[0] + w[1] + w[2];
+
+ if (wtot != 0.0f) {
+ mul_v3_fl(w, 1.0f / wtot);
+ }
+ else /* dummy values for zero area face */
+ w[0] = w[1] = w[2] = 1.0f / 3.0f;
+}
+
/* same as #barycentric_weights_v2 but works with a quad,
* note: untested for values outside the quad's bounds
* this is #interp_weights_poly_v2 expanded for quads only */
@@ -2342,7 +2356,7 @@ void barycentric_weights_v2_quad(const float v1[2], const float v2[2], const flo
#endif
/* inline mean_value_half_tan four times here */
- float t[4] = {
+ const float t[4] = {
MEAN_VALUE_HALF_TAN_V2(area, 0, 1),
MEAN_VALUE_HALF_TAN_V2(area, 1, 2),
MEAN_VALUE_HALF_TAN_V2(area, 2, 3),
@@ -2383,9 +2397,8 @@ void barycentric_transform(float pt_tar[3], float const pt_src[3],
* be re-applied. The weights are applied directly to the targets 3D points and the
* z-depth is used to scale the targets normal as an offset.
* This saves transforming the target into its Z-Up orientation and back (which could also work) */
- const float z_up[3] = {0, 0, 1};
float no_tar[3], no_src[3];
- float quat_src[4];
+ float mat_src[3][3];
float pt_src_xy[3];
float tri_xy_src[3][3];
float w_src[3];
@@ -2395,19 +2408,14 @@ void barycentric_transform(float pt_tar[3], float const pt_src[3],
normal_tri_v3(no_tar, tri_tar_p1, tri_tar_p2, tri_tar_p3);
normal_tri_v3(no_src, tri_src_p1, tri_src_p2, tri_src_p3);
- rotation_between_vecs_to_quat(quat_src, no_src, z_up);
- normalize_qt(quat_src);
-
- copy_v3_v3(pt_src_xy, pt_src);
- copy_v3_v3(tri_xy_src[0], tri_src_p1);
- copy_v3_v3(tri_xy_src[1], tri_src_p2);
- copy_v3_v3(tri_xy_src[2], tri_src_p3);
+ axis_dominant_v3_to_m3(mat_src, no_src);
/* make the source tri xy space */
- mul_qt_v3(quat_src, pt_src_xy);
- mul_qt_v3(quat_src, tri_xy_src[0]);
- mul_qt_v3(quat_src, tri_xy_src[1]);
- mul_qt_v3(quat_src, tri_xy_src[2]);
+ mul_v3_m3v3(pt_src_xy, mat_src, pt_src);
+ mul_v3_m3v3(tri_xy_src[0], mat_src, tri_src_p1);
+ mul_v3_m3v3(tri_xy_src[1], mat_src, tri_src_p2);
+ mul_v3_m3v3(tri_xy_src[2], mat_src, tri_src_p3);
+
barycentric_weights_v2(tri_xy_src[0], tri_xy_src[1], tri_xy_src[2], pt_src_xy, w_src);
interp_v3_v3v3v3(pt_tar, tri_tar_p1, tri_tar_p2, tri_tar_p3, w_src);
@@ -2545,7 +2553,7 @@ void interp_weights_poly_v3(float *w, float v[][3], const int n, const float co[
{
const float eps = 0.00001f; /* take care, low values cause [#36105] */
const float eps_sq = eps * eps;
- float *v_curr, *v_next;
+ const float *v_curr, *v_next;
float ht_prev, ht; /* half tangents */
float totweight = 0.0f;
int i = 0;
@@ -2614,7 +2622,7 @@ void interp_weights_poly_v2(float *w, float v[][2], const int n, const float co[
{
const float eps = 0.00001f; /* take care, low values cause [#36105] */
const float eps_sq = eps * eps;
- float *v_curr, *v_next;
+ const float *v_curr, *v_next;
float ht_prev, ht; /* half tangents */
float totweight = 0.0f;
int i = 0;
@@ -2987,9 +2995,10 @@ void polarview_m4(float Vm[4][4], float dist, float azimuth, float incidence, fl
void lookat_m4(float mat[4][4], float vx, float vy, float vz, float px, float py, float pz, float twist)
{
float sine, cosine, hyp, hyp1, dx, dy, dz;
- float mat1[4][4] = MAT4_UNITY;
+ float mat1[4][4];
unit_m4(mat);
+ unit_m4(mat1);
rotate_m4(mat, 'Z', -twist);
diff --git a/source/blender/blenlib/intern/math_geom_inline.c b/source/blender/blenlib/intern/math_geom_inline.c
index 0e243c5e198..5a64ed63ecf 100644
--- a/source/blender/blenlib/intern/math_geom_inline.c
+++ b/source/blender/blenlib/intern/math_geom_inline.c
@@ -34,6 +34,9 @@
#include <string.h>
+/* A few small defines. Keep'em local! */
+#define SMALL_NUMBER 1.e-8f
+
/********************************** Polygons *********************************/
MINLINE float cross_tri_v2(const float v1[2], const float v2[2], const float v3[2])
@@ -227,4 +230,63 @@ MINLINE float plane_point_side_v3(const float plane[4], const float co[3])
return dot_v3v3(co, plane) + plane[3];
}
+/* useful to calculate an even width shell, by taking the angle between 2 planes.
+ * The return value is a scale on the offset.
+ * no angle between planes is 1.0, as the angle between the 2 planes approaches 180d
+ * the distance gets very high, 180d would be inf, but this case isn't valid */
+MINLINE float shell_angle_to_dist(const float angle)
+{
+ return (UNLIKELY(angle < SMALL_NUMBER)) ? 1.0f : fabsf(1.0f / cosf(angle));
+}
+/**
+ * equivalent to ``shell_angle_to_dist(angle_normalized_v3v3(a, b))``
+ */
+MINLINE float shell_v3v3_normalized_to_dist(const float a[3], const float b[3])
+{
+ const float angle_cos = fabsf(dot_v3v3(a, b));
+ BLI_ASSERT_UNIT_V3(a);
+ BLI_ASSERT_UNIT_V3(b);
+ return (UNLIKELY(angle_cos < SMALL_NUMBER)) ? 1.0f : (1.0f / angle_cos);
+}
+/**
+ * equivalent to ``shell_angle_to_dist(angle_normalized_v2v2(a, b))``
+ */
+MINLINE float shell_v2v2_normalized_to_dist(const float a[2], const float b[2])
+{
+ const float angle_cos = fabsf(dot_v2v2(a, b));
+ BLI_ASSERT_UNIT_V2(a);
+ BLI_ASSERT_UNIT_V2(b);
+ return (UNLIKELY(angle_cos < SMALL_NUMBER)) ? 1.0f : (1.0f / angle_cos);
+}
+
+/**
+ * equivalent to ``shell_angle_to_dist(angle_normalized_v3v3(a, b) / 2)``
+ */
+MINLINE float shell_v3v3_mid_normalized_to_dist(const float a[3], const float b[3])
+{
+ float angle_cos;
+ float ab[3];
+ BLI_ASSERT_UNIT_V3(a);
+ BLI_ASSERT_UNIT_V3(b);
+ add_v3_v3v3(ab, a, b);
+ angle_cos = (normalize_v3(ab) != 0.0f) ? fabsf(dot_v3v3(a, ab)) : 0.0f;
+ return (UNLIKELY(angle_cos < SMALL_NUMBER)) ? 1.0f : (1.0f / angle_cos);
+}
+
+/**
+ * equivalent to ``shell_angle_to_dist(angle_normalized_v2v2(a, b) / 2)``
+ */
+MINLINE float shell_v2v2_mid_normalized_to_dist(const float a[2], const float b[2])
+{
+ float angle_cos;
+ float ab[2];
+ BLI_ASSERT_UNIT_V2(a);
+ BLI_ASSERT_UNIT_V2(b);
+ add_v2_v2v2(ab, a, b);
+ angle_cos = (normalize_v2(ab) != 0.0f) ? fabsf(dot_v2v2(a, ab)) : 0.0f;
+ return (UNLIKELY(angle_cos < SMALL_NUMBER)) ? 1.0f : (1.0f / angle_cos);
+}
+
+#undef SMALL_NUMBER
+
#endif /* __MATH_GEOM_INLINE_C__ */
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index 9fc5909c20d..de272b12ebd 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -400,6 +400,46 @@ float normalize_qt_qt(float r[4], const float q[4])
return normalize_qt(r);
}
+/**
+ * Calculate a rotation matrix from 2 normalized vectors.
+ */
+void rotation_between_vecs_to_mat3(float m[3][3], const float v1[3], const float v2[3])
+{
+ float axis[3];
+ /* avoid calculating the angle */
+ float angle_sin;
+ float angle_cos;
+
+ BLI_ASSERT_UNIT_V3(v1);
+ BLI_ASSERT_UNIT_V3(v2);
+
+ cross_v3_v3v3(axis, v1, v2);
+
+ angle_sin = normalize_v3(axis);
+ angle_cos = dot_v3v3(v1, v2);
+
+ if (angle_sin > FLT_EPSILON) {
+axis_calc:
+ BLI_ASSERT_UNIT_V3(axis);
+ axis_angle_normalized_to_mat3_ex(m, axis, angle_sin, angle_cos);
+ BLI_ASSERT_UNIT_M3(m);
+ }
+ else {
+ if (angle_cos > 0.0f) {
+ /* Same vectors, zero rotation... */
+ unit_m3(m);
+ }
+ else {
+ /* Colinear but opposed vectors, 180 rotation... */
+ ortho_v3_v3(axis, v1);
+ normalize_v3(axis);
+ angle_sin = 0.0f; /* sin(M_PI) */
+ angle_cos = -1.0f; /* cos(M_PI) */
+ goto axis_calc;
+ }
+ }
+}
+
/* note: expects vectors to be normalized */
void rotation_between_vecs_to_quat(float q[4], const float v1[3], const float v2[3])
{
@@ -480,6 +520,7 @@ float angle_qtqt(const float q1[4], const float q2[4])
void vec_to_quat(float q[4], const float vec[3], short axis, const short upflag)
{
+ const float eps = 0.0001f;
float nor[3], tvec[3];
float angle, si, co, len;
@@ -513,7 +554,7 @@ void vec_to_quat(float q[4], const float vec[3], short axis, const short upflag)
nor[1] = -tvec[2];
nor[2] = tvec[1];
- if (fabsf(tvec[1]) + fabsf(tvec[2]) < 0.0001f)
+ if (fabsf(tvec[1]) + fabsf(tvec[2]) < eps)
nor[1] = 1.0f;
co = tvec[0];
@@ -523,7 +564,7 @@ void vec_to_quat(float q[4], const float vec[3], short axis, const short upflag)
nor[1] = 0.0;
nor[2] = -tvec[0];
- if (fabsf(tvec[0]) + fabsf(tvec[2]) < 0.0001f)
+ if (fabsf(tvec[0]) + fabsf(tvec[2]) < eps)
nor[2] = 1.0f;
co = tvec[1];
@@ -533,7 +574,7 @@ void vec_to_quat(float q[4], const float vec[3], short axis, const short upflag)
nor[1] = tvec[0];
nor[2] = 0.0;
- if (fabsf(tvec[0]) + fabsf(tvec[1]) < 0.0001f)
+ if (fabsf(tvec[0]) + fabsf(tvec[1]) < eps)
nor[0] = 1.0f;
co = tvec[2];
@@ -542,12 +583,7 @@ void vec_to_quat(float q[4], const float vec[3], short axis, const short upflag)
normalize_v3(nor);
- angle = 0.5f * saacos(co);
- si = sinf(angle);
- q[0] = cosf(angle);
- q[1] = nor[0] * si;
- q[2] = nor[1] * si;
- q[3] = nor[2] * si;
+ axis_angle_normalized_to_quat(q, nor, saacos(co));
if (axis != upflag) {
float mat[3][3];
@@ -830,31 +866,51 @@ void eulO_to_axis_angle(float axis[3], float *angle, const float eul[3], const s
quat_to_axis_angle(axis, angle, q);
}
-/* axis angle to 3x3 matrix - note: requires that axis is normalized */
-void axis_angle_normalized_to_mat3(float mat[3][3], const float nor[3], const float angle)
+/**
+ * axis angle to 3x3 matrix
+ *
+ * This takes the angle with sin/cos applied so we can avoid calculating it in some cases.
+ *
+ * \param axis rotation axis (must be normalized).
+ * \param co cos(angle)
+ * \param si sin(angle)
+ */
+void axis_angle_normalized_to_mat3_ex(float mat[3][3], const float axis[3],
+ const float angle_sin, const float angle_cos)
{
- float nsi[3], co, si, ico;
+ float nsi[3], ico;
+ float n_00, n_01, n_11, n_02, n_12, n_22;
- BLI_ASSERT_UNIT_V3(nor);
+ BLI_ASSERT_UNIT_V3(axis);
/* now convert this to a 3x3 matrix */
- co = cosf(angle);
- si = sinf(angle);
- ico = (1.0f - co);
- nsi[0] = nor[0] * si;
- nsi[1] = nor[1] * si;
- nsi[2] = nor[2] * si;
+ ico = (1.0f - angle_cos);
+ nsi[0] = axis[0] * angle_sin;
+ nsi[1] = axis[1] * angle_sin;
+ nsi[2] = axis[2] * angle_sin;
+
+ n_00 = (axis[0] * axis[0]) * ico;
+ n_01 = (axis[0] * axis[1]) * ico;
+ n_11 = (axis[1] * axis[1]) * ico;
+ n_02 = (axis[0] * axis[2]) * ico;
+ n_12 = (axis[1] * axis[2]) * ico;
+ n_22 = (axis[2] * axis[2]) * ico;
- mat[0][0] = ((nor[0] * nor[0]) * ico) + co;
- mat[0][1] = ((nor[0] * nor[1]) * ico) + nsi[2];
- mat[0][2] = ((nor[0] * nor[2]) * ico) - nsi[1];
- mat[1][0] = ((nor[0] * nor[1]) * ico) - nsi[2];
- mat[1][1] = ((nor[1] * nor[1]) * ico) + co;
- mat[1][2] = ((nor[1] * nor[2]) * ico) + nsi[0];
- mat[2][0] = ((nor[0] * nor[2]) * ico) + nsi[1];
- mat[2][1] = ((nor[1] * nor[2]) * ico) - nsi[0];
- mat[2][2] = ((nor[2] * nor[2]) * ico) + co;
+ mat[0][0] = n_00 + angle_cos;
+ mat[0][1] = n_01 + nsi[2];
+ mat[0][2] = n_02 - nsi[1];
+ mat[1][0] = n_01 - nsi[2];
+ mat[1][1] = n_11 + angle_cos;
+ mat[1][2] = n_12 + nsi[0];
+ mat[2][0] = n_02 + nsi[1];
+ mat[2][1] = n_12 - nsi[0];
+ mat[2][2] = n_22 + angle_cos;
+}
+
+void axis_angle_normalized_to_mat3(float mat[3][3], const float axis[3], const float angle)
+{
+ axis_angle_normalized_to_mat3_ex(mat, axis, sinf(angle), cosf(angle));
}
@@ -1380,11 +1436,15 @@ void eulO_to_mat4(float M[4][4], const float e[3], const short order)
void mat3_to_eulO(float eul[3], const short order, float M[3][3])
{
float eul1[3], eul2[3];
+ float d1, d2;
mat3_to_eulo2(M, eul1, eul2, order);
+ d1 = fabsf(eul1[0]) + fabsf(eul1[1]) + fabsf(eul1[2]);
+ d2 = fabsf(eul2[0]) + fabsf(eul2[1]) + fabsf(eul2[2]);
+
/* return best, which is just the one with lowest values it in */
- if (fabsf(eul1[0]) + fabsf(eul1[1]) + fabsf(eul1[2]) > fabsf(eul2[0]) + fabsf(eul2[1]) + fabsf(eul2[2])) {
+ if (d1 > d2) {
copy_v3_v3(eul, eul2);
}
else {
@@ -1418,10 +1478,12 @@ void mat3_to_compatible_eulO(float eul[3], float oldrot[3], const short order, f
d2 = fabsf(eul2[0] - oldrot[0]) + fabsf(eul2[1] - oldrot[1]) + fabsf(eul2[2] - oldrot[2]);
/* return best, which is just the one with lowest difference */
- if (d1 > d2)
+ if (d1 > d2) {
copy_v3_v3(eul, eul2);
- else
+ }
+ else {
copy_v3_v3(eul, eul1);
+ }
}
void mat4_to_compatible_eulO(float eul[3], float oldrot[3], const short order, float M[4][4])
@@ -1442,7 +1504,8 @@ void rotate_eulO(float beul[3], const short order, char axis, float ang)
assert(axis >= 'X' && axis <= 'Z');
- eul[0] = eul[1] = eul[2] = 0.0f;
+ zero_v3(eul);
+
if (axis == 'X')
eul[0] = ang;
else if (axis == 'Y')
@@ -1478,9 +1541,7 @@ void eulO_to_gimbal_axis(float gmat[3][3], const float eul[3], const short order
/* Last axis is global */
- gmat[R->axis[2]][0] = 0;
- gmat[R->axis[2]][1] = 0;
- gmat[R->axis[2]][2] = 0;
+ zero_v3(gmat[R->axis[2]]);
gmat[R->axis[2]][R->axis[2]] = 1;
}
@@ -1600,7 +1661,7 @@ void dquat_to_mat4(float mat[4][4], const DualQuat *dq)
void add_weighted_dq_dq(DualQuat *dqsum, const DualQuat *dq, float weight)
{
- int flipped = 0;
+ bool flipped = false;
/* make sure we interpolate quats in the right direction */
if (dot_qtqt(dq->quat, dqsum->quat) < 0) {
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c
index 8455bf7550f..7d3829f04d3 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -583,25 +583,33 @@ void reflect_v3_v3v3(float out[3], const float vec[3], const float normal[3])
out[2] = vec[2] - (dot2 * normal[2]);
}
-void ortho_basis_v3v3_v3(float v1[3], float v2[3], const float v[3])
+/**
+ * Takes a vector and computes 2 orthogonal directions.
+ *
+ * \note if \a n is n unit length, computed values will be too.
+ */
+void ortho_basis_v3v3_v3(float r_n1[3], float r_n2[3], const float n[3])
{
- const float f = sqrtf(v[0] * v[0] + v[1] * v[1]);
+ const float eps = FLT_EPSILON;
+ const float f = len_squared_v2(n);
+
+ if (f > eps) {
+ const float d = 1.0f / sqrtf(f);
- if (f < 1e-35f) {
- // degenerate case
- v1[0] = (v[2] < 0.0f) ? -1.0f : 1.0f;
- v1[1] = v1[2] = v2[0] = v2[2] = 0.0f;
- v2[1] = 1.0f;
+ BLI_assert(finite(d));
+
+ r_n1[0] = n[1] * d;
+ r_n1[1] = -n[0] * d;
+ r_n1[2] = 0.0f;
+ r_n2[0] = -n[2] * r_n1[1];
+ r_n2[1] = n[2] * r_n1[0];
+ r_n2[2] = n[0] * r_n1[1] - n[1] * r_n1[0];
}
else {
- const float d = 1.0f / f;
-
- v1[0] = v[1] * d;
- v1[1] = -v[0] * d;
- v1[2] = 0.0f;
- v2[0] = -v[2] * v1[1];
- v2[1] = v[2] * v1[0];
- v2[2] = v[0] * v1[1] - v[1] * v1[0];
+ /* degenerate case */
+ r_n1[0] = (n[2] < 0.0f) ? -1.0f : 1.0f;
+ r_n1[1] = r_n1[2] = r_n2[0] = r_n2[2] = 0.0f;
+ r_n2[1] = 1.0f;
}
}
@@ -984,6 +992,15 @@ void fill_vn_i(int *array_tar, const int size, const int val)
}
}
+void fill_vn_short(short *array_tar, const int size, const short val)
+{
+ short *tar = array_tar + (size - 1);
+ int i = size;
+ while (i--) {
+ *(tar--) = val;
+ }
+}
+
void fill_vn_ushort(unsigned short *array_tar, const int size, const unsigned short val)
{
unsigned short *tar = array_tar + (size - 1);
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index 594f9bf7bdb..4226a04ca5b 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -31,14 +31,11 @@
* \ingroup bli
*/
-
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
-#include "MEM_guardedalloc.h"
-
#include "DNA_listBase.h"
#include "BLI_utildefines.h"
@@ -53,6 +50,8 @@
#include "GHOST_Path-api.h"
#ifdef WIN32
+# include "MEM_guardedalloc.h"
+
# include "utf_winfunc.h"
# include "utfconv.h"
# include <io.h>
@@ -329,7 +328,7 @@ void BLI_uniquename(ListBase *list, void *vlink, const char *defname, char delim
BLI_uniquename_cb(uniquename_unique_check, &data, defname, delim, GIVE_STRADDR(vlink, name_offs), name_len);
}
-
+static int BLI_path_unc_prefix_len(const char *path); /* defined below in same file */
/* ******************** string encoding ***************** */
@@ -394,7 +393,9 @@ void BLI_cleanup_path(const char *relabase, char *path)
memmove(start, eind, strlen(eind) + 1);
}
- while ( (start = strstr(path, "\\\\")) ) {
+ /* remove two consecutive backslashes, but skip the UNC prefix,
+ * which needs to be preserved */
+ while ( (start = strstr(path + BLI_path_unc_prefix_len(path), "\\\\")) ) {
eind = start + strlen("\\\\") - 1;
memmove(start, eind, strlen(eind) + 1);
}
@@ -463,6 +464,110 @@ bool BLI_path_is_rel(const char *path)
return path[0] == '/' && path[1] == '/';
}
+/* return true if the path is a UNC share */
+bool BLI_path_is_unc(const char *name)
+{
+ return name[0] == '\\' && name[1] == '\\';
+}
+
+/**
+ * Returns the length of the identifying prefix
+ * of a UNC path which can start with '\\' (short version)
+ * or '\\?\' (long version)
+ * If the path is not a UNC path, return 0
+ *
+ * \param name the path name
+ */
+static int BLI_path_unc_prefix_len(const char *path)
+{
+ if (BLI_path_is_unc(path)) {
+ if ((path[2] == '?') && (path[3] == '\\') ) {
+ /* we assume long UNC path like \\?\server\share\folder etc... */
+ return 4;
+ }
+ else {
+ return 2;
+ }
+ }
+
+ return 0;
+}
+
+#if defined(WIN32)
+
+/* return true if the path is absolute ie starts with a drive specifier (eg A:\) or is a UNC path */
+static bool BLI_path_is_abs(const char *name)
+{
+ return (name[1] == ':' && (name[2] == '\\' || name[2] == '/') ) || BLI_path_is_unc(name);
+}
+
+static wchar_t *next_slash(wchar_t *path)
+{
+ wchar_t *slash = path;
+ while (*slash && *slash != L'\\') slash++;
+ return slash;
+}
+
+/* adds a slash if the unc path points sto a share */
+static void BLI_path_add_slash_to_share(wchar_t *uncpath)
+{
+ wchar_t *slash_after_server = next_slash(uncpath + 2);
+ if (*slash_after_server) {
+ wchar_t *slash_after_share = next_slash(slash_after_server + 1);
+ if (!(*slash_after_share)) {
+ slash_after_share[0] = L'\\';
+ slash_after_share[1] = L'\0';
+ }
+ }
+}
+
+static void BLI_path_unc_to_short(wchar_t *unc)
+{
+ wchar_t tmp[PATH_MAX];
+
+ int len = wcslen(unc);
+ int copy_start = 0;
+ /* convert:
+ * \\?\UNC\server\share\folder\... to \\server\share\folder\...
+ * \\?\C:\ to C:\ and \\?\C:\folder\... to C:\folder\...
+ */
+ if ((len > 3) &&
+ (unc[0] == L'\\') &&
+ (unc[1] == L'\\') &&
+ (unc[2] == L'?') &&
+ ((unc[3] == L'\\') || (unc[3] == L'/')))
+ {
+ if ((len > 5) && (unc[5] == L':')) {
+ wcsncpy(tmp, unc + 4, len - 4);
+ tmp[len - 4] = L'\0';
+ wcscpy(unc, tmp);
+ }
+ else if ((len > 7) && (wcsncmp(&unc[4], L"UNC", 3) == 0) &&
+ ((unc[7] == L'\\') || (unc[7] == L'/')))
+ {
+ tmp[0] = L'\\';
+ tmp[1] = L'\\';
+ wcsncpy(tmp + 2, unc + 8, len - 8);
+ tmp[len - 6] = L'\0';
+ wcscpy(unc, tmp);
+ }
+ }
+}
+
+void BLI_cleanup_unc(char *path, int maxlen)
+{
+ wchar_t *tmp_16 = alloc_utf16_from_8(path, 1);
+ BLI_cleanup_unc_16(tmp_16);
+ conv_utf_16_to_8(tmp_16, path, maxlen);
+}
+
+void BLI_cleanup_unc_16(wchar_t *path_16)
+{
+ BLI_path_unc_to_short(path_16);
+ BLI_path_add_slash_to_share(path_16);
+}
+#endif
+
/**
* Replaces *file with a relative version (prefixed by "//") such that BLI_path_abs, given
* the same *relfile, will convert it back to its original value.
@@ -484,7 +589,7 @@ void BLI_path_rel(char *file, const char *relfile)
}
#ifdef WIN32
- if (BLI_strnlen(relfile, 3) > 2 && relfile[1] != ':') {
+ if (BLI_strnlen(relfile, 3) > 2 && !BLI_path_is_abs(relfile)) {
char *ptemp;
/* fix missing volume name in relative base,
* can happen with old recent-files.txt files */
@@ -500,15 +605,35 @@ void BLI_path_rel(char *file, const char *relfile)
}
if (BLI_strnlen(file, 3) > 2) {
- if (temp[1] == ':' && file[1] == ':' && temp[0] != file[0])
+ bool is_unc = BLI_path_is_unc(file);
+
+ /* Ensure paths are both UNC paths or are both drives */
+ if (BLI_path_is_unc(temp) != is_unc) {
+ return;
+ }
+
+ /* Ensure both UNC paths are on the same share */
+ if (is_unc) {
+ int off;
+ int slash = 0;
+ for (off = 0; temp[off] && slash < 4; off++) {
+ if (temp[off] != file[off])
+ return;
+
+ if (temp[off] == '\\')
+ slash++;
+ }
+ }
+ else if (temp[1] == ':' && file[1] == ':' && temp[0] != file[0]) {
return;
+ }
}
#else
BLI_strncpy(temp, relfile, FILE_MAX);
#endif
- BLI_char_switch(temp, '\\', '/');
- BLI_char_switch(file, '\\', '/');
+ BLI_char_switch(temp + BLI_path_unc_prefix_len(temp), '\\', '/');
+ BLI_char_switch(file + BLI_path_unc_prefix_len(file), '\\', '/');
/* remove /./ which confuse the following slash counting... */
BLI_cleanup_path(NULL, file);
@@ -520,8 +645,8 @@ void BLI_path_rel(char *file, const char *relfile)
if (lslash) {
/* find the prefix of the filename that is equal for both filenames.
* This is replaced by the two slashes at the beginning */
- char *p = temp;
- char *q = file;
+ const char *p = temp;
+ const char *q = file;
char *r = res;
#ifdef WIN32
@@ -576,6 +701,48 @@ void BLI_path_rel(char *file, const char *relfile)
}
/**
+ * Appends a suffix to the string, fitting it before the extension
+ *
+ * string = Foo.png, suffix = 123, separator = _
+ * Foo.png -> Foo_123.png
+ *
+ * \param string original (and final) string
+ * \param maxlen Maximum length of string
+ * \param suffix String to append to the original string
+ * \param sep Optional separator character
+ * \return true if succeeded
+ */
+bool BLI_path_suffix(char *string, size_t maxlen, const char *suffix, const char *sep)
+{
+ const size_t string_len = strlen(string);
+ const size_t suffix_len = strlen(suffix);
+ const size_t sep_len = strlen(sep);
+ ssize_t a;
+ char extension[FILE_MAX];
+ bool has_extension = false;
+
+ if (string_len + sep_len + suffix_len >= maxlen)
+ return false;
+
+ for (a = string_len - 1; a >= 0; a--) {
+ if (string[a] == '.') {
+ has_extension = true;
+ break;
+ }
+ else if (ELEM(string[a], '/', '\\')) {
+ break;
+ }
+ }
+
+ if (!has_extension)
+ a = string_len;
+
+ BLI_strncpy(extension, string + a, sizeof(extension));
+ sprintf(string + a, "%s%s%s", sep, suffix, extension);
+ return true;
+}
+
+/**
* Replaces path with the path of its parent directory, returning true if
* it was able to find a parent directory within the pathname.
*/
@@ -727,7 +894,7 @@ bool BLI_path_abs(char *path, const char *basepath)
* blend file as a lib main - we are basically checking for the case that a
* UNIX root '/' is passed.
*/
- if (!wasrelative && (vol[1] != ':' && (vol[0] == '\0' || vol[0] == '/' || vol[0] == '\\'))) {
+ if (!wasrelative && !BLI_path_is_abs(path)) {
char *p = path;
get_default_root(tmp);
// get rid of the slashes at the beginning of the path
@@ -757,24 +924,28 @@ bool BLI_path_abs(char *path, const char *basepath)
#endif
- BLI_strncpy(base, basepath, sizeof(base));
-
- /* file component is ignored, so don't bother with the trailing slash */
- BLI_cleanup_path(NULL, base);
-
/* push slashes into unix mode - strings entering this part are
* potentially messed up: having both back- and forward slashes.
* Here we push into one conform direction, and at the end we
* push them into the system specific dir. This ensures uniformity
* of paths and solving some problems (and prevent potential future
- * ones) -jesterKing. */
- BLI_char_switch(tmp, '\\', '/');
- BLI_char_switch(base, '\\', '/');
+ * ones) -jesterKing.
+ * For UNC paths the first characters containing the UNC prefix
+ * shouldn't be switched as we need to distinguish them from
+ * paths relative to the .blend file -elubie */
+ BLI_char_switch(tmp + BLI_path_unc_prefix_len(tmp), '\\', '/');
/* Paths starting with // will get the blend file as their base,
* this isn't standard in any os but is used in blender all over the place */
if (wasrelative) {
- const char * const lslash = BLI_last_slash(base);
+ const char *lslash;
+ BLI_strncpy(base, basepath, sizeof(base));
+
+ /* file component is ignored, so don't bother with the trailing slash */
+ BLI_cleanup_path(NULL, base);
+ lslash = BLI_last_slash(base);
+ BLI_char_switch(base + BLI_path_unc_prefix_len(base), '\\', '/');
+
if (lslash) {
const int baselen = (int) (lslash - base) + 1; /* length up to and including last "/" */
/* use path for temp storage here, we copy back over it right away */
@@ -823,7 +994,7 @@ bool BLI_path_cwd(char *path)
const int filelen = strlen(path);
#ifdef WIN32
- if (filelen >= 3 && path[1] == ':' && (path[2] == '\\' || path[2] == '/'))
+ if ((filelen >= 3 && BLI_path_is_abs(path)) || BLI_path_is_unc(path))
wasrelative = false;
#else
if (filelen >= 2 && path[0] == '/')
@@ -1369,7 +1540,7 @@ void BLI_clean(char *path)
BLI_char_switch(path + 2, '/', '\\');
}
#else
- BLI_char_switch(path, '\\', '/');
+ BLI_char_switch(path + BLI_path_unc_prefix_len(path), '\\', '/');
#endif
}
@@ -1486,9 +1657,12 @@ void BLI_make_file_string(const char *relabase, char *string, const char *dir, c
BLI_strncpy(string, dir, 3);
dir += 2;
}
+ else if (BLI_strnlen(dir, 3) >= 2 && BLI_path_is_unc(dir)) {
+ string[0] = 0;
+ }
else { /* no drive specified */
/* first option: get the drive from the relabase if it has one */
- if (relabase && strlen(relabase) >= 2 && relabase[1] == ':') {
+ if (relabase && BLI_strnlen(relabase, 3) >= 2 && relabase[1] == ':') {
BLI_strncpy(string, relabase, 3);
string[2] = '\\';
string[3] = '\0';
@@ -1590,7 +1764,7 @@ bool BLI_testextensie_glob(const char *str, const char *ext_fnmatch)
char pattern[16];
while (ext_step[0]) {
- char *ext_next;
+ const char *ext_next;
int len_ext;
if ((ext_next = strchr(ext_step, ';'))) {
@@ -1924,8 +2098,8 @@ int BLI_rebase_path(char *abs, size_t abs_len,
*/
const char *BLI_first_slash(const char *string)
{
- char * const ffslash = strchr(string, '/');
- char * const fbslash = strchr(string, '\\');
+ const char * const ffslash = strchr(string, '/');
+ const char * const fbslash = strchr(string, '\\');
if (!ffslash) return fbslash;
else if (!fbslash) return ffslash;
diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c
index 69049b51f87..05e4984d9a3 100644
--- a/source/blender/blenlib/intern/scanfill.c
+++ b/source/blender/blenlib/intern/scanfill.c
@@ -865,7 +865,7 @@ unsigned int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const
/* Newell's Method */
/* Similar code used elsewhere, but this checks for double ups
* which historically this function supports so better not change */
- float *v_prev;
+ const float *v_prev;
zero_v3(n);
eve = sf_ctx->fillvertbase.last;
diff --git a/source/blender/blenlib/intern/scanfill_utils.c b/source/blender/blenlib/intern/scanfill_utils.c
index 1ece34a0944..828cb3a580b 100644
--- a/source/blender/blenlib/intern/scanfill_utils.c
+++ b/source/blender/blenlib/intern/scanfill_utils.c
@@ -319,7 +319,7 @@ static bool scanfill_preprocess_self_isect(
ScanFillVert *v_prev;
ScanFillVert *v_curr;
- int inside = false;
+ bool inside = false;
/* first vert */
#if 0
diff --git a/source/blender/blenlib/intern/smallhash.c b/source/blender/blenlib/intern/smallhash.c
index 9177b2fae36..d6b2383bd47 100644
--- a/source/blender/blenlib/intern/smallhash.c
+++ b/source/blender/blenlib/intern/smallhash.c
@@ -55,7 +55,6 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
-#include "BLI_alloca.h"
#include "BLI_smallhash.h"
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c
index de40cab425d..2c6fc9f2058 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -361,7 +361,7 @@ static void bli_adddirstrings(struct BuildDirCtx *dir_ctx)
BLI_strncpy(file->owner, pwuser->pw_name, sizeof(file->owner));
}
else {
- BLI_snprintf(file->owner, sizeof(file->owner), "%d", file->s.st_uid);
+ BLI_snprintf(file->owner, sizeof(file->owner), "%u", file->s.st_uid);
}
}
#endif
@@ -478,16 +478,29 @@ int BLI_exists(const char *name)
#else
struct _stati64 st;
#endif
- /* in Windows stat doesn't recognize dir ending on a slash
- * To not break code where the ending slash is expected we
- * don't mess with the argument name directly here - elubie */
- wchar_t *tmp_16 = alloc_utf16_from_8(name, 0);
+ wchar_t *tmp_16 = alloc_utf16_from_8(name, 1);
int len, res;
unsigned int old_error_mode;
len = wcslen(tmp_16);
- if (len > 3 && (tmp_16[len - 1] == L'\\' || tmp_16[len - 1] == L'/'))
+ /* in Windows #stat doesn't recognize dir ending on a slash
+ * so we remove it here */
+ if (len > 3 && (tmp_16[len - 1] == L'\\' || tmp_16[len - 1] == L'/')) {
tmp_16[len - 1] = '\0';
+ }
+ /* two special cases where the trailing slash is needed:
+ * 1. after the share part of a UNC path
+ * 2. after the C:\ when the path is the volume only
+ */
+ if ((len >= 3) && (tmp_16[0] == L'\\') && (tmp_16[1] == L'\\')) {
+ BLI_cleanup_unc_16(tmp_16);
+ }
+
+ if ((tmp_16[1] == L':') && (tmp_16[2] == L'\0')) {
+ tmp_16[2] = L'\\';
+ tmp_16[3] = L'\0';
+ }
+
/* change error mode so user does not get a "no disk in drive" popup
* when looking for a file on an empty CD/DVD drive */
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c
index bbc135479ef..892bb16a543 100644
--- a/source/blender/blenlib/intern/string.c
+++ b/source/blender/blenlib/intern/string.c
@@ -289,7 +289,7 @@ escape_finish:
char *BLI_str_quoted_substrN(const char *__restrict str, const char *__restrict prefix)
{
size_t prefixLen = strlen(prefix);
- char *startMatch, *endMatch;
+ const char *startMatch, *endMatch;
/* get the starting point (i.e. where prefix starts, and add prefixLen+1 to it to get be after the first " */
startMatch = strstr(str, prefix) + prefixLen + 1;
diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c
index be933269fb5..74e979a8579 100644
--- a/source/blender/blenlib/intern/string_utf8.c
+++ b/source/blender/blenlib/intern/string_utf8.c
@@ -536,7 +536,7 @@ unsigned int BLI_str_utf8_as_unicode_step(const char *__restrict p, size_t *__re
if (UNLIKELY(len == -1)) {
/* when called with NULL end, result will never be NULL,
* checks for a NULL character */
- char *p_next = BLI_str_find_next_char_utf8(p, NULL);
+ const char *p_next = BLI_str_find_next_char_utf8(p, NULL);
/* will never return the same pointer unless '\0',
* eternal loop is prevented */
*index += (size_t)(p_next - p);
diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c
index 95986b11292..ded2fd7e06d 100644
--- a/source/blender/blenlib/intern/threads.c
+++ b/source/blender/blenlib/intern/threads.c
@@ -54,25 +54,10 @@
# include <sys/time.h>
#endif
-#ifdef _OPENMP
-#include <omp.h>
-#endif
-
-#if defined(__APPLE__) && defined(_OPENMP)
-#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 2) && !defined(__clang__)
+#if defined(__APPLE__) && defined(_OPENMP) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2) && !defined(__clang__)
# define USE_APPLE_OMP_FIX
#endif
-/* how many cores not counting HT aka physical cores */
-static int system_physical_thread_count(void)
-{
- int ptcount;
- size_t ptcount_len = sizeof(ptcount);
- sysctlbyname("hw.physicalcpu", &ptcount, &ptcount_len, NULL, 0);
- return ptcount;
-}
-#endif // __APPLE__
-
#ifdef USE_APPLE_OMP_FIX
/* ************** libgomp (Apple gcc 4.2.1) TLS bug workaround *************** */
extern pthread_key_t gomp_tls_key;
@@ -350,22 +335,6 @@ void BLI_end_threads(ListBase *threadbase)
/* System Information */
-/* gets the number of openmp threads the system can make use of */
-int BLI_omp_thread_count(void)
-{
- int t;
-#ifdef _OPENMP
-#ifdef __APPLE__
- t = system_physical_thread_count();
-#else
- t = omp_get_num_procs();
-#endif
-#else
- t = 1;
-#endif
- return t;
-}
-
/* how many threads are native on this system? */
int BLI_system_thread_count(void)
{
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index 5dcf875a32b..d9bcfc2e8f9 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -42,7 +42,6 @@
#include "BLI_utildefines.h"
#include "BLI_path_util.h"
-#include "BLI_fileops.h"
#include "BLI_ghash.h"
#include "BLI_linklist.h"
#include "BLI_listbase.h"
@@ -55,7 +54,6 @@
#include "BKE_main.h"
#include "BKE_library.h" // for BKE_main_free
#include "BKE_idcode.h"
-#include "BKE_report.h"
#include "BLO_readfile.h"
#include "BLO_undofile.h"
@@ -102,8 +100,8 @@ void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp)
if (bhead->code == ENDB)
break;
else {
- short *sp = fd->filesdna->structs[bhead->SDNAnr];
- char *name = fd->filesdna->types[sp[0]];
+ const short *sp = fd->filesdna->structs[bhead->SDNAnr];
+ const char *name = fd->filesdna->types[sp[0]];
char buf[4];
buf[0] = (bhead->code >> 24) & 0xFF;
@@ -131,7 +129,7 @@ LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, int ofblocktype,
for (bhead = blo_firstbhead(fd); bhead; bhead = blo_nextbhead(fd, bhead)) {
if (bhead->code == ofblocktype) {
- char *idname = bhead_id_name(fd, bhead);
+ const char *idname = bhead_id_name(fd, bhead);
BLI_linklist_prepend(&names, strdup(idname + 2));
tot++;
@@ -156,7 +154,7 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to
for (bhead = blo_firstbhead(fd); bhead; bhead = blo_nextbhead(fd, bhead)) {
if (bhead->code == ofblocktype) {
- char *idname = bhead_id_name(fd, bhead);
+ const char *idname = bhead_id_name(fd, bhead);
switch (GS(idname)) {
case ID_MA: /* fall through */
case ID_TE: /* fall through */
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index bcbfdc78013..066c4ea67f1 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -106,54 +106,40 @@
#include "BLI_endian_switch.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
-#include "BLI_edgehash.h"
#include "BLI_threads.h"
#include "BLI_mempool.h"
#include "BLF_translation.h"
-#include "BKE_anim.h"
-#include "BKE_action.h"
#include "BKE_armature.h"
#include "BKE_brush.h"
-#include "BKE_colortools.h"
#include "BKE_constraint.h"
#include "BKE_context.h"
#include "BKE_curve.h"
-#include "BKE_deform.h"
#include "BKE_depsgraph.h"
#include "BKE_effect.h"
#include "BKE_fcurve.h"
#include "BKE_global.h" // for G
#include "BKE_group.h"
-#include "BKE_image.h"
-#include "BKE_lattice.h"
#include "BKE_library.h" // for which_libbase
#include "BKE_idcode.h"
-#include "BKE_idprop.h"
#include "BKE_material.h"
#include "BKE_main.h" // for Main
#include "BKE_mesh.h" // for ME_ defines (patching)
#include "BKE_modifier.h"
#include "BKE_multires.h"
#include "BKE_node.h" // for tree type defines
-#include "BKE_ocean.h"
#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
-#include "BKE_property.h" // for BKE_bproperty_object_get
#include "BKE_report.h"
#include "BKE_sca.h" // for init_actuator
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_sequencer.h"
-#include "BKE_text.h" // for txt_extended_ascii_as_utf8
-#include "BKE_texture.h"
-#include "BKE_tracking.h"
#include "BKE_treehash.h"
#include "BKE_sound.h"
-#include "BKE_writeffmpeg.h"
#include "IMB_imbuf.h" // for proxy / timecode versioning stuff
@@ -537,7 +523,7 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab
// printf("blo_find_main: converted to %s\n", name1);
for (m = mainlist->first; m; m = m->next) {
- char *libname = (m->curlib) ? m->curlib->filepath : m->name;
+ const char *libname = (m->curlib) ? m->curlib->filepath : m->name;
if (BLI_path_cmp(name1, libname) == 0) {
if (G.debug & G_DEBUG) printf("blo_find_main: found library %s\n", libname);
@@ -2394,6 +2380,7 @@ static bNodeTree *nodetree_from_id(ID *id)
case ID_WO: return ((World *)id)->nodetree;
case ID_LA: return ((Lamp *)id)->nodetree;
case ID_TE: return ((Tex *)id)->nodetree;
+ case ID_LS: return ((FreestyleLineStyle *)id)->nodetree;
}
return NULL;
}
@@ -2462,7 +2449,7 @@ static void lib_verify_nodetree(Main *main, int UNUSED(open))
} FOREACH_NODETREE_END
{
- int has_old_groups = 0;
+ bool has_old_groups = false;
/* XXX this should actually be part of do_versions, but since we need
* finished library linking, it is not possible there. Instead in do_versions
* we have set the NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2 flag, so at this point we can do the
@@ -2752,12 +2739,12 @@ typedef struct tConstraintLinkData {
ID *id;
} tConstraintLinkData;
/* callback function used to relink constraint ID-links */
-static void lib_link_constraint_cb(bConstraint *UNUSED(con), ID **idpoin, short isReference, void *userdata)
+static void lib_link_constraint_cb(bConstraint *UNUSED(con), ID **idpoin, bool is_reference, void *userdata)
{
tConstraintLinkData *cld= (tConstraintLinkData *)userdata;
/* for reference types, we need to increment the usercounts on load... */
- if (isReference) {
+ if (is_reference) {
/* reference type - with usercount */
*idpoin = newlibadr_us(cld->fd, cld->id->lib, *idpoin);
}
@@ -2787,7 +2774,7 @@ static void lib_link_constraints(FileData *fd, ID *id, ListBase *conlist)
cld.fd = fd;
cld.id = id;
- BKE_id_loop_constraints(conlist, lib_link_constraint_cb, &cld);
+ BKE_constraints_id_loop(conlist, lib_link_constraint_cb, &cld);
}
static void direct_link_constraints(FileData *fd, ListBase *lb)
@@ -3052,7 +3039,7 @@ static void lib_link_key(FileData *fd, Main *main)
static void switch_endian_keyblock(Key *key, KeyBlock *kb)
{
int elemsize, a, b;
- char *data, *poin, *cp;
+ const char *data, *poin, *cp;
elemsize = key->elemsize;
data = kb->data;
@@ -4333,7 +4320,7 @@ static void lib_link_object(FileData *fd, Main *main)
/* When the object is local and the data is library its possible
* the material list size gets out of sync. [#22663] */
if (ob->data && ob->id.lib != ((ID *)ob->data)->lib) {
- short *totcol_data = give_totcolp(ob);
+ const short *totcol_data = give_totcolp(ob);
/* Only expand so as not to loose any object materials that might be set. */
if (totcol_data && (*totcol_data > ob->totcol)) {
/* printf("'%s' %d -> %d\n", ob->id.name, ob->totcol, *totcol_data); */
@@ -5982,7 +5969,10 @@ void blo_lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *cursc
else if (sl->spacetype == SPACE_BUTS) {
SpaceButs *sbuts = (SpaceButs *)sl;
sbuts->pinid = restore_pointer_by_name(newmain, sbuts->pinid, USER_IGNORE);
- //XXX if (sbuts->ri) sbuts->ri->curtile = 0;
+
+ /* TODO: restore path pointers: T40046
+ * (complicated because this contains data pointers too, not just ID)*/
+ MEM_SAFE_FREE(sbuts->path);
}
else if (sl->spacetype == SPACE_FILE) {
SpaceFile *sfile = (SpaceFile *)sl;
@@ -6924,6 +6914,8 @@ static void lib_link_linestyle(FileData *fd, Main *main)
{
FreestyleLineStyle *linestyle;
LineStyleModifier *m;
+ MTex *mtex;
+ int a;
linestyle = main->linestyle.first;
while (linestyle) {
@@ -6964,6 +6956,17 @@ static void lib_link_linestyle(FileData *fd, Main *main)
break;
}
}
+ for (a=0; a < MAX_MTEX; a++) {
+ mtex = linestyle->mtex[a];
+ if (mtex) {
+ mtex->tex = newlibadr_us(fd, linestyle->id.lib, mtex->tex);
+ mtex->object = newlibadr(fd, linestyle->id.lib, mtex->object);
+ }
+ }
+ if (linestyle->nodetree) {
+ lib_link_ntree(fd, &linestyle->id, linestyle->nodetree);
+ linestyle->nodetree->id.lib = linestyle->id.lib;
+ }
}
linestyle = linestyle->id.next;
}
@@ -7073,6 +7076,7 @@ static void direct_link_linestyle_geometry_modifier(FileData *UNUSED(fd), LineSt
static void direct_link_linestyle(FileData *fd, FreestyleLineStyle *linestyle)
{
+ int a;
LineStyleModifier *modifier;
linestyle->adt= newdataadr(fd, linestyle->adt);
@@ -7089,6 +7093,14 @@ static void direct_link_linestyle(FileData *fd, FreestyleLineStyle *linestyle)
link_list(fd, &linestyle->geometry_modifiers);
for (modifier = linestyle->geometry_modifiers.first; modifier; modifier = modifier->next)
direct_link_linestyle_geometry_modifier(fd, modifier);
+ for (a = 0; a < MAX_MTEX; a++) {
+ linestyle->mtex[a] = newdataadr(fd, linestyle->mtex[a]);
+ }
+ linestyle->nodetree = newdataadr(fd, linestyle->nodetree);
+ if (linestyle->nodetree) {
+ direct_link_id(fd, &linestyle->nodetree->id);
+ direct_link_nodetree(fd, linestyle->nodetree);
+ }
}
/* ************** GENERAL & MAIN ******************** */
@@ -8208,7 +8220,7 @@ typedef struct tConstraintExpandData {
Main *mainvar;
} tConstraintExpandData;
/* callback function used to expand constraint ID-links */
-static void expand_constraint_cb(bConstraint *UNUSED(con), ID **idpoin, short UNUSED(isReference), void *userdata)
+static void expand_constraint_cb(bConstraint *UNUSED(con), ID **idpoin, bool UNUSED(is_reference), void *userdata)
{
tConstraintExpandData *ced = (tConstraintExpandData *)userdata;
expand_doit(ced->fd, ced->mainvar, *idpoin);
@@ -8223,7 +8235,7 @@ static void expand_constraints(FileData *fd, Main *mainvar, ListBase *lb)
ced.fd = fd;
ced.mainvar = mainvar;
- BKE_id_loop_constraints(lb, expand_constraint_cb, &ced);
+ BKE_constraints_id_loop(lb, expand_constraint_cb, &ced);
/* deprecated manual expansion stuff */
for (curcon = lb->first; curcon; curcon = curcon->next) {
@@ -8489,6 +8501,8 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce)
{
if (seq->scene) expand_doit(fd, mainvar, seq->scene);
if (seq->scene_camera) expand_doit(fd, mainvar, seq->scene_camera);
+ if (seq->clip) expand_doit(fd, mainvar, seq->clip);
+ if (seq->mask) expand_doit(fd, mainvar, seq->mask);
if (seq->sound) expand_doit(fd, mainvar, seq->sound);
}
SEQ_END
@@ -8574,8 +8588,18 @@ static void expand_mask(FileData *fd, Main *mainvar, Mask *mask)
static void expand_linestyle(FileData *fd, Main *mainvar, FreestyleLineStyle *linestyle)
{
+ int a;
LineStyleModifier *m;
+ for (a = 0; a < MAX_MTEX; a++) {
+ if (linestyle->mtex[a]) {
+ expand_doit(fd, mainvar, linestyle->mtex[a]->tex);
+ expand_doit(fd, mainvar, linestyle->mtex[a]->object);
+ }
+ }
+ if (linestyle->nodetree)
+ expand_nodetree(fd, mainvar, linestyle->nodetree);
+
if (linestyle->adt)
expand_animdata(fd, mainvar, linestyle->adt);
for (m = linestyle->color_modifiers.first; m; m = m->next) {
diff --git a/source/blender/blenloader/intern/runtime.c b/source/blender/blenloader/intern/runtime.c
index ca9f2faf998..d6fd2f92443 100644
--- a/source/blender/blenloader/intern/runtime.c
+++ b/source/blender/blenloader/intern/runtime.c
@@ -72,7 +72,7 @@ int BLO_is_a_runtime(const char *path)
int datastart;
char buf[8];
- if (fd < 0)
+ if (fd == -1)
goto cleanup;
lseek(fd, -12, SEEK_END);
@@ -104,7 +104,7 @@ BlendFileData *BLO_read_runtime(const char *path, ReportList *reports)
fd = BLI_open(path, O_BINARY | O_RDONLY, 0);
- if (fd < 0) {
+ if (fd == -1) {
BKE_reportf(reports, RPT_ERROR, "Unable to open '%s': %s", path, strerror(errno));
goto cleanup;
}
diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c
index 17600d1fcd1..06d871c8db0 100644
--- a/source/blender/blenloader/intern/versioning_250.c
+++ b/source/blender/blenloader/intern/versioning_250.c
@@ -69,7 +69,6 @@
#include "BLI_utildefines.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
-#include "BLI_edgehash.h"
#include "BKE_anim.h"
#include "BKE_armature.h"
@@ -1267,7 +1266,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
Lattice *lt;
Curve *cu;
Key *key;
- float *data;
+ const float *data;
int a, tot;
/* shape keys are no longer applied to the mesh itself, but rather
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index 8fadfa69fac..ada32aadbe2 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -34,25 +34,82 @@
/* allow readfile to use deprecated functionality */
#define DNA_DEPRECATED_ALLOW
-#include "DNA_curve_types.h"
+#include "DNA_constraint_types.h"
#include "DNA_sdna_types.h"
#include "DNA_space_types.h"
#include "DNA_screen_types.h"
#include "DNA_object_types.h"
+#include "DNA_mesh_types.h"
#include "DNA_modifier_types.h"
-#include "DNA_sdna_types.h"
+#include "DNA_linestyle_types.h"
#include "DNA_genfile.h"
+#include "BLI_blenlib.h"
+#include "BLI_math.h"
#include "BKE_main.h"
#include "BKE_node.h"
+#include "BLI_math.h"
+#include "BLI_string.h"
+
#include "BLO_readfile.h"
#include "readfile.h"
+static void do_version_constraints_radians_degrees_270_1(ListBase *lb)
+{
+ bConstraint *con;
+
+ for (con = lb->first; con; con = con->next) {
+ if (con->type == CONSTRAINT_TYPE_TRANSFORM) {
+ bTransformConstraint *data = (bTransformConstraint *)con->data;
+ const float deg_to_rad_f = DEG2RADF(1.0f);
+
+ if (data->from == TRANS_ROTATION) {
+ mul_v3_fl(data->from_min, deg_to_rad_f);
+ mul_v3_fl(data->from_max, deg_to_rad_f);
+ }
+
+ if (data->to == TRANS_ROTATION) {
+ mul_v3_fl(data->to_min, deg_to_rad_f);
+ mul_v3_fl(data->to_max, deg_to_rad_f);
+ }
+ }
+ }
+}
+
+static void do_version_constraints_radians_degrees_270_5(ListBase *lb)
+{
+ bConstraint *con;
+
+ for (con = lb->first; con; con = con->next) {
+ if (con->type == CONSTRAINT_TYPE_TRANSFORM) {
+ bTransformConstraint *data = (bTransformConstraint *)con->data;
+
+ if (data->from == TRANS_ROTATION) {
+ copy_v3_v3(data->from_min_rot, data->from_min);
+ copy_v3_v3(data->from_max_rot, data->from_max);
+ }
+ else if (data->from == TRANS_SCALE) {
+ copy_v3_v3(data->from_min_scale, data->from_min);
+ copy_v3_v3(data->from_max_scale, data->from_max);
+ }
+
+ if (data->to == TRANS_ROTATION) {
+ copy_v3_v3(data->to_min_rot, data->to_min);
+ copy_v3_v3(data->to_max_rot, data->to_max);
+ }
+ else if (data->to == TRANS_SCALE) {
+ copy_v3_v3(data->to_min_scale, data->to_min);
+ copy_v3_v3(data->to_max_scale, data->to_max);
+ }
+ }
+ }
+}
+
void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
{
if (!MAIN_VERSION_ATLEAST(main, 270, 0)) {
@@ -110,4 +167,116 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
}
+
+ if (!MAIN_VERSION_ATLEAST(main, 270, 1)) {
+ Scene *sce;
+ Object *ob;
+
+ /* Update Transform constraint (another deg -> rad stuff). */
+ for (ob = main->object.first; ob; ob = ob->id.next) {
+ do_version_constraints_radians_degrees_270_1(&ob->constraints);
+
+ if (ob->pose) {
+ /* Bones constraints! */
+ bPoseChannel *pchan;
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ do_version_constraints_radians_degrees_270_1(&pchan->constraints);
+ }
+ }
+ }
+
+ for (sce = main->scene.first; sce; sce = sce->id.next) {
+ if (sce->r.raytrace_structure == R_RAYSTRUCTURE_BLIBVH) {
+ sce->r.raytrace_structure = R_RAYSTRUCTURE_AUTO;
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(main, 270, 2)) {
+ Mesh *me;
+
+ /* Mesh smoothresh deg->rad. */
+ for (me = main->mesh.first; me; me = me->id.next) {
+ me->smoothresh = DEG2RADF(me->smoothresh);
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(main, 270, 3)) {
+ FreestyleLineStyle *linestyle;
+
+ for (linestyle = main->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)) {
+ /* 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) {
+ ScrArea *sa;
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ ARegion *ar;
+ ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
+
+ for (ar = lb->first; ar; ar = ar->next) {
+ BLI_listbase_clear(&ar->ui_previews);
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(main, 270, 5)) {
+ Object *ob;
+
+ /* Update Transform constraint (again :|). */
+ for (ob = main->object.first; ob; ob = ob->id.next) {
+ do_version_constraints_radians_degrees_270_5(&ob->constraints);
+
+ if (ob->pose) {
+ /* Bones constraints! */
+ bPoseChannel *pchan;
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ do_version_constraints_radians_degrees_270_5(&pchan->constraints);
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "Material", "int", "mode2")) {
+ Material *ma;
+
+ for (ma = main->mat.first; ma; ma = ma->id.next)
+ ma->mode2 = MA_CASTSHADOW;
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "BakeData", "bake")) {
+ Scene *sce;
+
+ for (sce = main->scene.first; sce; sce = sce->id.next) {
+ sce->r.bake.flag = R_BAKE_CLEAR;
+ sce->r.bake.width = 512;
+ sce->r.bake.height = 512;
+ sce->r.bake.margin = 16;
+ sce->r.bake.normal_space = R_BAKE_SPACE_TANGENT;
+ sce->r.bake.normal_swizzle[0] = R_BAKE_POSX;
+ sce->r.bake.normal_swizzle[1] = R_BAKE_POSY;
+ sce->r.bake.normal_swizzle[2] = R_BAKE_POSZ;
+ BLI_strncpy(sce->r.bake.filepath, U.renderdir, sizeof(sce->r.bake.filepath));
+
+ sce->r.bake.im_format.planes = R_IMF_PLANES_RGBA;
+ sce->r.bake.im_format.imtype = R_IMF_IMTYPE_PNG;
+ sce->r.bake.im_format.depth = R_IMF_CHAN_DEPTH_8;
+ sce->r.bake.im_format.quality = 90;
+ sce->r.bake.im_format.compress = 15;
+ }
+ }
}
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index b14402e72db..1e881eb11f9 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -26,6 +26,7 @@
*/
#include "BLI_utildefines.h"
+#include "BLI_math.h"
#include "DNA_freestyle_types.h"
#include "DNA_linestyle_types.h"
@@ -33,6 +34,7 @@
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "DNA_userdef_types.h"
+#include "DNA_mesh_types.h"
#include "BKE_main.h"
@@ -45,6 +47,7 @@ void BLO_update_defaults_startup_blend(Main *main)
Scene *scene;
SceneRenderLayer *srl;
FreestyleLineStyle *linestyle;
+ Mesh *me;
for (scene = main->scene.first; scene; scene = scene->id.next) {
scene->r.im_format.planes = R_IMF_PLANES_RGBA;
@@ -56,8 +59,12 @@ void BLO_update_defaults_startup_blend(Main *main)
}
}
- for (linestyle = main->linestyle.first; linestyle; linestyle = linestyle->id.next)
- linestyle->flag = LS_SAME_OBJECT;
+ for (linestyle = main->linestyle.first; linestyle; linestyle = linestyle->id.next) {
+ linestyle->flag = LS_SAME_OBJECT | LS_NO_SORTING | LS_TEXTURE;
+ linestyle->sort_key = LS_SORT_KEY_DISTANCE_FROM_CAMERA;
+ linestyle->integration_type = LS_INTEGRATION_MEAN;
+ linestyle->texstep = 1.0;
+ }
{
bScreen *screen;
@@ -75,5 +82,9 @@ void BLO_update_defaults_startup_blend(Main *main)
}
}
}
+
+ for (me = main->mesh.first; me; me = me->id.next) {
+ me->smoothresh = DEG2RADF(180.0f);
+ }
}
diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c
index 0283d9b04fb..572c6d0a02d 100644
--- a/source/blender/blenloader/intern/versioning_legacy.c
+++ b/source/blender/blenloader/intern/versioning_legacy.c
@@ -77,14 +77,12 @@
#include "BLI_utildefines.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
-#include "BLI_edgehash.h"
#include "BKE_armature.h"
#include "BKE_colortools.h"
#include "BKE_constraint.h"
#include "BKE_deform.h"
#include "BKE_fcurve.h"
-#include "BKE_global.h" // for G
#include "BKE_image.h"
#include "BKE_lattice.h"
#include "BKE_main.h" // for Main
@@ -541,7 +539,7 @@ void blo_do_version_old_trackto_to_constraints(Object *ob)
{
/* create new trackto constraint from the relationship */
if (ob->track) {
- bConstraint *con = BKE_add_ob_constraint(ob, "AutoTrack", CONSTRAINT_TYPE_TRACKTO);
+ bConstraint *con = BKE_constraint_add_for_object(ob, "AutoTrack", CONSTRAINT_TYPE_TRACKTO);
bTrackToConstraint *data = con->data;
/* copy tracking settings from the object */
@@ -3572,8 +3570,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
Object *ob;
World *wrld;
for (ob = main->object.first; ob; ob = ob->id.next) {
- /* pad3 is used for m_contactProcessingThreshold */
- ob->m_contactProcessingThreshold = 1.0f;
if (ob->parent) {
/* check if top parent has compound shape set and if yes, set this object
* to compound shaper as well (was the behavior before, now it's optional) */
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 46e735245b4..45139789f1e 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -143,7 +143,6 @@
#include "BLI_bitmap.h"
#include "BLI_blenlib.h"
#include "BLI_linklist.h"
-#include "BLI_math.h"
#include "BLI_mempool.h"
#include "BKE_action.h"
@@ -152,7 +151,6 @@
#include "BKE_curve.h"
#include "BKE_constraint.h"
#include "BKE_global.h" // for G
-#include "BKE_idprop.h"
#include "BKE_library.h" // for set_listbasepointers
#include "BKE_main.h"
#include "BKE_node.h"
@@ -344,7 +342,7 @@ static int endwrite(WriteData *wd)
static void writestruct_at_address(WriteData *wd, int filecode, const char *structname, int nr, void *adr, void *data)
{
BHead bh;
- short *sp;
+ const short *sp;
if (adr==NULL || data==NULL || nr==0) return;
@@ -1265,7 +1263,7 @@ static void write_constraints(WriteData *wd, ListBase *conlist)
bConstraint *con;
for (con=conlist->first; con; con=con->next) {
- bConstraintTypeInfo *cti= BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti= BKE_constraint_typeinfo_get(con);
/* Write the specific data */
if (cti && con->data) {
@@ -1337,7 +1335,7 @@ static void write_pose(WriteData *wd, bPose *pose)
/* write IK param */
if (pose->ikparam) {
- char *structname = (char *)BKE_pose_ikparam_get_name(pose);
+ const char *structname = (char *)BKE_pose_ikparam_get_name(pose);
if (structname)
writestruct(wd, DATA, structname, 1, pose->ikparam);
}
@@ -1784,7 +1782,7 @@ static void write_customdata(WriteData *wd, ID *id, int count, CustomData *data,
write_mdisps(wd, count, layer->data, layer->flag & CD_FLAG_EXTERNAL);
}
else if (layer->type == CD_PAINT_MASK) {
- float *layer_data = layer->data;
+ const float *layer_data = layer->data;
writedata(wd, DATA, sizeof(*layer_data) * count, layer_data);
}
else if (layer->type == CD_GRID_PAINT_MASK) {
@@ -2091,7 +2089,7 @@ static void write_worlds(WriteData *wd, ListBase *idbase)
if (wrld->mtex[a]) writestruct(wd, DATA, "MTex", 1, wrld->mtex[a]);
}
- /* nodetree is integral part of lamps, no libdata */
+ /* nodetree is integral part of world, no libdata */
if (wrld->nodetree) {
writestruct(wd, DATA, "bNodeTree", 1, wrld->nodetree);
write_nodetree(wd, wrld->nodetree);
@@ -3250,6 +3248,7 @@ static void write_linestyle_geometry_modifiers(WriteData *wd, ListBase *modifier
static void write_linestyles(WriteData *wd, ListBase *idbase)
{
FreestyleLineStyle *linestyle;
+ int a;
for (linestyle = idbase->first; linestyle; linestyle = linestyle->id.next) {
if (linestyle->id.us>0 || wd->current) {
@@ -3262,6 +3261,13 @@ static void write_linestyles(WriteData *wd, ListBase *idbase)
write_linestyle_alpha_modifiers(wd, &linestyle->alpha_modifiers);
write_linestyle_thickness_modifiers(wd, &linestyle->thickness_modifiers);
write_linestyle_geometry_modifiers(wd, &linestyle->geometry_modifiers);
+ for (a=0; a<MAX_MTEX; a++) {
+ if (linestyle->mtex[a]) writestruct(wd, DATA, "MTex", 1, linestyle->mtex[a]);
+ }
+ if (linestyle->nodetree) {
+ writestruct(wd, DATA, "bNodeTree", 1, linestyle->nodetree);
+ write_nodetree(wd, linestyle->nodetree);
+ }
}
}
}
@@ -3469,7 +3475,7 @@ int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportL
BLI_snprintf(tempname, sizeof(tempname), "%s@", filepath);
file = BLI_open(tempname, O_BINARY+O_WRONLY+O_CREAT+O_TRUNC, 0666);
- if (file < 0) {
+ if (file == -1) {
BKE_reportf(reports, RPT_ERROR, "Cannot open file %s for writing: %s", tempname, strerror(errno));
return 0;
}
diff --git a/source/blender/bmesh/bmesh_class.h b/source/blender/bmesh/bmesh_class.h
index 01e4c911d19..83b02764046 100644
--- a/source/blender/bmesh/bmesh_class.h
+++ b/source/blender/bmesh/bmesh_class.h
@@ -66,7 +66,7 @@ typedef struct BMHeader {
int index; /* notes:
* - Use BM_elem_index_get/set macros for index
* - Uninitialized to -1 so we can easily tell its not set.
- * - Used for edge/vert/face, check BMesh.elem_index_dirty for valid index values,
+ * - Used for edge/vert/face/loop, check BMesh.elem_index_dirty for valid index values,
* this is abused by various tools which set it dirty.
* - For loops this is used for sorting during tessellation. */
@@ -188,9 +188,8 @@ typedef struct BMesh {
int totvertsel, totedgesel, totfacesel;
/* flag index arrays as being dirty so we can check if they are clean and
- * avoid looping over the entire vert/edge/face array in those cases.
- * valid flags are - BM_VERT | BM_EDGE | BM_FACE.
- * BM_LOOP isn't handled so far. */
+ * avoid looping over the entire vert/edge/face/loop array in those cases.
+ * valid flags are - BM_VERT | BM_EDGE | BM_FACE | BM_LOOP. */
char elem_index_dirty;
/* flag array table as being dirty so we know when its safe to use it,
@@ -286,6 +285,12 @@ extern void bpy_bm_generic_invalidate(struct BPy_BMGeneric *self);
typedef bool (*BMElemFilterFunc)(BMElem *, void *user_data);
/* defines */
+#define BM_ELEM_CD_SET_INT(ele, offset, f) \
+ { assert(offset != -1); *((int *)((char *)(ele)->head.data + (offset))) = (f); } (void)0
+
+#define BM_ELEM_CD_GET_INT(ele, offset) \
+ (assert(offset != -1), *((int *)((char *)(ele)->head.data + (offset))))
+
#define BM_ELEM_CD_GET_VOID_P(ele, offset) \
(assert(offset != -1), (void *)((char *)(ele)->head.data + (offset)))
diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c
index 109f964a5f9..eef1e7bbb4f 100644
--- a/source/blender/bmesh/intern/bmesh_construct.c
+++ b/source/blender/bmesh/intern/bmesh_construct.c
@@ -388,7 +388,7 @@ BMFace *BM_face_create_ngon_vcloud(BMesh *bm, BMVert **vert_arr, int len,
float cent[3], nor[3];
- float *far = NULL, *far_cross = NULL;
+ const float *far = NULL, *far_cross = NULL;
float far_vec[3];
float far_cross_vec[3];
diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c
index ed1789ff225..1f81b59badc 100644
--- a/source/blender/bmesh/intern/bmesh_core.c
+++ b/source/blender/bmesh/intern/bmesh_core.c
@@ -29,7 +29,6 @@
#include "MEM_guardedalloc.h"
#include "BLI_math_vector.h"
-#include "BLI_listbase.h"
#include "BLI_array.h"
#include "BLI_alloca.h"
#include "BLI_smallhash.h"
@@ -60,7 +59,11 @@
BMVert *BM_vert_create(BMesh *bm, const float co[3],
const BMVert *v_example, const eBMCreateFlag create_flag)
{
- BMVert *v = BLI_mempool_calloc(bm->vpool);
+ BMVert *v = BLI_mempool_alloc(bm->vpool);
+
+
+ /* --- assign all members --- */
+ v->head.data = NULL;
#ifdef USE_DEBUG_INDEX_MEMCHECK
DEBUG_MEMCHECK_INDEX_INVALIDATE(v)
@@ -68,6 +71,26 @@ BMVert *BM_vert_create(BMesh *bm, const float co[3],
BM_elem_index_set(v, -1); /* set_ok_invalid */
#endif
+ v->head.htype = BM_VERT;
+ v->head.hflag = 0;
+ v->head.api_flag = 0;
+
+ /* allocate flags */
+ v->oflags = bm->vtoolflagpool ? BLI_mempool_calloc(bm->vtoolflagpool) : NULL;
+
+ /* 'v->no' is handled by BM_elem_attrs_copy */
+ if (co) {
+ copy_v3_v3(v->co, co);
+ }
+ else {
+ zero_v3(v->co);
+ }
+ zero_v3(v->no);
+
+ v->e = NULL;
+ /* --- done --- */
+
+
/* disallow this flag for verts - its meaningless */
BLI_assert((create_flag & BM_CREATE_NO_DOUBLE) == 0);
@@ -77,18 +100,6 @@ BMVert *BM_vert_create(BMesh *bm, const float co[3],
bm->totvert++;
- v->head.htype = BM_VERT;
-
- /* 'v->no' is handled by BM_elem_attrs_copy */
- if (co) {
- copy_v3_v3(v->co, co);
- }
-
- /* allocate flags */
- if (bm->vtoolflagpool) {
- v->oflags = BLI_mempool_calloc(bm->vtoolflagpool);
- }
-
if (!(create_flag & BM_CREATE_SKIP_CD)) {
if (v_example) {
int *keyi;
@@ -121,11 +132,18 @@ BMEdge *BM_edge_create(BMesh *bm, BMVert *v1, BMVert *v2,
const BMEdge *e_example, const eBMCreateFlag create_flag)
{
BMEdge *e;
-
+
+ BLI_assert(v1 != v2);
+ BLI_assert(v1->head.htype == BM_VERT && v2->head.htype == BM_VERT);
+
if ((create_flag & BM_CREATE_NO_DOUBLE) && (e = BM_edge_exists(v1, v2)))
return e;
- e = BLI_mempool_calloc(bm->epool);
+ e = BLI_mempool_alloc(bm->epool);
+
+
+ /* --- assign all members --- */
+ e->head.data = NULL;
#ifdef USE_DEBUG_INDEX_MEMCHECK
DEBUG_MEMCHECK_INDEX_INVALIDATE(e)
@@ -133,27 +151,30 @@ BMEdge *BM_edge_create(BMesh *bm, BMVert *v1, BMVert *v2,
BM_elem_index_set(e, -1); /* set_ok_invalid */
#endif
- /* may add to middle of the pool */
- bm->elem_index_dirty |= BM_EDGE;
- bm->elem_table_dirty |= BM_EDGE;
-
- bm->totedge++;
-
e->head.htype = BM_EDGE;
-
+ e->head.hflag = BM_ELEM_SMOOTH | BM_ELEM_DRAW;
+ e->head.api_flag = 0;
+
/* allocate flags */
- if (bm->etoolflagpool) {
- e->oflags = BLI_mempool_calloc(bm->etoolflagpool);
- }
+ e->oflags = bm->etoolflagpool ? BLI_mempool_calloc(bm->etoolflagpool) : NULL;
e->v1 = v1;
e->v2 = v2;
-
- BM_elem_flag_enable(e, BM_ELEM_SMOOTH | BM_ELEM_DRAW);
-
+ e->l = NULL;
+
+ memset(&e->v1_disk_link, 0, sizeof(BMDiskLink) * 2);
+ /* --- done --- */
+
+
bmesh_disk_edge_append(e, e->v1);
bmesh_disk_edge_append(e, e->v2);
-
+
+ /* may add to middle of the pool */
+ bm->elem_index_dirty |= BM_EDGE;
+ bm->elem_table_dirty |= BM_EDGE;
+
+ bm->totedge++;
+
if (!(create_flag & BM_CREATE_SKIP_CD)) {
if (e_example) {
BM_elem_attrs_copy(bm, bm, e_example, e);
@@ -163,7 +184,6 @@ BMEdge *BM_edge_create(BMesh *bm, BMVert *v1, BMVert *v2,
}
}
-
BM_CHECK_ELEMENT(e);
return e;
@@ -174,14 +194,27 @@ static BMLoop *bm_loop_create(BMesh *bm, BMVert *v, BMEdge *e, BMFace *f,
{
BMLoop *l = NULL;
- l = BLI_mempool_calloc(bm->lpool);
- l->next = l->prev = NULL;
+ l = BLI_mempool_alloc(bm->lpool);
+
+ /* --- assign all members --- */
+ l->head.data = NULL;
+ BM_elem_index_set(l, 0); /* set_loop */
+ l->head.hflag = 0;
+ l->head.htype = BM_LOOP;
+ l->head.api_flag = 0;
+
l->v = v;
l->e = e;
l->f = f;
- l->radial_next = l->radial_prev = NULL;
- l->head.data = NULL;
- l->head.htype = BM_LOOP;
+
+ l->radial_next = NULL;
+ l->radial_prev = NULL;
+ l->next = NULL;
+ l->prev = NULL;
+ /* --- done --- */
+
+ /* may add to middle of the pool */
+ bm->elem_index_dirty |= BM_LOOP;
bm->totloop++;
@@ -284,36 +317,48 @@ BMFace *BM_face_copy(BMesh *bm_dst, BMesh *bm_src, BMFace *f,
/**
* only create the face, since this calloc's the length is initialized to 0,
* leave adding loops to the caller.
+ *
+ * \note, caller needs to handle customdata.
*/
-BLI_INLINE BMFace *bm_face_create__internal(BMesh *bm, const eBMCreateFlag create_flag)
+BLI_INLINE BMFace *bm_face_create__internal(BMesh *bm)
{
BMFace *f;
- f = BLI_mempool_calloc(bm->fpool);
+ f = BLI_mempool_alloc(bm->fpool);
+
+ /* --- assign all members --- */
+ f->head.data = NULL;
#ifdef USE_DEBUG_INDEX_MEMCHECK
DEBUG_MEMCHECK_INDEX_INVALIDATE(f)
#else
BM_elem_index_set(f, -1); /* set_ok_invalid */
#endif
+ f->head.htype = BM_FACE;
+ f->head.hflag = 0;
+ f->head.api_flag = 0;
+
+ /* allocate flags */
+ f->oflags = bm->ftoolflagpool ? BLI_mempool_calloc(bm->ftoolflagpool) : NULL;
+
+#ifdef USE_BMESH_HOLES
+ BLI_listbase_clear(&f->loops);
+#else
+ f->l_first = NULL;
+#endif
+ f->len = 0;
+ zero_v3(f->no);
+ f->mat_nr = 0;
+ /* --- done --- */
+
+
/* may add to middle of the pool */
bm->elem_index_dirty |= BM_FACE;
bm->elem_table_dirty |= BM_FACE;
bm->totface++;
- f->head.htype = BM_FACE;
-
- /* allocate flags */
- if (bm->ftoolflagpool) {
- f->oflags = BLI_mempool_calloc(bm->ftoolflagpool);
- }
-
- if (!(create_flag & BM_CREATE_SKIP_CD)) {
- CustomData_bmesh_set_default(&bm->pdata, &f->head.data);
- }
-
#ifdef USE_BMESH_HOLES
f->totbounds = 0;
#endif
@@ -353,7 +398,7 @@ BMFace *BM_face_create(BMesh *bm, BMVert **verts, BMEdge **edges, const int len,
}
}
- f = bm_face_create__internal(bm, create_flag);
+ f = bm_face_create__internal(bm);
startl = lastl = bm_face_boundary_add(bm, f, verts[0], edges[0], create_flag);
@@ -634,6 +679,7 @@ static void bm_kill_only_face(BMesh *bm, BMFace *f)
static void bm_kill_only_loop(BMesh *bm, BMLoop *l)
{
bm->totloop--;
+ bm->elem_index_dirty |= BM_LOOP;
if (l->head.data)
CustomData_bmesh_free_block(&bm->ldata, &l->head.data);
@@ -759,13 +805,13 @@ void BM_edge_kill(BMesh *bm, BMEdge *e)
void BM_vert_kill(BMesh *bm, BMVert *v)
{
if (v->e) {
- BMEdge *e, *nexte;
+ BMEdge *e, *e_next;
e = v->e;
while (v->e) {
- nexte = bmesh_disk_edge_next(e, v);
+ e_next = bmesh_disk_edge_next(e, v);
BM_edge_kill(bm, e);
- e = nexte;
+ e = e_next;
}
}
@@ -982,12 +1028,8 @@ static bool disk_is_flagged(BMVert *v, int flag)
do {
if (!BM_ELEM_API_FLAG_TEST(l->f, flag))
return false;
-
- l = l->radial_next;
- } while (l != e->l);
-
- e = bmesh_disk_edge_next(e, v);
- } while (e != v->e);
+ } while ((l = l->radial_next) != e->l);
+ } while ((e = bmesh_disk_edge_next(e, v)) != v->e);
return true;
}
@@ -1201,14 +1243,14 @@ error:
return NULL;
}
-static BMFace *bm_face_create__sfme(BMesh *bm, BMFace *UNUSED(example))
+static BMFace *bm_face_create__sfme(BMesh *bm, BMFace *f_example)
{
BMFace *f;
#ifdef USE_BMESH_HOLES
BMLoopList *lst;
#endif
- f = bm_face_create__internal(bm, 0);
+ f = bm_face_create__internal(bm);
#ifdef USE_BMESH_HOLES
lst = BLI_mempool_calloc(bm->looplistpool);
@@ -1219,6 +1261,8 @@ static BMFace *bm_face_create__sfme(BMesh *bm, BMFace *UNUSED(example))
f->totbounds = 1;
#endif
+ BM_elem_attrs_copy(bm, bm, f_example, f);
+
return f;
}
diff --git a/source/blender/bmesh/intern/bmesh_delete.c b/source/blender/bmesh/intern/bmesh_delete.c
index 42b1c09b7ef..c5c9403884b 100644
--- a/source/blender/bmesh/intern/bmesh_delete.c
+++ b/source/blender/bmesh/intern/bmesh_delete.c
@@ -31,7 +31,6 @@
* BM remove functions.
*/
-#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
diff --git a/source/blender/bmesh/intern/bmesh_edgeloop.c b/source/blender/bmesh/intern/bmesh_edgeloop.c
index bedb9c56af6..bbf4b661a1b 100644
--- a/source/blender/bmesh/intern/bmesh_edgeloop.c
+++ b/source/blender/bmesh/intern/bmesh_edgeloop.c
@@ -298,7 +298,7 @@ bool BM_mesh_edgeloops_find_path(BMesh *bm, ListBase *r_eloops,
BMVert *v_match[2] = {NULL, NULL};
ListBase lb_src = {NULL, NULL};
ListBase lb_dst = {NULL, NULL};
- BLI_mempool *vs_pool = BLI_mempool_create(sizeof(struct VertStep), 1, 512, BLI_MEMPOOL_NOP);
+ BLI_mempool *vs_pool = BLI_mempool_create(sizeof(struct VertStep), 0, 512, BLI_MEMPOOL_NOP);
/* edge args are dummy */
vs_add(vs_pool, &lb_src, v_src, v_src->e, 1);
@@ -544,9 +544,9 @@ void BM_edgeloop_calc_center(BMesh *UNUSED(bm), BMEdgeLoopStore *el_store)
LinkData *node_first = el_store->verts.first;
LinkData *node_next = node_first;
- float const *v_prev = NODE_AS_CO(node_prev);
- float const *v_curr = NODE_AS_CO(node_curr);
- float const *v_next = NODE_AS_CO(node_next);
+ const float *v_prev = NODE_AS_CO(node_prev);
+ const float *v_curr = NODE_AS_CO(node_curr);
+ const float *v_next = NODE_AS_CO(node_next);
float totw = 0.0f;
float w_prev;
@@ -582,8 +582,8 @@ void BM_edgeloop_calc_center(BMesh *UNUSED(bm), BMEdgeLoopStore *el_store)
bool BM_edgeloop_calc_normal(BMesh *UNUSED(bm), BMEdgeLoopStore *el_store)
{
LinkData *node_curr = el_store->verts.first;
- float const *v_prev = NODE_AS_CO(el_store->verts.last);
- float const *v_curr = NODE_AS_CO(node_curr);
+ const float *v_prev = NODE_AS_CO(el_store->verts.last);
+ const float *v_curr = NODE_AS_CO(node_curr);
zero_v3(el_store->no);
@@ -619,8 +619,8 @@ bool BM_edgeloop_calc_normal(BMesh *UNUSED(bm), BMEdgeLoopStore *el_store)
bool BM_edgeloop_calc_normal_aligned(BMesh *UNUSED(bm), BMEdgeLoopStore *el_store, const float no_align[3])
{
LinkData *node_curr = el_store->verts.first;
- float const *v_prev = NODE_AS_CO(el_store->verts.last);
- float const *v_curr = NODE_AS_CO(node_curr);
+ const float *v_prev = NODE_AS_CO(el_store->verts.last);
+ const float *v_curr = NODE_AS_CO(node_curr);
zero_v3(el_store->no);
diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c
index e5921bb49d7..2250b8135d7 100644
--- a/source/blender/bmesh/intern/bmesh_interp.c
+++ b/source/blender/bmesh/intern/bmesh_interp.c
@@ -33,7 +33,6 @@
#include "MEM_guardedalloc.h"
-#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "BLI_alloca.h"
@@ -295,8 +294,9 @@ static float quad_coord(const float aa[3], const float bb[3], const float cc[3],
return f1;
}
-static int quad_co(float *x, float *y, float v1[3], float v2[3], float v3[3], float v4[3],
- float p[3], float n[3])
+static int quad_co(float *x, float *y,
+ const float v1[3], const float v2[3], const float v3[3], const float v4[3],
+ const float p[3], const float n[3])
{
float projverts[5][3], n2[3];
float dprojverts[4][3], origin[3] = {0.0f, 0.0f, 0.0f};
@@ -317,12 +317,7 @@ static int quad_co(float *x, float *y, float v1[3], float v2[3], float v3[3], fl
/* rotate */
poly_rotate_plane(n, projverts, 5);
-
- /* flatten */
- for (i = 0; i < 5; i++) {
- projverts[i][2] = 0.0f;
- }
-
+
/* subtract origin */
for (i = 0; i < 4; i++) {
sub_v3_v3(projverts[i], projverts[4]);
@@ -389,8 +384,8 @@ static bool mdisp_in_mdispquad(BMLoop *l, BMLoop *tl, float p[3], float *x, floa
return 1;
}
-static float bm_loop_flip_equotion(float mat[2][2], float b[2], float target_axis_x[3], float target_axis_y[3],
- float coord[3], int i, int j)
+static float bm_loop_flip_equotion(float mat[2][2], float b[2], const float target_axis_x[3], const float target_axis_y[3],
+ const float coord[3], int i, int j)
{
mat[0][0] = target_axis_x[i];
mat[0][1] = target_axis_y[i];
@@ -889,7 +884,7 @@ void BM_data_layer_copy(BMesh *bm, CustomData *data, int type, int src_n, int ds
float BM_elem_float_data_get(CustomData *cd, void *element, int type)
{
- float *f = CustomData_bmesh_get(cd, ((BMHeader *)element)->data, type);
+ const float *f = CustomData_bmesh_get(cd, ((BMHeader *)element)->data, type);
return f ? *f : 0.0f;
}
diff --git a/source/blender/bmesh/intern/bmesh_log.c b/source/blender/bmesh/intern/bmesh_log.c
index 372252db8fe..7d3bc0e16b3 100644
--- a/source/blender/bmesh/intern/bmesh_log.c
+++ b/source/blender/bmesh/intern/bmesh_log.c
@@ -67,6 +67,7 @@ struct BMLogEntry {
/* Vertices whose coordinates, mask value, or hflag have changed */
GHash *modified_verts;
+ GHash *modified_faces;
BLI_mempool *pool_verts;
BLI_mempool *pool_faces;
@@ -120,6 +121,7 @@ typedef struct {
typedef struct {
unsigned int v_ids[3];
+ char hflag;
} BMLogFace;
/************************* Get/set element IDs ************************/
@@ -178,12 +180,10 @@ static BMFace *bm_log_face_from_id(BMLog *log, unsigned int id)
/* Get a vertex's paint-mask value
*
* Returns zero if no paint-mask layer is present */
-static float vert_mask_get(BMesh *bm, BMVert *v)
+static float vert_mask_get(BMVert *v, const int cd_vert_mask_offset)
{
- float *mask = CustomData_bmesh_get(&bm->vdata, v->head.data, CD_PAINT_MASK);
- BLI_assert((CustomData_has_layer(&bm->vdata, CD_PAINT_MASK) == 0) == (mask == NULL));
- if (mask) {
- return *mask;
+ if (cd_vert_mask_offset != -1) {
+ return BM_ELEM_CD_GET_FLOAT(v, cd_vert_mask_offset);
}
else {
return 0.0f;
@@ -193,31 +193,29 @@ static float vert_mask_get(BMesh *bm, BMVert *v)
/* Set a vertex's paint-mask value
*
* Has no effect is no paint-mask layer is present */
-static void vert_mask_set(BMesh *bm, BMVert *v, float new_mask)
+static void vert_mask_set(BMVert *v, const float new_mask, const int cd_vert_mask_offset)
{
- float *mask = CustomData_bmesh_get(&bm->vdata, v->head.data, CD_PAINT_MASK);
- BLI_assert((CustomData_has_layer(&bm->vdata, CD_PAINT_MASK) == 0) == (mask == NULL));
- if (*mask) {
- *mask = new_mask;
+ if (cd_vert_mask_offset != -1) {
+ BM_ELEM_CD_SET_FLOAT(v, cd_vert_mask_offset, new_mask);
}
}
/* Update a BMLogVert with data from a BMVert */
-static void bm_log_vert_bmvert_copy(BMesh *bm, BMLogVert *lv, BMVert *v)
+static void bm_log_vert_bmvert_copy(BMLogVert *lv, BMVert *v, const int cd_vert_mask_offset)
{
copy_v3_v3(lv->co, v->co);
normal_float_to_short_v3(lv->no, v->no);
- lv->mask = vert_mask_get(bm, v);
+ lv->mask = vert_mask_get(v, cd_vert_mask_offset);
lv->hflag = v->head.hflag;
}
/* Allocate and initialize a BMLogVert */
-static BMLogVert *bm_log_vert_alloc(BMesh *bm, BMLog *log, BMVert *v)
+static BMLogVert *bm_log_vert_alloc(BMLog *log, BMVert *v, const int cd_vert_mask_offset)
{
BMLogEntry *entry = log->current_entry;
BMLogVert *lv = BLI_mempool_alloc(entry->pool_verts);
- bm_log_vert_bmvert_copy(bm, lv, v);
+ bm_log_vert_bmvert_copy(lv, v, cd_vert_mask_offset);
return lv;
}
@@ -238,6 +236,7 @@ static BMLogFace *bm_log_face_alloc(BMLog *log, BMFace *f)
lf->v_ids[1] = bm_log_vert_id_get(log, v[1]);
lf->v_ids[2] = bm_log_vert_id_get(log, v[2]);
+ lf->hflag = f->head.hflag;
return lf;
}
@@ -246,6 +245,8 @@ static BMLogFace *bm_log_face_alloc(BMLog *log, BMFace *f)
static void bm_log_verts_unmake(BMesh *bm, BMLog *log, GHash *verts)
{
+ const int cd_vert_mask_offset = CustomData_get_offset(&bm->vdata, CD_PAINT_MASK);
+
GHashIterator gh_iter;
GHASH_ITER (gh_iter, verts) {
void *key = BLI_ghashIterator_getKey(&gh_iter);
@@ -255,7 +256,7 @@ static void bm_log_verts_unmake(BMesh *bm, BMLog *log, GHash *verts)
/* Ensure the log has the final values of the vertex before
* deleting it */
- bm_log_vert_bmvert_copy(bm, lv, v);
+ bm_log_vert_bmvert_copy(lv, v, cd_vert_mask_offset);
BM_vert_kill(bm, v);
}
@@ -289,13 +290,15 @@ static void bm_log_faces_unmake(BMesh *bm, BMLog *log, GHash *faces)
static void bm_log_verts_restore(BMesh *bm, BMLog *log, GHash *verts)
{
+ const int cd_vert_mask_offset = CustomData_get_offset(&bm->vdata, CD_PAINT_MASK);
+
GHashIterator gh_iter;
GHASH_ITER (gh_iter, verts) {
void *key = BLI_ghashIterator_getKey(&gh_iter);
BMLogVert *lv = BLI_ghashIterator_getValue(&gh_iter);
BMVert *v = BM_vert_create(bm, lv->co, NULL, BM_CREATE_NOP);
+ vert_mask_set(v, lv->mask, cd_vert_mask_offset);
v->head.hflag = lv->hflag;
- vert_mask_set(bm, v, lv->mask);
normal_short_to_float_v3(v->no, lv->no);
bm_log_vert_id_set(log, v, GET_UINT_FROM_POINTER(key));
}
@@ -313,12 +316,15 @@ static void bm_log_faces_restore(BMesh *bm, BMLog *log, GHash *faces)
BMFace *f;
f = BM_face_create_verts(bm, v, 3, NULL, BM_CREATE_NOP, true);
+ f->head.hflag = lf->hflag;
bm_log_face_id_set(log, f, GET_UINT_FROM_POINTER(key));
}
}
static void bm_log_vert_values_swap(BMesh *bm, BMLog *log, GHash *verts)
{
+ const int cd_vert_mask_offset = CustomData_get_offset(&bm->vdata, CD_PAINT_MASK);
+
GHashIterator gh_iter;
GHASH_ITER (gh_iter, verts) {
void *key = BLI_ghashIterator_getKey(&gh_iter);
@@ -334,8 +340,21 @@ static void bm_log_vert_values_swap(BMesh *bm, BMLog *log, GHash *verts)
normal_short_to_float_v3(v->no, normal);
SWAP(char, v->head.hflag, lv->hflag);
mask = lv->mask;
- lv->mask = vert_mask_get(bm, v);
- vert_mask_set(bm, v, mask);
+ lv->mask = vert_mask_get(v, cd_vert_mask_offset);
+ vert_mask_set(v, mask, cd_vert_mask_offset);
+ }
+}
+
+static void bm_log_face_values_swap(BMLog *log, GHash *faces)
+{
+ GHashIterator gh_iter;
+ GHASH_ITER (gh_iter, faces) {
+ void *key = BLI_ghashIterator_getKey(&gh_iter);
+ BMLogFace *lf = BLI_ghashIterator_getValue(&gh_iter);
+ unsigned int id = GET_UINT_FROM_POINTER(key);
+ BMFace *f = bm_log_face_from_id(log, id);
+
+ SWAP(char, f->head.hflag, lf->hflag);
}
}
@@ -372,9 +391,10 @@ static BMLogEntry *bm_log_entry_create(void)
entry->added_verts = BLI_ghash_ptr_new(__func__);
entry->added_faces = BLI_ghash_ptr_new(__func__);
entry->modified_verts = BLI_ghash_ptr_new(__func__);
+ entry->modified_faces = BLI_ghash_ptr_new(__func__);
- entry->pool_verts = BLI_mempool_create(sizeof(BMLogVert), 1, 64, BLI_MEMPOOL_NOP);
- entry->pool_faces = BLI_mempool_create(sizeof(BMLogFace), 1, 64, BLI_MEMPOOL_NOP);
+ entry->pool_verts = BLI_mempool_create(sizeof(BMLogVert), 0, 64, BLI_MEMPOOL_NOP);
+ entry->pool_faces = BLI_mempool_create(sizeof(BMLogFace), 0, 64, BLI_MEMPOOL_NOP);
return entry;
}
@@ -389,6 +409,7 @@ static void bm_log_entry_free(BMLogEntry *entry)
BLI_ghash_free(entry->added_verts, NULL, NULL);
BLI_ghash_free(entry->added_faces, NULL, NULL);
BLI_ghash_free(entry->modified_verts, NULL, NULL);
+ BLI_ghash_free(entry->modified_faces, NULL, NULL);
BLI_mempool_destroy(entry->pool_verts);
BLI_mempool_destroy(entry->pool_faces);
@@ -509,6 +530,7 @@ BMLog *BM_log_from_existing_entries_create(BMesh *bm, BMLogEntry *entry)
bm_log_id_ghash_retake(log->unused_ids, entry->added_verts);
bm_log_id_ghash_retake(log->unused_ids, entry->added_faces);
bm_log_id_ghash_retake(log->unused_ids, entry->modified_verts);
+ bm_log_id_ghash_retake(log->unused_ids, entry->modified_faces);
}
return log;
@@ -704,6 +726,7 @@ void BM_log_undo(BMesh *bm, BMLog *log)
/* Restore vertex coordinates, mask, and hflag */
bm_log_vert_values_swap(bm, log, entry->modified_verts);
+ bm_log_face_values_swap(log, entry->modified_faces);
}
}
@@ -740,6 +763,7 @@ void BM_log_redo(BMesh *bm, BMLog *log)
/* Restore vertex coordinates, mask, and hflag */
bm_log_vert_values_swap(bm, log, entry->modified_verts);
+ bm_log_face_values_swap(log, entry->modified_faces);
}
}
@@ -766,7 +790,7 @@ void BM_log_redo(BMesh *bm, BMLog *log)
* state so that a subsequent redo operation will restore the newer
* vertex state.
*/
-void BM_log_vert_before_modified(BMesh *bm, BMLog *log, BMVert *v)
+void BM_log_vert_before_modified(BMLog *log, BMVert *v, const int cd_vert_mask_offset)
{
BMLogEntry *entry = log->current_entry;
BMLogVert *lv;
@@ -775,31 +799,48 @@ void BM_log_vert_before_modified(BMesh *bm, BMLog *log, BMVert *v)
/* Find or create the BMLogVert entry */
if ((lv = BLI_ghash_lookup(entry->added_verts, key))) {
- bm_log_vert_bmvert_copy(bm, lv, v);
+ bm_log_vert_bmvert_copy(lv, v, cd_vert_mask_offset);
}
else if (!BLI_ghash_haskey(entry->modified_verts, key)) {
- lv = bm_log_vert_alloc(bm, log, v);
+ lv = bm_log_vert_alloc(log, v, cd_vert_mask_offset);
BLI_ghash_insert(entry->modified_verts, key, lv);
}
}
+
/* Log a new vertex as added to the BMesh
*
* The new vertex gets a unique ID assigned. It is then added to a map
* of added vertices, with the key being its ID and the value
* containing everything needed to reconstruct that vertex.
*/
-void BM_log_vert_added(BMesh *bm, BMLog *log, BMVert *v)
+void BM_log_vert_added(BMLog *log, BMVert *v, const int cd_vert_mask_offset)
{
BMLogVert *lv;
unsigned int v_id = range_tree_uint_take_any(log->unused_ids);
void *key = SET_UINT_IN_POINTER(v_id);
bm_log_vert_id_set(log, v, v_id);
- lv = bm_log_vert_alloc(bm, log, v);
+ lv = bm_log_vert_alloc(log, v, cd_vert_mask_offset);
BLI_ghash_insert(log->current_entry->added_verts, key, lv);
}
+
+/* Log a face before it is modified
+ *
+ * This is intended to handle only header flags and we always
+ * assume face has been added before
+ */
+void BM_log_face_modified(BMLog *log, BMFace *f)
+{
+ BMLogFace *lf;
+ unsigned int f_id = bm_log_face_id_get(log, f);
+ void *key = SET_UINT_IN_POINTER(f_id);
+
+ lf = bm_log_face_alloc(log, f);
+ BLI_ghash_insert(log->current_entry->modified_faces, key, lf);
+}
+
/* Log a new face as added to the BMesh
*
* The new face gets a unique ID assigned. It is then added to a map
@@ -836,7 +877,7 @@ void BM_log_face_added(BMLog *log, BMFace *f)
* If there's a move record for the vertex, that's used as the
* vertices original location, then the move record is deleted.
*/
-void BM_log_vert_removed(BMesh *bm, BMLog *log, BMVert *v)
+void BM_log_vert_removed(BMLog *log, BMVert *v, const int cd_vert_mask_offset)
{
BMLogEntry *entry = log->current_entry;
unsigned int v_id = bm_log_vert_id_get(log, v);
@@ -852,7 +893,7 @@ void BM_log_vert_removed(BMesh *bm, BMLog *log, BMVert *v)
else {
BMLogVert *lv, *lv_mod;
- lv = bm_log_vert_alloc(bm, log, v);
+ lv = bm_log_vert_alloc(log, v, cd_vert_mask_offset);
BLI_ghash_insert(entry->deleted_verts, key, lv);
/* If the vertex was modified before deletion, ensure that the
@@ -901,13 +942,14 @@ void BM_log_face_removed(BMLog *log, BMFace *f)
/* Log all vertices/faces in the BMesh as added */
void BM_log_all_added(BMesh *bm, BMLog *log)
{
+ const int cd_vert_mask_offset = CustomData_get_offset(&bm->vdata, CD_PAINT_MASK);
BMIter bm_iter;
BMVert *v;
BMFace *f;
/* Log all vertices as newly created */
BM_ITER_MESH (v, &bm_iter, bm, BM_VERTS_OF_MESH) {
- BM_log_vert_added(bm, log, v);
+ BM_log_vert_added(log, v, cd_vert_mask_offset);
}
/* Log all faces as newly created */
@@ -919,6 +961,7 @@ void BM_log_all_added(BMesh *bm, BMLog *log)
/* Log all vertices/faces in the BMesh as removed */
void BM_log_before_all_removed(BMesh *bm, BMLog *log)
{
+ const int cd_vert_mask_offset = CustomData_get_offset(&bm->vdata, CD_PAINT_MASK);
BMIter bm_iter;
BMVert *v;
BMFace *f;
@@ -930,7 +973,7 @@ void BM_log_before_all_removed(BMesh *bm, BMLog *log)
/* Log deletion of all vertices */
BM_ITER_MESH (v, &bm_iter, bm, BM_VERTS_OF_MESH) {
- BM_log_vert_removed(bm, log, v);
+ BM_log_vert_removed(log, v, cd_vert_mask_offset);
}
}
diff --git a/source/blender/bmesh/intern/bmesh_log.h b/source/blender/bmesh/intern/bmesh_log.h
index 3cd2fd70081..7a26506439f 100644
--- a/source/blender/bmesh/intern/bmesh_log.h
+++ b/source/blender/bmesh/intern/bmesh_log.h
@@ -61,16 +61,19 @@ void BM_log_undo(BMesh *bm, BMLog *log);
void BM_log_redo(BMesh *bm, BMLog *log);
/* Log a vertex before it is modified */
-void BM_log_vert_before_modified(BMesh *bm, BMLog *log, struct BMVert *v);
+void BM_log_vert_before_modified(BMLog *log, struct BMVert *v, const int cd_vert_mask_offset);
/* Log a new vertex as added to the BMesh */
-void BM_log_vert_added(BMesh *bm, BMLog *log, struct BMVert *v);
+void BM_log_vert_added(BMLog *log, struct BMVert *v, const int cd_vert_mask_offset);
+
+/* Log a face before it is modified */
+void BM_log_face_modified(BMLog *log, struct BMFace *f);
/* Log a new face as added to the BMesh */
void BM_log_face_added(BMLog *log, struct BMFace *f);
/* Log a vertex as removed from the BMesh */
-void BM_log_vert_removed(BMesh *bm, BMLog *log, struct BMVert *v);
+void BM_log_vert_removed(BMLog *log, struct BMVert *v, const int cd_vert_mask_offset);
/* Log a face as removed from the BMesh */
void BM_log_face_removed(BMLog *log, struct BMFace *f);
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index ec01f13414e..e9d3c36eb1a 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -31,6 +31,7 @@
#include "DNA_listBase.h"
#include "DNA_object_types.h"
+#include "BLI_linklist_stack.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
@@ -67,9 +68,9 @@ void BM_mesh_elem_toolflags_ensure(BMesh *bm)
return;
}
- bm->vtoolflagpool = BLI_mempool_create(sizeof(BMFlagLayer), max_ii(512, bm->totvert), 512, BLI_MEMPOOL_NOP);
- bm->etoolflagpool = BLI_mempool_create(sizeof(BMFlagLayer), max_ii(512, bm->totedge), 512, BLI_MEMPOOL_NOP);
- bm->ftoolflagpool = BLI_mempool_create(sizeof(BMFlagLayer), max_ii(512, bm->totface), 512, BLI_MEMPOOL_NOP);
+ bm->vtoolflagpool = BLI_mempool_create(sizeof(BMFlagLayer), bm->totvert, 512, BLI_MEMPOOL_NOP);
+ bm->etoolflagpool = BLI_mempool_create(sizeof(BMFlagLayer), bm->totedge, 512, BLI_MEMPOOL_NOP);
+ bm->ftoolflagpool = BLI_mempool_create(sizeof(BMFlagLayer), bm->totface, 512, BLI_MEMPOOL_NOP);
#pragma omp parallel sections if (bm->totvert + bm->totedge + bm->totface >= BM_OMP_LIMIT)
{
@@ -431,6 +432,240 @@ void BM_verts_calc_normal_vcos(BMesh *bm, const float (*fnos)[3], const float (*
MEM_freeN(edgevec);
}
+/**
+ * Helpers for #BM_mesh_loop_normals_update and #BM_loops_calc_normals_vnos
+ */
+static void bm_mesh_edges_sharp_tag(BMesh *bm, const float (*vnos)[3], const float (*fnos)[3], float split_angle,
+ float (*r_lnos)[3])
+{
+ BMIter eiter;
+ BMEdge *e;
+ int i;
+
+ const bool check_angle = (split_angle < (float)M_PI);
+
+ if (check_angle) {
+ split_angle = cosf(split_angle);
+ }
+
+ {
+ char hflag = BM_LOOP;
+ if (vnos) {
+ hflag |= BM_VERT;
+ }
+ if (fnos) {
+ hflag |= BM_FACE;
+ }
+ BM_mesh_elem_index_ensure(bm, hflag);
+ }
+
+ /* This first loop checks which edges are actually smooth, and pre-populate lnos with vnos (as if they were
+ * all smooth).
+ */
+ BM_ITER_MESH_INDEX (e, &eiter, bm, BM_EDGES_OF_MESH, i) {
+ BMLoop *l_a, *l_b;
+
+ BM_elem_index_set(e, i); /* set_inline */
+ BM_elem_flag_disable(e, BM_ELEM_TAG); /* Clear tag (means edge is sharp). */
+
+ /* An edge with only two loops, might be smooth... */
+ if (BM_edge_loop_pair(e, &l_a, &l_b)) {
+ bool is_angle_smooth = true;
+ if (check_angle) {
+ const float *no_a = fnos ? fnos[BM_elem_index_get(l_a->f)] : l_a->f->no;
+ const float *no_b = fnos ? fnos[BM_elem_index_get(l_b->f)] : l_b->f->no;
+ is_angle_smooth = (dot_v3v3(no_a, no_b) >= split_angle);
+ }
+
+ /* We only tag edges that are *really* smooth... */
+ if (is_angle_smooth &&
+ BM_elem_flag_test_bool(e, BM_ELEM_SMOOTH) &&
+ BM_elem_flag_test_bool(l_a->f, BM_ELEM_SMOOTH) &&
+ BM_elem_flag_test_bool(l_b->f, BM_ELEM_SMOOTH))
+ {
+ const float *no;
+ BM_elem_flag_enable(e, BM_ELEM_TAG);
+
+ /* linked vertices might be fully smooth, copy their normals to loop ones. */
+ no = vnos ? vnos[BM_elem_index_get(l_a->v)] : l_a->v->no;
+ copy_v3_v3(r_lnos[BM_elem_index_get(l_a)], no);
+ no = vnos ? vnos[BM_elem_index_get(l_b->v)] : l_b->v->no;
+ copy_v3_v3(r_lnos[BM_elem_index_get(l_b)], no);
+ }
+ }
+ }
+
+ bm->elem_index_dirty &= ~BM_EDGE;
+}
+
+/* BMesh version of BKE_mesh_normals_loop_split() in mesh_evaluate.c */
+static void bm_mesh_loops_calc_normals(BMesh *bm, const float (*vcos)[3], const float (*fnos)[3], float (*r_lnos)[3])
+{
+ BMIter fiter;
+ BMFace *f_curr;
+
+ /* Temp normal stack. */
+ BLI_SMALLSTACK_DECLARE(normal, float *);
+
+ {
+ char hflag = BM_LOOP;
+ if (vcos) {
+ hflag |= BM_VERT;
+ }
+ if (fnos) {
+ hflag |= BM_FACE;
+ }
+ BM_mesh_elem_index_ensure(bm, hflag);
+ }
+
+ /* We now know edges that can be smoothed (they are tagged), and edges that will be hard (they aren't).
+ * Now, time to generate the normals.
+ */
+ BM_ITER_MESH (f_curr, &fiter, bm, BM_FACES_OF_MESH) {
+ BMLoop *l_curr, *l_first;
+
+ l_curr = l_first = BM_FACE_FIRST_LOOP(f_curr);
+ do {
+ if (BM_elem_flag_test_bool(l_curr->e, BM_ELEM_TAG)) {
+ /* A smooth edge.
+ * We skip it because it is either:
+ * - in the middle of a 'smooth fan' already computed (or that will be as soon as we hit
+ * one of its ends, i.e. one of its two sharp edges), or...
+ * - the related vertex is a "full smooth" one, in which case pre-populated normals from vertex
+ * are just fine!
+ */
+ }
+ else if (!BM_elem_flag_test_bool(l_curr->prev->e, BM_ELEM_TAG)) {
+ /* Simple case (both edges around that vertex are sharp in related polygon),
+ * this vertex just takes its poly normal.
+ */
+ const float *no = fnos ? fnos[BM_elem_index_get(f_curr)] : f_curr->no;
+ copy_v3_v3(r_lnos[BM_elem_index_get(l_curr)], no);
+ }
+ else {
+ /* We have to fan around current vertex, until we find the other non-smooth edge,
+ * and accumulate face normals into the vertex!
+ * Note in case this vertex has only one sharp edge, this is a waste because the normal is the same as
+ * the vertex normal, but I do not see any easy way to detect that (would need to count number
+ * of sharp edges per vertex, I doubt the additional memory usage would be worth it, especially as
+ * it should not be a common case in real-life meshes anyway).
+ */
+ BMVert *v_pivot = l_curr->v;
+ BMEdge *e_next;
+ BMLoop *lfan_pivot, *lfan_pivot_next;
+ float lnor[3] = {0.0f, 0.0f, 0.0f};
+ float vec_curr[3], vec_next[3];
+
+ const float *co_pivot = vcos ? vcos[BM_elem_index_get(v_pivot)] : v_pivot->co;
+
+ lfan_pivot = l_curr;
+ e_next = lfan_pivot->e; /* Current edge here, actually! */
+
+ /* Only need to compute previous edge's vector once, then we can just reuse old current one! */
+ {
+ const BMVert *v_2 = BM_edge_other_vert(e_next, v_pivot);
+ const float *co_2 = vcos ? vcos[BM_elem_index_get(v_2)] : v_2->co;
+
+ sub_v3_v3v3(vec_curr, co_2, co_pivot);
+ normalize_v3(vec_curr);
+ }
+
+ while (true) {
+ /* Much simpler than in sibling code with basic Mesh data! */
+ lfan_pivot_next = BM_vert_step_fan_loop(lfan_pivot, &e_next);
+ if (lfan_pivot_next) {
+ BLI_assert(lfan_pivot_next->v == v_pivot);
+ }
+ else {
+ /* next edge is non-manifold, we have to find it ourselves! */
+ e_next = (lfan_pivot->e == e_next) ? lfan_pivot->prev->e : lfan_pivot->e;
+ }
+
+ /* Compute edge vector.
+ * NOTE: We could pre-compute those into an array, in the first iteration, instead of computing them
+ * twice (or more) here. However, time gained is not worth memory and time lost,
+ * given the fact that this code should not be called that much in real-life meshes...
+ */
+ {
+ const BMVert *v_2 = BM_edge_other_vert(e_next, v_pivot);
+ const float *co_2 = vcos ? vcos[BM_elem_index_get(v_2)] : v_2->co;
+
+ sub_v3_v3v3(vec_next, co_2, co_pivot);
+ normalize_v3(vec_next);
+ }
+
+ {
+ /* Code similar to accumulate_vertex_normals_poly. */
+ /* Calculate angle between the two poly edges incident on this vertex. */
+ const BMFace *f = lfan_pivot->f;
+ const float fac = saacos(dot_v3v3(vec_next, vec_curr));
+ const float *no = fnos ? fnos[BM_elem_index_get(f)] : f->no;
+ /* Accumulate */
+ madd_v3_v3fl(lnor, no, fac);
+ }
+
+ /* We store here a pointer to all loop-normals processed. */
+ BLI_SMALLSTACK_PUSH(normal, (float *)r_lnos[BM_elem_index_get(lfan_pivot)]);
+
+ if (!BM_elem_flag_test_bool(e_next, BM_ELEM_TAG)) {
+ /* Next edge is sharp, we have finished with this fan of faces around this vert! */
+ break;
+ }
+
+ /* Copy next edge vector to current one. */
+ copy_v3_v3(vec_curr, vec_next);
+ /* Next pivot loop to current one. */
+ lfan_pivot = lfan_pivot_next;
+ }
+
+ /* In case we get a zero normal here, just use vertex normal already set! */
+ if (LIKELY(normalize_v3(lnor) != 0.0f)) {
+ /* Copy back the final computed normal into all related loop-normals. */
+ float *nor;
+ while ((nor = BLI_SMALLSTACK_POP(normal))) {
+ copy_v3_v3(nor, lnor);
+ }
+ }
+ }
+ } while ((l_curr = l_curr->next) != l_first);
+ }
+
+ BLI_SMALLSTACK_FREE(normal);
+}
+
+#if 0 /* Unused currently */
+/**
+ * \brief BMesh Compute Loop Normals
+ *
+ * Updates the loop normals of a mesh. Assumes vertex and face normals are valid (else call BM_mesh_normals_update()
+ * first)!
+ */
+void BM_mesh_loop_normals_update(BMesh *bm, const float split_angle, float (*r_lnos)[3])
+{
+ /* Tag smooth edges and set lnos from vnos when they might be completely smooth... */
+ bm_mesh_edges_sharp_tag(bm, NULL, NULL, split_angle, r_lnos);
+
+ /* Finish computing lnos by accumulating face normals in each fan of faces defined by sharp edges. */
+ bm_mesh_loops_calc_normals(bm, NULL, NULL, r_lnos);
+}
+#endif
+
+/**
+ * \brief BMesh Compute Loop Normals from/to external data.
+ *
+ * Compute split normals, i.e. vertex normals associated with each poly (hence 'loop normals').
+ * Useful to materialize sharp edges (or non-smooth faces) without actually modifying the geometry (splitting edges).
+ */
+void BM_loops_calc_normal_vcos(BMesh *bm, const float (*vcos)[3], const float (*vnos)[3], const float (*fnos)[3],
+ const float split_angle, float (*r_lnos)[3])
+{
+ /* Tag smooth edges and set lnos from vnos when they might be completely smooth... */
+ bm_mesh_edges_sharp_tag(bm, vnos, fnos, split_angle, r_lnos);
+
+ /* Finish computing lnos by accumulating face normals in each fan of faces defined by sharp edges. */
+ bm_mesh_loops_calc_normals(bm, vcos, fnos, r_lnos);
+}
+
static void UNUSED_FUNCTION(bm_mdisps_space_set)(Object *ob, BMesh *bm, int from, int to)
{
/* switch multires data out of tangent space */
@@ -585,19 +820,39 @@ void BM_mesh_elem_index_ensure(BMesh *bm, const char hflag)
#pragma omp section
{
- if (hflag & BM_FACE) {
- if (bm->elem_index_dirty & BM_FACE) {
+ if (hflag & (BM_FACE | BM_LOOP)) {
+ if (bm->elem_index_dirty & (BM_FACE | BM_LOOP)) {
BMIter iter;
BMElem *ele;
+ const bool update_face = (hflag & BM_FACE) && (bm->elem_index_dirty & BM_FACE);
+ const bool update_loop = (hflag & BM_LOOP) && (bm->elem_index_dirty & BM_LOOP);
+
int index;
+ int index_loop = 0;
+
BM_ITER_MESH_INDEX (ele, &iter, bm, BM_FACES_OF_MESH, index) {
- BM_elem_index_set(ele, index); /* set_ok */
+ if (update_face) {
+ BM_elem_index_set(ele, index); /* set_ok */
+ }
+
+ if (update_loop) {
+ BMLoop *l_iter, *l_first;
+
+ l_iter = l_first = BM_FACE_FIRST_LOOP((BMFace *)ele);
+ do {
+ BM_elem_index_set(l_iter, index_loop++); /* set_ok */
+ } while ((l_iter = l_iter->next) != l_first);
+ }
}
+
BLI_assert(index == bm->totface);
+ if (update_loop) {
+ BLI_assert(index_loop == bm->totloop);
+ }
}
else {
- // printf("%s: skipping face index calc!\n", __func__);
+ // printf("%s: skipping face/loop index calc!\n", __func__);
}
}
}
@@ -1006,7 +1261,7 @@ void BM_mesh_remap(BMesh *bm, unsigned int *vert_idx, unsigned int *edge_idx, un
BLI_ghash_insert(fptr_map, (void *)*fap, (void *)new_fap);
}
- bm->elem_index_dirty |= BM_FACE;
+ bm->elem_index_dirty |= BM_FACE | BM_LOOP;
MEM_freeN(faces_pool);
MEM_freeN(faces_copy);
diff --git a/source/blender/bmesh/intern/bmesh_mesh.h b/source/blender/bmesh/intern/bmesh_mesh.h
index c3ff30e5a2b..3923c2515a3 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.h
+++ b/source/blender/bmesh/intern/bmesh_mesh.h
@@ -39,6 +39,8 @@ void BM_mesh_clear(BMesh *bm);
void BM_mesh_normals_update(BMesh *bm);
void BM_verts_calc_normal_vcos(BMesh *bm, const float (*fnos)[3], const float (*vcos)[3], float (*vnos)[3]);
+void BM_loops_calc_normal_vcos(BMesh *bm, const float (*vcos)[3], const float (*vnos)[3], const float (*pnos)[3],
+ const float split_angle, float (*r_lnos)[3]);
void bmesh_edit_begin(BMesh *bm, const BMOpTypeFlag type_flag);
void bmesh_edit_end(BMesh *bm, const BMOpTypeFlag type_flag);
diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.c b/source/blender/bmesh/intern/bmesh_mesh_conv.c
index 775c917e4aa..b7be0cc0ae2 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_conv.c
+++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c
@@ -233,12 +233,12 @@ void BM_mesh_bm_from_me(BMesh *bm, Mesh *me,
BMEdge *e, **etable = NULL;
BMFace *f;
float (*keyco)[3] = NULL;
- int *keyi;
int totuv, i, j;
int cd_vert_bweight_offset;
int cd_edge_bweight_offset;
int cd_edge_crease_offset;
+ int cd_shape_keyindex_offset;
/* free custom data */
/* this isnt needed in most cases but do just incase */
@@ -325,6 +325,7 @@ void BM_mesh_bm_from_me(BMesh *bm, Mesh *me,
cd_vert_bweight_offset = CustomData_get_offset(&bm->vdata, CD_BWEIGHT);
cd_edge_bweight_offset = CustomData_get_offset(&bm->edata, CD_BWEIGHT);
cd_edge_crease_offset = CustomData_get_offset(&bm->edata, CD_CREASE);
+ cd_shape_keyindex_offset = me->key ? CustomData_get_offset(&bm->vdata, CD_SHAPE_KEYINDEX) : -1;
for (i = 0, mvert = me->mvert; i < me->totvert; i++, mvert++) {
v = vtable[i] = BM_vert_create(bm, keyco && set_key ? keyco[i] : mvert->co, NULL, BM_CREATE_SKIP_CD);
@@ -348,10 +349,7 @@ void BM_mesh_bm_from_me(BMesh *bm, Mesh *me,
/* set shapekey data */
if (me->key) {
/* set shape key original index */
- keyi = CustomData_bmesh_get(&bm->vdata, v->head.data, CD_SHAPE_KEYINDEX);
- if (keyi) {
- *keyi = i;
- }
+ if (cd_shape_keyindex_offset != -1) BM_ELEM_CD_SET_INT(v, cd_shape_keyindex_offset, i);
for (block = me->key->block.first, j = 0; block; block = block->next, j++) {
float *co = CustomData_bmesh_get_n(&bm->vdata, v->head.data, CD_SHAPEKEY, j);
@@ -441,6 +439,7 @@ void BM_mesh_bm_from_me(BMesh *bm, Mesh *me,
}
bm->elem_index_dirty &= ~BM_FACE; /* added in order, clear dirty flag */
+ bm->elem_index_dirty |= BM_LOOP; /* did not set the loop indices */
if (me->mselect && me->totselect != 0) {
@@ -495,9 +494,9 @@ void BM_mesh_bm_from_me(BMesh *bm, Mesh *me,
*/
static BMVert **bm_to_mesh_vertex_map(BMesh *bm, int ototvert)
{
+ const int cd_shape_keyindex_offset = CustomData_get_offset(&bm->vdata, CD_SHAPE_KEYINDEX);
BMVert **vertMap = NULL;
BMVert *eve;
- int index;
int i = 0;
BMIter iter;
@@ -505,32 +504,22 @@ static BMVert **bm_to_mesh_vertex_map(BMesh *bm, int ototvert)
BLI_assert(ototvert > 0);
vertMap = MEM_callocN(sizeof(*vertMap) * ototvert, "vertMap");
- if (CustomData_has_layer(&bm->vdata, CD_SHAPE_KEYINDEX)) {
- int *keyi;
- BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
- keyi = CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_SHAPE_KEYINDEX);
- if (keyi) {
- if (((index = *keyi) != ORIGINDEX_NONE) && (index < ototvert)) {
- vertMap[index] = eve;
- }
- }
- else {
- if (i < ototvert) {
- vertMap[i] = eve;
- }
+ if (cd_shape_keyindex_offset != -1) {
+ BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, i) {
+ const int keyi = BM_ELEM_CD_GET_INT(eve, cd_shape_keyindex_offset);
+ if ((keyi != ORIGINDEX_NONE) && (keyi < ototvert)) {
+ vertMap[keyi] = eve;
}
- i++;
}
}
else {
- BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
+ BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, i) {
if (i < ototvert) {
vertMap[i] = eve;
}
else {
break;
}
- i++;
}
}
@@ -824,6 +813,8 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, bool do_tessface)
/* see comment below, this logic is in twice */
if (me->key) {
+ const int cd_shape_keyindex_offset = CustomData_get_offset(&bm->vdata, CD_SHAPE_KEYINDEX);
+
KeyBlock *currkey;
KeyBlock *actkey = BLI_findlink(&me->key->block, bm->shapenr - 1);
@@ -867,16 +858,17 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, bool do_tessface)
}
}
- if (act_is_basis) { /* active key is a base */
+ /* active key is a base */
+ if (act_is_basis && (cd_shape_keyindex_offset != -1)) {
float (*fp)[3] = actkey->data;
- int *keyi;
ofs = MEM_callocN(sizeof(float) * 3 * bm->totvert, "currkey->data");
mvert = me->mvert;
BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, i) {
- keyi = CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_SHAPE_KEYINDEX);
- if (keyi && *keyi != ORIGINDEX_NONE) {
- sub_v3_v3v3(ofs[i], mvert->co, fp[*keyi]);
+ const int keyi = BM_ELEM_CD_GET_INT(eve, cd_shape_keyindex_offset);
+
+ if (keyi != ORIGINDEX_NONE) {
+ sub_v3_v3v3(ofs[i], mvert->co, fp[keyi]);
}
else {
/* if there are new vertices in the mesh, we can't propagate the offset
@@ -893,12 +885,14 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, bool do_tessface)
}
for (currkey = me->key->block.first; currkey; currkey = currkey->next) {
- int apply_offset = (ofs && (currkey != actkey) && (bm->shapenr - 1 == currkey->relative));
- int *keyi;
+ const bool apply_offset = (ofs && (currkey != actkey) && (bm->shapenr - 1 == currkey->relative));
+ int cd_shape_offset;
+ int keyi;
float (*ofs_pt)[3] = ofs;
- float *newkey, *oldkey, *fp;
+ float *newkey, (*oldkey)[3], *fp;
j = bm_to_mesh_shape_layer_index_from_kb(bm, currkey);
+ cd_shape_offset = CustomData_get_n_offset(&bm->vdata, CD_SHAPEKEY, j);
fp = newkey = MEM_callocN(me->key->elemsize * bm->totvert, "currkey->data");
@@ -911,26 +905,29 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, bool do_tessface)
copy_v3_v3(fp, eve->co);
if (actkey != me->key->refkey) { /* important see bug [#30771] */
- if (oldverts) {
- keyi = CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_SHAPE_KEYINDEX);
- if (*keyi != ORIGINDEX_NONE && *keyi < currkey->totelem) { /* valid old vertex */
- copy_v3_v3(mvert->co, oldverts[*keyi].co);
+ if (cd_shape_keyindex_offset != -1) {
+ if (oldverts) {
+ keyi = BM_ELEM_CD_GET_INT(eve, cd_shape_keyindex_offset);
+ if (keyi != ORIGINDEX_NONE && keyi < currkey->totelem) { /* valid old vertex */
+ copy_v3_v3(mvert->co, oldverts[keyi].co);
+ }
}
}
}
}
else if (j != -1) {
/* in most cases this runs */
- copy_v3_v3(fp, CustomData_bmesh_get_n(&bm->vdata, eve->head.data, CD_SHAPEKEY, j));
+ copy_v3_v3(fp, BM_ELEM_CD_GET_VOID_P(eve, cd_shape_offset));
}
- else if (oldkey &&
- (keyi = CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_SHAPE_KEYINDEX)) &&
- (*keyi != ORIGINDEX_NONE && *keyi < currkey->totelem))
+ else if ((oldkey != NULL) &&
+ (cd_shape_keyindex_offset != -1) &&
+ ((keyi = BM_ELEM_CD_GET_INT(eve, cd_shape_keyindex_offset)) != ORIGINDEX_NONE) &&
+ (keyi < currkey->totelem))
{
/* old method of reconstructing keys via vertice's original key indices,
* currently used if the new method above fails (which is theoretically
* possible in certain cases of undo) */
- copy_v3_v3(fp, &oldkey[3 * (*keyi)]);
+ copy_v3_v3(fp, oldkey[keyi]);
}
else {
/* fail! fill in with dummy value */
diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c
index a72ebbb6f2c..60de592f964 100644
--- a/source/blender/bmesh/intern/bmesh_mods.c
+++ b/source/blender/bmesh/intern/bmesh_mods.c
@@ -32,7 +32,6 @@
#include "BLI_math.h"
#include "BLI_array.h"
-#include "BLI_smallhash.h"
#include "BKE_customdata.h"
@@ -192,8 +191,7 @@ bool BM_disk_dissolve(BMesh *bm, BMVert *v)
done = false;
break;
}
- e = bmesh_disk_edge_next(e, v);
- } while (e != v->e);
+ } while ((e = bmesh_disk_edge_next(e, v)) != v->e);
}
/* collapse the vertex */
@@ -303,8 +301,6 @@ BMFace *BM_face_split(BMesh *bm, BMFace *f,
#endif
if (f_new) {
- BM_elem_attrs_copy(bm, bm, f, f_new);
-
/* handle multires update */
if (has_mdisp) {
BMLoop *l_iter;
@@ -393,9 +389,6 @@ BMFace *BM_face_split_n(BMesh *bm, BMFace *f,
* The radial_next is for f and goes from v_b to v_a */
if (f_new) {
- BM_elem_attrs_copy(bm, bm, f, f_new);
- copy_v3_v3(f_new->no, f->no);
-
e = (*r_l)->e;
for (i = 0; i < n; i++) {
v_new = bmesh_semv(bm, v_b, e, &e_new);
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c
index 305ae5283b0..f8cca0a3707 100644
--- a/source/blender/bmesh/intern/bmesh_opdefines.c
+++ b/source/blender/bmesh/intern/bmesh_opdefines.c
@@ -1119,7 +1119,7 @@ static BMOpDefine bmo_subdivide_edges_def = {
/*
* Subdivide Edge-Ring.
*
- * Take an edge-ring, and supdivide with interpolation options.
+ * Take an edge-ring, and subdivide with interpolation options.
*/
static BMOpDefine bmo_subdivide_edgering_def = {
"subdivide_edgering",
diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c
index ec94602e8e2..2a6b4d70419 100644
--- a/source/blender/bmesh/intern/bmesh_operators.c
+++ b/source/blender/bmesh/intern/bmesh_operators.c
@@ -347,13 +347,10 @@ void _bmo_slot_copy(BMOpSlot slot_args_src[BMO_OP_MAX_SLOTS], const char *slot_n
}
}
else if (slot_dst->slot_type == BMO_OP_SLOT_MAPPING) {
- GHashIterator it;
- for (BLI_ghashIterator_init(&it, slot_src->data.ghash);
- BLI_ghashIterator_done(&it) == false;
- BLI_ghashIterator_step(&it))
- {
- void *key = BLI_ghashIterator_getKey(&it);
- void *val = BLI_ghashIterator_getValue(&it);
+ GHashIterator gh_iter;
+ GHASH_ITER (gh_iter, slot_src->data.ghash) {
+ void *key = BLI_ghashIterator_getKey(&gh_iter);
+ void *val = BLI_ghashIterator_getValue(&gh_iter);
BLI_ghash_insert(slot_dst->data.ghash, key, val);
}
}
@@ -722,17 +719,15 @@ void *bmo_slot_buffer_grow(BMesh *bm, BMOperator *op, int slot_code, int totadd)
void BMO_slot_map_to_flag(BMesh *bm, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name,
const char htype, const short oflag)
{
- GHashIterator it;
+ GHashIterator gh_iter;
BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BMElemF *ele_f;
BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING);
- for (BLI_ghashIterator_init(&it, slot->data.ghash);
- (ele_f = BLI_ghashIterator_getKey(&it));
- BLI_ghashIterator_step(&it))
- {
+ GHASH_ITER (gh_iter, slot->data.ghash) {
+ ele_f = BLI_ghashIterator_getKey(&gh_iter);
if (ele_f->head.htype & htype) {
BMO_elem_flag_enable(bm, ele_f, oflag);
}
@@ -1167,9 +1162,9 @@ static void bmo_flag_layer_alloc(BMesh *bm)
bm->totflags++;
- bm->vtoolflagpool = BLI_mempool_create(sizeof(BMFlagLayer) * bm->totflags, max_ii(512, bm->totvert), 512, BLI_MEMPOOL_NOP);
- bm->etoolflagpool = BLI_mempool_create(sizeof(BMFlagLayer) * bm->totflags, max_ii(512, bm->totedge), 512, BLI_MEMPOOL_NOP);
- bm->ftoolflagpool = BLI_mempool_create(sizeof(BMFlagLayer) * bm->totflags, max_ii(512, bm->totface), 512, BLI_MEMPOOL_NOP);
+ bm->vtoolflagpool = BLI_mempool_create(sizeof(BMFlagLayer) * bm->totflags, bm->totvert, 512, BLI_MEMPOOL_NOP);
+ bm->etoolflagpool = BLI_mempool_create(sizeof(BMFlagLayer) * bm->totflags, bm->totedge, 512, BLI_MEMPOOL_NOP);
+ bm->ftoolflagpool = BLI_mempool_create(sizeof(BMFlagLayer) * bm->totflags, bm->totface, 512, BLI_MEMPOOL_NOP);
#pragma omp parallel sections if (bm->totvert + bm->totedge + bm->totface >= BM_OMP_LIMIT)
{
@@ -1424,10 +1419,19 @@ void *BMO_iter_step(BMOIter *iter)
return ele;
}
else if (slot->slot_type == BMO_OP_SLOT_MAPPING) {
- void *ret = BLI_ghashIterator_getKey(&iter->giter);
- iter->val = BLI_ghashIterator_getValue_p(&iter->giter);
+ void *ret;
+
+
+ if (BLI_ghashIterator_done(&iter->giter) == false) {
+ ret = BLI_ghashIterator_getKey(&iter->giter);
+ iter->val = BLI_ghashIterator_getValue_p(&iter->giter);
- BLI_ghashIterator_step(&iter->giter);
+ BLI_ghashIterator_step(&iter->giter);
+ }
+ else {
+ ret = NULL;
+ iter->val = NULL;
+ }
return ret;
}
diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c
index aff7d37abe9..3422656b50c 100644
--- a/source/blender/bmesh/intern/bmesh_polygon.c
+++ b/source/blender/bmesh/intern/bmesh_polygon.c
@@ -37,7 +37,6 @@
#include "BLI_math.h"
#include "BLI_memarena.h"
#include "BLI_polyfill2d.h"
-#include "BLI_listbase.h"
#include "bmesh.h"
#include "bmesh_tools.h"
@@ -70,40 +69,16 @@ static bool testedgesidef(const float v1[2], const float v2[2], const float v3[2
}
/**
- * \brief COMPUTE POLY NORMAL
- *
- * Computes the normal of a planar
- * polygon See Graphics Gems for
- * computing newell normal.
- */
-static void calc_poly_normal(float normal[3], float verts[][3], int nverts)
-{
- float const *v_prev = verts[nverts - 1];
- float const *v_curr = verts[0];
- float n[3] = {0.0f};
- int i;
-
- /* Newell's Method */
- for (i = 0; i < nverts; v_prev = v_curr, v_curr = verts[++i]) {
- add_newell_cross_v3_v3v3(n, v_prev, v_curr);
- }
-
- if (UNLIKELY(normalize_v3_v3(normal, n) == 0.0f)) {
- normal[2] = 1.0f; /* other axis set to 0.0 */
- }
-}
-
-/**
* \brief COMPUTE POLY NORMAL (BMFace)
*
- * Same as #calc_poly_normal but operates directly on a bmesh face.
+ * Same as #normal_poly_v3 but operates directly on a bmesh face.
*/
static void bm_face_calc_poly_normal(const BMFace *f, float n[3])
{
BMLoop *l_first = BM_FACE_FIRST_LOOP(f);
BMLoop *l_iter = l_first;
- float const *v_prev = l_first->prev->v->co;
- float const *v_curr = l_first->v->co;
+ const float *v_prev = l_first->prev->v->co;
+ const float *v_curr = l_first->v->co;
zero_v3(n);
@@ -133,8 +108,8 @@ static void bm_face_calc_poly_normal_vertex_cos(BMFace *f, float r_no[3],
{
BMLoop *l_first = BM_FACE_FIRST_LOOP(f);
BMLoop *l_iter = l_first;
- float const *v_prev = vertexCos[BM_elem_index_get(l_first->prev->v)];
- float const *v_curr = vertexCos[BM_elem_index_get(l_first->v)];
+ const float *v_prev = vertexCos[BM_elem_index_get(l_first->prev->v)];
+ const float *v_curr = vertexCos[BM_elem_index_get(l_first->v)];
zero_v3(r_no);
@@ -229,15 +204,15 @@ void BM_face_calc_tessellation(const BMFace *f, BMLoop **r_loops, unsigned int (
*/
float BM_face_calc_area(BMFace *f)
{
- BMLoop *l;
- BMIter iter;
+ BMLoop *l_iter, *l_first;
float (*verts)[3] = BLI_array_alloca(verts, f->len);
float area;
- int i;
+ unsigned int i = 0;
- BM_ITER_ELEM_INDEX (l, &iter, f, BM_LOOPS_OF_FACE, i) {
- copy_v3_v3(verts[i], l->v->co);
- }
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ copy_v3_v3(verts[i++], l_iter->v->co);
+ } while ((l_iter = l_iter->next) != l_first);
if (f->len == 3) {
area = area_tri_v3(verts[0], verts[1], verts[2]);
@@ -246,9 +221,7 @@ float BM_face_calc_area(BMFace *f)
area = area_quad_v3(verts[0], verts[1], verts[2], verts[3]);
}
else {
- float normal[3];
- calc_poly_normal(normal, verts, f->len);
- area = area_poly_v3((const float (*)[3])verts, f->len, normal);
+ area = area_poly_v3((const float (*)[3])verts, f->len);
}
return area;
@@ -388,46 +361,6 @@ void BM_face_calc_center_mean_weighted(BMFace *f, float r_cent[3])
}
/**
- * COMPUTE POLY PLANE
- *
- * Projects a set polygon's vertices to
- * a plane defined by the average
- * of its edges cross products
- */
-void calc_poly_plane(float (*verts)[3], const int nverts)
-{
-
- float avgc[3], norm[3], mag, avgn[3];
- float *v1, *v2, *v3;
- int i;
-
- if (nverts < 3)
- return;
-
- zero_v3(avgn);
- zero_v3(avgc);
-
- for (i = 0; i < nverts; i++) {
- v1 = verts[i];
- v2 = verts[(i + 1) % nverts];
- v3 = verts[(i + 2) % nverts];
- normal_tri_v3(norm, v1, v2, v3);
-
- add_v3_v3(avgn, norm);
- }
-
- if (UNLIKELY(normalize_v3(avgn) == 0.0f)) {
- avgn[2] = 1.0f;
- }
-
- for (i = 0; i < nverts; i++) {
- v1 = verts[i];
- mag = dot_v3v3(v1, avgn);
- madd_v3_v3fl(v1, avgn, -mag);
- }
-}
-
-/**
* \brief BM LEGAL EDGES
*
* takes in a face and a list of edges, and sets to NULL any edge in
@@ -456,15 +389,18 @@ static void scale_edge_v2f(float v1[2], float v2[2], const float fac)
* Rotates a polygon so that it's
* normal is pointing towards the mesh Z axis
*/
-void poly_rotate_plane(const float normal[3], float (*verts)[3], const int nverts)
+void poly_rotate_plane(const float normal[3], float (*verts)[3], const unsigned int nverts)
{
float mat[3][3];
+ float co[3];
+ unsigned int i;
- if (axis_dominant_v3_to_m3(mat, normal)) {
- int i;
- for (i = 0; i < nverts; i++) {
- mul_m3_v3(mat, verts[i]);
- }
+ co[2] = 0.0f;
+
+ axis_dominant_v3_to_m3(mat, normal);
+ for (i = 0; i < nverts; i++) {
+ mul_v2_m3v3(co, mat, verts[i]);
+ copy_v3_v3(verts[i], co);
}
}
diff --git a/source/blender/bmesh/intern/bmesh_private.h b/source/blender/bmesh/intern/bmesh_private.h
index 7ec418b2253..cac4713c8b2 100644
--- a/source/blender/bmesh/intern/bmesh_private.h
+++ b/source/blender/bmesh/intern/bmesh_private.h
@@ -72,8 +72,7 @@ enum {
#define BM_ELEM_API_FLAG_TEST(element, f) ((element)->head.api_flag & (f))
#define BM_ELEM_API_FLAG_CLEAR(element) ((element)->head.api_flag = 0)
-void calc_poly_plane(float (*verts)[3], const int nverts);
-void poly_rotate_plane(const float normal[3], float (*verts)[3], const int nverts);
+void poly_rotate_plane(const float normal[3], float (*verts)[3], unsigned const int nverts);
/* include the rest of our private declarations */
#include "bmesh_structure.h"
diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c
index f240a10efc8..67f333215d9 100644
--- a/source/blender/bmesh/intern/bmesh_queries.c
+++ b/source/blender/bmesh/intern/bmesh_queries.c
@@ -1236,7 +1236,7 @@ float BM_vert_calc_shell_factor(BMVert *v)
BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) {
const float face_angle = BM_loop_calc_face_angle(l);
- accum_shell += shell_angle_to_dist(angle_normalized_v3v3(v->no, l->f->no)) * face_angle;
+ accum_shell += shell_v3v3_normalized_to_dist(v->no, l->f->no) * face_angle;
accum_angle += face_angle;
}
@@ -1260,7 +1260,7 @@ float BM_vert_calc_shell_factor_ex(BMVert *v, const char hflag)
BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) {
if (BM_elem_flag_test(l->f, hflag)) { /* <-- main difference to BM_vert_calc_shell_factor! */
const float face_angle = BM_loop_calc_face_angle(l);
- accum_shell += shell_angle_to_dist(angle_normalized_v3v3(v->no, l->f->no)) * face_angle;
+ accum_shell += shell_v3v3_normalized_to_dist(v->no, l->f->no) * face_angle;
accum_angle += face_angle;
tot_sel++;
}
diff --git a/source/blender/bmesh/intern/bmesh_walkers.c b/source/blender/bmesh/intern/bmesh_walkers.c
index 72b4c5d6623..75513a48d98 100644
--- a/source/blender/bmesh/intern/bmesh_walkers.c
+++ b/source/blender/bmesh/intern/bmesh_walkers.c
@@ -115,7 +115,7 @@ void BMW_init(BMWalker *walker, BMesh *bm, int type,
BLI_assert(mask_face == 0 || (walker->valid_mask & BM_FACE));
}
- walker->worklist = BLI_mempool_create(walker->structsize, 128, 128, BLI_MEMPOOL_NOP);
+ 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 ee0e35b1013..70b90238f96 100644
--- a/source/blender/bmesh/intern/bmesh_walkers_impl.c
+++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c
@@ -211,8 +211,7 @@ static void *bmw_ShellWalker_step(BMWalker *walker)
newState->curedge = curedge;
}
}
- curedge = bmesh_disk_edge_next(curedge, shellWalk.base);
- } while (curedge != shellWalk.curedge);
+ } while ((curedge = bmesh_disk_edge_next(curedge, shellWalk.base)) != shellWalk.curedge);
return shellWalk.curedge;
}
@@ -472,8 +471,10 @@ static void bmw_LoopWalker_begin(BMWalker *walker, void *data)
BMwLoopWalker *lwalk = NULL, owalk, *owalk_pt;
BMEdge *e = data;
BMVert *v;
- int vert_edge_count[2] = {BM_vert_edge_count_nonwire(e->v1),
- BM_vert_edge_count_nonwire(e->v2)};
+ const int vert_edge_count[2] = {
+ BM_vert_edge_count_nonwire(e->v1),
+ BM_vert_edge_count_nonwire(e->v2),
+ };
v = e->v1;
diff --git a/source/blender/bmesh/operators/bmo_connect.c b/source/blender/bmesh/operators/bmo_connect.c
index 89969640320..2e45cb9fec1 100644
--- a/source/blender/bmesh/operators/bmo_connect.c
+++ b/source/blender/bmesh/operators/bmo_connect.c
@@ -26,7 +26,6 @@
* Connect verts across faces (splits faces).
*/
-#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BLI_alloca.h"
#include "BLI_linklist_stack.h"
diff --git a/source/blender/bmesh/operators/bmo_connect_nonplanar.c b/source/blender/bmesh/operators/bmo_connect_nonplanar.c
index 334647fc68c..15447c97b5f 100644
--- a/source/blender/bmesh/operators/bmo_connect_nonplanar.c
+++ b/source/blender/bmesh/operators/bmo_connect_nonplanar.c
@@ -43,7 +43,7 @@
*/
static bool bm_face_subset_calc_normal(BMLoop *l_first, BMLoop *l_last, float r_no[3])
{
- float const *v_prev, *v_curr;
+ const float *v_prev, *v_curr;
/* Newell's Method */
BMLoop *l_iter = l_first;
diff --git a/source/blender/bmesh/operators/bmo_connect_pair.c b/source/blender/bmesh/operators/bmo_connect_pair.c
index 7f23744d61e..b497ab2f693 100644
--- a/source/blender/bmesh/operators/bmo_connect_pair.c
+++ b/source/blender/bmesh/operators/bmo_connect_pair.c
@@ -387,7 +387,7 @@ void bmo_connect_vert_pair_exec(BMesh *bm, BMOperator *op)
/* setup context */
{
BLI_listbase_clear(&pc.state_lb);
- pc.link_pool = BLI_mempool_create(sizeof(PathLink), 1, 512, BLI_MEMPOOL_NOP);
+ pc.link_pool = BLI_mempool_create(sizeof(PathLink), 0, 512, BLI_MEMPOOL_NOP);
}
/* calculate matrix */
diff --git a/source/blender/bmesh/operators/bmo_edgenet.c b/source/blender/bmesh/operators/bmo_edgenet.c
index de41bc7937d..0c5de590ccf 100644
--- a/source/blender/bmesh/operators/bmo_edgenet.c
+++ b/source/blender/bmesh/operators/bmo_edgenet.c
@@ -114,7 +114,7 @@ void bmo_edgenet_prepare_exec(BMesh *bm, BMOperator *op)
BLI_array_declare(edges1);
BLI_array_declare(edges2);
BLI_array_declare(edges);
- int ok = 1;
+ bool ok = true;
int i, count;
BMO_slot_buffer_flag_enable(bm, op->slots_in, "edges", BM_EDGE, EDGE_MARK);
diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c
index 90c514bfd02..f924d478f1a 100644
--- a/source/blender/bmesh/operators/bmo_extrude.c
+++ b/source/blender/bmesh/operators/bmo_extrude.c
@@ -602,7 +602,7 @@ static void solidify_add_thickness(BMesh *bm, const float dist)
v = l->v;
index = BM_elem_index_get(v);
vert_accum[index] += face_angles[i];
- vert_angles[index] += shell_angle_to_dist(angle_normalized_v3v3(v->no, f->no)) * face_angles[i];
+ vert_angles[index] += shell_v3v3_normalized_to_dist(v->no, f->no) * face_angles[i];
i++;
}
}
diff --git a/source/blender/bmesh/operators/bmo_hull.c b/source/blender/bmesh/operators/bmo_hull.c
index c0aea34ec35..26a4dbe1e1d 100644
--- a/source/blender/bmesh/operators/bmo_hull.c
+++ b/source/blender/bmesh/operators/bmo_hull.c
@@ -213,15 +213,15 @@ static HullFinalEdges *hull_final_edges(GSet *hull_triangles)
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), 128, 128, BLI_MEMPOOL_NOP);
- final_edges->link_pool = BLI_mempool_create(sizeof(LinkData), 128, 128, BLI_MEMPOOL_NOP);
+ final_edges->base_pool = BLI_mempool_create(sizeof(ListBase), 0, 128, BLI_MEMPOOL_NOP);
+ final_edges->link_pool = BLI_mempool_create(sizeof(LinkData), 0, 128, BLI_MEMPOOL_NOP);
GSET_ITER (iter, hull_triangles) {
+ HullTriangle *t = BLI_gsetIterator_getKey(&iter);
LinkData *link;
int i;
-
+
for (i = 0; i < 3; i++) {
- HullTriangle *t = BLI_gsetIterator_getKey(&iter);
BMVert *v1 = t->v[i];
BMVert *v2 = t->v[(i + 1) % 3];
ListBase *adj;
@@ -574,7 +574,7 @@ void bmo_convex_hull_exec(BMesh *bm, BMOperator *op)
BMO_elem_flag_enable(bm, ele, HULL_FLAG_INTERIOR_ELE);
}
- hull_pool = BLI_mempool_create(sizeof(HullTriangle), 128, 128, BLI_MEMPOOL_NOP);
+ hull_pool = BLI_mempool_create(sizeof(HullTriangle), 0, 128, BLI_MEMPOOL_NOP);
hull_triangles = BLI_gset_ptr_new("hull_triangles");
hull_from_bullet(bm, op, hull_triangles, hull_pool);
diff --git a/source/blender/bmesh/operators/bmo_inset.c b/source/blender/bmesh/operators/bmo_inset.c
index 29522b62707..cb4255d337e 100644
--- a/source/blender/bmesh/operators/bmo_inset.c
+++ b/source/blender/bmesh/operators/bmo_inset.c
@@ -201,7 +201,7 @@ static void bmo_face_inset_individual(
copy_v3_v3(v_new_co, l_iter->v->co);
if (use_even_offset) {
- mul_v3_fl(tvec, shell_angle_to_dist(angle_normalized_v3v3(eno_prev, eno_next) / 2.0f));
+ mul_v3_fl(tvec, shell_v3v3_mid_normalized_to_dist(eno_prev, eno_next));
}
/* Modify vertices and their normals */
@@ -395,9 +395,6 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
const float thickness = BMO_slot_float_get(op->slots_in, "thickness");
const float depth = BMO_slot_float_get(op->slots_in, "depth");
- /* store vert coords in normals, needed for 'use_edge_rail' */
-#define USE_VERTNORMAL_HACK
-
int edge_info_len = 0;
BMIter iter;
@@ -410,6 +407,11 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
int iface_array_len;
MemArena *interp_arena = NULL;
+ /* BMVert original location storage */
+ const bool use_vert_coords_orig = use_edge_rail;
+ MemArena *vert_coords_orig = NULL;
+ GHash *vert_coords = NULL;
+
BMVert *v;
BMEdge *e;
BMFace *f;
@@ -456,11 +458,6 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
BM_elem_index_set(e, -1); /* set_dirty! */
}
-
-#ifdef USE_VERTNORMAL_HACK
- copy_v3_v3(e->v1->no, e->v1->co);
- copy_v3_v3(e->v2->no, e->v2->co);
-#endif
}
bm->elem_index_dirty |= BM_EDGE;
@@ -479,6 +476,22 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
}
}
+
+ if (use_vert_coords_orig) {
+ vert_coords_orig = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
+ vert_coords = BLI_ghash_ptr_new(__func__);
+ }
+
+ /* util macros */
+#define VERT_ORIG_STORE(_v) { \
+ float *_co = BLI_memarena_alloc(vert_coords_orig, sizeof(float[3])); \
+ copy_v3_v3(_co, (_v)->co); \
+ BLI_ghash_insert(vert_coords, _v, _co); \
+ } (void)0
+#define VERT_ORIG_GET(_v) \
+ (const float *)BLI_ghash_lookup_default(vert_coords, (_v), (_v)->co)
+
+
for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
if ((es->l = bm_edge_is_mixed_face_tag(es->e_old->l))) {
/* do nothing */
@@ -572,9 +585,9 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
/* in some cases the edge doesn't split off */
if (r_vout_len == 1) {
-#ifdef USE_VERTNORMAL_HACK
- copy_v3_v3(vout[0]->no, vout[0]->co);
-#endif
+ if (use_vert_coords_orig) {
+ VERT_ORIG_STORE(vout[0]);
+ }
MEM_freeN(vout);
continue;
}
@@ -586,9 +599,9 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
int vert_edge_tag_tot = 0;
int vecpair[2];
-#ifdef USE_VERTNORMAL_HACK
- copy_v3_v3(v_split->no, v_split->co);
-#endif
+ if (use_vert_coords_orig) {
+ VERT_ORIG_STORE(v_split);
+ }
/* find adjacent */
BM_ITER_ELEM (e, &iter, v_split, BM_EDGES_OF_VERT) {
@@ -647,11 +660,12 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
/* note that we can't use 'l_other_a->v' directly since it
* may be inset and give a feedback loop. */
-#ifdef USE_VERTNORMAL_HACK
- co_other = l_other_a->v->no;
-#else
- co_other = l_other_a->v->co;
-#endif
+ if (use_vert_coords_orig) {
+ co_other = VERT_ORIG_GET(l_other_a->v);
+ }
+ else {
+ co_other = l_other_a->v->co;
+ }
sub_v3_v3v3(tvec, co_other, v_split->co);
is_mid = false;
@@ -680,14 +694,16 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
/* scale by edge angle */
if (use_even_offset) {
if (is_mid) {
- mul_v3_fl(tvec, shell_angle_to_dist(angle_normalized_v3v3(e_info_a->no,
- e_info_b->no) / 2.0f));
+ mul_v3_fl(tvec, shell_v3v3_mid_normalized_to_dist(e_info_a->no,
+ e_info_b->no));
}
else {
- mul_v3_fl(tvec, shell_angle_to_dist(max_ff(angle_normalized_v3v3(tvec,
- e_info_a->no),
- angle_normalized_v3v3(tvec,
- e_info_b->no))));
+ /* use the largest angle */
+ mul_v3_fl(tvec,
+ shell_v3v3_normalized_to_dist(tvec,
+ len_squared_v3v3(tvec, e_info_a->no) >
+ len_squared_v3v3(tvec, e_info_b->no) ?
+ e_info_a->no : e_info_b->no));
}
}
@@ -758,7 +774,7 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
normalize_v3(tvec);
if (use_even_offset) {
- mul_v3_fl(tvec, shell_angle_to_dist(angle_normalized_v3v3(e_no_a, tvec)));
+ mul_v3_fl(tvec, shell_v3v3_normalized_to_dist(e_no_a, tvec));
}
}
else {
@@ -810,6 +826,11 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
}
}
+ if (use_vert_coords_orig) {
+ BLI_memarena_free(vert_coords_orig);
+ BLI_ghash_free(vert_coords, NULL, NULL);
+ }
+
if (use_interpolate) {
for (i = 0; i < iface_array_len; i++) {
if (iface_array[i]) {
@@ -927,7 +948,7 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
zero_v3(es->e_new->v2->no);
}
for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
- float *no = es->l->f->no;
+ const float *no = es->l->f->no;
add_v3_v3(es->e_new->v1->no, no);
add_v3_v3(es->e_new->v2->no, no);
}
diff --git a/source/blender/bmesh/operators/bmo_removedoubles.c b/source/blender/bmesh/operators/bmo_removedoubles.c
index cef7c70d520..216d3410de8 100644
--- a/source/blender/bmesh/operators/bmo_removedoubles.c
+++ b/source/blender/bmesh/operators/bmo_removedoubles.c
@@ -219,7 +219,7 @@ void bmo_weld_verts_exec(BMesh *bm, BMOperator *op)
}
}
}
- bm->elem_index_dirty |= BM_FACE;
+ bm->elem_index_dirty |= BM_FACE | BM_LOOP;
/* faces get "modified" by creating new faces here, then at the
* end the old faces are deleted */
diff --git a/source/blender/bmesh/operators/bmo_similar.c b/source/blender/bmesh/operators/bmo_similar.c
index 2d6ceb23f37..f779828a00d 100644
--- a/source/blender/bmesh/operators/bmo_similar.c
+++ b/source/blender/bmesh/operators/bmo_similar.c
@@ -438,7 +438,7 @@ void bmo_similar_edges_exec(BMesh *bm, BMOperator *op)
case SIMEDGE_CREASE:
{
- float *c1, *c2;
+ const float *c1, *c2;
c1 = CustomData_bmesh_get(&bm->edata, e->head.data, CD_CREASE);
c2 = CustomData_bmesh_get(&bm->edata, es->head.data, CD_CREASE);
@@ -453,7 +453,7 @@ void bmo_similar_edges_exec(BMesh *bm, BMOperator *op)
case SIMEDGE_BEVEL:
{
- float *c1, *c2;
+ const float *c1, *c2;
c1 = CustomData_bmesh_get(&bm->edata, e->head.data, CD_BWEIGHT);
c2 = CustomData_bmesh_get(&bm->edata, es->head.data, CD_BWEIGHT);
diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c
index 1e93340d8a3..e0c86564db4 100644
--- a/source/blender/bmesh/operators/bmo_subdivide.c
+++ b/source/blender/bmesh/operators/bmo_subdivide.c
@@ -1002,7 +1002,7 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
/* copy original-geometry displacements to current coordinates */
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);
+ const float *co = BM_ELEM_CD_GET_VOID_P(v, params.shape_info.cd_vert_shape_offset_tmp);
copy_v3_v3(v->co, co);
}
@@ -1147,7 +1147,7 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
/* copy original-geometry displacements to current coordinates */
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);
+ const float *co = BM_ELEM_CD_GET_VOID_P(v, params.shape_info.cd_vert_shape_offset_tmp);
copy_v3_v3(v->co, co);
}
diff --git a/source/blender/bmesh/tools/bmesh_beautify.c b/source/blender/bmesh/tools/bmesh_beautify.c
index cbe704dbf19..90d26a775d3 100644
--- a/source/blender/bmesh/tools/bmesh_beautify.c
+++ b/source/blender/bmesh/tools/bmesh_beautify.c
@@ -59,16 +59,14 @@ typedef struct EdRotState {
int f1, f2; /* face vert, small -> large */
} EdRotState;
+#if 0
+/* use BLI_ghashutil_inthash_v4 direct */
static unsigned int erot_gsetutil_hash(const void *ptr)
{
const EdRotState *e_state = (const EdRotState *)ptr;
- unsigned int
- hash = BLI_ghashutil_inthash(SET_INT_IN_POINTER(e_state->v1));
- hash ^= BLI_ghashutil_inthash(SET_INT_IN_POINTER(e_state->v2));
- hash ^= BLI_ghashutil_inthash(SET_INT_IN_POINTER(e_state->f1));
- hash ^= BLI_ghashutil_inthash(SET_INT_IN_POINTER(e_state->f2));
- return hash;
+ return BLI_ghashutil_inthash_v4(&e_state->v1);
}
+#endif
static int erot_gsetutil_cmp(const void *a, const void *b)
{
const EdRotState *e_state_a = (const EdRotState *)a;
@@ -86,7 +84,7 @@ static int erot_gsetutil_cmp(const void *a, const void *b)
static GSet *erot_gset_new(void)
{
- return BLI_gset_new(erot_gsetutil_hash, erot_gsetutil_cmp, __func__);
+ return BLI_gset_new(BLI_ghashutil_inthash_v4_p, erot_gsetutil_cmp, __func__);
}
/* ensure v0 is smaller */
@@ -135,10 +133,11 @@ static float bm_edge_calc_rotate_beauty__area(
/* not a loop (only to be able to break out) */
do {
float v1_xy[2], v2_xy[2], v3_xy[2], v4_xy[2];
+ bool is_zero_a, is_zero_b;
/* first get the 2d values */
{
- bool is_zero_a, is_zero_b;
+ float no_a[3], no_b[3];
float no[3];
float axis_mat[3][3];
@@ -148,23 +147,20 @@ static float bm_edge_calc_rotate_beauty__area(
(ELEM3(v3, v1, v2, v4) == false) &&
(ELEM3(v4, v1, v2, v3) == false));
- is_zero_a = area_tri_v3(v2, v3, v4) <= FLT_EPSILON;
- is_zero_b = area_tri_v3(v2, v4, v1) <= FLT_EPSILON;
+ is_zero_a = (normal_tri_v3(no_a, v2, v3, v4) <= FLT_EPSILON);
+ is_zero_b = (normal_tri_v3(no_b, v2, v4, v1) <= FLT_EPSILON);
if (LIKELY(is_zero_a == false && is_zero_b == false)) {
- float no_a[3], no_b[3];
- normal_tri_v3(no_a, v2, v3, v4); /* a */
- normal_tri_v3(no_b, v2, v4, v1); /* b */
add_v3_v3v3(no, no_a, no_b);
if (UNLIKELY(normalize_v3(no) <= FLT_EPSILON)) {
break;
}
}
else if (is_zero_a == false) {
- normal_tri_v3(no, v2, v3, v4); /* a */
+ copy_v3_v3(no, no_a);
}
else if (is_zero_b == false) {
- normal_tri_v3(no, v2, v4, v1); /* b */
+ copy_v3_v3(no, no_b);
}
else {
/* both zero area, no useful normal can be calculated */
@@ -182,7 +178,32 @@ static float bm_edge_calc_rotate_beauty__area(
// printf("%p %p %p %p - %p %p\n", v1, v2, v3, v4, e->l->f, e->l->radial_next->f);
- if (is_quad_convex_v2(v1_xy, v2_xy, v3_xy, v4_xy)) {
+ if (is_zero_a == false && is_zero_b == false) {
+ /* both tri's are valid, check we make a concave quad */
+ if (!is_quad_convex_v2(v1_xy, v2_xy, v3_xy, v4_xy)) {
+ break;
+ }
+ }
+ else {
+ /* one of the tri's was degenerate, chech we're not rotating
+ * into a different degenerate shape or flipping the face */
+ float area_a, area_b;
+
+ area_a = area_tri_signed_v2(v1_xy, v2_xy, v3_xy);
+ area_b = area_tri_signed_v2(v1_xy, v3_xy, v4_xy);
+
+ if ((fabsf(area_a) <= FLT_EPSILON) || (fabsf(area_b) <= FLT_EPSILON)) {
+ /* one of the new rotations is degenerate */
+ break;
+ }
+
+ if ((area_a >= 0.0f) != (area_b >= 0.0f)) {
+ /* rotation would cause flipping */
+ break;
+ }
+ }
+
+ {
/* testing rule: the area divided by the perimeter,
* check if (1-3) beats the existing (2-4) edge rotation */
float area_a, area_b;
@@ -251,7 +272,8 @@ static float bm_edge_calc_rotate_beauty__angle(
}
float BM_verts_calc_rotate_beauty(
-const BMVert *v1, const BMVert *v2, const BMVert *v3, const BMVert *v4, const short flag, const short method)
+ const BMVert *v1, const BMVert *v2, const BMVert *v3, const BMVert *v4,
+ const short flag, const short method)
{
/* not a loop (only to be able to break out) */
do {
@@ -385,7 +407,7 @@ void BM_mesh_beautify_fill(BMesh *bm, BMEdge **edge_array, const int edge_array_
HeapNode **eheap_table; /* edge index aligned table pointing to the eheap */
GSet **edge_state_arr = MEM_callocN((size_t)edge_array_len * sizeof(GSet *), __func__);
- BLI_mempool *edge_state_pool = BLI_mempool_create(sizeof(EdRotState), 512, 512, BLI_MEMPOOL_NOP);
+ BLI_mempool *edge_state_pool = BLI_mempool_create(sizeof(EdRotState), 0, 512, BLI_MEMPOOL_NOP);
int i;
#ifdef DEBUG_TIME
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
index d781f9c3572..33ba4b9550e 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -1197,7 +1197,7 @@ static void get_profile_point(BevelParams *bp, const Profile *pro, int i, int n,
static void calculate_profile(BevelParams *bp, BoundVert *bndv)
{
int i, k, ns;
- float *uvals;
+ const float *uvals;
float co[3], co2[3], p[3], m[4][4];
float *prof_co, *prof_co_k;
float r;
@@ -1375,7 +1375,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
BevVert *bvother;
VMesh *vm;
float co[3];
- const float *no;
+ const float *no;
float lastd;
vm = bv->vmesh;
@@ -2821,6 +2821,7 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
* Want edges to be ordered so that they share faces.
* There may be one or more chains of shared faces broken by
* gaps where there are no faces.
+ * TODO: Want to ignore wire edges completely for edge beveling.
* TODO: make following work when more than one gap.
*/
@@ -2838,7 +2839,6 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
first_bme = bme;
}
ntot++;
-
BM_BEVEL_EDGE_TAG_DISABLE(bme);
}
if (!first_bme)
@@ -2850,10 +2850,6 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
return NULL;
}
- /* avoid calling BM_vert_edge_count since we loop over edges already */
- // ntot = BM_vert_edge_count(v);
- // BLI_assert(ntot == BM_vert_edge_count(v));
-
bv = (BevVert *)BLI_memarena_alloc(bp->mem_arena, (sizeof(BevVert)));
bv->v = v;
bv->edgecount = ntot;
@@ -2938,6 +2934,11 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
}
}
+ /* now done with tag flag */
+ BM_ITER_ELEM (bme, &iter, v, BM_EDGES_OF_VERT) {
+ BM_BEVEL_EDGE_TAG_DISABLE(bme);
+ }
+
/* if edge array doesn't go CCW around vertex from average normal side,
* reverse the array, being careful to reverse face pointers too */
if (ntot > 1) {
@@ -3016,7 +3017,6 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
e->offset_l = e->offset_l_spec;
e->offset_r = e->offset_r_spec;
- BM_BEVEL_EDGE_TAG_DISABLE(e->e);
if (e->fprev && e->fnext)
e->is_seam = !contig_ldata_across_edge(bm, e->e, e->fprev, e->fnext);
else
diff --git a/source/blender/bmesh/tools/bmesh_decimate_collapse.c b/source/blender/bmesh/tools/bmesh_decimate_collapse.c
index 00915d60428..f614c43193a 100644
--- a/source/blender/bmesh/tools/bmesh_decimate_collapse.c
+++ b/source/blender/bmesh/tools/bmesh_decimate_collapse.c
@@ -30,7 +30,6 @@
#include "MEM_guardedalloc.h"
-#include "DNA_scene_types.h"
#include "BLI_math.h"
#include "BLI_quadric.h"
@@ -146,8 +145,8 @@ static bool bm_edge_collapse_is_degenerate_flip(BMEdge *e, const float optimize_
BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) {
if (l->e != e && l->prev->e != e) {
- float *co_prev = l->prev->v->co;
- float *co_next = l->next->v->co;
+ const float *co_prev = l->prev->v->co;
+ const float *co_next = l->next->v->co;
float cross_exist[3];
float cross_optim[3];
@@ -1006,7 +1005,7 @@ void BM_mesh_decimate_collapse(BMesh *bm, const float factor, float *vweights, c
bm_decim_build_edge_cost(bm, vquadrics, vweights, eheap, eheap_table);
face_tot_target = bm->totface * factor;
- bm->elem_index_dirty |= BM_FACE | BM_EDGE | BM_VERT;
+ bm->elem_index_dirty |= BM_ALL;
#ifdef USE_CUSTOMDATA
diff --git a/source/blender/bmesh/tools/bmesh_edgenet.c b/source/blender/bmesh/tools/bmesh_edgenet.c
index 576d604c1cb..ddf43949258 100644
--- a/source/blender/bmesh/tools/bmesh_edgenet.c
+++ b/source/blender/bmesh/tools/bmesh_edgenet.c
@@ -443,8 +443,8 @@ void BM_mesh_edgenet(BMesh *bm,
const bool use_edge_tag, const bool use_new_face_tag)
{
VertNetInfo *vnet_info = MEM_callocN(sizeof(*vnet_info) * (size_t)bm->totvert, __func__);
- BLI_mempool *edge_queue_pool = BLI_mempool_create(sizeof(LinkNode), 1, 512, BLI_MEMPOOL_NOP);
- BLI_mempool *path_pool = BLI_mempool_create(sizeof(LinkNode), 1, 512, BLI_MEMPOOL_NOP);
+ BLI_mempool *edge_queue_pool = BLI_mempool_create(sizeof(LinkNode), 0, 512, BLI_MEMPOOL_NOP);
+ BLI_mempool *path_pool = BLI_mempool_create(sizeof(LinkNode), 0, 512, BLI_MEMPOOL_NOP);
LinkNode *edge_queue = NULL;
BMEdge *e;
@@ -500,7 +500,7 @@ void BM_mesh_edgenet(BMesh *bm,
BLI_assert(BLI_mempool_count(path_pool) == 0);
}
- bm->elem_index_dirty |= BM_FACE;
+ bm->elem_index_dirty |= BM_FACE | BM_LOOP;
BLI_mempool_destroy(edge_queue_pool);
BLI_mempool_destroy(path_pool);
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index 61a675d4c8f..f2c057d32d8 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -187,7 +187,7 @@ void AnimationExporter::make_anim_frames_from_targets(Object *ob, std::vector<fl
for (con = (bConstraint *)conlist->first; con; con = con->next) {
ListBase targets = {NULL, NULL};
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
if (!validateConstraints(con)) continue;
@@ -999,7 +999,9 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Obj
BIK_release_tree(scene, ob, ctime);
}
- enable_fcurves(ob->adt->action, NULL);
+ if (ob->adt) {
+ enable_fcurves(ob->adt->action, NULL);
+ }
source.finish();
@@ -1526,7 +1528,7 @@ void AnimationExporter::sample_animation(float *v, std::vector<float> &frames, i
bool AnimationExporter::validateConstraints(bConstraint *con)
{
bool valid = true;
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
/* these we can skip completely (invalid constraints...) */
if (cti == NULL) valid = false;
if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)) valid = false;
@@ -1545,7 +1547,7 @@ void AnimationExporter::calc_ob_mat_at_time(Object *ob, float ctime , float mat[
for (con = (bConstraint *)conlist->first; con; con = con->next) {
ListBase targets = {NULL, NULL};
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
if (cti && cti->get_constraint_targets) {
bConstraintTarget *ct;
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp
index ea0f6cf0049..bbbbbf211c6 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -478,7 +478,7 @@ void DocumentImporter::create_constraints(ExtraTags *et, Object *ob)
std::string name;
short* type = 0;
et->setData("type", type);
- BKE_add_ob_constraint(ob, "Test_con", *type);
+ BKE_constraint_add_for_object(ob, "Test_con", *type);
}
}
diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp
index 3d5d79f55ea..1bf245c39e0 100644
--- a/source/blender/collada/GeometryExporter.cpp
+++ b/source/blender/collada/GeometryExporter.cpp
@@ -289,6 +289,12 @@ void GeometryExporter::createLooseEdgeList(Object *ob,
}
+std::string GeometryExporter::makeVertexColorSourceId(std::string& geom_id, char *layer_name)
+{
+ std::string result = getIdBySemantics(geom_id, COLLADASW::InputSemantic::COLOR) + "-" + layer_name;
+ return result;
+}
+
// powerful because it handles both cases when there is material and when there's not
void GeometryExporter::createPolylist(short material_index,
bool has_uvs,
@@ -365,9 +371,20 @@ void GeometryExporter::createPolylist(short material_index,
}
}
- if (has_color) {
- COLLADASW::Input input4(COLLADASW::InputSemantic::COLOR, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::COLOR), has_uvs ? 3 : 2);
- til.push_back(input4);
+ int totlayer_mcol = CustomData_number_of_layers(&me->ldata, CD_MLOOPCOL);
+ if (totlayer_mcol > 0) {
+ int map_index = 0;
+
+ for (int a = 0; a < totlayer_mcol; a++) {
+ char *layer_name = bc_CustomData_get_layer_name(&me->ldata, CD_MLOOPCOL, a);
+ COLLADASW::Input input4(COLLADASW::InputSemantic::COLOR,
+ makeUrl(makeVertexColorSourceId(geom_id, layer_name)),
+ (has_uvs) ? 3 : 2, // all color layers have same index order
+ map_index // set number equals color map index
+ );
+ til.push_back(input4);
+ map_index++;
+ }
}
// sets <vcount>
@@ -420,6 +437,7 @@ void GeometryExporter::createVertsSource(std::string geom_id, Mesh *me)
ARRAY_ID_SUFFIX);
source.setAccessorCount(totverts);
source.setAccessorStride(3);
+
COLLADASW::SourceBase::ParameterNameList &param = source.getParameterNameList();
param.push_back("X");
param.push_back("Y");
@@ -437,40 +455,54 @@ void GeometryExporter::createVertsSource(std::string geom_id, Mesh *me)
}
+
void GeometryExporter::createVertexColorSource(std::string geom_id, Mesh *me)
{
- MLoopCol *mloopcol = (MLoopCol *)CustomData_get_layer(&me->ldata, CD_MLOOPCOL);
- if (mloopcol == NULL)
+ /* Find number of vertex color layers */
+ int totlayer_mcol = CustomData_number_of_layers(&me->ldata, CD_MLOOPCOL);
+ if (totlayer_mcol == 0)
return;
+ int map_index = 0;
+ for (int a = 0; a < totlayer_mcol; a++) {
- COLLADASW::FloatSourceF source(mSW);
- source.setId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::COLOR));
- source.setArrayId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::COLOR) + ARRAY_ID_SUFFIX);
- source.setAccessorCount(me->totloop);
- source.setAccessorStride(3);
+ map_index++;
+ MLoopCol *mloopcol = (MLoopCol *)CustomData_get_layer_n(&me->ldata, CD_MLOOPCOL, a);
- COLLADASW::SourceBase::ParameterNameList &param = source.getParameterNameList();
- param.push_back("R");
- param.push_back("G");
- param.push_back("B");
+ COLLADASW::FloatSourceF source(mSW);
- source.prepareToAppendValues();
+ char *layer_name = bc_CustomData_get_layer_name(&me->ldata, CD_MLOOPCOL, a);
+ std::string layer_id = makeVertexColorSourceId(geom_id, layer_name);
+ source.setId(layer_id);
- MPoly *mpoly;
- int i;
- for (i = 0, mpoly = me->mpoly; i < me->totpoly; i++, mpoly++) {
- MLoopCol *mlc = mloopcol + mpoly->loopstart;
- for (int j = 0; j < mpoly->totloop; j++, mlc++) {
- source.appendValues(
- mlc->r / 255.0f,
- mlc->g / 255.0f,
- mlc->b / 255.0f
- );
+ source.setNodeName(layer_name);
+
+ source.setArrayId(layer_id + ARRAY_ID_SUFFIX);
+ source.setAccessorCount(me->totloop);
+ source.setAccessorStride(3);
+
+ COLLADASW::SourceBase::ParameterNameList &param = source.getParameterNameList();
+ param.push_back("R");
+ param.push_back("G");
+ param.push_back("B");
+
+ source.prepareToAppendValues();
+
+ MPoly *mpoly;
+ int i;
+ for (i = 0, mpoly = me->mpoly; i < me->totpoly; i++, mpoly++) {
+ MLoopCol *mlc = mloopcol + mpoly->loopstart;
+ for (int j = 0; j < mpoly->totloop; j++, mlc++) {
+ source.appendValues(
+ mlc->r / 255.0f,
+ mlc->g / 255.0f,
+ mlc->b / 255.0f
+ );
+ }
}
- }
- source.finish();
+ source.finish();
+ }
}
diff --git a/source/blender/collada/GeometryExporter.h b/source/blender/collada/GeometryExporter.h
index 5b67f80e98d..4d54e79d796 100644
--- a/source/blender/collada/GeometryExporter.h
+++ b/source/blender/collada/GeometryExporter.h
@@ -100,7 +100,8 @@ public:
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);
+
COLLADASW::URI getUrlBySemantics(std::string geom_id, COLLADASW::InputSemantic::Semantics type, std::string other_suffix = "");
COLLADASW::URI makeUrl(std::string id);
diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp
index d631a43676f..211c34ed325 100644
--- a/source/blender/collada/MeshImporter.cpp
+++ b/source/blender/collada/MeshImporter.cpp
@@ -173,6 +173,42 @@ void UVDataWrapper::getUV(int uv_index, float *uv)
}
}
+VCOLDataWrapper::VCOLDataWrapper(COLLADAFW::MeshVertexData& vdata) : mVData(&vdata){
+}
+
+void VCOLDataWrapper::get_vcol(int v_index, MLoopCol *mloopcol)
+{
+ int stride = mVData->getStride(0);
+ if (stride == 0) stride = 3;
+
+ switch (mVData->getType()) {
+ case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT:
+ {
+ COLLADAFW::ArrayPrimitiveType<float> *values = mVData->getFloatValues();
+ if (values->empty()) return;
+
+ mloopcol->r = FTOCHAR((*values)[v_index * stride]);
+ mloopcol->g = FTOCHAR((*values)[v_index * stride + 1]);
+ mloopcol->b = FTOCHAR((*values)[v_index * stride + 2]);
+ }
+ break;
+
+ case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE:
+ {
+ COLLADAFW::ArrayPrimitiveType<double> *values = mVData->getDoubleValues();
+ if (values->empty()) return;
+
+ mloopcol->r = FTOCHAR((*values)[v_index * stride]);
+ mloopcol->g = FTOCHAR((*values)[v_index * stride + 1]);
+ mloopcol->b = FTOCHAR((*values)[v_index * stride + 2]);
+ }
+ break;
+ default:
+ fprintf(stderr, "VCOLDataWrapper.getvcol(): unknown data type\n");
+ }
+
+}
+
MeshImporter::MeshImporter(UnitConverter *unitconv, ArmatureImporter *arm, Scene *sce) : unitconverter(unitconv), scene(sce), armature_importer(arm) {
}
@@ -187,6 +223,17 @@ void MeshImporter::set_poly_indices(MPoly *mpoly, MLoop *mloop, int loop_index,
}
}
+void MeshImporter::set_vcol(MLoopCol *mlc, VCOLDataWrapper &vob, int loop_index, COLLADAFW::IndexList &index_list, int count)
+{
+ COLLADAFW::UIntValuesArray& indices =index_list.getIndices();
+ int index;
+ for(index = 0; index < count; index++,mlc++)
+ {
+ int v_index = indices[index+loop_index];
+ vob.get_vcol(v_index,mlc);
+ }
+}
+
void MeshImporter::set_face_uv(MLoopUV *mloopuv, UVDataWrapper &uvs,
int start_index, COLLADAFW::IndexList& index_list, int count)
{
@@ -328,6 +375,17 @@ bool MeshImporter::primitive_has_faces(COLLADAFW::MeshPrimitive *mp) {
return has_faces;
}
+
+static std::string extract_vcolname(const COLLADAFW::String &collada_id) {
+ std::string colname = collada_id;
+ int spos = colname.find("-mesh-colors-");
+ if (spos != std::string::npos) {
+ colname = colname.substr(spos+13);
+ }
+ return colname;
+}
+
+
// =================================================================
// Return the number of faces by summing up
// the facecounts of the parts.
@@ -337,8 +395,8 @@ bool MeshImporter::primitive_has_faces(COLLADAFW::MeshPrimitive *mp) {
void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me)
{
COLLADAFW::MeshPrimitiveArray& prim_arr = collada_mesh->getMeshPrimitives();
- int total_poly_count = 0;
- int total_loop_count = 0;
+ int total_poly_count = 0;
+ int total_loop_count = 0;
// collect edge_count and face_count from all parts
for (int i = 0; i < prim_arr.getCount(); i++) {
@@ -360,6 +418,7 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me)
total_poly_count += prim_poly_count;
total_loop_count += prim_loop_count;
+
break;
}
default:
@@ -394,6 +453,17 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me)
me->mtpoly = (MTexPoly *)CustomData_get_layer_n(&me->pdata, CD_MTEXPOLY, 0);
me->mloopuv = (MLoopUV *) CustomData_get_layer_n(&me->ldata, CD_MLOOPUV, 0);
}
+
+ int totcolset = collada_mesh->getColors().getInputInfosArray().getCount();
+ if (totcolset > 0) {
+ for (int i = 0; i < totcolset; i++) {
+ COLLADAFW::MeshVertexData::InputInfos *info = collada_mesh->getColors().getInputInfosArray()[i];
+ COLLADAFW::String colname = extract_vcolname(info->mName);
+ CustomData_add_layer_named(&me->ldata,CD_MLOOPCOL,CD_DEFAULT,NULL,me->totloop, colname.c_str());
+ }
+ me->mloopcol = (MLoopCol *) CustomData_get_layer_n(&me->ldata, CD_MLOOPCOL, 0);
+ }
+
}
}
@@ -538,6 +608,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
allocate_poly_data(collada_mesh, me);
UVDataWrapper uvs(collada_mesh->getUVCoords());
+ VCOLDataWrapper vcol(collada_mesh->getColors());
MPoly *mpoly = me->mpoly;
MLoop *mloop = me->mloop;
@@ -553,9 +624,9 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
COLLADAFW::MeshPrimitive *mp = prim_arr[i];
// faces
- size_t prim_totpoly = mp->getFaceCount();
- unsigned int *position_indices = mp->getPositionIndices().getData();
- unsigned int *normal_indices = mp->getNormalIndices().getData();
+ size_t prim_totpoly = mp->getFaceCount();
+ unsigned int *position_indices = mp->getPositionIndices().getData();
+ unsigned int *normal_indices = mp->getNormalIndices().getData();
bool mp_has_normals = primitive_has_useable_normals(mp);
bool mp_has_faces = primitive_has_faces(mp);
@@ -564,7 +635,6 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
// since we cannot set mpoly->mat_nr here, we store a portion of me->mpoly in Primitive
Primitive prim = {mpoly, 0};
- COLLADAFW::IndexListArray& index_list_array = mp->getUVCoordIndicesArray();
// If MeshPrimitive is TRIANGLE_FANS we split it into triangles
// The first trifan vertex will be the first vertex in every triangle
@@ -611,6 +681,9 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons *)mp;
unsigned int start_index = 0;
+ COLLADAFW::IndexListArray& index_list_array_uvcoord = mp->getUVCoordIndicesArray();
+ COLLADAFW::IndexListArray& index_list_array_vcolor = mp->getColorIndicesArray();
+
for (unsigned int j = 0; j < prim_totpoly; j++) {
// Vertices in polygon:
@@ -618,15 +691,15 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
set_poly_indices(mpoly, mloop, loop_index, position_indices, vcount);
- for (unsigned int uvset_index = 0; uvset_index < index_list_array.getCount(); uvset_index++) {
+ for (unsigned int uvset_index = 0; uvset_index < index_list_array_uvcoord.getCount(); uvset_index++) {
// get mtface by face index and uv set index
- COLLADAFW::IndexList& index_list = *index_list_array[uvset_index];
+ COLLADAFW::IndexList& index_list = *index_list_array_uvcoord[uvset_index];
MLoopUV *mloopuv = (MLoopUV *)CustomData_get_layer_named(&me->ldata, CD_MLOOPUV, index_list.getName().c_str());
if (mloopuv == NULL) {
- fprintf(stderr, "Collada import: Mesh [%s] : Unknown reference to TEXCOORD [#%s].", me->id.name, index_list.getName().c_str() );
+ fprintf(stderr, "Collada import: Mesh [%s] : Unknown reference to TEXCOORD [#%s].\n", me->id.name, index_list.getName().c_str() );
}
else {
- set_face_uv(mloopuv+loop_index, uvs, start_index, *index_list_array[uvset_index], vcount);
+ set_face_uv(mloopuv+loop_index, uvs, start_index, *index_list_array_uvcoord[uvset_index], vcount);
}
}
@@ -634,10 +707,23 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
if (!is_flat_face(normal_indices, nor, vcount))
mpoly->flag |= ME_SMOOTH;
}
-
+
+ for(unsigned int vcolor_index = 0 ; vcolor_index < index_list_array_vcolor.getCount();vcolor_index++)
+ {
+ COLLADAFW::IndexList& index_list = *index_list_array_vcolor[vcolor_index];
+ COLLADAFW::String colname = extract_vcolname(index_list.getName());
+ MLoopCol *mloopcol = (MLoopCol *)CustomData_get_layer_named(&me->ldata, CD_MLOOPCOL, colname.c_str());
+ if (mloopcol == NULL) {
+ fprintf(stderr, "Collada import: Mesh [%s] : Unknown reference to VCOLOR [#%s].\n", me->id.name, index_list.getName().c_str() );
+ }
+ else {
+ set_vcol(mloopcol+loop_index, vcol, start_index, *index_list_array_vcolor[vcolor_index], vcount);
+ }
+ }
+
mpoly++;
- mloop += vcount;
- loop_index += vcount;
+ mloop += vcount;
+ loop_index += vcount;
start_index += vcount;
prim.totpoly++;
@@ -654,6 +740,8 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
if (mp_has_faces)
mat_prim_map[mp->getMaterialId()].push_back(prim);
+
+
}
geom_uid_mat_mapping_map[collada_mesh->getUniqueId()] = mat_prim_map;
@@ -1114,5 +1202,6 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry *geom)
// read_lines() must be called after the face edges have been generated.
// Oterwise the loose edges will be silently deleted again.
read_lines(mesh, me);
+
return true;
}
diff --git a/source/blender/collada/MeshImporter.h b/source/blender/collada/MeshImporter.h
index 5275420f4b5..9fc1d777f62 100644
--- a/source/blender/collada/MeshImporter.h
+++ b/source/blender/collada/MeshImporter.h
@@ -77,6 +77,14 @@ public:
void getUV(int uv_index, float *uv);
};
+class VCOLDataWrapper
+{
+ COLLADAFW::MeshVertexData *mVData;
+public:
+ VCOLDataWrapper(COLLADAFW::MeshVertexData& vdata);
+ void get_vcol(int v_index, MLoopCol *mloopcol);
+};
+
class MeshImporter : public MeshImporterBase
{
private:
@@ -113,6 +121,12 @@ private:
COLLADAFW::IndexList& index_list,
int count);
+ void set_vcol(MLoopCol *mloopcol,
+ VCOLDataWrapper &vob,
+ int loop_index,
+ COLLADAFW::IndexList& index_list,
+ int count);
+
#ifdef COLLADA_DEBUG
void print_index_list(COLLADAFW::IndexList& index_list);
#endif
diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp
index a3bb02520da..b50b8b0a302 100644
--- a/source/blender/collada/SceneExporter.cpp
+++ b/source/blender/collada/SceneExporter.cpp
@@ -193,8 +193,10 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce)
if (BLI_listbase_is_empty(&ob->constraints) == false) {
bConstraint *con = (bConstraint *) ob->constraints.first;
while (con) {
- std::string con_name(id_name(con));
+ std::string con_name(translate_id(con->name));
std::string con_tag = con_name + "_constraint";
+ printf("%s\n", con_name.c_str());
+ printf("%s\n\n", con_tag.c_str());
colladaNode.addExtraTechniqueChildParameter("blender",con_tag,"type",con->type);
colladaNode.addExtraTechniqueChildParameter("blender",con_tag,"enforce",con->enforce);
colladaNode.addExtraTechniqueChildParameter("blender",con_tag,"flag",con->flag);
@@ -208,7 +210,7 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce)
//not ideal: add the target object name as another parameter.
//No real mapping in the .dae
//Need support for multiple target objects also.
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
if (cti && cti->get_constraint_targets) {
diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt
index 1ab0820bd76..abd2bf705f8 100644
--- a/source/blender/compositor/CMakeLists.txt
+++ b/source/blender/compositor/CMakeLists.txt
@@ -54,36 +54,33 @@ set(SRC
intern/COM_compositor.cpp
intern/COM_ExecutionSystem.cpp
intern/COM_ExecutionSystem.h
- intern/COM_ExecutionSystemHelper.cpp
- intern/COM_ExecutionSystemHelper.h
+ intern/COM_NodeConverter.cpp
+ intern/COM_NodeConverter.h
+ intern/COM_NodeOperationBuilder.cpp
+ intern/COM_NodeOperationBuilder.h
+ intern/COM_NodeGraph.cpp
+ intern/COM_NodeGraph.h
intern/COM_Converter.cpp
intern/COM_Converter.h
intern/COM_ExecutionGroup.cpp
intern/COM_ExecutionGroup.h
intern/COM_Node.cpp
intern/COM_Node.h
- intern/COM_NodeBase.cpp
- intern/COM_NodeBase.h
intern/COM_NodeOperation.cpp
intern/COM_NodeOperation.h
- intern/COM_Socket.cpp
- intern/COM_Socket.h
intern/COM_SocketReader.cpp
intern/COM_SocketReader.h
- intern/COM_InputSocket.cpp
- intern/COM_InputSocket.h
- intern/COM_OutputSocket.cpp
- intern/COM_OutputSocket.h
- intern/COM_SocketConnection.cpp
- intern/COM_SocketConnection.h
intern/COM_MemoryProxy.cpp
intern/COM_MemoryProxy.h
intern/COM_MemoryBuffer.cpp
intern/COM_MemoryBuffer.h
- intern/COM_MemoryBufferColor
- intern/COM_MemoryBufferVector
- intern/COM_MemoryBufferValue
- intern/COM_WorkScheduler.cpp
+ intern/COM_MemoryBufferColor.cpp
+ intern/COM_MemoryBufferColor.h
+ intern/COM_MemoryBufferVector.cpp
+ intern/COM_MemoryBufferVector.h
+ intern/COM_MemoryBufferValue.cpp
+ intern/COM_MemoryBufferValue.h
+ intern/COM_WorkScheduler.cpp
intern/COM_WorkScheduler.h
intern/COM_WorkPackage.cpp
intern/COM_WorkPackage.h
@@ -99,8 +96,8 @@ set(SRC
intern/COM_OpenCLDevice.h
intern/COM_CompositorContext.cpp
intern/COM_CompositorContext.h
- intern/COM_SingleThreadedNodeOperation.cpp
- intern/COM_SingleThreadedNodeOperation.h
+ intern/COM_SingleThreadedOperation.cpp
+ intern/COM_SingleThreadedOperation.h
intern/COM_Debug.cpp
intern/COM_Debug.h
@@ -108,10 +105,6 @@ set(SRC
operations/COM_QualityStepHelper.cpp
# Internal nodes
- nodes/COM_MuteNode.cpp
- nodes/COM_MuteNode.h
- nodes/COM_GroupNode.cpp
- nodes/COM_GroupNode.h
nodes/COM_SocketProxyNode.cpp
nodes/COM_SocketProxyNode.h
@@ -246,22 +239,10 @@ set(SRC
# converter nodes
nodes/COM_IDMaskNode.cpp
nodes/COM_IDMaskNode.h
- nodes/COM_SeparateRGBANode.cpp
- nodes/COM_SeparateRGBANode.h
- nodes/COM_CombineRGBANode.cpp
- nodes/COM_CombineRGBANode.h
- nodes/COM_SeparateHSVANode.cpp
- nodes/COM_SeparateHSVANode.h
- nodes/COM_CombineHSVANode.cpp
- nodes/COM_CombineHSVANode.h
- nodes/COM_SeparateYUVANode.cpp
- nodes/COM_SeparateYUVANode.h
- nodes/COM_CombineYUVANode.cpp
- nodes/COM_CombineYUVANode.h
- nodes/COM_SeparateYCCANode.cpp
- nodes/COM_SeparateYCCANode.h
- nodes/COM_CombineYCCANode.cpp
- nodes/COM_CombineYCCANode.h
+ nodes/COM_SeparateColorNode.cpp
+ nodes/COM_SeparateColorNode.h
+ nodes/COM_CombineColorNode.cpp
+ nodes/COM_CombineColorNode.h
nodes/COM_NormalNode.cpp
nodes/COM_NormalNode.h
diff --git a/source/blender/compositor/COM_compositor.h b/source/blender/compositor/COM_compositor.h
index b79c26aa236..2cf2c690d3e 100644
--- a/source/blender/compositor/COM_compositor.h
+++ b/source/blender/compositor/COM_compositor.h
@@ -213,8 +213,8 @@ extern "C" {
* (is called from [@ref ExecutionGroup.scheduleChunkWhenPossible])
* @see ExecutionGroup.scheduleChunk Schedule a chunk on the WorkScheduler
* @see NodeOperation.determineDependingAreaOfInterest Influence the area of interest of a chunk.
- * @see WriteBufferOperation NodeOperation to write to a MemoryProxy/MemoryBuffer
- * @see ReadBufferOperation NodeOperation to read from a MemoryProxy/MemoryBuffer
+ * @see WriteBufferOperation Operation to write to a MemoryProxy/MemoryBuffer
+ * @see ReadBufferOperation Operation to read from a MemoryProxy/MemoryBuffer
* @see MemoryProxy proxy for information about memory image (a image consist out of multiple chunks)
* @see MemoryBuffer Allocated memory for a single chunk
*
diff --git a/source/blender/compositor/COM_defines.h b/source/blender/compositor/COM_defines.h
index f3e224a3601..f8211cd061b 100644
--- a/source/blender/compositor/COM_defines.h
+++ b/source/blender/compositor/COM_defines.h
@@ -24,7 +24,7 @@
#define __COM_DEFINES_H__
/**
- * @brief possible data types for SocketConnection
+ * @brief possible data types for sockets
* @ingroup Model
*/
typedef enum DataType {
diff --git a/source/blender/compositor/intern/COM_CPUDevice.cpp b/source/blender/compositor/intern/COM_CPUDevice.cpp
index 7029aa032cc..c7c3f7769fe 100644
--- a/source/blender/compositor/intern/COM_CPUDevice.cpp
+++ b/source/blender/compositor/intern/COM_CPUDevice.cpp
@@ -30,7 +30,7 @@ void CPUDevice::execute(WorkPackage *work)
executionGroup->determineChunkRect(&rect, chunkNumber);
- executionGroup->getOutputNodeOperation()->executeRegion(&rect, chunkNumber);
+ executionGroup->getOutputOperation()->executeRegion(&rect, chunkNumber);
executionGroup->finalizeChunkExecution(chunkNumber, NULL);
}
diff --git a/source/blender/compositor/intern/COM_CompositorContext.h b/source/blender/compositor/intern/COM_CompositorContext.h
index 223f900b391..a398ae937a3 100644
--- a/source/blender/compositor/intern/COM_CompositorContext.h
+++ b/source/blender/compositor/intern/COM_CompositorContext.h
@@ -181,11 +181,11 @@ public:
*/
void setHasActiveOpenCLDevices(bool hasAvtiveOpenCLDevices) { this->m_hasActiveOpenCLDevices = hasAvtiveOpenCLDevices; }
- int getChunksize() { return this->getbNodeTree()->chunksize; }
+ int getChunksize() const { return this->getbNodeTree()->chunksize; }
void setFastCalculation(bool fastCalculation) {this->m_fastCalculation = fastCalculation;}
- bool isFastCalculation() {return this->m_fastCalculation;}
- inline bool isGroupnodeBufferEnabled() {return this->getbNodeTree()->flag & NTREE_COM_GROUPNODE_BUFFER;}
+ bool isFastCalculation() const { return this->m_fastCalculation; }
+ bool isGroupnodeBufferEnabled() const { return this->getbNodeTree()->flag & NTREE_COM_GROUPNODE_BUFFER; }
};
diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp
index 7103b49f32f..9251e161839 100644
--- a/source/blender/compositor/intern/COM_Converter.cpp
+++ b/source/blender/compositor/intern/COM_Converter.cpp
@@ -22,7 +22,14 @@
#include <string.h>
+extern "C" {
+#include "DNA_node_types.h"
+
#include "BKE_node.h"
+}
+
+#include "COM_NodeOperationBuilder.h"
+#include "COM_NodeOperation.h"
#include "COM_AlphaOverNode.h"
#include "COM_BilateralBlurNode.h"
@@ -41,10 +48,7 @@
#include "COM_ColorRampNode.h"
#include "COM_ColorSpillNode.h"
#include "COM_ColorToBWNode.h"
-#include "COM_CombineHSVANode.h"
-#include "COM_CombineRGBANode.h"
-#include "COM_CombineYCCANode.h"
-#include "COM_CombineYUVANode.h"
+#include "COM_CombineColorNode.h"
#include "COM_CompositorNode.h"
#include "COM_ConvertAlphaNode.h"
#include "COM_ConvertOperation.h"
@@ -61,12 +65,10 @@
#include "COM_DoubleEdgeMaskNode.h"
#include "COM_EllipseMaskNode.h"
#include "COM_ExecutionSystem.h"
-#include "COM_ExecutionSystemHelper.h"
#include "COM_FilterNode.h"
#include "COM_FlipNode.h"
#include "COM_GammaNode.h"
#include "COM_GlareNode.h"
-#include "COM_GroupNode.h"
#include "COM_HueSaturationValueCorrectNode.h"
#include "COM_HueSaturationValueNode.h"
#include "COM_IDMaskNode.h"
@@ -85,7 +87,6 @@
#include "COM_MixNode.h"
#include "COM_MovieClipNode.h"
#include "COM_MovieDistortionNode.h"
-#include "COM_MuteNode.h"
#include "COM_NormalNode.h"
#include "COM_NormalizeNode.h"
#include "COM_OutputFileNode.h"
@@ -93,13 +94,9 @@
#include "COM_RotateNode.h"
#include "COM_ScaleNode.h"
#include "COM_ScaleOperation.h"
-#include "COM_SeparateHSVANode.h"
-#include "COM_SeparateRGBANode.h"
-#include "COM_SeparateYCCANode.h"
-#include "COM_SeparateYUVANode.h"
+#include "COM_SeparateColorNode.h"
#include "COM_SetAlphaNode.h"
#include "COM_SetValueOperation.h"
-#include "COM_SocketConnection.h"
#include "COM_SplitViewerNode.h"
#include "COM_Stabilize2dNode.h"
#include "COM_SwitchNode.h"
@@ -119,30 +116,24 @@
#include "COM_PixelateNode.h"
#include "COM_PlaneTrackDeformNode.h"
-Node *Converter::convert(bNode *b_node, bool fast)
+bool Converter::is_fast_node(bNode *b_node)
{
- Node *node = NULL;
+ return !(b_node->type == CMP_NODE_BLUR ||
+ b_node->type == CMP_NODE_VECBLUR ||
+ b_node->type == CMP_NODE_BILATERALBLUR ||
+ b_node->type == CMP_NODE_DEFOCUS ||
+ b_node->type == CMP_NODE_BOKEHBLUR ||
+ b_node->type == CMP_NODE_GLARE ||
+ b_node->type == CMP_NODE_DBLUR ||
+ b_node->type == CMP_NODE_MOVIEDISTORTION ||
+ b_node->type == CMP_NODE_LENSDIST ||
+ b_node->type == CMP_NODE_DOUBLEEDGEMASK ||
+ b_node->type == CMP_NODE_DILATEERODE);
+}
- if (b_node->flag & NODE_MUTED) {
- node = new MuteNode(b_node);
- return node;
- }
- if (fast) {
- if (b_node->type == CMP_NODE_BLUR ||
- b_node->type == CMP_NODE_VECBLUR ||
- b_node->type == CMP_NODE_BILATERALBLUR ||
- b_node->type == CMP_NODE_DEFOCUS ||
- b_node->type == CMP_NODE_BOKEHBLUR ||
- b_node->type == CMP_NODE_GLARE ||
- b_node->type == CMP_NODE_DBLUR ||
- b_node->type == CMP_NODE_MOVIEDISTORTION ||
- b_node->type == CMP_NODE_LENSDIST ||
- b_node->type == CMP_NODE_DOUBLEEDGEMASK ||
- b_node->type == CMP_NODE_DILATEERODE)
- {
- return new MuteNode(b_node);
- }
- }
+Node *Converter::convert(bNode *b_node)
+{
+ Node *node = NULL;
switch (b_node->type) {
case CMP_NODE_COMPOSITE:
@@ -221,11 +212,9 @@ Node *Converter::convert(bNode *b_node, bool fast)
node = new InvertNode(b_node);
break;
case NODE_GROUP:
- node = new GroupNode(b_node);
- break;
case NODE_GROUP_INPUT:
case NODE_GROUP_OUTPUT:
- /* handled in GroupNode::ungroup */
+ /* handled in NodeCompiler */
break;
case CMP_NODE_NORMAL:
node = new NormalNode(b_node);
@@ -405,52 +394,45 @@ Node *Converter::convert(bNode *b_node, bool fast)
case CMP_NODE_CORNERPIN:
node = new CornerPinNode(b_node);
break;
- default:
- node = new MuteNode(b_node);
- break;
}
return node;
}
-void Converter::convertDataType(SocketConnection *connection, ExecutionSystem *system)
+
+NodeOperation *Converter::convertDataType(NodeOperationOutput *from, NodeOperationInput *to)
{
- OutputSocket *outputSocket = connection->getFromSocket();
- InputSocket *inputSocket = connection->getToSocket();
- DataType fromDatatype = outputSocket->getDataType();
- DataType toDatatype = inputSocket->getDataType();
- NodeOperation *converter = NULL;
+ DataType fromDatatype = from->getDataType();
+ DataType toDatatype = to->getDataType();
+
if (fromDatatype == COM_DT_VALUE && toDatatype == COM_DT_COLOR) {
- converter = new ConvertValueToColorOperation();
+ return new ConvertValueToColorOperation();
}
else if (fromDatatype == COM_DT_VALUE && toDatatype == COM_DT_VECTOR) {
- converter = new ConvertValueToVectorOperation();
+ return new ConvertValueToVectorOperation();
}
else if (fromDatatype == COM_DT_COLOR && toDatatype == COM_DT_VALUE) {
- converter = new ConvertColorToValueOperation();
+ return new ConvertColorToValueOperation();
}
else if (fromDatatype == COM_DT_COLOR && toDatatype == COM_DT_VECTOR) {
- converter = new ConvertColorToVectorOperation();
+ return new ConvertColorToVectorOperation();
}
else if (fromDatatype == COM_DT_VECTOR && toDatatype == COM_DT_VALUE) {
- converter = new ConvertVectorToValueOperation();
+ return new ConvertVectorToValueOperation();
}
else if (fromDatatype == COM_DT_VECTOR && toDatatype == COM_DT_COLOR) {
- converter = new ConvertVectorToColorOperation();
- }
- if (converter != NULL) {
- inputSocket->relinkConnections(converter->getInputSocket(0));
- ExecutionSystemHelper::addLink(system->getConnections(), converter->getOutputSocket(), inputSocket);
- system->addOperation(converter);
+ return new ConvertVectorToColorOperation();
}
+
+ return NULL;
}
-void Converter::convertResolution(SocketConnection *connection, ExecutionSystem *system)
+void Converter::convertResolution(NodeOperationBuilder &builder, NodeOperationOutput *fromSocket, NodeOperationInput *toSocket)
{
- InputSocketResizeMode mode = connection->getToSocket()->getResizeMode();
+ InputResizeMode mode = toSocket->getResizeMode();
- NodeOperation *toOperation = (NodeOperation *)connection->getToNode();
+ NodeOperation *toOperation = &toSocket->getOperation();
const float toWidth = toOperation->getWidth();
const float toHeight = toOperation->getHeight();
- NodeOperation *fromOperation = (NodeOperation *)connection->getFromNode();
+ NodeOperation *fromOperation = &fromSocket->getOperation();
const float fromWidth = fromOperation->getWidth();
const float fromHeight = fromOperation->getHeight();
bool doCenter = false;
@@ -499,62 +481,59 @@ void Converter::convertResolution(SocketConnection *connection, ExecutionSystem
if (doCenter) {
NodeOperation *first = NULL;
- SocketConnection *c;
ScaleOperation *scaleOperation = NULL;
if (doScale) {
scaleOperation = new ScaleOperation();
+ scaleOperation->getInputSocket(1)->setResizeMode(COM_SC_NO_RESIZE);
+ scaleOperation->getInputSocket(2)->setResizeMode(COM_SC_NO_RESIZE);
first = scaleOperation;
SetValueOperation *sxop = new SetValueOperation();
sxop->setValue(scaleX);
- c = ExecutionSystemHelper::addLink(system->getConnections(), sxop->getOutputSocket(), scaleOperation->getInputSocket(1));
- c->setIgnoreResizeCheck(true);
+ builder.addLink(sxop->getOutputSocket(), scaleOperation->getInputSocket(1));
SetValueOperation *syop = new SetValueOperation();
syop->setValue(scaleY);
- c = ExecutionSystemHelper::addLink(system->getConnections(), syop->getOutputSocket(), scaleOperation->getInputSocket(2));
- c->setIgnoreResizeCheck(true);
- system->addOperation(sxop);
- system->addOperation(syop);
+ builder.addLink(syop->getOutputSocket(), scaleOperation->getInputSocket(2));
+ builder.addOperation(sxop);
+ builder.addOperation(syop);
unsigned int resolution[2] = {fromOperation->getWidth(),
fromOperation->getHeight()};
scaleOperation->setResolution(resolution);
sxop->setResolution(resolution);
syop->setResolution(resolution);
- system->addOperation(scaleOperation);
-
- c->setIgnoreResizeCheck(true);
+ builder.addOperation(scaleOperation);
}
TranslateOperation *translateOperation = new TranslateOperation();
+ translateOperation->getInputSocket(1)->setResizeMode(COM_SC_NO_RESIZE);
+ translateOperation->getInputSocket(2)->setResizeMode(COM_SC_NO_RESIZE);
if (!first) first = translateOperation;
SetValueOperation *xop = new SetValueOperation();
xop->setValue(addX);
- c = ExecutionSystemHelper::addLink(system->getConnections(), xop->getOutputSocket(), translateOperation->getInputSocket(1));
- c->setIgnoreResizeCheck(true);
+ builder.addLink(xop->getOutputSocket(), translateOperation->getInputSocket(1));
SetValueOperation *yop = new SetValueOperation();
yop->setValue(addY);
- c = ExecutionSystemHelper::addLink(system->getConnections(), yop->getOutputSocket(), translateOperation->getInputSocket(2));
- c->setIgnoreResizeCheck(true);
- system->addOperation(xop);
- system->addOperation(yop);
+ builder.addLink(yop->getOutputSocket(), translateOperation->getInputSocket(2));
+ builder.addOperation(xop);
+ builder.addOperation(yop);
unsigned int resolution[2] = {toOperation->getWidth(),
toOperation->getHeight()};
translateOperation->setResolution(resolution);
xop->setResolution(resolution);
yop->setResolution(resolution);
- system->addOperation(translateOperation);
+ builder.addOperation(translateOperation);
if (doScale) {
- c = ExecutionSystemHelper::addLink(system->getConnections(), scaleOperation->getOutputSocket(), translateOperation->getInputSocket(0));
- c->setIgnoreResizeCheck(true);
+ translateOperation->getInputSocket(0)->setResizeMode(COM_SC_NO_RESIZE);
+ builder.addLink(scaleOperation->getOutputSocket(), translateOperation->getInputSocket(0));
}
- InputSocket *inputSocket = connection->getToSocket();
- inputSocket->relinkConnections(first->getInputSocket(0));
- c = ExecutionSystemHelper::addLink(system->getConnections(), translateOperation->getOutputSocket(), inputSocket);
- c->setIgnoreResizeCheck(true);
+ /* remove previous link and replace */
+ builder.removeInputLink(toSocket);
+ first->getInputSocket(0)->setResizeMode(COM_SC_NO_RESIZE);
+ toSocket->setResizeMode(COM_SC_NO_RESIZE);
+ builder.addLink(fromSocket, first->getInputSocket(0));
+ builder.addLink(translateOperation->getOutputSocket(), toSocket);
}
-
- connection->setIgnoreResizeCheck(true);
}
diff --git a/source/blender/compositor/intern/COM_Converter.h b/source/blender/compositor/intern/COM_Converter.h
index 15bda0839fa..311cec35644 100644
--- a/source/blender/compositor/intern/COM_Converter.h
+++ b/source/blender/compositor/intern/COM_Converter.h
@@ -23,8 +23,17 @@
#ifndef _COM_Converter_h
#define _COM_Converter_h
-#include "DNA_node_types.h"
-#include "COM_Node.h"
+#ifdef WITH_CXX_GUARDEDALLOC
+# include "MEM_guardedalloc.h"
+#endif
+
+struct bNode;
+
+class Node;
+class NodeOperation;
+class NodeOperationInput;
+class NodeOperationOutput;
+class NodeOperationBuilder;
/**
* @brief Conversion methods for the compositor
@@ -35,37 +44,42 @@ public:
* @brief Convert/wraps a bNode in its Node instance.
*
* For all nodetypes a wrapper class is created.
- * Muted nodes are wrapped with MuteNode.
*
* @note When adding a new node to blender, this method needs to be changed to return the correct Node instance.
*
* @see Node
- * @see MuteNode
*/
- static Node *convert(bNode *b_node, bool fast);
+ static Node *convert(bNode *b_node);
+
+ /**
+ * @brief True if the node is considered 'fast'.
+ *
+ * Slow nodes will be skipped if fast execution is required.
+ */
+ static bool is_fast_node(bNode *b_node);
/**
* @brief This method will add a datetype conversion rule when the to-socket does not support the from-socket actual data type.
*
* @note this method is called when conversion is needed.
*
- * @param connection the SocketConnection what needs conversion
+ * @param link the NodeLink what needs conversion
* @param system the ExecutionSystem to add the conversion to.
- * @see SocketConnection - a link between two sockets
+ * @see NodeLink - a link between two sockets
*/
- static void convertDataType(SocketConnection *connection, ExecutionSystem *system);
+ static NodeOperation *convertDataType(NodeOperationOutput *from, NodeOperationInput *to);
/**
- * @brief This method will add a resolution rule based on the settings of the InputSocket.
+ * @brief This method will add a resolution rule based on the settings of the NodeInput.
*
* @note Conversion logic is implemented in this method
* @see InputSocketResizeMode for the possible conversions.
*
- * @param connection the SocketConnection what needs conversion
+ * @param link the NodeLink what needs conversion
* @param system the ExecutionSystem to add the conversion to.
- * @see SocketConnection - a link between two sockets
+ * @see NodeLink - a link between two sockets
*/
- static void convertResolution(SocketConnection *connection, ExecutionSystem *system);
+ static void convertResolution(NodeOperationBuilder &builder, NodeOperationOutput *fromSocket, NodeOperationInput *toSocket);
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("COM:Converter")
diff --git a/source/blender/compositor/intern/COM_Debug.cpp b/source/blender/compositor/intern/COM_Debug.cpp
index f5e3cca976c..a453af5ad13 100644
--- a/source/blender/compositor/intern/COM_Debug.cpp
+++ b/source/blender/compositor/intern/COM_Debug.cpp
@@ -46,10 +46,12 @@ extern "C" {
int DebugInfo::m_file_index = 0;
DebugInfo::NodeNameMap DebugInfo::m_node_names;
+DebugInfo::OpNameMap DebugInfo::m_op_names;
std::string DebugInfo::m_current_node_name;
+std::string DebugInfo::m_current_op_name;
DebugInfo::GroupStateMap DebugInfo::m_group_states;
-std::string DebugInfo::node_name(NodeBase *node)
+std::string DebugInfo::node_name(const Node *node)
{
NodeNameMap::const_iterator it = m_node_names.find(node);
if (it != m_node_names.end())
@@ -58,56 +60,65 @@ std::string DebugInfo::node_name(NodeBase *node)
return "";
}
+std::string DebugInfo::operation_name(const NodeOperation *op)
+{
+ OpNameMap::const_iterator it = m_op_names.find(op);
+ if (it != m_op_names.end())
+ return it->second;
+ else
+ return "";
+}
+
void DebugInfo::convert_started()
{
- m_node_names.clear();
+ m_op_names.clear();
}
-void DebugInfo::execute_started(ExecutionSystem *system)
+void DebugInfo::execute_started(const ExecutionSystem *system)
{
m_file_index = 1;
m_group_states.clear();
- for (int i = 0; i < system->getExecutionGroups().size(); ++i)
- m_group_states[system->getExecutionGroups()[i]] = EG_WAIT;
+ for (ExecutionSystem::Groups::const_iterator it = system->m_groups.begin(); it != system->m_groups.end(); ++it)
+ m_group_states[*it] = EG_WAIT;
}
-void DebugInfo::node_added(Node *node)
+void DebugInfo::node_added(const Node *node)
{
m_node_names[node] = std::string(node->getbNode() ? node->getbNode()->name : "");
}
-void DebugInfo::node_to_operations(Node *node)
+void DebugInfo::node_to_operations(const Node *node)
{
m_current_node_name = m_node_names[node];
}
-void DebugInfo::operation_added(NodeOperation *operation)
+void DebugInfo::operation_added(const NodeOperation *operation)
{
- m_node_names[operation] = m_current_node_name;
+ m_op_names[operation] = m_current_node_name;
}
-void DebugInfo::operation_read_write_buffer(NodeOperation *operation)
+void DebugInfo::operation_read_write_buffer(const NodeOperation *operation)
{
- m_current_node_name = m_node_names[operation];
+ m_current_op_name = m_op_names[operation];
}
-void DebugInfo::execution_group_started(ExecutionGroup *group)
+void DebugInfo::execution_group_started(const ExecutionGroup *group)
{
m_group_states[group] = EG_RUNNING;
}
-void DebugInfo::execution_group_finished(ExecutionGroup *group)
+void DebugInfo::execution_group_finished(const ExecutionGroup *group)
{
m_group_states[group] = EG_FINISHED;
}
-int DebugInfo::graphviz_operation(ExecutionSystem *system, NodeOperation *operation, ExecutionGroup *group, char *str, int maxlen)
+int DebugInfo::graphviz_operation(const ExecutionSystem *system, const NodeOperation *operation, const ExecutionGroup *group, char *str, int maxlen)
{
int len = 0;
std::string fillcolor = "gainsboro";
if (operation->isViewerOperation()) {
- ViewerOperation *viewer = (ViewerOperation *)operation;
+ const ViewerOperation *viewer = (const ViewerOperation *)operation;
if (viewer->isActiveViewerOutput()) {
fillcolor = "lightskyblue1";
}
@@ -139,7 +150,7 @@ int DebugInfo::graphviz_operation(ExecutionSystem *system, NodeOperation *operat
if (totinputs != 0) {
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "{");
for (int k = 0; k < totinputs; k++) {
- InputSocket *socket = operation->getInputSocket(k);
+ NodeOperationInput *socket = operation->getInputSocket(k);
if (k != 0) {
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "|");
}
@@ -160,7 +171,7 @@ int DebugInfo::graphviz_operation(ExecutionSystem *system, NodeOperation *operat
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "|");
}
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "%s\\n(%s)", m_node_names[operation].c_str(), typeid(*operation).name());
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "%s\\n(%s)", m_op_names[operation].c_str(), typeid(*operation).name());
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, " (%d,%d)", operation->getWidth(), operation->getHeight());
@@ -169,7 +180,7 @@ int DebugInfo::graphviz_operation(ExecutionSystem *system, NodeOperation *operat
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "|");
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "{");
for (int k = 0; k < totoutputs; k++) {
- OutputSocket *socket = operation->getOutputSocket(k);
+ NodeOperationOutput *socket = operation->getOutputSocket(k);
if (k != 0) {
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "|");
}
@@ -227,7 +238,7 @@ int DebugInfo::graphviz_legend(char *str, int maxlen)
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, " <TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\" CELLPADDING=\"4\">\r\n");
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "<TR><TD COLSPAN=\"2\"><B>Legend</B></TD></TR>\r\n");
- len += graphviz_legend_color("Operation", "gainsboro", str + len, maxlen > len ? maxlen - len : 0);
+ len += graphviz_legend_color("NodeOperation", "gainsboro", str + len, maxlen > len ? maxlen - len : 0);
len += graphviz_legend_color("Output", "dodgerblue1", str + len, maxlen > len ? maxlen - len : 0);
len += graphviz_legend_color("Viewer", "lightskyblue3", str + len, maxlen > len ? maxlen - len : 0);
len += graphviz_legend_color("Active Viewer", "lightskyblue1", str + len, maxlen > len ? maxlen - len : 0);
@@ -248,26 +259,29 @@ int DebugInfo::graphviz_legend(char *str, int maxlen)
return len;
}
-bool DebugInfo::graphviz_system(ExecutionSystem *system, char *str, int maxlen)
+bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int maxlen)
{
char strbuf[64];
int len = 0;
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "digraph compositorexecution {\r\n");
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "ranksep=1.5\r\n");
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "rankdir=LR\r\n");
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "splines=false\r\n");
- int totnodes = system->getNodes().size();
- for (int i = 0; i < totnodes; i++) {
- Node *node = system->getNodes()[i];
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "// NODE: %s\r\n", node->getbNode()->typeinfo->ui_name);
+#if 0
+ for (ExecutionSystem::Operations::const_iterator it = system->m_operations.begin();
+ it != system->m_operations.end(); ++it) {
+ NodeOperation *op = *it;
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "// OPERATION: %s\r\n", node->getbNode()->typeinfo->ui_name);
}
+#endif
- int totgroups = system->getExecutionGroups().size();
- int totops = system->getOperations().size();
+ int totops = system->m_operations.size();
+ int totgroups = system->m_groups.size();
std::map<NodeOperation *, std::vector<std::string> > op_groups;
for (int i = 0; i < totgroups; ++i) {
- ExecutionGroup *group = system->getExecutionGroups()[i];
+ const ExecutionGroup *group = system->m_groups[i];
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "// GROUP: %d\r\n", i);
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "subgraph cluster_%d{\r\n", i);
@@ -286,10 +300,8 @@ bool DebugInfo::graphviz_system(ExecutionSystem *system, char *str, int maxlen)
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "fillcolor=chartreuse4\r\n");
}
- for (int j = 0; j < totops; ++j) {
- NodeOperation *operation = system->getOperations()[j];
- if (!group->containsOperation(operation))
- continue;
+ for (ExecutionGroup::Operations::const_iterator it = group->m_operations.begin(); it != group->m_operations.end(); ++it) {
+ NodeOperation *operation = *it;
sprintf(strbuf, "_%p", group);
op_groups[operation].push_back(std::string(strbuf));
@@ -297,14 +309,14 @@ bool DebugInfo::graphviz_system(ExecutionSystem *system, char *str, int maxlen)
len += graphviz_operation(system, operation, group, str + len, maxlen > len ? maxlen - len : 0);
}
-// len += snprintf(str+len, maxlen>len ? maxlen-len : 0, "// OUTPUTOPERATION: %p\r\n", group->getOutputNodeOperation());
-// len += snprintf(str+len, maxlen>len ? maxlen-len : 0, " O_%p\r\n", group->getOutputNodeOperation());
+// len += snprintf(str+len, maxlen>len ? maxlen-len : 0, "// OUTPUTOPERATION: %p\r\n", group->getOutputOperation());
+// len += snprintf(str+len, maxlen>len ? maxlen-len : 0, " O_%p\r\n", group->getOutputOperation());
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "}\r\n");
}
/* operations not included in any group */
for (int j = 0; j < totops; ++j) {
- NodeOperation *operation = system->getOperations()[j];
+ NodeOperation *operation = system->m_operations[j];
if (op_groups.find(operation) != op_groups.end())
continue;
@@ -314,7 +326,7 @@ bool DebugInfo::graphviz_system(ExecutionSystem *system, char *str, int maxlen)
}
for (int i = 0; i < totops; i++) {
- NodeOperation *operation = system->getOperations()[i];
+ NodeOperation *operation = system->m_operations[i];
if (operation->isReadBufferOperation()) {
ReadBufferOperation *read = (ReadBufferOperation *)operation;
@@ -330,16 +342,18 @@ bool DebugInfo::graphviz_system(ExecutionSystem *system, char *str, int maxlen)
}
}
- int totcon = system->getConnections().size();
- for (int i = 0; i < totcon; i++) {
- SocketConnection *connection = system->getConnections()[i];
+ for (int i = 0; i < totops; i++) {
+ NodeOperation *op = system->m_operations[i];
- std::string color;
- if (!connection->isValid()) {
- color = "red";
- }
- else {
- switch (connection->getFromSocket()->getDataType()) {
+ for (NodeOperation::Inputs::const_iterator it = op->m_inputs.begin(); it != op->m_inputs.end(); ++it) {
+ NodeOperationInput *to = *it;
+ NodeOperationOutput *from = to->getLink();
+
+ if (!from)
+ continue;
+
+ std::string color;
+ switch (from->getDataType()) {
case COM_DT_VALUE:
color = "grey";
break;
@@ -350,22 +364,18 @@ bool DebugInfo::graphviz_system(ExecutionSystem *system, char *str, int maxlen)
color = "orange";
break;
}
- }
-
- NodeBase *from_node = connection->getFromNode();
- NodeBase *to_node = connection->getToNode();
- OutputSocket *from_sock = connection->getFromSocket();
- InputSocket *to_sock = connection->getToSocket();
- if (from_node->isOperation() && to_node->isOperation()) {
- NodeOperation *from_op = (NodeOperation *)from_node;
- NodeOperation *to_op = (NodeOperation *)to_node;
+
+ NodeOperation *to_op = &to->getOperation();
+ NodeOperation *from_op = &from->getOperation();
std::vector<std::string> &from_groups = op_groups[from_op];
std::vector<std::string> &to_groups = op_groups[to_op];
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "// CONNECTION: %p.%p -> %p.%p\r\n", from_op, from_sock, to_op, to_sock);
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "// CONNECTION: %p.%p -> %p.%p\r\n",
+ from_op, from, to_op, to);
for (int k = 0; k < from_groups.size(); ++k) {
for (int l = 0; l < to_groups.size(); ++l) {
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "\"O_%p%s\":\"OUT_%p\":s -> \"O_%p%s\":\"IN_%p\":n", from_op, from_groups[k].c_str(), from_sock, to_op, to_groups[l].c_str(), to_sock);
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "\"O_%p%s\":\"OUT_%p\":e -> \"O_%p%s\":\"IN_%p\":w",
+ from_op, from_groups[k].c_str(), from, to_op, to_groups[l].c_str(), to);
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, " [color=%s]", color.c_str());
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "\r\n");
}
@@ -380,7 +390,7 @@ bool DebugInfo::graphviz_system(ExecutionSystem *system, char *str, int maxlen)
return (len < maxlen);
}
-void DebugInfo::graphviz(ExecutionSystem *system)
+void DebugInfo::graphviz(const ExecutionSystem *system)
{
char str[1000000];
if (graphviz_system(system, str, sizeof(str) - 1)) {
@@ -399,15 +409,16 @@ void DebugInfo::graphviz(ExecutionSystem *system)
#else
-std::string DebugInfo::node_name(NodeBase * /*node*/) { return ""; }
+std::string DebugInfo::node_name(const Node * /*node*/) { return ""; }
+std::string DebugInfo::operation_name(const NodeOperation * /*op*/) { return ""; }
void DebugInfo::convert_started() {}
-void DebugInfo::execute_started(ExecutionSystem * /*system*/) {}
-void DebugInfo::node_added(Node * /*node*/) {}
-void DebugInfo::node_to_operations(Node * /*node*/) {}
-void DebugInfo::operation_added(NodeOperation * /*operation*/) {}
-void DebugInfo::operation_read_write_buffer(NodeOperation * /*operation*/) {}
-void DebugInfo::execution_group_started(ExecutionGroup * /*group*/) {}
-void DebugInfo::execution_group_finished(ExecutionGroup * /*group*/) {}
-void DebugInfo::graphviz(ExecutionSystem * /*system*/) {}
+void DebugInfo::execute_started(const ExecutionSystem * /*system*/) {}
+void DebugInfo::node_added(const Node * /*node*/) {}
+void DebugInfo::node_to_operations(const Node * /*node*/) {}
+void DebugInfo::operation_added(const NodeOperation * /*operation*/) {}
+void DebugInfo::operation_read_write_buffer(const NodeOperation * /*operation*/) {}
+void DebugInfo::execution_group_started(const ExecutionGroup * /*group*/) {}
+void DebugInfo::execution_group_finished(const ExecutionGroup * /*group*/) {}
+void DebugInfo::graphviz(const ExecutionSystem * /*system*/) {}
#endif
diff --git a/source/blender/compositor/intern/COM_Debug.h b/source/blender/compositor/intern/COM_Debug.h
index cc108157769..204e7e4f57c 100644
--- a/source/blender/compositor/intern/COM_Debug.h
+++ b/source/blender/compositor/intern/COM_Debug.h
@@ -27,7 +27,6 @@
#include "COM_defines.h"
-class NodeBase;
class Node;
class NodeOperation;
class ExecutionSystem;
@@ -41,37 +40,41 @@ public:
EG_FINISHED
} GroupState;
- typedef std::map<NodeBase *, std::string> NodeNameMap;
- typedef std::map<ExecutionGroup *, GroupState> GroupStateMap;
+ typedef std::map<const Node *, std::string> NodeNameMap;
+ typedef std::map<const NodeOperation *, std::string> OpNameMap;
+ typedef std::map<const ExecutionGroup *, GroupState> GroupStateMap;
- static std::string node_name(NodeBase *node);
+ static std::string node_name(const Node *node);
+ static std::string operation_name(const NodeOperation *op);
static void convert_started();
- static void execute_started(ExecutionSystem *system);
+ static void execute_started(const ExecutionSystem *system);
- static void node_added(Node *node);
- static void node_to_operations(Node *node);
- static void operation_added(NodeOperation *operation);
- static void operation_read_write_buffer(NodeOperation *operation);
+ static void node_added(const Node *node);
+ static void node_to_operations(const Node *node);
+ static void operation_added(const NodeOperation *operation);
+ static void operation_read_write_buffer(const NodeOperation *operation);
- static void execution_group_started(ExecutionGroup *group);
- static void execution_group_finished(ExecutionGroup *group);
+ static void execution_group_started(const ExecutionGroup *group);
+ static void execution_group_finished(const ExecutionGroup *group);
- static void graphviz(ExecutionSystem *system);
+ static void graphviz(const ExecutionSystem *system);
#ifdef COM_DEBUG
protected:
- static int graphviz_operation(ExecutionSystem *system, NodeOperation *operation, ExecutionGroup *group, char *str, int maxlen);
+ static int graphviz_operation(const ExecutionSystem *system, const NodeOperation *operation, const ExecutionGroup *group, char *str, int maxlen);
static int graphviz_legend_color(const char *name, const char *color, char *str, int maxlen);
static int graphviz_legend_line(const char *name, const char *color, const char *style, char *str, int maxlen);
static int graphviz_legend_group(const char *name, const char *color, const char *style, char *str, int maxlen);
static int graphviz_legend(char *str, int maxlen);
- static bool graphviz_system(ExecutionSystem *system, char *str, int maxlen);
+ static bool graphviz_system(const ExecutionSystem *system, char *str, int maxlen);
private:
static int m_file_index;
static NodeNameMap m_node_names; /**< map nodes to usable names for debug output */
+ static OpNameMap m_op_names; /**< map operations to usable names for debug output */
static std::string m_current_node_name; /**< base name for all operations added by a node */
+ static std::string m_current_op_name; /**< base name for automatic sub-operations */
static GroupStateMap m_group_states; /**< for visualizing group states */
#endif
};
diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cpp b/source/blender/compositor/intern/COM_ExecutionGroup.cpp
index a8cd9284087..4ed8cc31eea 100644
--- a/source/blender/compositor/intern/COM_ExecutionGroup.cpp
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp
@@ -26,8 +26,6 @@
#include <stdlib.h>
#include "COM_ExecutionGroup.h"
-#include "COM_InputSocket.h"
-#include "COM_SocketConnection.h"
#include "COM_defines.h"
#include "COM_ExecutionSystem.h"
#include "COM_ReadBufferOperation.h"
@@ -36,7 +34,6 @@
#include "COM_WorkScheduler.h"
#include "COM_ViewerOperation.h"
#include "COM_ChunkOrder.h"
-#include "COM_ExecutionSystemHelper.h"
#include "COM_Debug.h"
#include "MEM_guardedalloc.h"
@@ -69,84 +66,43 @@ ExecutionGroup::ExecutionGroup()
CompositorPriority ExecutionGroup::getRenderPriotrity()
{
- return this->getOutputNodeOperation()->getRenderPriority();
-}
-
-bool ExecutionGroup::containsOperation(NodeOperation *operation)
-{
- for (vector<NodeOperation *>::const_iterator iterator = this->m_operations.begin(); iterator != this->m_operations.end(); ++iterator) {
- NodeOperation *inListOperation = *iterator;
- if (inListOperation == operation) {
- return true;
- }
- }
- return false;
-}
-
-const bool ExecutionGroup::isComplex() const
-{
- return this->m_complex;
+ return this->getOutputOperation()->getRenderPriority();
}
bool ExecutionGroup::canContainOperation(NodeOperation *operation)
{
if (!this->m_initialized) { return true; }
+
if (operation->isReadBufferOperation()) { return true; }
if (operation->isWriteBufferOperation()) { return false; }
if (operation->isSetOperation()) { return true; }
-
- if (!this->isComplex()) {
- return (!operation->isComplex());
- }
- else {
- return false;
- }
+
+ /* complex groups don't allow further ops (except read buffer and values, see above) */
+ if (m_complex) { return false; }
+ /* complex ops can't be added to other groups (except their own, which they initialize, see above) */
+ if (operation->isComplex()) { return false; }
+
+ return true;
}
-void ExecutionGroup::addOperation(ExecutionSystem *system, NodeOperation *operation)
+bool ExecutionGroup::addOperation(NodeOperation *operation)
{
- /* should never happen but in rare cases it can - it causes confusing crashes */
- BLI_assert(operation->isOperation() == true);
-
- if (containsOperation(operation)) return;
- if (canContainOperation(operation)) {
- if (!operation->isBufferOperation()) {
- this->m_complex = operation->isComplex();
- this->m_openCL = operation->isOpenCL();
- this->m_singleThreaded = operation->isSingleThreaded();
- this->m_initialized = true;
- }
- this->m_operations.push_back(operation);
- if (operation->isReadBufferOperation()) {
- ReadBufferOperation *readOperation = (ReadBufferOperation *)operation;
- WriteBufferOperation *writeOperation = readOperation->getMemoryProxy()->getWriteBufferOperation();
- this->addOperation(system, writeOperation);
- }
- else {
- unsigned int index;
- for (index = 0; index < operation->getNumberOfInputSockets(); index++) {
- InputSocket *inputSocket = operation->getInputSocket(index);
- if (inputSocket->isConnected()) {
- NodeOperation *node = (NodeOperation *)inputSocket->getConnection()->getFromNode();
- this->addOperation(system, node);
- }
- }
- }
- }
- else {
- if (operation->isWriteBufferOperation()) {
- WriteBufferOperation *writeoperation = (WriteBufferOperation *)operation;
- if (writeoperation->getMemoryProxy()->getExecutor() == NULL) {
- ExecutionGroup *newGroup = new ExecutionGroup();
- writeoperation->getMemoryProxy()->setExecutor(newGroup);
- newGroup->addOperation(system, operation);
- ExecutionSystemHelper::addExecutionGroup(system->getExecutionGroups(), newGroup);
- }
- }
+ if (!canContainOperation(operation))
+ return false;
+
+ if (!operation->isReadBufferOperation() && !operation->isWriteBufferOperation()) {
+ m_complex = operation->isComplex();
+ m_openCL = operation->isOpenCL();
+ m_singleThreaded = operation->isSingleThreaded();
+ m_initialized = true;
}
+
+ m_operations.push_back(operation);
+
+ return true;
}
-NodeOperation *ExecutionGroup::getOutputNodeOperation() const
+NodeOperation *ExecutionGroup::getOutputOperation() const
{
return this->m_operations[0]; // the first operation of the group is always the output operation.
}
@@ -197,7 +153,7 @@ void ExecutionGroup::deinitExecution()
}
void ExecutionGroup::determineResolution(unsigned int resolution[2])
{
- NodeOperation *operation = this->getOutputNodeOperation();
+ NodeOperation *operation = this->getOutputOperation();
resolution[0] = operation->getWidth();
resolution[1] = operation->getHeight();
this->setResolution(resolution);
@@ -226,7 +182,7 @@ void ExecutionGroup::determineNumberOfChunks()
*/
void ExecutionGroup::execute(ExecutionSystem *graph)
{
- CompositorContext &context = graph->getContext();
+ const CompositorContext &context = graph->getContext();
const bNodeTree *bTree = context.getbNodeTree();
if (this->m_width == 0 || this->m_height == 0) {return; } /// @note: break out... no pixels to calculate.
if (bTree->test_break && bTree->test_break(bTree->tbh)) {return; } /// @note: early break out for blur and preview nodes
@@ -243,7 +199,7 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
for (chunkNumber = 0; chunkNumber < this->m_numberOfChunks; chunkNumber++) {
chunkOrder[chunkNumber] = chunkNumber;
}
- NodeOperation *operation = this->getOutputNodeOperation();
+ NodeOperation *operation = this->getOutputOperation();
float centerX = 0.5;
float centerY = 0.5;
OrderOfChunks chunkorder = COM_ORDER_OF_CHUNKS_DEFAULT;
@@ -443,7 +399,7 @@ void ExecutionGroup::printBackgroundStats(void)
BLI_timestr(execution_time, timestr, sizeof(timestr));
printf("| Elapsed %s ", timestr);
- printf("| Tree %s, Tile %d-%d ", this->m_bTree->id.name + 2,
+ printf("| Tree %s, Tile %u-%u ", this->m_bTree->id.name + 2,
this->m_chunksFinished, this->m_numberOfChunks);
fputc('\n', stdout);
@@ -506,7 +462,7 @@ void ExecutionGroup::determineChunkRect(rcti *rect, const unsigned int chunkNumb
MemoryBuffer *ExecutionGroup::allocateOutputBuffer(int chunkNumber, rcti *rect)
{
// we asume that this method is only called from complex execution groups.
- NodeOperation *operation = this->getOutputNodeOperation();
+ NodeOperation *operation = this->getOutputOperation();
if (operation->isWriteBufferOperation()) {
WriteBufferOperation *writeOperation = (WriteBufferOperation *)operation;
MemoryBuffer *buffer = MemoryBuffer::create(writeOperation->getMemoryProxy(), rect);
@@ -615,7 +571,7 @@ bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem *graph, int xChun
void ExecutionGroup::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
- this->getOutputNodeOperation()->determineDependingAreaOfInterest(input, readOperation, output);
+ this->getOutputOperation()->determineDependingAreaOfInterest(input, readOperation, output);
}
void ExecutionGroup::determineDependingMemoryProxies(vector<MemoryProxy *> *memoryProxies)
@@ -634,7 +590,7 @@ bool ExecutionGroup::isOpenCL()
void ExecutionGroup::setViewerBorder(float xmin, float xmax, float ymin, float ymax)
{
- NodeOperation *operation = this->getOutputNodeOperation();
+ NodeOperation *operation = this->getOutputOperation();
if (operation->isViewerOperation() || operation->isPreviewOperation()) {
BLI_rcti_init(&this->m_viewerBorder, xmin * this->m_width, xmax * this->m_width,
@@ -644,7 +600,7 @@ void ExecutionGroup::setViewerBorder(float xmin, float xmax, float ymin, float y
void ExecutionGroup::setRenderBorder(float xmin, float xmax, float ymin, float ymax)
{
- NodeOperation *operation = this->getOutputNodeOperation();
+ NodeOperation *operation = this->getOutputOperation();
if (operation->isOutputOperation(true)) {
/* Basically, setting border need to happen for only operations
diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.h b/source/blender/compositor/intern/COM_ExecutionGroup.h
index 47f8447015d..4b6f51c72c0 100644
--- a/source/blender/compositor/intern/COM_ExecutionGroup.h
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.h
@@ -31,6 +31,12 @@
#include "COM_Device.h"
#include "COM_CompositorContext.h"
+using std::vector;
+
+class ExecutionSystem;
+class MemoryProxy;
+class ReadBufferOperation;
+class Device;
/**
* @brief the execution state of a chunk in an ExecutionGroup
@@ -51,23 +57,22 @@ typedef enum ChunkExecutionState {
COM_ES_EXECUTED = 2
} ChunkExecutionState;
-class MemoryProxy;
-class ReadBufferOperation;
-class Device;
-
/**
- * @brief Class ExecutionGroup is a group of NodeOperations that are executed as one.
+ * @brief Class ExecutionGroup is a group of Operations that are executed as one.
* This grouping is used to combine Operations that can be executed as one whole when multi-processing.
* @ingroup Execution
*/
class ExecutionGroup {
+public:
+ typedef std::vector<NodeOperation*> Operations;
+
private:
// fields
/**
* @brief list of operations in this ExecutionGroup
*/
- vector<NodeOperation *> m_operations;
+ Operations m_operations;
/**
* @brief is this ExecutionGroup an input ExecutionGroup
@@ -130,7 +135,7 @@ private:
/**
* @brief a cached vector of all read operations in the execution group.
*/
- vector<NodeOperation *> m_cachedReadOperations;
+ Operations m_cachedReadOperations;
/**
* @brief reference to the original bNodeTree, this field is only set for the 'top' execution group.
@@ -152,8 +157,8 @@ private:
ChunkExecutionState *m_chunkExecutionStates;
/**
- * @brief indicator when this ExecutionGroup has valid NodeOperations in its vector for Execution
- * @note When building the ExecutionGroup NodeOperations are added via recursion. First a WriteBufferOperations is added, then the
+ * @brief indicator when this ExecutionGroup has valid Operations in its vector for Execution
+ * @note When building the ExecutionGroup Operations are added via recursion. First a WriteBufferOperations is added, then the
* @note Operation containing the settings that is important for the ExecutiongGroup is added,
* @note When this occurs, these settings are copied over from the node to the ExecutionGroup
* @note and the Initialized flag is set to true.
@@ -245,23 +250,17 @@ private:
public:
// constructors
ExecutionGroup();
-
- // methods
- /**
- * @brief check to see if a NodeOperation is already inside this execution group
- * @param operation the NodeOperation to check
- * @return [true,false]
- */
- bool containsOperation(NodeOperation *operation);
+ // methods
/**
* @brief add an operation to this ExecutionGroup
* @note this method will add input of the operations recursively
* @note this method can create multiple ExecutionGroup's
* @param system
* @param operation
+ * @return True if the operation was successfully added
*/
- void addOperation(ExecutionSystem *system, NodeOperation *operation);
+ bool addOperation(NodeOperation *operation);
/**
* @brief is this ExecutionGroup an output ExecutionGroup
@@ -292,24 +291,24 @@ public:
/**
* @brief get the width of this execution group
*/
- const unsigned int getWidth() { return this->m_width; }
+ unsigned int getWidth() const { return m_width; }
/**
* @brief get the height of this execution group
*/
- const unsigned int getHeight() { return this->m_height; }
+ unsigned int getHeight() const { return m_height; }
/**
* @brief does this ExecutionGroup contains a complex NodeOperation
*/
- const bool isComplex() const;
+ bool isComplex() const { return m_complex; }
/**
* @brief get the output operation of this ExecutionGroup
* @return NodeOperation *output operation
*/
- NodeOperation *getOutputNodeOperation() const;
+ NodeOperation *getOutputOperation() const;
/**
* @brief compose multiple chunks into a single chunk
@@ -419,12 +418,12 @@ public:
void setRenderBorder(float xmin, float xmax, float ymin, float ymax);
+ /* allow the DebugInfo class to look at internals */
+ friend class DebugInfo;
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("COM:ExecutionGroup")
#endif
-
- /* allow the DebugInfo class to peek inside without having to add getters for everything */
- friend class DebugInfo;
};
#endif
diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cpp b/source/blender/compositor/intern/COM_ExecutionSystem.cpp
index 7bdec355a95..46aa06f75e6 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystem.cpp
+++ b/source/blender/compositor/intern/COM_ExecutionSystem.cpp
@@ -29,15 +29,11 @@ extern "C" {
}
#include "COM_Converter.h"
+#include "COM_NodeOperationBuilder.h"
#include "COM_NodeOperation.h"
#include "COM_ExecutionGroup.h"
-#include "COM_NodeBase.h"
#include "COM_WorkScheduler.h"
#include "COM_ReadBufferOperation.h"
-#include "COM_GroupNode.h"
-#include "COM_WriteBufferOperation.h"
-#include "COM_ReadBufferOperation.h"
-#include "COM_ExecutionSystemHelper.h"
#include "COM_Debug.h"
#include "BKE_global.h"
@@ -63,14 +59,15 @@ ExecutionSystem::ExecutionSystem(RenderData *rd, Scene *scene, bNodeTree *editin
this->m_context.setRendering(rendering);
this->m_context.setHasActiveOpenCLDevices(WorkScheduler::hasGPUDevices() && (editingtree->flag & NTREE_COM_OPENCL));
- ExecutionSystemHelper::addbNodeTree(*this, 0, editingtree, NODE_INSTANCE_KEY_BASE);
-
this->m_context.setRenderData(rd);
this->m_context.setViewSettings(viewSettings);
this->m_context.setDisplaySettings(displaySettings);
- this->convertToOperations();
- this->groupOperations(); /* group operations in ExecutionGroups */
+ {
+ NodeOperationBuilder builder(&m_context, editingtree);
+ builder.convertToOperations(this);
+ }
+
unsigned int index;
unsigned int resolution[2];
@@ -107,16 +104,6 @@ ExecutionSystem::ExecutionSystem(RenderData *rd, Scene *scene, bNodeTree *editin
ExecutionSystem::~ExecutionSystem()
{
unsigned int index;
- for (index = 0; index < this->m_connections.size(); index++) {
- SocketConnection *connection = this->m_connections[index];
- delete connection;
- }
- this->m_connections.clear();
- for (index = 0; index < this->m_nodes.size(); index++) {
- Node *node = this->m_nodes[index];
- delete node;
- }
- this->m_nodes.clear();
for (index = 0; index < this->m_operations.size(); index++) {
NodeOperation *operation = this->m_operations[index];
delete operation;
@@ -129,14 +116,19 @@ ExecutionSystem::~ExecutionSystem()
this->m_groups.clear();
}
+void ExecutionSystem::set_operations(const Operations &operations, const Groups &groups)
+{
+ m_operations = operations;
+ m_groups = groups;
+}
+
void ExecutionSystem::execute()
{
DebugInfo::execute_started(this);
unsigned int order = 0;
for (vector<NodeOperation *>::iterator iter = this->m_operations.begin(); iter != this->m_operations.end(); ++iter) {
- NodeBase *node = *iter;
- NodeOperation *operation = (NodeOperation *) node;
+ NodeOperation *operation = *iter;
if (operation->isReadBufferOperation()) {
ReadBufferOperation *readOperation = (ReadBufferOperation *)operation;
readOperation->setOffset(order);
@@ -196,202 +188,6 @@ void ExecutionSystem::executeGroups(CompositorPriority priority)
}
}
-void ExecutionSystem::addOperation(NodeOperation *operation)
-{
- ExecutionSystemHelper::addOperation(this->m_operations, operation);
- DebugInfo::operation_added(operation);
-}
-
-void ExecutionSystem::addReadWriteBufferOperations(NodeOperation *operation)
-{
- DebugInfo::operation_read_write_buffer(operation);
-
- // for every input add write and read operation if input is not a read operation
- // only add read operation to other links when they are attached to buffered operations.
- unsigned int index;
- for (index = 0; index < operation->getNumberOfInputSockets(); index++) {
- InputSocket *inputsocket = operation->getInputSocket(index);
- if (inputsocket->isConnected()) {
- SocketConnection *connection = inputsocket->getConnection();
- NodeOperation *otherEnd = (NodeOperation *)connection->getFromNode();
- if (!otherEnd->isReadBufferOperation()) {
- // check of other end already has write operation
- OutputSocket *fromsocket = connection->getFromSocket();
- WriteBufferOperation *writeoperation = fromsocket->findAttachedWriteBufferOperation();
- if (writeoperation == NULL) {
- writeoperation = new WriteBufferOperation(fromsocket->getDataType());
- writeoperation->setbNodeTree(this->getContext().getbNodeTree());
- this->addOperation(writeoperation);
- ExecutionSystemHelper::addLink(this->getConnections(), fromsocket, writeoperation->getInputSocket(0));
- writeoperation->readResolutionFromInputSocket();
- }
- ReadBufferOperation *readoperation = new ReadBufferOperation(fromsocket->getDataType());
- readoperation->setMemoryProxy(writeoperation->getMemoryProxy());
- connection->setFromSocket(readoperation->getOutputSocket());
- readoperation->getOutputSocket()->addConnection(connection);
- readoperation->readResolutionFromWriteBuffer();
- this->addOperation(readoperation);
- }
- }
- }
- /*
- * link the outputsocket to a write operation
- * link the writeoperation to a read operation
- * link the read operation to the next node.
- */
- OutputSocket *outputsocket = operation->getOutputSocket();
- if (outputsocket->isConnected()) {
- WriteBufferOperation *writeOperation = NULL;
- /* try to find existing write buffer operation first */
- for (index = 0; index < outputsocket->getNumberOfConnections(); index++) {
- SocketConnection *connection = outputsocket->getConnection(index);
- NodeBase *otherEnd = connection->getToNode();
- if (otherEnd->isOperation()) {
- NodeOperation *otherEndOp = (NodeOperation *)otherEnd;
- if (otherEndOp->isWriteBufferOperation()) {
- writeOperation = (WriteBufferOperation *)otherEndOp;
- break;
- }
- }
- }
- /* if no write buffer operation exists yet, create a new one */
- if (!writeOperation) {
- writeOperation = new WriteBufferOperation(outputsocket->getDataType());
- writeOperation->setbNodeTree(this->getContext().getbNodeTree());
- this->addOperation(writeOperation);
- ExecutionSystemHelper::addLink(this->getConnections(), outputsocket, writeOperation->getInputSocket(0));
- }
- writeOperation->readResolutionFromInputSocket();
-
- for (index = 0; index < outputsocket->getNumberOfConnections(); index++) {
- SocketConnection *connection = outputsocket->getConnection(index);
- /* skip existing connections to write buffer operation */
- if (connection->getToNode() == writeOperation)
- continue;
-
- ReadBufferOperation *readoperation = new ReadBufferOperation(outputsocket->getDataType());
- readoperation->setMemoryProxy(writeOperation->getMemoryProxy());
- connection->setFromSocket(readoperation->getOutputSocket());
- readoperation->getOutputSocket()->addConnection(connection);
- readoperation->readResolutionFromWriteBuffer();
- this->addOperation(readoperation);
- }
- }
-}
-
-#ifndef NDEBUG
-/* if this fails, there are still connection to/from this node,
- * which have not been properly relinked to operations!
- */
-static void debug_check_node_connections(Node *node)
-{
- /* note: connected inputs are not checked here,
- * it would break quite a lot and such inputs are ignored later anyway
- */
-#if 0
- for (int i = 0; i < node->getNumberOfInputSockets(); ++i) {
- BLI_assert(!node->getInputSocket(i)->isConnected());
- }
-#endif
- for (int i = 0; i < node->getNumberOfOutputSockets(); ++i) {
- BLI_assert(!node->getOutputSocket(i)->isConnected());
- }
-}
-#else
-/* stub */
-#define debug_check_node_connections(node)
-#endif
-
-void ExecutionSystem::convertToOperations()
-{
- unsigned int index;
-
- for (index = 0; index < this->m_nodes.size(); index++) {
- Node *node = (Node *)this->m_nodes[index];
- DebugInfo::node_to_operations(node);
- node->convertToOperations(this, &this->m_context);
-
- debug_check_node_connections(node);
- }
-
- for (index = 0; index < this->m_connections.size(); index++) {
- SocketConnection *connection = this->m_connections[index];
- if (connection->isValid()) {
- if (connection->getFromSocket()->getDataType() != connection->getToSocket()->getDataType()) {
- Converter::convertDataType(connection, this);
- }
- }
- }
-
- // determine all resolutions of the operations (Width/Height)
- for (index = 0; index < this->m_operations.size(); index++) {
- NodeOperation *operation = this->m_operations[index];
- if (operation->isOutputOperation(this->m_context.isRendering()) && !operation->isPreviewOperation()) {
- unsigned int resolution[2] = {0, 0};
- unsigned int preferredResolution[2] = {0, 0};
- operation->determineResolution(resolution, preferredResolution);
- operation->setResolution(resolution);
- }
- }
- for (index = 0; index < this->m_operations.size(); index++) {
- NodeOperation *operation = this->m_operations[index];
- if (operation->isOutputOperation(this->m_context.isRendering()) && operation->isPreviewOperation()) {
- unsigned int resolution[2] = {0, 0};
- unsigned int preferredResolution[2] = {0, 0};
- operation->determineResolution(resolution, preferredResolution);
- operation->setResolution(resolution);
- }
- }
-
- // add convert resolution operations when needed.
- for (index = 0; index < this->m_connections.size(); index++) {
- SocketConnection *connection = this->m_connections[index];
- if (connection->isValid()) {
- if (connection->needsResolutionConversion()) {
- Converter::convertResolution(connection, this);
- }
- }
- }
-}
-
-void ExecutionSystem::groupOperations()
-{
- vector<NodeOperation *> outputOperations;
- NodeOperation *operation;
- unsigned int index;
- // surround complex operations with ReadBufferOperation and WriteBufferOperation
- for (index = 0; index < this->m_operations.size(); index++) {
- operation = this->m_operations[index];
- if (operation->isComplex()) {
- this->addReadWriteBufferOperations(operation);
- }
- }
- ExecutionSystemHelper::findOutputNodeOperations(&outputOperations, this->getOperations(), this->m_context.isRendering());
- for (vector<NodeOperation *>::iterator iter = outputOperations.begin(); iter != outputOperations.end(); ++iter) {
- operation = *iter;
- ExecutionGroup *group = new ExecutionGroup();
- group->addOperation(this, operation);
- group->setOutputExecutionGroup(true);
- ExecutionSystemHelper::addExecutionGroup(this->getExecutionGroups(), group);
- }
-}
-
-void ExecutionSystem::addSocketConnection(SocketConnection *connection)
-{
- this->m_connections.push_back(connection);
-}
-
-void ExecutionSystem::removeSocketConnection(SocketConnection *connection)
-{
- for (vector<SocketConnection *>::iterator it = m_connections.begin(); it != m_connections.end(); ++it) {
- if (*it == connection) {
- this->m_connections.erase(it);
- return;
- }
- }
-}
-
-
void ExecutionSystem::findOutputExecutionGroup(vector<ExecutionGroup *> *result, CompositorPriority priority) const
{
unsigned int index;
diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.h b/source/blender/compositor/intern/COM_ExecutionSystem.h
index 7402ff90fb5..ab903206f0a 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystem.h
+++ b/source/blender/compositor/intern/COM_ExecutionSystem.h
@@ -29,7 +29,6 @@ class ExecutionGroup;
#include "DNA_node_types.h"
#include <vector>
#include "COM_Node.h"
-#include "COM_SocketConnection.h"
#include "BKE_text.h"
#include "COM_ExecutionGroup.h"
#include "COM_NodeOperation.h"
@@ -73,7 +72,7 @@ using namespace std;
* As values are ordered differently than colors a conversion happens.
*
* - Image size conversions: the system can automatically convert when resolutions do not match.
- * An InputSocket has a resize mode. This can be any of the following settings.
+ * An NodeInput has a resize mode. This can be any of the following settings.
* - [@ref InputSocketResizeMode.COM_SC_CENTER]: The center of both images are aligned
* - [@ref InputSocketResizeMode.COM_SC_FIT_WIDTH]: The width of both images are aligned
* - [@ref InputSocketResizeMode.COM_SC_FIT_HEIGHT]: the height of both images are aligned
@@ -115,6 +114,10 @@ using namespace std;
* @brief the ExecutionSystem contains the whole compositor tree.
*/
class ExecutionSystem {
+public:
+ typedef std::vector<NodeOperation*> Operations;
+ typedef std::vector<ExecutionGroup*> Groups;
+
private:
/**
* @brief the context used during execution
@@ -122,34 +125,17 @@ private:
CompositorContext m_context;
/**
- * @brief vector of nodes
- */
- vector<Node *> m_nodes;
-
- /**
* @brief vector of operations
*/
- vector<NodeOperation *> m_operations;
+ Operations m_operations;
/**
* @brief vector of groups
*/
- vector<ExecutionGroup *> m_groups;
-
- /**
- * @brief vector of connections
- */
- vector<SocketConnection *> m_connections;
+ Groups m_groups;
private: //methods
/**
- * @brief add ReadBufferOperation and WriteBufferOperation around an operation
- * @param operation the operation to add the bufferoperations around.
- */
- void addReadWriteBufferOperations(NodeOperation *operation);
-
-
- /**
* find all execution group with output nodes
*/
void findOutputExecutionGroup(vector<ExecutionGroup *> *result, CompositorPriority priority) const;
@@ -175,6 +161,7 @@ public:
*/
~ExecutionSystem();
+ void set_operations(const Operations &operations, const Groups &groups);
/**
* @brief execute this system
@@ -185,70 +172,16 @@ public:
void execute();
/**
- * @brief Add an operation to the operation list
- *
- * @param operation the operation to add
- */
- void addOperation(NodeOperation *operation);
-
- /**
- * Add an editor link to the system. convert it to an socketconnection (CPP-representative)
- * this converted socket is returned.
- */
- SocketConnection *addNodeLink(bNodeLink *bNodeLink);
- void addSocketConnection(SocketConnection *connection);
-
- /**
- * Remove a socket connection from the system.
- */
- void removeSocketConnection(SocketConnection *connection);
-
- /**
- * @brief Convert all nodes to operations
- */
- void convertToOperations();
-
- /**
- * @brief group operations in ExecutionGroup's
- * @see ExecutionGroup
- */
- void groupOperations();
-
- /**
* @brief get the reference to the compositor context
*/
- CompositorContext &getContext() { return this->m_context; }
-
- /**
- * @brief get the reference to the compositor nodes
- */
- vector<Node *> &getNodes() { return this->m_nodes; }
-
- /**
- * @brief get the reference to the compositor connections
- */
- vector<SocketConnection *>& getConnections() { return this->m_connections; }
-
- /**
- * @brief get the reference to the list of execution groups
- */
- vector<ExecutionGroup *>& getExecutionGroups() { return this->m_groups; }
-
- /**
- * @brief get the reference to the list of operations
- */
- vector<NodeOperation *>& getOperations() { return this->m_operations; }
+ const CompositorContext &getContext() const { return this->m_context; }
private:
-
- /**
- * @brief determine the actual data types of all sockets
- * @param nodes list of nodes or operations to do the data type determination
- */
- void determineActualSocketDataTypes(vector<NodeBase *> &nodes);
-
void executeGroups(CompositorPriority priority);
+ /* allow the DebugInfo class to look at internals */
+ friend class DebugInfo;
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("COM:ExecutionSystem")
#endif
diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp
deleted file mode 100644
index 7def96d426e..00000000000
--- a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the 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:
- * Jeroen Bakker
- * Monique Dewanchand
- */
-
-#include "COM_ExecutionSystemHelper.h"
-
-#include "PIL_time.h"
-
-#include "COM_Converter.h"
-#include "COM_NodeOperation.h"
-#include "COM_ExecutionGroup.h"
-#include "COM_NodeBase.h"
-#include "COM_WorkScheduler.h"
-#include "COM_ReadBufferOperation.h"
-#include "COM_GroupNode.h"
-#include "COM_WriteBufferOperation.h"
-#include "COM_ReadBufferOperation.h"
-#include "COM_ViewerOperation.h"
-#include "COM_Debug.h"
-
-extern "C" {
-#include "BKE_node.h"
-}
-
-void ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree *tree, bNodeInstanceKey parent_key)
-{
- vector<Node *>& nodes = system.getNodes();
- vector<SocketConnection *>& links = system.getConnections();
-
- const bNodeTree *basetree = system.getContext().getbNodeTree();
- /* update viewers in the active edittree as well the base tree (for backdrop) */
- bool is_active_group = ((parent_key.value == basetree->active_viewer_key.value) ||
- (tree == basetree));
-
- /* add all nodes of the tree to the node list */
- bNode *node = (bNode *)tree->nodes.first;
- while (node != NULL) {
- Node *nnode = addNode(nodes, node, is_active_group, system.getContext().isFastCalculation());
- if (nnode) {
- nnode->setbNodeTree(tree);
- nnode->setInstanceKey(BKE_node_instance_key(parent_key, tree, node));
- }
- node = node->next;
- }
-
- NodeRange node_range(nodes.begin() + nodes_start, nodes.end());
-
- /* add all nodelinks of the tree to the link list */
- bNodeLink *nodelink = (bNodeLink *)tree->links.first;
- while (nodelink != NULL) {
- addNodeLink(node_range, links, nodelink);
- nodelink = nodelink->next;
- }
-
- /* Expand group nodes
- * Only go up to nodes_end, to avoid ungrouping nested node groups repeatedly.
- */
- int nodes_end = nodes.size();
- for (unsigned int i = nodes_start; i < nodes_end; ++i) {
- Node *execnode = nodes[i];
- if (execnode->isGroupNode()) {
- GroupNode *groupNode = (GroupNode *)execnode;
- groupNode->ungroup(system);
- }
- }
-}
-
-void ExecutionSystemHelper::addNode(vector<Node *>& nodes, Node *node)
-{
- nodes.push_back(node);
-}
-
-Node *ExecutionSystemHelper::addNode(vector<Node *>& nodes, bNode *b_node, bool inActiveGroup, bool fast)
-{
- Node *node = Converter::convert(b_node, fast);
- if (node) {
- node->setIsInActiveGroup(inActiveGroup);
- addNode(nodes, node);
-
- DebugInfo::node_added(node);
- }
- return node;
-}
-void ExecutionSystemHelper::addOperation(vector<NodeOperation *>& operations, NodeOperation *operation)
-{
- operations.push_back(operation);
-}
-
-void ExecutionSystemHelper::addExecutionGroup(vector<ExecutionGroup *>& executionGroups, ExecutionGroup *executionGroup)
-{
- executionGroups.push_back(executionGroup);
-}
-
-void ExecutionSystemHelper::findOutputNodeOperations(vector<NodeOperation *> *result, vector<NodeOperation *>& operations, bool rendering)
-{
- unsigned int index;
-
- for (index = 0; index < operations.size(); index++) {
- NodeOperation *operation = operations[index];
- if (operation->isOutputOperation(rendering)) {
- result->push_back(operation);
- }
- }
-}
-
-static InputSocket *find_input(NodeRange &node_range, bNode *bnode, bNodeSocket *bsocket)
-{
- for (NodeIterator it = node_range.first; it != node_range.second; ++it) {
- Node *node = *it;
- InputSocket *input = node->findInputSocketBybNodeSocket(bsocket);
- if (input)
- return input;
- }
- return NULL;
-}
-static OutputSocket *find_output(NodeRange &node_range, bNode *bnode, bNodeSocket *bsocket)
-{
- for (NodeIterator it = node_range.first; it != node_range.second; ++it) {
- Node *node = *it;
- OutputSocket *output = node->findOutputSocketBybNodeSocket(bsocket);
- if (output)
- return output;
- }
- return NULL;
-}
-SocketConnection *ExecutionSystemHelper::addNodeLink(NodeRange &node_range, vector<SocketConnection *>& links, bNodeLink *b_nodelink)
-{
- /// @note: ignore invalid links
- if (!(b_nodelink->flag & NODE_LINK_VALID))
- return NULL;
-
- InputSocket *inputSocket = find_input(node_range, b_nodelink->tonode, b_nodelink->tosock);
- OutputSocket *outputSocket = find_output(node_range, b_nodelink->fromnode, b_nodelink->fromsock);
- if (inputSocket == NULL || outputSocket == NULL) {
- return NULL;
- }
- if (inputSocket->isConnected()) {
- return NULL;
- }
- SocketConnection *connection = addLink(links, outputSocket, inputSocket);
- return connection;
-}
-
-SocketConnection *ExecutionSystemHelper::addLink(vector<SocketConnection *>& links, OutputSocket *fromSocket, InputSocket *toSocket)
-{
- SocketConnection *newconnection = new SocketConnection();
- newconnection->setFromSocket(fromSocket);
- newconnection->setToSocket(toSocket);
- fromSocket->addConnection(newconnection);
- toSocket->setConnection(newconnection);
- links.push_back(newconnection);
- return newconnection;
-}
diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.h b/source/blender/compositor/intern/COM_ExecutionSystemHelper.h
deleted file mode 100644
index ae9e75e0408..00000000000
--- a/source/blender/compositor/intern/COM_ExecutionSystemHelper.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the 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:
- * Jeroen Bakker
- * Monique Dewanchand
- */
-
-class ExecutionGroup;
-
-#ifndef _COM_ExecutionSystemHelper_h
-#define _COM_ExecutionSystemHelper_h
-
-#include "DNA_node_types.h"
-#include <vector>
-#include "COM_Node.h"
-#include "COM_SocketConnection.h"
-#include "BKE_text.h"
-#include "COM_ExecutionGroup.h"
-
-using namespace std;
-
-/**
- *
- */
-class ExecutionSystemHelper {
-
-public:
-
- /**
- * @brief add an bNodeTree to the nodes list and connections
- * @param system Execution system
- * @param nodes_start Starting index in the system's nodes list for nodes in this tree.
- * @param tree bNodeTree to add
- * @return Node representing the "Compositor node" of the maintree. or NULL when a subtree is added
- */
- static void addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree *tree, bNodeInstanceKey parent_key);
-
- /**
- * @brief add an editor node to the system.
- * this node is converted to a Node instance.
- * and the converted node is returned
- *
- * @param b_node node to add
- * @return Node that represents the bNode or null when not able to convert.
- */
- static Node *addNode(vector<Node *>& nodes, bNode *b_node, bool isInActiveGroup, bool fast);
-
- /**
- * @brief Add a Node to a list
- *
- * @param nodes the list where the node needs to be added to
- * @param node the node to be added
- */
- static void addNode(vector<Node *>& nodes, Node *node);
-
- /**
- * @brief Add an operation to the operation list
- *
- * The id of the operation is updated.
- *
- * @param operations the list where the operation need to be added to
- * @param operation the operation to add
- */
- static void addOperation(vector<NodeOperation *> &operations, NodeOperation *operation);
-
- /**
- * @brief Add an ExecutionGroup to a list
- *
- * The id of the ExecutionGroup is updated.
- *
- * @param executionGroups the list where the executionGroup need to be added to
- * @param executionGroup the ExecutionGroup to add
- */
- static void addExecutionGroup(vector<ExecutionGroup *>& executionGroups, ExecutionGroup *executionGroup);
-
- /**
- * Find all Node Operations that needs to be executed.
- * @param rendering
- * the rendering parameter will tell what type of execution we are doing
- * false is editing, true is rendering
- */
- static void findOutputNodeOperations(vector<NodeOperation *> *result, vector<NodeOperation *>& operations, bool rendering);
-
- /**
- * @brief add a bNodeLink to the list of links
- * the bNodeLink will be wrapped in a SocketConnection
- *
- * @note Cyclic links will be ignored
- *
- * @param node_range list of possible nodes for lookup.
- * @param links list of links to add the bNodeLink to
- * @param bNodeLink the link to be added
- * @return the created SocketConnection or NULL
- */
- static SocketConnection *addNodeLink(NodeRange &node_range, vector<SocketConnection *>& links, bNodeLink *bNodeLink);
-
- /**
- * @brief create a new SocketConnection and add to a vector of links
- * @param links the vector of links
- * @param fromSocket the startpoint of the connection
- * @param toSocket the endpoint of the connection
- * @return the new created SocketConnection
- */
- static SocketConnection *addLink(vector<SocketConnection *>& links, OutputSocket *fromSocket, InputSocket *toSocket);
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("COM:ExecutionSystemHelper")
-#endif
-};
-
-#endif /* _COM_ExecutionSystemHelper_h */
diff --git a/source/blender/compositor/intern/COM_InputSocket.cpp b/source/blender/compositor/intern/COM_InputSocket.cpp
deleted file mode 100644
index 6868745d631..00000000000
--- a/source/blender/compositor/intern/COM_InputSocket.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the 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:
- * Jeroen Bakker
- * Monique Dewanchand
- */
-
-#include "COM_Socket.h"
-#include "COM_Node.h"
-#include "COM_SocketConnection.h"
-#include "COM_ExecutionSystem.h"
-
-InputSocket::InputSocket(DataType datatype) : Socket(datatype)
-{
- this->m_connection = NULL;
- this->m_resizeMode = COM_SC_CENTER;
-}
-InputSocket::InputSocket(DataType datatype, InputSocketResizeMode resizeMode) : Socket(datatype)
-{
- this->m_connection = NULL;
- this->m_resizeMode = resizeMode;
-}
-
-InputSocket::InputSocket(InputSocket *from) : Socket(from->getDataType())
-{
- this->m_connection = NULL;
- this->m_resizeMode = from->getResizeMode();
-}
-
-int InputSocket::isInputSocket() const { return true; }
-const int InputSocket::isConnected() const { return this->m_connection != NULL; }
-
-void InputSocket::setConnection(SocketConnection *connection)
-{
- this->m_connection = connection;
-}
-SocketConnection *InputSocket::getConnection()
-{
- return this->m_connection;
-}
-
-void InputSocket::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
-{
- if (this->isConnected()) {
- this->m_connection->getFromSocket()->determineResolution(resolution, preferredResolution);
- }
- else {
- return;
- }
-}
-
-void InputSocket::relinkConnections(InputSocket *relinkToSocket)
-{
- if (!isConnected()) {
- return;
- }
- SocketConnection *connection = this->getConnection();
- connection->setToSocket(relinkToSocket);
- relinkToSocket->setConnection(connection);
- this->setConnection(NULL);
-}
-
-void InputSocket::relinkConnectionsDuplicate(InputSocket *relinkToSocket, int editorNodeInputSocketIndex, ExecutionSystem *graph)
-{
- if (!this->isConnected()) {
- Node *node = (Node *)this->getNode();
- switch (this->getDataType()) {
- case COM_DT_COLOR:
- node->addSetColorOperation(graph, relinkToSocket, editorNodeInputSocketIndex);
- break;
- case COM_DT_VECTOR:
- node->addSetVectorOperation(graph, relinkToSocket, editorNodeInputSocketIndex);
- break;
- case COM_DT_VALUE:
- node->addSetValueOperation(graph, relinkToSocket, editorNodeInputSocketIndex);
- break;
- }
- return;
- }
- SocketConnection *newConnection = new SocketConnection();
- OutputSocket *fromSocket = this->getConnection()->getFromSocket();
- newConnection->setToSocket(relinkToSocket);
- newConnection->setFromSocket(fromSocket);
- relinkToSocket->setConnection(newConnection);
- fromSocket->addConnection(newConnection);
- graph->addSocketConnection(newConnection);
-}
-
-void InputSocket::relinkConnections(InputSocket *relinkToSocket, int editorNodeInputSocketIndex, ExecutionSystem *graph)
-{
- if (isConnected()) {
- relinkConnections(relinkToSocket);
- }
- else {
- Node *node = (Node *)this->getNode();
- switch (this->getDataType()) {
- case COM_DT_COLOR:
- node->addSetColorOperation(graph, relinkToSocket, editorNodeInputSocketIndex);
- break;
- case COM_DT_VECTOR:
- node->addSetVectorOperation(graph, relinkToSocket, editorNodeInputSocketIndex);
- break;
- case COM_DT_VALUE:
- node->addSetValueOperation(graph, relinkToSocket, editorNodeInputSocketIndex);
- break;
- }
- }
-}
-
-void InputSocket::unlinkConnections(ExecutionSystem *system)
-{
- SocketConnection *connection = getConnection();
- if (connection) {
- system->removeSocketConnection(connection);
- connection->getFromSocket()->removeConnection(connection);
- setConnection(NULL);
- delete connection;
- }
-}
-
-bool InputSocket::isStatic()
-{
- if (isConnected()) {
- NodeBase *node = this->getConnection()->getFromNode();
- if (node) {
- return node->isStatic();
- }
- }
- return true;
-}
-SocketReader *InputSocket::getReader()
-{
- return this->getOperation();
-}
-
-NodeOperation *InputSocket::getOperation() const
-{
- if (isConnected()) {
- return (NodeOperation *)this->m_connection->getFromSocket()->getNode();
- }
- else {
- return NULL;
- }
-}
diff --git a/source/blender/compositor/intern/COM_InputSocket.h b/source/blender/compositor/intern/COM_InputSocket.h
deleted file mode 100644
index 23490b66bba..00000000000
--- a/source/blender/compositor/intern/COM_InputSocket.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the 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:
- * Jeroen Bakker
- * Monique Dewanchand
- */
-
-#ifndef _COM_InputSocket_h
-#define _COM_InputSocket_h
-
-#include <vector>
-#include "COM_Socket.h"
-#include "COM_SocketReader.h"
-
-using namespace std;
-class SocketConnection;
-class Node;
-class ExecutionSystem;
-class OutputSocket;
-class ChannelInfo;
-class NodeOperation;
-
-/**
- * @brief Resize modes of inputsockets
- * How are the input and working resolutions matched
- * @ingroup Model
- */
-typedef enum InputSocketResizeMode {
- /** @brief Center the input image to the center of the working area of the node, no resizing occurs */
- COM_SC_CENTER = NS_CR_CENTER,
- /** @brief The bottom left of the input image is the bottom left of the working area of the node, no resizing occurs */
- COM_SC_NO_RESIZE = NS_CR_NONE,
- /** @brief Fit the width of the input image to the width of the working area of the node */
- COM_SC_FIT_WIDTH = NS_CR_FIT_WIDTH,
- /** @brief Fit the height of the input image to the height of the working area of the node */
- COM_SC_FIT_HEIGHT = NS_CR_FIT_HEIGHT,
- /** @brief Fit the width or the height of the input image to the width or height of the working area of the node, image will be larger than the working area */
- COM_SC_FIT = NS_CR_FIT,
- /** @brief Fit the width and the height of the input image to the width and height of the working area of the node, image will be equally larger than the working area */
- COM_SC_STRETCH = NS_CR_STRETCH
-} InputSocketResizeMode;
-
-/**
- * @brief InputSocket are sockets that can receive data/input
- * @ingroup Model
- */
-class InputSocket : public Socket {
-private:
- /**
- * @brief connection connected to this InputSocket.
- * An input socket can only have a single connection
- */
- SocketConnection *m_connection;
-
- /**
- * @brief resize mode of this socket
- */
- InputSocketResizeMode m_resizeMode;
-
-
-public:
- InputSocket(DataType datatype);
- InputSocket(DataType datatype, InputSocketResizeMode resizeMode);
- InputSocket(InputSocket *from);
-
- void setConnection(SocketConnection *connection);
- SocketConnection *getConnection();
-
- const int isConnected() const;
- int isInputSocket() const;
-
- /**
- * @brief determine the resolution of this data going through this socket
- * @param resolution the result of this operation
- * @param preferredResolution the preferable resolution as no resolution could be determined
- */
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
-
- /**
- * @brief move all connections of this input socket to another socket
- * only use this method when already checked the availability of a SocketConnection
- * @param relinkToSocket the socket to move to connections to
- */
- void relinkConnections(InputSocket *relinkToSocket);
-
- /**
- * @brief move all connections of this input socket to another socket
- * @param relinkToSocket the socket to move to connections to
- * @param editorNodeInputSocketIndex index of the socket number of the bNode (used to retrieve the value for autoconnection)
- * @param system ExecutionSystem to update to
- */
- void relinkConnections(InputSocket *relinkToSocket, int editorNodeInputSocketIndex, ExecutionSystem *system);
-
- /**
- * @brief add a connection of this input socket to another socket
- * @warning make sure to remove the original connection with \a unlinkConnections afterward.
- * @param relinkToSocket the socket to move to connections to
- * @param editorNodeInputSocketIndex index of the socket number of the bNode (used to retrieve the value for autoconnection)
- * @param system ExecutionSystem to update to
- */
- void relinkConnectionsDuplicate(InputSocket *relinkToSocket, int editorNodeInputSocketIndex, ExecutionSystem *system);
-
- /**
- * @brief remove all connections of this input socket.
- * @warning \a relinkConnectionsDuplicate should be used to ensure this socket is still connected.
- * @param system ExecutionSystem to update to
- */
- void unlinkConnections(ExecutionSystem *system);
-
- /**
- * @brief set the resize mode
- * @param resizeMode the new resize mode.
- */
- void setResizeMode(InputSocketResizeMode resizeMode) {
- this->m_resizeMode = resizeMode;
- }
-
- /**
- * @brief get the resize mode of this socket
- * @return InputSocketResizeMode
- */
- InputSocketResizeMode getResizeMode() const {
- return this->m_resizeMode;
- }
-
- const ChannelInfo *getChannelInfo(const int channelnumber);
-
- bool isStatic();
-
- SocketReader *getReader();
- NodeOperation *getOperation() const;
-};
-
-#endif
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cpp b/source/blender/compositor/intern/COM_MemoryBuffer.cpp
index 32229e2d912..ff20d4cf7f9 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.cpp
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.cpp
@@ -21,8 +21,12 @@
*/
#include "COM_MemoryBuffer.h"
+
#include "MEM_guardedalloc.h"
-//#include "BKE_global.h"
+
+using std::min;
+using std::max;
+
#include "COM_MemoryBufferColor.h"
#include "COM_MemoryBufferVector.h"
#include "COM_MemoryBufferValue.h"
@@ -46,7 +50,7 @@ MemoryBuffer* MemoryBuffer::create(MemoryProxy *memoryProxy, unsigned int chunkN
type = memoryProxy->getDataType();
if (type == COM_DT_VALUE) {
- return new MemoryBufferValue(memoryProxy, chunkNumber, rect);
+ return new MemoryBufferValue(memoryProxy, chunkNumber, rect);
}
else if (type == COM_DT_VECTOR) {
return new MemoryBufferVector(memoryProxy, chunkNumber, rect);
@@ -57,30 +61,30 @@ MemoryBuffer* MemoryBuffer::create(MemoryProxy *memoryProxy, unsigned int chunkN
}
MemoryBuffer* MemoryBuffer::create(MemoryProxy *memoryProxy, rcti *rect) {
- DataType type;
- type = memoryProxy->getDataType();
+ DataType type;
+ type = memoryProxy->getDataType();
- if (type==COM_DT_VALUE){
- return new MemoryBufferValue(memoryProxy, rect);
- }
- else if (type == COM_DT_VECTOR) {
- return new MemoryBufferVector(memoryProxy, rect);
- }
- else {
- return new MemoryBufferColor(memoryProxy, rect);
- }
+ if (type==COM_DT_VALUE){
+ return new MemoryBufferValue(memoryProxy, rect);
+ }
+ else if (type == COM_DT_VECTOR) {
+ return new MemoryBufferVector(memoryProxy, rect);
+ }
+ else {
+ return new MemoryBufferColor(memoryProxy, rect);
+ }
}
MemoryBuffer* MemoryBuffer::create(DataType datatype, rcti *rect) {
- if (datatype==COM_DT_VALUE){
- return new MemoryBufferValue(datatype, rect);
- }
- else if (datatype == COM_DT_VECTOR) {
- return new MemoryBufferVector(datatype, rect);
- }
- else {
- return new MemoryBufferColor(datatype, rect);
- }
+ if (datatype==COM_DT_VALUE){
+ return new MemoryBufferValue(datatype, rect);
+ }
+ else if (datatype == COM_DT_VECTOR) {
+ return new MemoryBufferVector(datatype, rect);
+ }
+ else {
+ return new MemoryBufferColor(datatype, rect);
+ }
}
MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber, rcti *rect, unsigned int no_channels)
@@ -106,13 +110,13 @@ MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, rcti *rect, unsigned int no
}
MemoryBuffer::MemoryBuffer(DataType datatype, rcti *rect, unsigned int no_channels) {
- BLI_rcti_init(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax);
- this->m_memoryProxy = NULL;
- this->m_chunkNumber = -1;
- this->m_buffer = (float *)MEM_mallocN(sizeof(float) * determineBufferSize() * no_channels, "COM_MemoryBuffer");
- this->m_state = COM_MB_TEMPORARILY;
- this->m_chunkWidth = this->m_rect.xmax - this->m_rect.xmin;
- this->m_no_channels = no_channels;
+ BLI_rcti_init(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax);
+ this->m_memoryProxy = NULL;
+ this->m_chunkNumber = -1;
+ this->m_buffer = (float *)MEM_mallocN(sizeof(float) * determineBufferSize() * no_channels, "COM_MemoryBuffer");
+ this->m_state = COM_MB_TEMPORARILY;
+ this->m_chunkWidth = this->m_rect.xmax - this->m_rect.xmin;
+ this->m_no_channels = no_channels;
}
void MemoryBuffer::clear()
@@ -174,7 +178,7 @@ float MemoryBuffer::getMaximumValue(rcti *rect)
BLI_rcti_isect(rect, &this->m_rect, &rect_clamp);
if (!BLI_rcti_is_empty(&rect_clamp)) {
- MemoryBuffer *temp = MemoryBuffer::create(COM_DT_VALUE, &rect_clamp);
+ MemoryBuffer *temp = MemoryBuffer::create(COM_DT_VALUE, &rect_clamp);
temp->copyContentFrom(this);
float result = temp->getMaximumValue();
delete temp;
@@ -189,7 +193,7 @@ float MemoryBuffer::getMaximumValue(rcti *rect)
MemoryBuffer::~MemoryBuffer()
{
if (this->m_buffer) {
- MEM_freeN(this->m_buffer);
+ MEM_freeN(this->m_buffer);
this->m_buffer = NULL;
}
}
@@ -197,4 +201,3 @@ MemoryBuffer::~MemoryBuffer()
const int MemoryBuffer::get_no_channels() const {
return this->m_no_channels;
}
-
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.h b/source/blender/compositor/intern/COM_MemoryBuffer.h
index 83889c96f55..cdf2fe76162 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.h
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.h
@@ -27,6 +27,7 @@ class MemoryBuffer;
#include "COM_ExecutionGroup.h"
#include "COM_MemoryProxy.h"
+#include "COM_SocketReader.h"
extern "C" {
# include "BLI_math.h"
diff --git a/source/blender/compositor/intern/COM_MemoryProxy.h b/source/blender/compositor/intern/COM_MemoryProxy.h
index 55bc5837b3a..f2d47a1bf59 100644
--- a/source/blender/compositor/intern/COM_MemoryProxy.h
+++ b/source/blender/compositor/intern/COM_MemoryProxy.h
@@ -28,6 +28,7 @@ class MemoryProxy;
#include "COM_ExecutionGroup.h"
class ExecutionGroup;
+class WriteBufferOperation;
/**
* @brief A MemoryProxy is a unique identifier for a memory buffer.
diff --git a/source/blender/compositor/intern/COM_Node.cpp b/source/blender/compositor/intern/COM_Node.cpp
index b62e2d08d9a..67f4d2523f3 100644
--- a/source/blender/compositor/intern/COM_Node.cpp
+++ b/source/blender/compositor/intern/COM_Node.cpp
@@ -22,27 +22,32 @@
#include <string.h>
+extern "C" {
#include "BKE_node.h"
-#include "COM_Node.h"
-#include "COM_NodeOperation.h"
-#include "COM_SetValueOperation.h"
-#include "COM_SetVectorOperation.h"
-#include "COM_SetColorOperation.h"
-#include "COM_SocketConnection.h"
+#include "RNA_access.h"
+}
+
#include "COM_ExecutionSystem.h"
-#include "COM_PreviewOperation.h"
+#include "COM_NodeOperation.h"
#include "COM_TranslateOperation.h"
#include "COM_SocketProxyNode.h"
-//#include <stdio.h>
#include "COM_defines.h"
-Node::Node(bNode *editorNode, bool create_sockets) : NodeBase()
+#include "COM_Node.h" /* own include */
+
+/**************
+ **** Node ****
+ **************/
+
+Node::Node(bNode *editorNode, bool create_sockets) :
+ m_editorNodeTree(NULL),
+ m_editorNode(editorNode),
+ m_inActiveGroup(false),
+ m_instanceKey(NODE_INSTANCE_KEY_NONE)
{
- setbNode(editorNode);
-
if (create_sockets) {
bNodeSocket *input = (bNodeSocket *)editorNode->inputs.first;
while (input != NULL) {
@@ -50,7 +55,7 @@ Node::Node(bNode *editorNode, bool create_sockets) : NodeBase()
if (input->type == SOCK_RGBA) dt = COM_DT_COLOR;
if (input->type == SOCK_VECTOR) dt = COM_DT_VECTOR;
- this->addInputSocket(dt, (InputSocketResizeMode)input->resizemode, input);
+ this->addInputSocket(dt, input);
input = input->next;
}
bNodeSocket *output = (bNodeSocket *)editorNode->outputs.first;
@@ -65,102 +70,50 @@ Node::Node(bNode *editorNode, bool create_sockets) : NodeBase()
}
}
-void Node::addSetValueOperation(ExecutionSystem *graph, InputSocket *inputsocket, int editorNodeInputSocketIndex)
+Node::~Node()
{
- InputSocket *input = getInputSocket(editorNodeInputSocketIndex);
- SetValueOperation *operation = new SetValueOperation();
- operation->setValue(input->getEditorValueFloat());
- this->addLink(graph, operation->getOutputSocket(), inputsocket);
- graph->addOperation(operation);
+ while (!this->m_outputsockets.empty()) {
+ delete (this->m_outputsockets.back());
+ this->m_outputsockets.pop_back();
+ }
+ while (!this->m_inputsockets.empty()) {
+ delete (this->m_inputsockets.back());
+ this->m_inputsockets.pop_back();
+ }
}
-void Node::addPreviewOperation(ExecutionSystem *system, CompositorContext *context, OutputSocket *outputSocket)
+void Node::addInputSocket(DataType datatype)
{
- if (this->isInActiveGroup()) {
- if (!(this->getbNode()->flag & NODE_HIDDEN)) { // do not calculate previews of hidden nodes.
- bNodeInstanceHash *previews = context->getPreviewHash();
- if (previews && (this->getbNode()->flag & NODE_PREVIEW)) {
- PreviewOperation *operation = new PreviewOperation(context->getViewSettings(), context->getDisplaySettings());
- system->addOperation(operation);
- operation->setbNode(this->getbNode());
- operation->setbNodeTree(system->getContext().getbNodeTree());
- operation->verifyPreview(previews, this->getInstanceKey());
- this->addLink(system, outputSocket, operation->getInputSocket(0));
- }
- }
- }
+ this->addInputSocket(datatype, NULL);
}
-void Node::addPreviewOperation(ExecutionSystem *system, CompositorContext *context, InputSocket *inputSocket)
+void Node::addInputSocket(DataType datatype, bNodeSocket *bSocket)
{
- if (inputSocket->isConnected() && this->isInActiveGroup()) {
- OutputSocket *outputsocket = inputSocket->getConnection()->getFromSocket();
- this->addPreviewOperation(system, context, outputsocket);
- }
+ NodeInput *socket = new NodeInput(this, bSocket, datatype);
+ this->m_inputsockets.push_back(socket);
}
-SocketConnection *Node::addLink(ExecutionSystem *graph, OutputSocket *outputSocket, InputSocket *inputsocket)
+void Node::addOutputSocket(DataType datatype)
{
- if (inputsocket->isConnected()) {
- return NULL;
- }
- SocketConnection *connection = new SocketConnection();
- connection->setFromSocket(outputSocket);
- outputSocket->addConnection(connection);
- connection->setToSocket(inputsocket);
- inputsocket->setConnection(connection);
- graph->addSocketConnection(connection);
- return connection;
-}
-
-void Node::addSetColorOperation(ExecutionSystem *graph, InputSocket *inputsocket, int editorNodeInputSocketIndex)
-{
- InputSocket *input = getInputSocket(editorNodeInputSocketIndex);
- SetColorOperation *operation = new SetColorOperation();
- float col[4];
- input->getEditorValueColor(col);
- operation->setChannel1(col[0]);
- operation->setChannel2(col[1]);
- operation->setChannel3(col[2]);
- operation->setChannel4(col[3]);
- this->addLink(graph, operation->getOutputSocket(), inputsocket);
- graph->addOperation(operation);
-}
-
-void Node::addSetVectorOperation(ExecutionSystem *graph, InputSocket *inputsocket, int editorNodeInputSocketIndex)
-{
- InputSocket *input = getInputSocket(editorNodeInputSocketIndex);
- SetVectorOperation *operation = new SetVectorOperation();
- float vec[3];
- input->getEditorValueVector(vec);
- operation->setX(vec[0]);
- operation->setY(vec[1]);
- operation->setZ(vec[2]);
- this->addLink(graph, operation->getOutputSocket(), inputsocket);
- graph->addOperation(operation);
-}
-
-NodeOperation *Node::convertToOperations_invalid_index(ExecutionSystem *graph, int index)
-{
- const float warning_color[4] = {1.0f, 0.0f, 1.0f, 1.0f};
- SetColorOperation *operation = new SetColorOperation();
- operation->setChannels(warning_color);
-
- /* link the operation */
- this->getOutputSocket(index)->relinkConnections(operation->getOutputSocket());
- graph->addOperation(operation);
- return operation;
-}
-
-/* when a node has no valid data (missing image / group pointer, or missing renderlayer from EXR) */
-void Node::convertToOperations_invalid(ExecutionSystem *graph, CompositorContext *context)
-{
- /* this is a really bad situation - bring on the pink! - so artists know this is bad */
- int index;
- vector<OutputSocket *> &outputsockets = this->getOutputSockets();
- for (index = 0; index < outputsockets.size(); index++) {
- convertToOperations_invalid_index(graph, index);
- }
+ this->addOutputSocket(datatype, NULL);
+
+}
+void Node::addOutputSocket(DataType datatype, bNodeSocket *bSocket)
+{
+ NodeOutput *socket = new NodeOutput(this, bSocket, datatype);
+ this->m_outputsockets.push_back(socket);
+}
+
+NodeOutput *Node::getOutputSocket(unsigned int index) const
+{
+ BLI_assert(index < this->m_outputsockets.size());
+ return this->m_outputsockets[index];
+}
+
+NodeInput *Node::getInputSocket(unsigned int index) const
+{
+ BLI_assert(index < this->m_inputsockets.size());
+ return this->m_inputsockets[index];
}
bNodeSocket *Node::getEditorInputSocket(int editorNodeInputSocketIndex)
@@ -190,28 +143,74 @@ bNodeSocket *Node::getEditorOutputSocket(int editorNodeInputSocketIndex)
return NULL;
}
-InputSocket *Node::findInputSocketBybNodeSocket(bNodeSocket *socket)
+
+/*******************
+ **** NodeInput ****
+ *******************/
+
+NodeInput::NodeInput(Node *node, bNodeSocket *b_socket, DataType datatype) :
+ m_node(node),
+ m_editorSocket(b_socket),
+ m_datatype(datatype),
+ m_link(NULL)
{
- vector<InputSocket *> &inputsockets = this->getInputSockets();
- unsigned int index;
- for (index = 0; index < inputsockets.size(); index++) {
- InputSocket *input = inputsockets[index];
- if (input->getbNodeSocket() == socket) {
- return input;
- }
- }
- return NULL;
}
-OutputSocket *Node::findOutputSocketBybNodeSocket(bNodeSocket *socket)
+void NodeInput::setLink(NodeOutput *link)
{
- vector<OutputSocket *> &outputsockets = this->getOutputSockets();
- unsigned int index;
- for (index = 0; index < outputsockets.size(); index++) {
- OutputSocket *output = outputsockets[index];
- if (output->getbNodeSocket() == socket) {
- return output;
- }
- }
- return NULL;
+ m_link = link;
+}
+
+float NodeInput::getEditorValueFloat()
+{
+ PointerRNA ptr;
+ RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr);
+ return RNA_float_get(&ptr, "default_value");
+}
+
+void NodeInput::getEditorValueColor(float *value)
+{
+ PointerRNA ptr;
+ RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr);
+ return RNA_float_get_array(&ptr, "default_value", value);
+}
+
+void NodeInput::getEditorValueVector(float *value)
+{
+ PointerRNA ptr;
+ RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr);
+ return RNA_float_get_array(&ptr, "default_value", value);
+}
+
+
+/********************
+ **** NodeOutput ****
+ ********************/
+
+NodeOutput::NodeOutput(Node *node, bNodeSocket *b_socket, DataType datatype) :
+ m_node(node),
+ m_editorSocket(b_socket),
+ m_datatype(datatype)
+{
+}
+
+float NodeOutput::getEditorValueFloat()
+{
+ PointerRNA ptr;
+ RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr);
+ return RNA_float_get(&ptr, "default_value");
+}
+
+void NodeOutput::getEditorValueColor(float *value)
+{
+ PointerRNA ptr;
+ RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr);
+ return RNA_float_get_array(&ptr, "default_value", value);
+}
+
+void NodeOutput::getEditorValueVector(float *value)
+{
+ PointerRNA ptr;
+ RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr);
+ return RNA_float_get_array(&ptr, "default_value", value);
}
diff --git a/source/blender/compositor/intern/COM_Node.h b/source/blender/compositor/intern/COM_Node.h
index c14a1973da5..6046af24c55 100644
--- a/source/blender/compositor/intern/COM_Node.h
+++ b/source/blender/compositor/intern/COM_Node.h
@@ -23,32 +23,50 @@
#ifndef __COM_NODE_H__
#define __COM_NODE_H__
-#include "COM_NodeBase.h"
-#include "COM_InputSocket.h"
-#include "COM_OutputSocket.h"
-#include "COM_CompositorContext.h"
#include "DNA_node_types.h"
#include "BKE_text.h"
-#include "COM_ExecutionSystem.h"
#include <vector>
#include <string>
#include <algorithm>
-using namespace std;
+/* common node includes
+ * added here so node files don't have to include themselves
+ */
+#include "COM_CompositorContext.h"
+#include "COM_NodeConverter.h"
class Node;
class NodeOperation;
-class ExecutionSystem;
-
-typedef vector<Node *> NodeList;
-typedef NodeList::iterator NodeIterator;
-typedef pair<NodeIterator, NodeIterator> NodeRange;
+class NodeConverter;
/**
* My node documentation.
*/
-class Node : public NodeBase {
+class Node {
+public:
+ typedef std::vector<NodeInput *> Inputs;
+ typedef std::vector<NodeOutput *> Outputs;
+
private:
+ /**
+ * @brief stores the reference to the SDNA bNode struct
+ */
+ bNodeTree *m_editorNodeTree;
+
+ /**
+ * @brief stores the reference to the SDNA bNode struct
+ */
+ bNode *m_editorNode;
+
+ /**
+ * @brief the list of actual inputsockets @see NodeInput
+ */
+ Inputs m_inputsockets;
+
+ /**
+ * @brief the list of actual outputsockets @see NodeOutput
+ */
+ Outputs m_outputsockets;
/**
* @brief Is this node part of the active group
@@ -60,10 +78,81 @@ private:
*/
bNodeInstanceKey m_instanceKey;
+protected:
+ /**
+ * @brief get access to the vector of input sockets
+ */
+ const Inputs &getInputSockets() const { return this->m_inputsockets; }
+
+ /**
+ * @brief get access to the vector of input sockets
+ */
+ const Outputs &getOutputSockets() const { return this->m_outputsockets; }
+
public:
Node(bNode *editorNode, bool create_sockets = true);
+ virtual ~Node();
+
+ /**
+ * @brief get the reference to the SDNA bNode struct
+ */
+ bNode *getbNode() const {return m_editorNode;}
/**
+ * @brief get the reference to the SDNA bNodeTree struct
+ */
+ bNodeTree *getbNodeTree() const {return m_editorNodeTree;}
+
+ /**
+ * @brief set the reference to the bNode
+ * @note used in Node instances to receive the storage/settings and complex node for highlight during execution
+ * @param bNode
+ */
+ void setbNode(bNode *node) {this->m_editorNode = node;}
+
+ /**
+ * @brief set the reference to the bNodeTree
+ * @param bNodeTree
+ */
+ void setbNodeTree(bNodeTree *nodetree) {this->m_editorNodeTree = nodetree;}
+
+ /**
+ * @brief Return the number of input sockets of this node.
+ */
+ const unsigned int getNumberOfInputSockets() const { return this->m_inputsockets.size(); }
+
+ /**
+ * @brief Return the number of output sockets of this node.
+ */
+ const unsigned int getNumberOfOutputSockets() const { return this->m_outputsockets.size(); }
+
+ /**
+ * get the reference to a certain outputsocket
+ * @param index
+ * the index of the needed outputsocket
+ */
+ NodeOutput *getOutputSocket(const unsigned int index) const;
+
+ /**
+ * get the reference to the first outputsocket
+ * @param index
+ * the index of the needed outputsocket
+ */
+ inline NodeOutput *getOutputSocket() const { return getOutputSocket(0); }
+
+ /**
+ * get the reference to a certain inputsocket
+ * @param index
+ * the index of the needed inputsocket
+ */
+ NodeInput *getInputSocket(const unsigned int index) const;
+
+ /** Check if this is an input node
+ * An input node is a node that only has output sockets and no input sockets
+ */
+ bool isInputNode() const { return m_inputsockets.empty(); }
+
+ /**
* @brief Is this node in the active group (the group that is being edited)
* @param isInActiveGroup
*/
@@ -75,7 +164,7 @@ public:
* the active group will be the main tree (all nodes that are not part of a group will be active)
* @return bool [false:true]
*/
- inline bool isInActiveGroup() { return this->m_inActiveGroup; }
+ inline bool isInActiveGroup() const { return this->m_inActiveGroup; }
/**
* @brief convert node to operation
@@ -85,76 +174,99 @@ public:
* @param system the ExecutionSystem where the operations need to be added
* @param context reference to the CompositorContext
*/
- virtual void convertToOperations(ExecutionSystem *system, CompositorContext *context) = 0;
-
- /**
- * this method adds a SetValueOperation as input of the input socket.
- * This can only be used from the convertToOperation method. all other usages are not allowed
- */
- void addSetValueOperation(ExecutionSystem *graph, InputSocket *inputsocket, int editorNodeInputSocketIndex);
-
- /**
- * this method adds a SetColorOperation as input of the input socket.
- * This can only be used from the convertToOperation method. all other usages are not allowed
- */
- void addSetColorOperation(ExecutionSystem *graph, InputSocket *inputsocket, int editorNodeInputSocketIndex);
-
- /**
- * this method adds a SetVectorOperation as input of the input socket.
- * This can only be used from the convertToOperation method. all other usages are not allowed
- */
- void addSetVectorOperation(ExecutionSystem *graph, InputSocket *inputsocket, int editorNodeInputSocketIndex);
+ virtual void convertToOperations(NodeConverter &converter, const CompositorContext &context) const = 0;
/**
* Create dummy warning operation, use when we can't get the source data.
*/
- NodeOperation *convertToOperations_invalid_index(ExecutionSystem *graph, int index);
+ NodeOperation *convertToOperations_invalid_index(NodeConverter *compiler, int index) const;
/**
* when a node has no valid data (missing image or a group nodes ID pointer is NULL)
* call this function from #convertToOperations, this way the node sockets are converted
* into valid outputs, without this the compositor system gets confused and crashes, see [#32490]
*/
- void convertToOperations_invalid(ExecutionSystem *graph, CompositorContext *context);
-
- /**
- * Creates a new link between an outputSocket and inputSocket and registrates the link to the graph
- * @return the new created link
- */
- SocketConnection *addLink(ExecutionSystem *graph, OutputSocket *outputSocket, InputSocket *inputsocket);
+ void convertToOperations_invalid(NodeConverter *compiler) const;
+ void setInstanceKey(bNodeInstanceKey instance_key) { m_instanceKey = instance_key; }
+ bNodeInstanceKey getInstanceKey() const { return m_instanceKey; }
+
+protected:
/**
- * is this node a group node.
- */
- virtual bool isGroupNode() const { return false; }
- /**
- * is this node a proxy node.
+ * @brief add an NodeInput to the collection of inputsockets
+ * @note may only be called in an constructor
+ * @param socket the NodeInput to add
*/
- virtual bool isProxyNode() const { return false; }
+ void addInputSocket(DataType datatype);
+ void addInputSocket(DataType datatype, bNodeSocket *socket);
/**
- * @brief find the InputSocket by bNodeSocket
- *
- * @param socket
+ * @brief add an NodeOutput to the collection of outputsockets
+ * @note may only be called in an constructor
+ * @param socket the NodeOutput to add
*/
- InputSocket *findInputSocketBybNodeSocket(bNodeSocket *socket);
+ void addOutputSocket(DataType datatype);
+ void addOutputSocket(DataType datatype, bNodeSocket *socket);
+
+ bNodeSocket *getEditorInputSocket(int editorNodeInputSocketIndex);
+ bNodeSocket *getEditorOutputSocket(int editorNodeOutputSocketIndex);
+};
+
+
+/**
+ * @brief NodeInput are sockets that can receive data/input
+ * @ingroup Model
+ */
+class NodeInput {
+private:
+ Node *m_node;
+ bNodeSocket *m_editorSocket;
+
+ DataType m_datatype;
/**
- * @brief find the OutputSocket by bNodeSocket
- *
- * @param socket
+ * @brief link connected to this NodeInput.
+ * An input socket can only have a single link
*/
- OutputSocket *findOutputSocketBybNodeSocket(bNodeSocket *socket);
+ NodeOutput *m_link;
- void setInstanceKey(bNodeInstanceKey instance_key) { m_instanceKey = instance_key; }
- bNodeInstanceKey getInstanceKey() const { return m_instanceKey; }
+public:
+ NodeInput(Node *node, bNodeSocket *b_socket, DataType datatype);
-protected:
- void addPreviewOperation(ExecutionSystem *system, CompositorContext *context, InputSocket *inputSocket);
- void addPreviewOperation(ExecutionSystem *system, CompositorContext *context, OutputSocket *outputSocket);
+ Node *getNode() const { return this->m_node; }
+ DataType getDataType() const { return m_datatype; }
+ bNodeSocket *getbNodeSocket() const { return this->m_editorSocket; }
- bNodeSocket *getEditorInputSocket(int editorNodeInputSocketIndex);
- bNodeSocket *getEditorOutputSocket(int editorNodeOutputSocketIndex);
+ void setLink(NodeOutput *link);
+ bool isLinked() const { return m_link; }
+ NodeOutput *getLink() { return m_link; }
+
+ float getEditorValueFloat();
+ void getEditorValueColor(float *value);
+ void getEditorValueVector(float *value);
+};
+
+
+/**
+ * @brief NodeOutput are sockets that can send data/input
+ * @ingroup Model
+ */
+class NodeOutput {
private:
+ Node *m_node;
+ bNodeSocket *m_editorSocket;
+
+ DataType m_datatype;
+
+public:
+ NodeOutput(Node *node, bNodeSocket *b_socket, DataType datatype);
+
+ Node *getNode() const { return this->m_node; }
+ DataType getDataType() const { return m_datatype; }
+ bNodeSocket *getbNodeSocket() const { return this->m_editorSocket; }
+
+ float getEditorValueFloat();
+ void getEditorValueColor(float *value);
+ void getEditorValueVector(float *value);
};
#endif /* __COM_NODE_H__ */
diff --git a/source/blender/compositor/intern/COM_NodeBase.cpp b/source/blender/compositor/intern/COM_NodeBase.cpp
deleted file mode 100644
index 5c2ce37bdea..00000000000
--- a/source/blender/compositor/intern/COM_NodeBase.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the 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:
- * Jeroen Bakker
- * Monique Dewanchand
- */
-
-#include <string.h>
-
-#include "BKE_node.h"
-
-#include "COM_NodeBase.h"
-#include "COM_NodeOperation.h"
-#include "COM_SetValueOperation.h"
-#include "COM_SetColorOperation.h"
-#include "COM_SocketConnection.h"
-#include "COM_ExecutionSystem.h"
-
-NodeBase::NodeBase()
-{
- this->m_editorNode = NULL;
-}
-
-
-NodeBase::~NodeBase()
-{
- while (!this->m_outputsockets.empty()) {
- delete (this->m_outputsockets.back());
- this->m_outputsockets.pop_back();
- }
- while (!this->m_inputsockets.empty()) {
- delete (this->m_inputsockets.back());
- this->m_inputsockets.pop_back();
- }
-}
-
-void NodeBase::addInputSocket(DataType datatype)
-{
- this->addInputSocket(datatype, COM_SC_CENTER, NULL);
-}
-
-void NodeBase::addInputSocket(DataType datatype, InputSocketResizeMode resizeMode)
-{
- this->addInputSocket(datatype, resizeMode, NULL);
-}
-void NodeBase::addInputSocket(DataType datatype, InputSocketResizeMode resizeMode, bNodeSocket *bSocket)
-{
- InputSocket *socket = new InputSocket(datatype, resizeMode);
- socket->setEditorSocket(bSocket);
- socket->setNode(this);
- this->m_inputsockets.push_back(socket);
-}
-
-void NodeBase::addOutputSocket(DataType datatype)
-{
- this->addOutputSocket(datatype, NULL);
-
-}
-void NodeBase::addOutputSocket(DataType datatype, bNodeSocket *bSocket)
-{
- OutputSocket *socket = new OutputSocket(datatype);
- socket->setEditorSocket(bSocket);
- socket->setNode(this);
- this->m_outputsockets.push_back(socket);
-}
-const bool NodeBase::isInputNode() const
-{
- return this->m_inputsockets.size() == 0;
-}
-
-OutputSocket *NodeBase::getOutputSocket(unsigned int index)
-{
- BLI_assert(index < this->m_outputsockets.size());
- return this->m_outputsockets[index];
-}
-
-InputSocket *NodeBase::getInputSocket(unsigned int index)
-{
- BLI_assert(index < this->m_inputsockets.size());
- return this->m_inputsockets[index];
-}
diff --git a/source/blender/compositor/intern/COM_NodeBase.h b/source/blender/compositor/intern/COM_NodeBase.h
deleted file mode 100644
index e2072575509..00000000000
--- a/source/blender/compositor/intern/COM_NodeBase.h
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the 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:
- * Jeroen Bakker
- * Monique Dewanchand
- */
-
-#ifndef __COM_NODEBASE_H__
-#define __COM_NODEBASE_H__
-
-#include "COM_InputSocket.h"
-#include "COM_OutputSocket.h"
-#include "DNA_node_types.h"
-#include "BKE_text.h"
-#include <vector>
-#include <string>
-
-using namespace std;
-
-
-class NodeOperation;
-class ExecutionSystem;
-
-/**
- * @brief The NodeBase class is the super-class of all node related objects like @see Node @see NodeOperation
- * the reason for the existence of this class is to support graph-nodes when using ExecutionSystem
- * the NodeBase also contains the reference to InputSocket and OutputSocket.
- * @ingroup Model
- */
-class NodeBase {
-private:
- /**
- * @brief the list of actual inputsockets @see InputSocket
- */
- vector<InputSocket *> m_inputsockets;
-
- /**
- * @brief the list of actual outputsockets @see OutputSocket
- */
- vector<OutputSocket *> m_outputsockets;
-
- /**
- * @brief stores the reference to the SDNA bNode struct
- */
- bNode *m_editorNode;
-
- /**
- * @brief stores the reference to the SDNA bNode struct
- */
- bNodeTree *m_editorNodeTree;
-
-protected:
- /**
- * @brief get access to the vector of input sockets
- */
- inline vector<InputSocket *>& getInputSockets() { return this->m_inputsockets; }
-
- /**
- * @brief get access to the vector of input sockets
- */
- inline vector<OutputSocket *>& getOutputSockets() { return this->m_outputsockets; }
-
-
-protected:
- /**
- * @brief destructor
- * clean up memory related to this NodeBase.
- */
- virtual ~NodeBase();
-
-public:
- /**
- * @brief get the reference to the SDNA bNode struct
- */
- bNode *getbNode() const {return m_editorNode;}
-
- /**
- * @brief get the reference to the SDNA bNodeTree struct
- */
- bNodeTree *getbNodeTree() const {return m_editorNodeTree;}
-
- /**
- * @brief set the reference to the bNode
- * @note used in Node instances to receive the storage/settings and complex node for highlight during execution
- * @param bNode
- */
- void setbNode(bNode *node) {this->m_editorNode = node;}
-
- /**
- * @brief set the reference to the bNodeTree
- * @param bNodeTree
- */
- void setbNodeTree(bNodeTree *nodetree) {this->m_editorNodeTree = nodetree;}
-
- /**
- * @brief is this node an operation?
- * This is true when the instance is of the subclass NodeOperation.
- * @return [true:false]
- * @see NodeOperation
- */
- virtual const bool isOperation() const { return false; }
-
- /**
- * @brief check if this is an input node
- * An input node is a node that only has output sockets and no input sockets
- * @return [false..true]
- */
- const bool isInputNode() const;
-
- /**
- * @brief Return the number of input sockets of this node.
- */
- const unsigned int getNumberOfInputSockets() const { return this->m_inputsockets.size(); }
-
- /**
- * @brief Return the number of output sockets of this node.
- */
- const unsigned int getNumberOfOutputSockets() const { return this->m_outputsockets.size(); }
-
- /**
- * get the reference to a certain outputsocket
- * @param index
- * the index of the needed outputsocket
- */
- OutputSocket *getOutputSocket(const unsigned int index);
-
- /**
- * get the reference to the first outputsocket
- * @param index
- * the index of the needed outputsocket
- */
- inline OutputSocket *getOutputSocket() { return getOutputSocket(0); }
-
- /**
- * get the reference to a certain inputsocket
- * @param index
- * the index of the needed inputsocket
- */
- InputSocket *getInputSocket(const unsigned int index);
-
- virtual bool isStatic() const { return false; }
- void getStaticValues(float *result) const { }
-
-protected:
- NodeBase();
-
- /**
- * @brief add an InputSocket to the collection of inputsockets
- * @note may only be called in an constructor
- * @param socket the InputSocket to add
- */
- void addInputSocket(DataType datatype);
- void addInputSocket(DataType datatype, InputSocketResizeMode resizeMode);
- void addInputSocket(DataType datatype, InputSocketResizeMode resizeMode, bNodeSocket *socket);
-
- /**
- * @brief add an OutputSocket to the collection of outputsockets
- * @note may only be called in an constructor
- * @param socket the OutputSocket to add
- */
- void addOutputSocket(DataType datatype);
- void addOutputSocket(DataType datatype, bNodeSocket *socket);
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeBase")
-#endif
-};
-
-#endif /* __COM_NODEBASE_H__ */
diff --git a/source/blender/compositor/intern/COM_NodeConverter.cpp b/source/blender/compositor/intern/COM_NodeConverter.cpp
new file mode 100644
index 00000000000..5965eade389
--- /dev/null
+++ b/source/blender/compositor/intern/COM_NodeConverter.cpp
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2013, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the 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:
+ * Lukas Toenne
+ */
+
+extern "C" {
+#include "BLI_utildefines.h"
+}
+
+#include "COM_Debug.h"
+
+#include "COM_NodeOperationBuilder.h"
+#include "COM_NodeOperation.h"
+#include "COM_SetValueOperation.h"
+#include "COM_SetVectorOperation.h"
+#include "COM_SetColorOperation.h"
+#include "COM_SocketProxyOperation.h"
+
+#include "COM_NodeConverter.h" /* own include */
+
+NodeConverter::NodeConverter(NodeOperationBuilder *builder) :
+ m_builder(builder)
+{
+}
+
+void NodeConverter::addOperation(NodeOperation *operation)
+{
+ m_builder->addOperation(operation);
+}
+
+void NodeConverter::mapInputSocket(NodeInput *node_socket, NodeOperationInput *operation_socket)
+{
+ m_builder->mapInputSocket(node_socket, operation_socket);
+}
+
+void NodeConverter::mapOutputSocket(NodeOutput *node_socket, NodeOperationOutput *operation_socket)
+{
+ m_builder->mapOutputSocket(node_socket, operation_socket);
+}
+
+void NodeConverter::addLink(NodeOperationOutput *from, NodeOperationInput *to)
+{
+ m_builder->addLink(from, to);
+}
+
+void NodeConverter::addPreview(NodeOperationOutput *output)
+{
+ m_builder->addPreview(output);
+}
+
+void NodeConverter::addNodeInputPreview(NodeInput *input)
+{
+ m_builder->addNodeInputPreview(input);
+}
+
+NodeOperation *NodeConverter::setInvalidOutput(NodeOutput *output)
+{
+ /* this is a really bad situation - bring on the pink! - so artists know this is bad */
+ const float warning_color[4] = {1.0f, 0.0f, 1.0f, 1.0f};
+
+ SetColorOperation *operation = new SetColorOperation();
+ operation->setChannels(warning_color);
+
+ m_builder->addOperation(operation);
+ m_builder->mapOutputSocket(output, operation->getOutputSocket());
+
+ return operation;
+}
+
+NodeOperationOutput *NodeConverter::addInputProxy(NodeInput *input)
+{
+ SocketProxyOperation *proxy = new SocketProxyOperation(input->getDataType());
+ m_builder->addOperation(proxy);
+
+ m_builder->mapInputSocket(input, proxy->getInputSocket(0));
+
+ return proxy->getOutputSocket();
+}
+
+NodeOperationInput *NodeConverter::addOutputProxy(NodeOutput *output)
+{
+ SocketProxyOperation *proxy = new SocketProxyOperation(output->getDataType());
+ m_builder->addOperation(proxy);
+
+ m_builder->mapOutputSocket(output, proxy->getOutputSocket());
+
+ return proxy->getInputSocket(0);
+}
+
+void NodeConverter::addInputValue(NodeOperationInput *input, float value)
+{
+ SetValueOperation *operation = new SetValueOperation();
+ operation->setValue(value);
+
+ m_builder->addOperation(operation);
+ m_builder->addLink(operation->getOutputSocket(), input);
+}
+
+void NodeConverter::addInputColor(NodeOperationInput *input, const float value[4])
+{
+ SetColorOperation *operation = new SetColorOperation();
+ operation->setChannels(value);
+
+ m_builder->addOperation(operation);
+ m_builder->addLink(operation->getOutputSocket(), input);
+}
+
+void NodeConverter::addInputVector(NodeOperationInput *input, const float value[3])
+{
+ SetVectorOperation *operation = new SetVectorOperation();
+ operation->setVector(value);
+
+ m_builder->addOperation(operation);
+ m_builder->addLink(operation->getOutputSocket(), input);
+}
+
+void NodeConverter::addOutputValue(NodeOutput *output, float value)
+{
+ SetValueOperation *operation = new SetValueOperation();
+ operation->setValue(value);
+
+ m_builder->addOperation(operation);
+ m_builder->mapOutputSocket(output, operation->getOutputSocket());
+}
+
+void NodeConverter::addOutputColor(NodeOutput *output, const float value[4])
+{
+ SetColorOperation *operation = new SetColorOperation();
+ operation->setChannels(value);
+
+ m_builder->addOperation(operation);
+ m_builder->mapOutputSocket(output, operation->getOutputSocket());
+}
+
+void NodeConverter::addOutputVector(NodeOutput *output, const float value[3])
+{
+ SetVectorOperation *operation = new SetVectorOperation();
+ operation->setVector(value);
+
+ m_builder->addOperation(operation);
+ m_builder->mapOutputSocket(output, operation->getOutputSocket());
+}
diff --git a/source/blender/compositor/intern/COM_NodeConverter.h b/source/blender/compositor/intern/COM_NodeConverter.h
new file mode 100644
index 00000000000..cad8408a2bf
--- /dev/null
+++ b/source/blender/compositor/intern/COM_NodeConverter.h
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2013, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the 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:
+ * Lukas Toenne
+ */
+
+#ifndef _COM_NodeCompiler_h
+#define _COM_NodeCompiler_h
+
+#ifdef WITH_CXX_GUARDEDALLOC
+# include "MEM_guardedalloc.h"
+#endif
+
+class NodeInput;
+class NodeOutput;
+
+class NodeOperation;
+class NodeOperationInput;
+class NodeOperationOutput;
+class NodeOperationBuilder;
+
+/** Interface type for converting a \a Node into \a NodeOperation.
+ * This is passed to \a Node::convertToOperation methods and allows them
+ * to register any number of operations, create links between them,
+ * and map original node sockets to their inputs or outputs.
+ */
+class NodeConverter {
+public:
+ NodeConverter(NodeOperationBuilder *builder);
+
+ /** Insert a new operation into the operations graph.
+ * The operation must be created by the node.
+ */
+ void addOperation(NodeOperation *operation);
+
+ /** Map input socket of the node to an operation socket.
+ * Links between nodes will then generate equivalent links between
+ * the mapped operation sockets.
+ *
+ * \note A \a Node input can be mapped to multiple \a NodeOperation inputs.
+ */
+ void mapInputSocket(NodeInput *node_socket, NodeOperationInput *operation_socket);
+ /** Map output socket of the node to an operation socket.
+ * Links between nodes will then generate equivalent links between
+ * the mapped operation sockets.
+ *
+ * \note A \a Node output can only be mapped to one \a NodeOperation output.
+ * Any existing operation output mapping will be replaced.
+ */
+ void mapOutputSocket(NodeOutput *node_socket, NodeOperationOutput *operation_socket);
+
+ /** Create a proxy operation for a node input.
+ * This operation will be removed later and replaced
+ * by direct links between the connected operations.
+ */
+ NodeOperationOutput *addInputProxy(NodeInput *input);
+ /** Create a proxy operation for a node output.
+ * This operation will be removed later and replaced
+ * by direct links between the connected operations.
+ */
+ NodeOperationInput *addOutputProxy(NodeOutput *output);
+
+ /** Define a constant input value. */
+ void addInputValue(NodeOperationInput *input, float value);
+ /** Define a constant input color. */
+ void addInputColor(NodeOperationInput *input, const float value[4]);
+ /** Define a constant input vector. */
+ void addInputVector(NodeOperationInput *input, const float value[3]);
+
+ /** Define a constant output value. */
+ void addOutputValue(NodeOutput *output, float value);
+ /** Define a constant output color. */
+ void addOutputColor(NodeOutput *output, const float value[4]);
+ /** Define a constant output vector. */
+ void addOutputVector(NodeOutput *output, const float value[3]);
+
+ /** Add an explicit link between two operations. */
+ void addLink(NodeOperationOutput *from, NodeOperationInput *to);
+
+ /** Add a preview operation for a operation output. */
+ void addPreview(NodeOperationOutput *output);
+ /** Add a preview operation for a node input. */
+ void addNodeInputPreview(NodeInput *input);
+
+ /** When a node has no valid data
+ * @note missing image / group pointer, or missing renderlayer from EXR
+ */
+ NodeOperation *setInvalidOutput(NodeOutput *output);
+
+private:
+ /** The internal builder for storing the results of the graph construction. */
+ NodeOperationBuilder *m_builder;
+
+#ifdef WITH_CXX_GUARDEDALLOC
+ MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeCompiler")
+#endif
+};
+
+#endif /* _COM_NodeCompiler_h */
diff --git a/source/blender/compositor/intern/COM_NodeGraph.cpp b/source/blender/compositor/intern/COM_NodeGraph.cpp
new file mode 100644
index 00000000000..5c3de84f13c
--- /dev/null
+++ b/source/blender/compositor/intern/COM_NodeGraph.cpp
@@ -0,0 +1,290 @@
+/*
+ * Copyright 2013, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the 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:
+ * Lukas Toenne
+ */
+
+#include <cstring>
+
+extern "C" {
+#include "BLI_listbase.h"
+#include "BLI_utildefines.h"
+
+#include "DNA_node_types.h"
+
+#include "BKE_node.h"
+}
+
+#include "COM_CompositorContext.h"
+#include "COM_Converter.h"
+#include "COM_Debug.h"
+#include "COM_Node.h"
+#include "COM_SocketProxyNode.h"
+
+#include "COM_NodeGraph.h" /* own include */
+
+/*******************
+ **** NodeGraph ****
+ *******************/
+
+NodeGraph::NodeGraph()
+{
+}
+
+NodeGraph::~NodeGraph()
+{
+ for (int index = 0; index < this->m_nodes.size(); index++) {
+ Node *node = this->m_nodes[index];
+ delete node;
+ }
+}
+
+void NodeGraph::from_bNodeTree(const CompositorContext &context, bNodeTree *tree)
+{
+ add_bNodeTree(context, 0, tree, NODE_INSTANCE_KEY_BASE);
+}
+
+bNodeSocket *NodeGraph::find_b_node_input(bNode *b_group_node, const char *identifier)
+{
+ for (bNodeSocket *b_sock = (bNodeSocket *)b_group_node->inputs.first; b_sock; b_sock = b_sock->next) {
+ if (STREQ(b_sock->identifier, identifier))
+ return b_sock;
+ }
+ return NULL;
+}
+
+bNodeSocket *NodeGraph::find_b_node_output(bNode *b_group_node, const char *identifier)
+{
+ for (bNodeSocket *b_sock = (bNodeSocket *)b_group_node->outputs.first; b_sock; b_sock = b_sock->next) {
+ if (STREQ(b_sock->identifier, identifier))
+ return b_sock;
+ }
+ return NULL;
+}
+
+void NodeGraph::add_node(Node *node, bNodeTree *b_ntree, bNodeInstanceKey key, bool is_active_group)
+{
+ node->setbNodeTree(b_ntree);
+ node->setInstanceKey(key);
+ node->setIsInActiveGroup(is_active_group);
+
+ m_nodes.push_back(node);
+
+ DebugInfo::node_added(node);
+}
+
+void NodeGraph::add_link(NodeOutput *fromSocket, NodeInput *toSocket)
+{
+ m_links.push_back(Link(fromSocket, toSocket));
+
+ /* register with the input */
+ toSocket->setLink(fromSocket);
+}
+
+void NodeGraph::add_bNodeTree(const CompositorContext &context, int nodes_start, bNodeTree *tree, bNodeInstanceKey parent_key)
+{
+ const bNodeTree *basetree = context.getbNodeTree();
+
+ /* update viewers in the active edittree as well the base tree (for backdrop) */
+ bool is_active_group = ((parent_key.value == basetree->active_viewer_key.value) ||
+ (tree == basetree));
+
+ /* add all nodes of the tree to the node list */
+ for (bNode *node = (bNode *)tree->nodes.first; node; node = node->next) {
+ bNodeInstanceKey key = BKE_node_instance_key(parent_key, tree, node);
+ add_bNode(context, tree, node, key, is_active_group);
+ }
+
+ NodeRange node_range(m_nodes.begin() + nodes_start, m_nodes.end());
+ /* add all nodelinks of the tree to the link list */
+ for (bNodeLink *nodelink = (bNodeLink *)tree->links.first; nodelink; nodelink = nodelink->next) {
+ add_bNodeLink(node_range, nodelink);
+ }
+}
+
+void NodeGraph::add_bNode(const CompositorContext &context, bNodeTree *b_ntree, bNode *b_node, bNodeInstanceKey key, bool is_active_group)
+{
+ /* replace muted nodes by proxies for internal links */
+ if (b_node->flag & NODE_MUTED) {
+ add_proxies_mute(b_ntree, b_node, key, is_active_group);
+ return;
+ }
+
+ /* replace slow nodes with proxies for fast execution */
+ if (context.isFastCalculation() && !Converter::is_fast_node(b_node)) {
+ add_proxies_skip(b_ntree, b_node, key, is_active_group);
+ return;
+ }
+
+ /* special node types */
+ if (b_node->type == NODE_GROUP) {
+ add_proxies_group(context, b_node, key);
+ }
+ else if (b_node->type == NODE_REROUTE) {
+ add_proxies_reroute(b_ntree, b_node, key, is_active_group);
+ }
+ else {
+ /* regular nodes, handled in Converter */
+ Node *node = Converter::convert(b_node);
+ if (node)
+ add_node(node, b_ntree, key, is_active_group);
+ }
+}
+
+NodeInput *NodeGraph::find_input(const NodeRange &node_range, bNodeSocket *b_socket)
+{
+ for (NodeGraph::NodeIterator it = node_range.first; it != node_range.second; ++it) {
+ Node *node = *it;
+ for (int index = 0; index < node->getNumberOfInputSockets(); index++) {
+ NodeInput *input = node->getInputSocket(index);
+ if (input->getbNodeSocket() == b_socket)
+ return input;
+ }
+ }
+ return NULL;
+}
+
+NodeOutput *NodeGraph::find_output(const NodeRange &node_range, bNodeSocket *b_socket)
+{
+ for (NodeGraph::NodeIterator it = node_range.first; it != node_range.second; ++it) {
+ Node *node = *it;
+ for (int index = 0; index < node->getNumberOfOutputSockets(); index++) {
+ NodeOutput *output = node->getOutputSocket(index);
+ if (output->getbNodeSocket() == b_socket)
+ return output;
+ }
+ }
+ return NULL;
+}
+
+void NodeGraph::add_bNodeLink(const NodeRange &node_range, bNodeLink *b_nodelink)
+{
+ /// @note: ignore invalid links
+ if (!(b_nodelink->flag & NODE_LINK_VALID))
+ return;
+
+ NodeInput *input = find_input(node_range, b_nodelink->tosock);
+ NodeOutput *output = find_output(node_range, b_nodelink->fromsock);
+ if (!input || !output)
+ return;
+ if (input->isLinked())
+ return;
+
+ add_link(output, input);
+}
+
+/* **** Special proxy node type conversions **** */
+
+void NodeGraph::add_proxies_mute(bNodeTree *b_ntree, bNode *b_node, bNodeInstanceKey key, bool is_active_group)
+{
+ for (bNodeLink *b_link = (bNodeLink *)b_node->internal_links.first; b_link; b_link = b_link->next) {
+ SocketProxyNode *proxy = new SocketProxyNode(b_node, b_link->fromsock, b_link->tosock);
+ add_node(proxy, b_ntree, key, is_active_group);
+ }
+}
+
+void NodeGraph::add_proxies_skip(bNodeTree *b_ntree, bNode *b_node, bNodeInstanceKey key, bool is_active_group)
+{
+ for (bNodeSocket *output = (bNodeSocket *)b_node->outputs.first; output; output = output->next) {
+ bNodeSocket *input;
+
+ /* look for first input with matching datatype for each output */
+ for (input = (bNodeSocket *)b_node->inputs.first; input; input = input->next) {
+ if (input->type == output->type)
+ break;
+ }
+
+ if (input) {
+ SocketProxyNode *proxy = new SocketProxyNode(b_node, input, output);
+ add_node(proxy, b_ntree, key, is_active_group);
+ }
+ }
+}
+
+void NodeGraph::add_proxies_group_inputs(bNode *b_node, bNode *b_node_io)
+{
+ bNodeTree *b_group_tree = (bNodeTree *)b_node->id;
+ BLI_assert(b_group_tree); /* should have been checked in advance */
+
+ /* not important for proxies */
+ bNodeInstanceKey key = NODE_INSTANCE_KEY_BASE;
+ bool is_active_group = false;
+
+ for (bNodeSocket *b_sock_io = (bNodeSocket *)b_node_io->outputs.first; b_sock_io; b_sock_io = b_sock_io->next) {
+ bNodeSocket *b_sock_group = find_b_node_input(b_node, b_sock_io->identifier);
+ if (b_sock_group) {
+ SocketProxyNode *proxy = new SocketProxyNode(b_node_io, b_sock_group, b_sock_io);
+ add_node(proxy, b_group_tree, key, is_active_group);
+ }
+ }
+}
+
+void NodeGraph::add_proxies_group_outputs(bNode *b_node, bNode *b_node_io, bool use_buffer)
+{
+ bNodeTree *b_group_tree = (bNodeTree *)b_node->id;
+ BLI_assert(b_group_tree); /* should have been checked in advance */
+
+ /* not important for proxies */
+ bNodeInstanceKey key = NODE_INSTANCE_KEY_BASE;
+ bool is_active_group = false;
+
+ for (bNodeSocket *b_sock_io = (bNodeSocket *)b_node_io->inputs.first; b_sock_io; b_sock_io = b_sock_io->next) {
+ bNodeSocket *b_sock_group = find_b_node_output(b_node, b_sock_io->identifier);
+ if (b_sock_group) {
+ if (use_buffer) {
+ SocketBufferNode *buffer = new SocketBufferNode(b_node_io, b_sock_io, b_sock_group);
+ add_node(buffer, b_group_tree, key, is_active_group);
+ }
+ else {
+ SocketProxyNode *proxy = new SocketProxyNode(b_node_io, b_sock_io, b_sock_group);
+ add_node(proxy, b_group_tree, key, is_active_group);
+ }
+ }
+ }
+}
+
+void NodeGraph::add_proxies_group(const CompositorContext &context, bNode *b_node, bNodeInstanceKey key)
+{
+ bNodeTree *b_group_tree = (bNodeTree *)b_node->id;
+
+ /* missing node group datablock can happen with library linking */
+ if (!b_group_tree) {
+ /* this error case its handled in convertToOperations() so we don't get un-convertred sockets */
+ return;
+ }
+
+ /* use node list size before adding proxies, so they can be connected in add_bNodeTree */
+ int nodes_start = m_nodes.size();
+
+ /* create proxy nodes for group input/output nodes */
+ for (bNode *b_node_io = (bNode *)b_group_tree->nodes.first; b_node_io; b_node_io = b_node_io->next) {
+ if (b_node_io->type == NODE_GROUP_INPUT)
+ add_proxies_group_inputs(b_node, b_node_io);
+
+ if (b_node_io->type == NODE_GROUP_OUTPUT && (b_node_io->flag & NODE_DO_OUTPUT))
+ add_proxies_group_outputs(b_node, b_node_io, context.isGroupnodeBufferEnabled());
+ }
+
+ add_bNodeTree(context, nodes_start, b_group_tree, key);
+}
+
+void NodeGraph::add_proxies_reroute(bNodeTree *b_ntree, bNode *b_node, bNodeInstanceKey key, bool is_active_group)
+{
+ SocketProxyNode *proxy = new SocketProxyNode(b_node, (bNodeSocket *)b_node->inputs.first, (bNodeSocket *)b_node->outputs.first);
+ add_node(proxy, b_ntree, key, is_active_group);
+}
diff --git a/source/blender/compositor/intern/COM_NodeGraph.h b/source/blender/compositor/intern/COM_NodeGraph.h
new file mode 100644
index 00000000000..81799d76e1d
--- /dev/null
+++ b/source/blender/compositor/intern/COM_NodeGraph.h
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2013, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the 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:
+ * Lukas Toenne
+ */
+
+#ifndef _COM_NodeGraph_h
+#define _COM_NodeGraph_h
+
+#include <map>
+#include <set>
+#include <vector>
+
+extern "C" {
+#include "DNA_node_types.h"
+}
+
+#ifdef WITH_CXX_GUARDEDALLOC
+# include "MEM_guardedalloc.h"
+#endif
+
+class CompositorContext;
+class Node;
+class NodeInput;
+class NodeOutput;
+
+/** Internal representation of DNA node data.
+ * This structure is converted into operations by \a NodeCompiler.
+ */
+class NodeGraph {
+public:
+ class Link {
+ private:
+ NodeOutput *m_from;
+ NodeInput *m_to;
+
+ public:
+ Link(NodeOutput *from, NodeInput *to) :
+ m_from(from),
+ m_to(to)
+ {}
+
+ NodeOutput *getFromSocket() const { return m_from; }
+ NodeInput *getToSocket() const { return m_to; }
+ };
+
+ typedef std::vector<Node *> Nodes;
+ typedef Nodes::iterator NodeIterator;
+ typedef std::vector<Link> Links;
+
+private:
+ Nodes m_nodes;
+ Links m_links;
+
+public:
+ NodeGraph();
+ ~NodeGraph();
+
+ const Nodes &nodes() const { return m_nodes; }
+ const Links &links() const { return m_links; }
+
+ void from_bNodeTree(const CompositorContext &context, bNodeTree *tree);
+
+protected:
+ typedef std::pair<NodeIterator, NodeIterator> NodeRange;
+
+ static bNodeSocket *find_b_node_input(bNode *b_node, const char *identifier);
+ static bNodeSocket *find_b_node_output(bNode *b_node, const char *identifier);
+
+ void add_node(Node *node, bNodeTree *b_ntree, bNodeInstanceKey key, bool is_active_group);
+ void add_link(NodeOutput *fromSocket, NodeInput *toSocket);
+
+ void add_bNodeTree(const CompositorContext &context, int nodes_start, bNodeTree *tree, bNodeInstanceKey parent_key);
+
+ void add_bNode(const CompositorContext &context, bNodeTree *b_ntree, bNode *b_node, bNodeInstanceKey key, bool is_active_group);
+
+ NodeInput *find_input(const NodeRange &node_range, bNodeSocket *b_socket);
+ NodeOutput *find_output(const NodeRange &node_range, bNodeSocket *b_socket);
+ void add_bNodeLink(const NodeRange &node_range, bNodeLink *bNodeLink);
+
+ /* **** Special proxy node type conversions **** */
+ /* These nodes are not represented in the node graph themselves,
+ * but converted into a number of proxy links
+ */
+
+ void add_proxies_mute(bNodeTree *b_ntree, bNode *b_node, bNodeInstanceKey key, bool is_active_group);
+ void add_proxies_skip(bNodeTree *b_ntree, bNode *b_node, bNodeInstanceKey key, bool is_active_group);
+
+ void add_proxies_group_inputs(bNode *b_node, bNode *b_node_io);
+ void add_proxies_group_outputs(bNode *b_node, bNode *b_node_io, bool use_buffer);
+ void add_proxies_group(const CompositorContext &context, bNode *b_node, bNodeInstanceKey key);
+
+ void add_proxies_reroute(bNodeTree *b_ntree, bNode *b_node, bNodeInstanceKey key, bool is_active_group);
+
+#ifdef WITH_CXX_GUARDEDALLOC
+ MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeGraph")
+#endif
+};
+
+#endif /* _COM_NodeGraph_h */
diff --git a/source/blender/compositor/intern/COM_NodeOperation.cpp b/source/blender/compositor/intern/COM_NodeOperation.cpp
index d33b8085022..f780c609dce 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.cpp
+++ b/source/blender/compositor/intern/COM_NodeOperation.cpp
@@ -23,12 +23,16 @@
#include <typeinfo>
#include <stdio.h>
-#include "COM_NodeOperation.h"
-#include "COM_InputSocket.h"
-#include "COM_SocketConnection.h"
#include "COM_defines.h"
+#include "COM_ExecutionSystem.h"
-NodeOperation::NodeOperation() : NodeBase()
+#include "COM_NodeOperation.h" /* own include */
+
+/*******************
+ **** NodeOperation ****
+ *******************/
+
+NodeOperation::NodeOperation()
{
this->m_resolutionInputSocketIndex = 0;
this->m_complex = false;
@@ -39,28 +43,63 @@ NodeOperation::NodeOperation() : NodeBase()
this->m_btree = NULL;
}
+NodeOperation::~NodeOperation()
+{
+ while (!this->m_outputs.empty()) {
+ delete (this->m_outputs.back());
+ this->m_outputs.pop_back();
+ }
+ while (!this->m_inputs.empty()) {
+ delete (this->m_inputs.back());
+ this->m_inputs.pop_back();
+ }
+}
+
+NodeOperationOutput *NodeOperation::getOutputSocket(unsigned int index) const
+{
+ BLI_assert(index < m_outputs.size());
+ return m_outputs[index];
+}
+
+NodeOperationInput *NodeOperation::getInputSocket(unsigned int index) const
+{
+ BLI_assert(index < m_inputs.size());
+ return m_inputs[index];
+}
+
+void NodeOperation::addInputSocket(DataType datatype, InputResizeMode resize_mode)
+{
+ NodeOperationInput *socket = new NodeOperationInput(this, datatype, resize_mode);
+ m_inputs.push_back(socket);
+}
+
+void NodeOperation::addOutputSocket(DataType datatype)
+{
+ NodeOperationOutput *socket = new NodeOperationOutput(this, datatype);
+ m_outputs.push_back(socket);
+}
+
void NodeOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
{
unsigned int temp[2];
unsigned int temp2[2];
- vector<InputSocket *> &inputsockets = this->getInputSockets();
- for (unsigned int index = 0; index < inputsockets.size(); index++) {
- InputSocket *inputSocket = inputsockets[index];
- if (inputSocket->isConnected()) {
+ for (unsigned int index = 0; index < m_inputs.size(); index++) {
+ NodeOperationInput *input = m_inputs[index];
+ if (input->isConnected()) {
if (index == this->m_resolutionInputSocketIndex) {
- inputSocket->determineResolution(resolution, preferredResolution);
+ input->determineResolution(resolution, preferredResolution);
temp2[0] = resolution[0];
temp2[1] = resolution[1];
break;
}
}
}
- for (unsigned int index = 0; index < inputsockets.size(); index++) {
- InputSocket *inputSocket = inputsockets[index];
- if (inputSocket->isConnected()) {
+ for (unsigned int index = 0; index < m_inputs.size(); index++) {
+ NodeOperationInput *input = m_inputs[index];
+ if (input->isConnected()) {
if (index != this->m_resolutionInputSocketIndex) {
- inputSocket->determineResolution(temp, temp2);
+ input->determineResolution(temp, temp2);
}
}
}
@@ -102,25 +141,29 @@ SocketReader *NodeOperation::getInputSocketReader(unsigned int inputSocketIndex)
{
return this->getInputSocket(inputSocketIndex)->getReader();
}
+
NodeOperation *NodeOperation::getInputOperation(unsigned int inputSocketIndex)
{
- return this->getInputSocket(inputSocketIndex)->getOperation();
+ NodeOperationInput *input = getInputSocket(inputSocketIndex);
+ if (input && input->isConnected())
+ return &input->getLink()->getOperation();
+ else
+ return NULL;
}
-void NodeOperation::getConnectedInputSockets(vector<InputSocket *> *sockets)
+void NodeOperation::getConnectedInputSockets(Inputs *sockets)
{
- vector<InputSocket *> &inputsockets = this->getInputSockets();
- for (vector<InputSocket *>::iterator iterator = inputsockets.begin(); iterator != inputsockets.end(); iterator++) {
- InputSocket *socket = *iterator;
- if (socket->isConnected()) {
- sockets->push_back(socket);
+ for (Inputs::const_iterator it = m_inputs.begin(); it != m_inputs.end(); ++it) {
+ NodeOperationInput *input = *it;
+ if (input->isConnected()) {
+ sockets->push_back(input);
}
}
}
bool NodeOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
- if (this->isInputNode()) {
+ if (isInputOperation()) {
BLI_rcti_init(output, input->xmin, input->xmax, input->ymin, input->ymax);
return false;
}
@@ -148,3 +191,56 @@ bool NodeOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOper
return !first;
}
}
+
+
+/*****************
+ **** OpInput ****
+ *****************/
+
+NodeOperationInput::NodeOperationInput(NodeOperation *op, DataType datatype, InputResizeMode resizeMode) :
+ m_operation(op),
+ m_datatype(datatype),
+ m_resizeMode(resizeMode),
+ m_link(NULL)
+{
+}
+
+SocketReader *NodeOperationInput::getReader()
+{
+ if (isConnected()) {
+ return &m_link->getOperation();
+ }
+ else {
+ return NULL;
+ }
+}
+
+void NodeOperationInput::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
+{
+ if (m_link)
+ m_link->determineResolution(resolution, preferredResolution);
+}
+
+
+/******************
+ **** OpOutput ****
+ ******************/
+
+NodeOperationOutput::NodeOperationOutput(NodeOperation *op, DataType datatype) :
+ m_operation(op),
+ m_datatype(datatype)
+{
+}
+
+void NodeOperationOutput::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
+{
+ NodeOperation &operation = getOperation();
+ if (operation.isResolutionSet()) {
+ resolution[0] = operation.getWidth();
+ resolution[1] = operation.getHeight();
+ }
+ else {
+ operation.determineResolution(resolution, preferredResolution);
+ operation.setResolution(resolution);
+ }
+}
diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h
index 160e493073e..3f636dff63c 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.h
+++ b/source/blender/compositor/intern/COM_NodeOperation.h
@@ -20,32 +20,72 @@
* Monique Dewanchand
*/
-#ifndef _COM_NodeOperation_h
-#define _COM_NodeOperation_h
-class OpenCLDevice;
-#include "COM_Node.h"
+#ifndef _COM_Operation_h
+#define _COM_Operation_h
+
+#include <list>
#include <string>
#include <sstream>
+
+extern "C" {
+#include "BLI_math_color.h"
+#include "BLI_math_vector.h"
+#include "BLI_threads.h"
+}
+
+#include "COM_Node.h"
#include "COM_MemoryBuffer.h"
#include "COM_MemoryProxy.h"
#include "COM_SocketReader.h"
+
#include "OCL_opencl.h"
-#include "list"
-#include "BLI_threads.h"
-#include "BLI_math_color.h"
-#include "BLI_math_vector.h"
+using std::list;
+using std::min;
+using std::max;
+class OpenCLDevice;
class ReadBufferOperation;
+class WriteBufferOperation;
+
+class NodeOperationInput;
+class NodeOperationOutput;
+
+/**
+ * @brief Resize modes of inputsockets
+ * How are the input and working resolutions matched
+ * @ingroup Model
+ */
+typedef enum InputResizeMode {
+ /** @brief Center the input image to the center of the working area of the node, no resizing occurs */
+ COM_SC_CENTER = NS_CR_CENTER,
+ /** @brief The bottom left of the input image is the bottom left of the working area of the node, no resizing occurs */
+ COM_SC_NO_RESIZE = NS_CR_NONE,
+ /** @brief Fit the width of the input image to the width of the working area of the node */
+ COM_SC_FIT_WIDTH = NS_CR_FIT_WIDTH,
+ /** @brief Fit the height of the input image to the height of the working area of the node */
+ COM_SC_FIT_HEIGHT = NS_CR_FIT_HEIGHT,
+ /** @brief Fit the width or the height of the input image to the width or height of the working area of the node, image will be larger than the working area */
+ COM_SC_FIT = NS_CR_FIT,
+ /** @brief Fit the width and the height of the input image to the width and height of the working area of the node, image will be equally larger than the working area */
+ COM_SC_STRETCH = NS_CR_STRETCH
+} InputResizeMode;
/**
- * @brief NodeOperation are contains calculation logic
+ * @brief NodeOperation contains calculation logic
*
* Subclasses needs to implement the execution method (defined in SocketReader) to implement logic.
* @ingroup Model
*/
-class NodeOperation : public NodeBase, public SocketReader {
+class NodeOperation : public SocketReader {
+public:
+ typedef std::vector<NodeOperationInput*> Inputs;
+ typedef std::vector<NodeOperationOutput*> Outputs;
+
private:
+ Inputs m_inputs;
+ Outputs m_outputs;
+
/**
* @brief the index of the input socket that will be used to determine the resolution
*/
@@ -85,15 +125,21 @@ private:
* @brief set to truth when resolution for this operation is set
*/
bool m_isResolutionSet;
+
public:
- /**
- * @brief is this node an operation?
- * This is true when the instance is of the subclass NodeOperation.
- * @return [true:false]
- * @see NodeBase
+ virtual ~NodeOperation();
+
+ unsigned int getNumberOfInputSockets() const { return m_inputs.size(); }
+ unsigned int getNumberOfOutputSockets() const { return m_outputs.size(); }
+ NodeOperationOutput *getOutputSocket(unsigned int index) const;
+ NodeOperationOutput *getOutputSocket() const { return getOutputSocket(0); }
+ NodeOperationInput *getInputSocket(unsigned int index) const;
+
+ /** Check if this is an input operation
+ * An input operation is an operation that only has output sockets and no input sockets
*/
- const bool isOperation() const { return true; }
-
+ bool isInputOperation() const { return m_inputs.empty(); }
+
/**
* @brief determine the resolution of this node
* @note this method will not set the resolution, this is the responsibility of the caller
@@ -117,15 +163,6 @@ public:
*/
virtual bool isOutputOperation(bool rendering) const { return false; }
- /**
- * isBufferOperation returns if this is an operation that work directly on buffers.
- *
- * there are only 2 implementation where this is true:
- * @see ReadBufferOperation
- * @see WriteBufferOperation
- * for all other operations this will result in false.
- */
- virtual int isBufferOperation() { return false; }
virtual int isSingleThreaded() { return false; }
void setbNodeTree(const bNodeTree *tree) { this->m_btree = tree; }
@@ -190,7 +227,7 @@ public:
}
- void getConnectedInputSockets(vector<InputSocket *> *sockets);
+ void getConnectedInputSockets(Inputs *sockets);
/**
* @brief is this operation complex
@@ -244,13 +281,14 @@ public:
* @see WorkScheduler.schedule
* @see ExecutionGroup.addOperation
*/
- bool isOpenCL() { return this->m_openCL; }
+ bool isOpenCL() const { return this->m_openCL; }
- virtual bool isViewerOperation() { return false; }
- virtual bool isPreviewOperation() { return false; }
- virtual bool isFileOutputOperation() { return false; }
+ virtual bool isViewerOperation() const { return false; }
+ virtual bool isPreviewOperation() const { return false; }
+ virtual bool isFileOutputOperation() const { return false; }
+ virtual bool isProxyOperation() const { return false; }
- inline bool isBreaked() {
+ inline bool isBreaked() const {
return this->m_btree->test_break(this->m_btree->tbh);
}
@@ -261,6 +299,9 @@ public:
protected:
NodeOperation();
+ void addInputSocket(DataType datatype, InputResizeMode resize_mode = COM_SC_CENTER);
+ void addOutputSocket(DataType datatype);
+
void setWidth(unsigned int width) { this->m_width = width; this->m_isResolutionSet = true; }
void setHeight(unsigned int height) { this->m_height = height; this->m_isResolutionSet = true; }
SocketReader *getInputSocketReader(unsigned int inputSocketindex);
@@ -271,7 +312,6 @@ protected:
void lockMutex();
void unlockMutex();
-
/**
* @brief set whether this operation is complex
*
@@ -285,6 +325,75 @@ protected:
*/
void setOpenCL(bool openCL) { this->m_openCL = openCL; }
+ /* allow the DebugInfo class to look at internals */
+ friend class DebugInfo;
+
+#ifdef WITH_CXX_GUARDEDALLOC
+ MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeOperation")
+#endif
+};
+
+
+class NodeOperationInput {
+private:
+ NodeOperation *m_operation;
+
+ /** Datatype of this socket. Is used for automatically data transformation.
+ * @section data-conversion
+ */
+ DataType m_datatype;
+
+ /** Resize mode of this socket */
+ InputResizeMode m_resizeMode;
+
+ /** Connected output */
+ NodeOperationOutput *m_link;
+
+public:
+ NodeOperationInput(NodeOperation *op, DataType datatype, InputResizeMode resizeMode = COM_SC_CENTER);
+
+ NodeOperation &getOperation() const { return *m_operation; }
+ DataType getDataType() const { return m_datatype; }
+
+ void setLink(NodeOperationOutput *link) { m_link = link; }
+ NodeOperationOutput *getLink() const { return m_link; }
+ bool isConnected() const { return m_link; }
+
+ void setResizeMode(InputResizeMode resizeMode) { this->m_resizeMode = resizeMode; }
+ InputResizeMode getResizeMode() const { return this->m_resizeMode; }
+
+ SocketReader *getReader();
+
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+
+#ifdef WITH_CXX_GUARDEDALLOC
+ MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeOperation")
+#endif
+};
+
+
+class NodeOperationOutput {
+private:
+ NodeOperation *m_operation;
+
+ /** Datatype of this socket. Is used for automatically data transformation.
+ * @section data-conversion
+ */
+ DataType m_datatype;
+
+public:
+ NodeOperationOutput(NodeOperation *op, DataType datatype);
+
+ NodeOperation &getOperation() const { return *m_operation; }
+ DataType getDataType() const { return m_datatype; }
+
+ /**
+ * @brief determine the resolution of this data going through this socket
+ * @param resolution the result of this operation
+ * @param preferredResolution the preferable resolution as no resolution could be determined
+ */
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeOperation")
#endif
diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp b/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
new file mode 100644
index 00000000000..5b9027b835d
--- /dev/null
+++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
@@ -0,0 +1,666 @@
+/*
+ * Copyright 2013, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the 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:
+ * Lukas Toenne
+ */
+
+extern "C" {
+#include "BLI_utildefines.h"
+}
+
+#include "COM_NodeConverter.h"
+#include "COM_Converter.h"
+#include "COM_Debug.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_Node.h"
+#include "COM_SocketProxyNode.h"
+
+#include "COM_NodeOperation.h"
+#include "COM_PreviewOperation.h"
+#include "COM_SetValueOperation.h"
+#include "COM_SetVectorOperation.h"
+#include "COM_SetColorOperation.h"
+#include "COM_SocketProxyOperation.h"
+#include "COM_ReadBufferOperation.h"
+#include "COM_WriteBufferOperation.h"
+
+#include "COM_NodeOperationBuilder.h" /* own include */
+
+NodeOperationBuilder::NodeOperationBuilder(const CompositorContext *context, bNodeTree *b_nodetree) :
+ m_context(context),
+ m_current_node(NULL)
+{
+ m_graph.from_bNodeTree(*context, b_nodetree);
+}
+
+NodeOperationBuilder::~NodeOperationBuilder()
+{
+}
+
+void NodeOperationBuilder::convertToOperations(ExecutionSystem *system)
+{
+ /* interface handle for nodes */
+ NodeConverter converter(this);
+
+ for (int index = 0; index < m_graph.nodes().size(); index++) {
+ Node *node = (Node *)m_graph.nodes()[index];
+
+ m_current_node = node;
+
+ DebugInfo::node_to_operations(node);
+ node->convertToOperations(converter, *m_context);
+ }
+
+ m_current_node = NULL;
+
+ /* The input map constructed by nodes maps operation inputs to node inputs.
+ * Inverting yields a map of node inputs to all connected operation inputs,
+ * so multiple operations can use the same node input.
+ */
+ OpInputInverseMap inverse_input_map;
+ for (InputSocketMap::const_iterator it = m_input_map.begin(); it != m_input_map.end(); ++it)
+ inverse_input_map[it->second].push_back(it->first);
+
+ for (NodeGraph::Links::const_iterator it = m_graph.links().begin(); it != m_graph.links().end(); ++it) {
+ const NodeGraph::Link &link = *it;
+ NodeOutput *from = link.getFromSocket();
+ NodeInput *to = link.getToSocket();
+
+ NodeOperationOutput *op_from = find_operation_output(m_output_map, from);
+ const OpInputs &op_to_list = find_operation_inputs(inverse_input_map, to);
+ if (!op_from || op_to_list.empty()) {
+ /* XXX allow this? error/debug message? */
+ //BLI_assert(false);
+ /* XXX note: this can happen with certain nodes (e.g. OutputFile)
+ * which only generate operations in certain circumstances (rendering)
+ * just let this pass silently for now ...
+ */
+ continue;
+ }
+
+ for (OpInputs::const_iterator it = op_to_list.begin(); it != op_to_list.end(); ++it) {
+ NodeOperationInput *op_to = *it;
+ addLink(op_from, op_to);
+ }
+ }
+
+ add_datatype_conversions();
+
+ add_operation_input_constants();
+
+ resolve_proxies();
+
+ determineResolutions();
+
+ /* surround complex ops with read/write buffer */
+ add_complex_operation_buffers();
+
+ /* links not available from here on */
+ /* XXX make m_links a local variable to avoid confusion! */
+ m_links.clear();
+
+ prune_operations();
+
+ /* ensure topological (link-based) order of nodes */
+ /*sort_operations();*/ /* not needed yet */
+
+ /* create execution groups */
+ group_operations();
+
+ /* transfer resulting operations to the system */
+ system->set_operations(m_operations, m_groups);
+}
+
+void NodeOperationBuilder::addOperation(NodeOperation *operation)
+{
+ m_operations.push_back(operation);
+}
+
+void NodeOperationBuilder::mapInputSocket(NodeInput *node_socket, NodeOperationInput *operation_socket)
+{
+ BLI_assert(m_current_node);
+ BLI_assert(node_socket->getNode() == m_current_node);
+
+ /* note: this maps operation sockets to node sockets.
+ * for resolving links the map will be inverted first in convertToOperations,
+ * to get a list of links for each node input socket.
+ */
+ m_input_map[operation_socket] = node_socket;
+}
+
+void NodeOperationBuilder::mapOutputSocket(NodeOutput *node_socket, NodeOperationOutput *operation_socket)
+{
+ BLI_assert(m_current_node);
+ BLI_assert(node_socket->getNode() == m_current_node);
+
+ m_output_map[node_socket] = operation_socket;
+}
+
+void NodeOperationBuilder::addLink(NodeOperationOutput *from, NodeOperationInput *to)
+{
+ if (to->isConnected())
+ return;
+
+ m_links.push_back(Link(from, to));
+
+ /* register with the input */
+ to->setLink(from);
+}
+
+void NodeOperationBuilder::removeInputLink(NodeOperationInput *to)
+{
+ for (Links::iterator it = m_links.begin(); it != m_links.end(); ++it) {
+ Link &link = *it;
+ if (link.to() == to) {
+ /* unregister with the input */
+ to->setLink(NULL);
+
+ m_links.erase(it);
+ return;
+ }
+ }
+}
+
+NodeInput *NodeOperationBuilder::find_node_input(const InputSocketMap &map, NodeOperationInput *op_input)
+{
+ InputSocketMap::const_iterator it = map.find(op_input);
+ return (it != map.end() ? it->second : NULL);
+}
+
+const NodeOperationBuilder::OpInputs &NodeOperationBuilder::find_operation_inputs(const OpInputInverseMap &map, NodeInput *node_input)
+{
+ static const OpInputs empty_list;
+ OpInputInverseMap::const_iterator it = map.find(node_input);
+ return (it != map.end() ? it->second : empty_list);
+}
+
+NodeOperationOutput *NodeOperationBuilder::find_operation_output(const OutputSocketMap &map, NodeOutput *node_output)
+{
+ OutputSocketMap::const_iterator it = map.find(node_output);
+ return (it != map.end() ? it->second : NULL);
+}
+
+PreviewOperation *NodeOperationBuilder::make_preview_operation() const
+{
+ BLI_assert(m_current_node);
+
+ if (!(m_current_node->getbNode()->flag & NODE_PREVIEW))
+ return NULL;
+ /* previews only in the active group */
+ if (!m_current_node->isInActiveGroup())
+ return NULL;
+ /* do not calculate previews of hidden nodes */
+ if (m_current_node->getbNode()->flag & NODE_HIDDEN)
+ return NULL;
+
+ bNodeInstanceHash *previews = m_context->getPreviewHash();
+ if (previews) {
+ PreviewOperation *operation = new PreviewOperation(m_context->getViewSettings(), m_context->getDisplaySettings());
+ operation->setbNodeTree(m_context->getbNodeTree());
+ operation->verifyPreview(previews, m_current_node->getInstanceKey());
+ return operation;
+ }
+
+ return NULL;
+}
+
+void NodeOperationBuilder::addPreview(NodeOperationOutput *output)
+{
+ PreviewOperation *operation = make_preview_operation();
+ if (operation) {
+ addOperation(operation);
+
+ addLink(output, operation->getInputSocket(0));
+ }
+}
+
+void NodeOperationBuilder::addNodeInputPreview(NodeInput *input)
+{
+ PreviewOperation *operation = make_preview_operation();
+ if (operation) {
+ addOperation(operation);
+
+ mapInputSocket(input, operation->getInputSocket(0));
+ }
+}
+
+/****************************
+ **** Optimization Steps ****
+ ****************************/
+
+void NodeOperationBuilder::add_datatype_conversions()
+{
+ Links convert_links;
+ for (Links::const_iterator it = m_links.begin(); it != m_links.end(); ++it) {
+ const Link &link = *it;
+ if (link.from()->getDataType() != link.to()->getDataType())
+ convert_links.push_back(link);
+ }
+ for (Links::const_iterator it = convert_links.begin(); it != convert_links.end(); ++it) {
+ const Link &link = *it;
+ NodeOperation *converter = Converter::convertDataType(link.from(), link.to());
+ if (converter) {
+ addOperation(converter);
+
+ removeInputLink(link.to());
+ addLink(link.from(), converter->getInputSocket(0));
+ addLink(converter->getOutputSocket(0), link.to());
+ }
+ }
+}
+
+void NodeOperationBuilder::add_operation_input_constants()
+{
+ /* Note: unconnected inputs cached first to avoid modifying
+ * m_operations while iterating over it
+ */
+ typedef std::vector<NodeOperationInput*> Inputs;
+ Inputs pending_inputs;
+ for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
+ NodeOperation *op = *it;
+ for (int k = 0; k < op->getNumberOfInputSockets(); ++k) {
+ NodeOperationInput *input = op->getInputSocket(k);
+ if (!input->isConnected())
+ pending_inputs.push_back(input);
+ }
+ }
+ for (Inputs::const_iterator it = pending_inputs.begin(); it != pending_inputs.end(); ++it) {
+ NodeOperationInput *input = *it;
+ add_input_constant_value(input, find_node_input(m_input_map, input));
+ }
+}
+
+void NodeOperationBuilder::add_input_constant_value(NodeOperationInput *input, NodeInput *node_input)
+{
+ switch (input->getDataType()) {
+ case COM_DT_VALUE: {
+ float value;
+ if (node_input && node_input->getbNodeSocket())
+ value = node_input->getEditorValueFloat();
+ else
+ value = 0.0f;
+
+ SetValueOperation *op = new SetValueOperation();
+ op->setValue(value);
+ addOperation(op);
+ addLink(op->getOutputSocket(), input);
+ break;
+ }
+ case COM_DT_COLOR: {
+ float value[4];
+ if (node_input && node_input->getbNodeSocket())
+ node_input->getEditorValueColor(value);
+ else
+ zero_v4(value);
+
+ SetColorOperation *op = new SetColorOperation();
+ op->setChannels(value);
+ addOperation(op);
+ addLink(op->getOutputSocket(), input);
+ break;
+ }
+ case COM_DT_VECTOR: {
+ float value[3];
+ if (node_input && node_input->getbNodeSocket())
+ node_input->getEditorValueVector(value);
+ else
+ zero_v3(value);
+
+ SetVectorOperation *op = new SetVectorOperation();
+ op->setVector(value);
+ addOperation(op);
+ addLink(op->getOutputSocket(), input);
+ break;
+ }
+ }
+}
+
+void NodeOperationBuilder::resolve_proxies()
+{
+ Links proxy_links;
+ for (Links::const_iterator it = m_links.begin(); it != m_links.end(); ++it) {
+ const Link &link = *it;
+ /* don't replace links from proxy to proxy, since we may need them for replacing others! */
+ if (link.from()->getOperation().isProxyOperation() &&
+ !link.to()->getOperation().isProxyOperation())
+ {
+ proxy_links.push_back(link);
+ }
+ }
+
+ for (Links::const_iterator it = proxy_links.begin(); it != proxy_links.end(); ++it) {
+ const Link &link = *it;
+
+ NodeOperationInput *to = link.to();
+ NodeOperationOutput *from = link.from();
+ do {
+ /* walk upstream bypassing the proxy operation */
+ from = from->getOperation().getInputSocket(0)->getLink();
+ } while (from && from->getOperation().isProxyOperation());
+
+ removeInputLink(to);
+ /* we may not have a final proxy input link,
+ * in that case it just gets dropped
+ */
+ if (from)
+ addLink(from, to);
+ }
+}
+
+void NodeOperationBuilder::determineResolutions()
+{
+ /* determine all resolutions of the operations (Width/Height) */
+ for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
+ NodeOperation *op = *it;
+
+ if (op->isOutputOperation(m_context->isRendering()) && !op->isPreviewOperation()) {
+ unsigned int resolution[2] = {0, 0};
+ unsigned int preferredResolution[2] = {0, 0};
+ op->determineResolution(resolution, preferredResolution);
+ op->setResolution(resolution);
+ }
+ }
+
+ for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
+ NodeOperation *op = *it;
+
+ if (op->isOutputOperation(m_context->isRendering()) && op->isPreviewOperation()) {
+ unsigned int resolution[2] = {0, 0};
+ unsigned int preferredResolution[2] = {0, 0};
+ op->determineResolution(resolution, preferredResolution);
+ op->setResolution(resolution);
+ }
+ }
+
+ /* add convert resolution operations when needed */
+ {
+ Links convert_links;
+ for (Links::const_iterator it = m_links.begin(); it != m_links.end(); ++it) {
+ const Link &link = *it;
+
+ if (link.to()->getResizeMode() != COM_SC_NO_RESIZE) {
+ NodeOperation &from_op = link.from()->getOperation();
+ NodeOperation &to_op = link.to()->getOperation();
+ if (from_op.getWidth() != to_op.getWidth() || from_op.getHeight() != to_op.getHeight())
+ convert_links.push_back(link);
+ }
+ }
+ for (Links::const_iterator it = convert_links.begin(); it != convert_links.end(); ++it) {
+ const Link &link = *it;
+ Converter::convertResolution(*this, link.from(), link.to());
+ }
+ }
+}
+
+NodeOperationBuilder::OpInputs NodeOperationBuilder::cache_output_links(NodeOperationOutput *output) const
+{
+ OpInputs inputs;
+ for (Links::const_iterator it = m_links.begin(); it != m_links.end(); ++it) {
+ const Link &link = *it;
+ if (link.from() == output)
+ inputs.push_back(link.to());
+ }
+ return inputs;
+}
+
+WriteBufferOperation *NodeOperationBuilder::find_attached_write_buffer_operation(NodeOperationOutput *output) const
+{
+ for (Links::const_iterator it = m_links.begin(); it != m_links.end(); ++it) {
+ const Link &link = *it;
+ if (link.from() == output) {
+ NodeOperation &op = link.to()->getOperation();
+ if (op.isWriteBufferOperation())
+ return (WriteBufferOperation *)(&op);
+ }
+ }
+ return NULL;
+}
+
+void NodeOperationBuilder::add_input_buffers(NodeOperation *operation, NodeOperationInput *input)
+{
+ if (!input->isConnected())
+ return;
+
+ NodeOperationOutput *output = input->getLink();
+ if (output->getOperation().isReadBufferOperation()) {
+ /* input is already buffered, no need to add another */
+ return;
+ }
+
+ /* this link will be replaced below */
+ removeInputLink(input);
+
+ /* check of other end already has write operation, otherwise add a new one */
+ WriteBufferOperation *writeoperation = find_attached_write_buffer_operation(output);
+ if (!writeoperation) {
+ writeoperation = new WriteBufferOperation(output->getDataType());
+ writeoperation->setbNodeTree(m_context->getbNodeTree());
+ addOperation(writeoperation);
+
+ addLink(output, writeoperation->getInputSocket(0));
+
+ writeoperation->readResolutionFromInputSocket();
+ }
+
+ /* add readbuffer op for the input */
+ ReadBufferOperation *readoperation = new ReadBufferOperation(output->getDataType());
+ readoperation->setMemoryProxy(writeoperation->getMemoryProxy());
+ this->addOperation(readoperation);
+
+ addLink(readoperation->getOutputSocket(), input);
+
+ readoperation->readResolutionFromWriteBuffer();
+}
+
+void NodeOperationBuilder::add_output_buffers(NodeOperation *operation, NodeOperationOutput *output)
+{
+ /* cache connected sockets, so we can safely remove links first before replacing them */
+ OpInputs targets = cache_output_links(output);
+ if (targets.empty())
+ return;
+
+ WriteBufferOperation *writeOperation = NULL;
+ for (OpInputs::const_iterator it = targets.begin(); it != targets.end(); ++it) {
+ NodeOperationInput *target = *it;
+
+ /* try to find existing write buffer operation */
+ if (target->getOperation().isWriteBufferOperation()) {
+ BLI_assert(writeOperation == NULL); /* there should only be one write op connected */
+ writeOperation = (WriteBufferOperation *)(&target->getOperation());
+ }
+ else {
+ /* remove all links to other nodes */
+ removeInputLink(target);
+ }
+ }
+
+ /* if no write buffer operation exists yet, create a new one */
+ if (!writeOperation) {
+ writeOperation = new WriteBufferOperation(operation->getOutputSocket()->getDataType());
+ writeOperation->setbNodeTree(m_context->getbNodeTree());
+ addOperation(writeOperation);
+
+ addLink(output, writeOperation->getInputSocket(0));
+ }
+
+ writeOperation->readResolutionFromInputSocket();
+
+ /* add readbuffer op for every former connected input */
+ for (OpInputs::const_iterator it = targets.begin(); it != targets.end(); ++it) {
+ NodeOperationInput *target = *it;
+ if (&target->getOperation() == writeOperation)
+ continue; /* skip existing write op links */
+
+ ReadBufferOperation *readoperation = new ReadBufferOperation(operation->getOutputSocket()->getDataType());
+ readoperation->setMemoryProxy(writeOperation->getMemoryProxy());
+ addOperation(readoperation);
+
+ addLink(readoperation->getOutputSocket(), target);
+
+ readoperation->readResolutionFromWriteBuffer();
+ }
+}
+
+void NodeOperationBuilder::add_complex_operation_buffers()
+{
+ /* note: complex ops and get cached here first, since adding operations
+ * will invalidate iterators over the main m_operations
+ */
+ Operations complex_ops;
+ for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it)
+ if ((*it)->isComplex())
+ complex_ops.push_back(*it);
+
+ for (Operations::const_iterator it = complex_ops.begin(); it != complex_ops.end(); ++it) {
+ NodeOperation *op = *it;
+
+ DebugInfo::operation_read_write_buffer(op);
+
+ for (int index = 0; index < op->getNumberOfInputSockets(); index++)
+ add_input_buffers(op, op->getInputSocket(index));
+
+ for (int index = 0; index < op->getNumberOfOutputSockets(); index++)
+ add_output_buffers(op, op->getOutputSocket(index));
+ }
+}
+
+typedef std::set<NodeOperation*> Tags;
+
+static void find_reachable_operations_recursive(Tags &reachable, NodeOperation *op)
+{
+ if (reachable.find(op) != reachable.end())
+ return;
+ reachable.insert(op);
+
+ for (int i = 0; i < op->getNumberOfInputSockets(); ++i) {
+ NodeOperationInput *input = op->getInputSocket(i);
+ if (input->isConnected())
+ find_reachable_operations_recursive(reachable, &input->getLink()->getOperation());
+ }
+
+ /* associated write-buffer operations are executed as well */
+ if (op->isReadBufferOperation()) {
+ ReadBufferOperation *read_op = (ReadBufferOperation *)op;
+ MemoryProxy *memproxy = read_op->getMemoryProxy();
+ find_reachable_operations_recursive(reachable, memproxy->getWriteBufferOperation());
+ }
+}
+
+void NodeOperationBuilder::prune_operations()
+{
+ Tags reachable;
+ for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
+ NodeOperation *op = *it;
+
+ /* output operations are primary executed operations */
+ if (op->isOutputOperation(m_context->isRendering()))
+ find_reachable_operations_recursive(reachable, op);
+ }
+
+ /* delete unreachable operations */
+ Operations reachable_ops;
+ for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
+ NodeOperation *op = *it;
+
+ if (reachable.find(op) != reachable.end())
+ reachable_ops.push_back(op);
+ else
+ delete op;
+ }
+ /* finally replace the operations list with the pruned list */
+ m_operations = reachable_ops;
+}
+
+/* topological (depth-first) sorting of operations */
+static void sort_operations_recursive(NodeOperationBuilder::Operations &sorted, Tags &visited, NodeOperation *op)
+{
+ if (visited.find(op) != visited.end())
+ return;
+ visited.insert(op);
+
+ for (int i = 0; i < op->getNumberOfInputSockets(); ++i) {
+ NodeOperationInput *input = op->getInputSocket(i);
+ if (input->isConnected())
+ sort_operations_recursive(sorted, visited, &input->getLink()->getOperation());
+ }
+
+ sorted.push_back(op);
+}
+
+void NodeOperationBuilder::sort_operations()
+{
+ Operations sorted;
+ sorted.reserve(m_operations.size());
+ Tags visited;
+
+ for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it)
+ sort_operations_recursive(sorted, visited, *it);
+
+ m_operations = sorted;
+}
+
+static void add_group_operations_recursive(Tags &visited, NodeOperation *op, ExecutionGroup *group)
+{
+ if (visited.find(op) != visited.end())
+ return;
+ visited.insert(op);
+
+ if (!group->addOperation(op))
+ return;
+
+ /* add all eligible input ops to the group */
+ for (int i = 0; i < op->getNumberOfInputSockets(); ++i) {
+ NodeOperationInput *input = op->getInputSocket(i);
+ if (input->isConnected())
+ add_group_operations_recursive(visited, &input->getLink()->getOperation(), group);
+ }
+}
+
+ExecutionGroup *NodeOperationBuilder::make_group(NodeOperation *op)
+{
+ ExecutionGroup *group = new ExecutionGroup();
+ m_groups.push_back(group);
+
+ Tags visited;
+ add_group_operations_recursive(visited, op, group);
+
+ return group;
+}
+
+void NodeOperationBuilder::group_operations()
+{
+ for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
+ NodeOperation *op = *it;
+
+ if (op->isOutputOperation(m_context->isRendering())) {
+ ExecutionGroup *group = make_group(op);
+ group->setOutputExecutionGroup(true);
+ }
+
+ /* add new groups for associated memory proxies where needed */
+ if (op->isReadBufferOperation()) {
+ ReadBufferOperation *read_op = (ReadBufferOperation *)op;
+ MemoryProxy *memproxy = read_op->getMemoryProxy();
+
+ if (memproxy->getExecutor() == NULL) {
+ ExecutionGroup *group = make_group(memproxy->getWriteBufferOperation());
+ memproxy->setExecutor(group);
+ }
+ }
+ }
+}
diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.h b/source/blender/compositor/intern/COM_NodeOperationBuilder.h
new file mode 100644
index 00000000000..ab890282bab
--- /dev/null
+++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.h
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2013, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the 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:
+ * Lukas Toenne
+ */
+
+#ifndef _COM_NodeCompilerImpl_h
+#define _COM_NodeCompilerImpl_h
+
+#include <map>
+#include <set>
+#include <vector>
+
+#include "COM_NodeGraph.h"
+
+using std::vector;
+
+class CompositorContext;
+
+class Node;
+class NodeInput;
+class NodeOutput;
+
+class ExecutionSystem;
+class ExecutionGroup;
+class NodeOperation;
+class NodeOperationInput;
+class NodeOperationOutput;
+
+class PreviewOperation;
+class WriteBufferOperation;
+
+class NodeOperationBuilder {
+public:
+ class Link {
+ private:
+ NodeOperationOutput *m_from;
+ NodeOperationInput *m_to;
+
+ public:
+ Link(NodeOperationOutput *from, NodeOperationInput *to) :
+ m_from(from),
+ m_to(to)
+ {}
+
+ NodeOperationOutput *from() const { return m_from; }
+ NodeOperationInput *to() const { return m_to; }
+ };
+
+ typedef std::vector<NodeOperation *> Operations;
+ typedef std::vector<Link> Links;
+ typedef std::vector<ExecutionGroup *> Groups;
+
+ typedef std::map<NodeOperationInput *, NodeInput *> InputSocketMap;
+ typedef std::map<NodeOutput *, NodeOperationOutput *> OutputSocketMap;
+
+ typedef std::vector<NodeOperationInput *> OpInputs;
+ typedef std::map<NodeInput *, OpInputs> OpInputInverseMap;
+
+private:
+ const CompositorContext *m_context;
+ NodeGraph m_graph;
+
+ Operations m_operations;
+ Links m_links;
+ Groups m_groups;
+
+ /** Maps operation inputs to node inputs */
+ InputSocketMap m_input_map;
+ /** Maps node outputs to operation outputs */
+ OutputSocketMap m_output_map;
+
+ Node *m_current_node;
+
+public:
+ NodeOperationBuilder(const CompositorContext *context, bNodeTree *b_nodetree);
+ ~NodeOperationBuilder();
+
+ const CompositorContext &context() const { return *m_context; }
+
+ void convertToOperations(ExecutionSystem *system);
+
+ void addOperation(NodeOperation *operation);
+
+ /** Map input socket of the current node to an operation socket */
+ void mapInputSocket(NodeInput *node_socket, NodeOperationInput *operation_socket);
+ /** Map output socket of the current node to an operation socket */
+ void mapOutputSocket(NodeOutput *node_socket, NodeOperationOutput *operation_socket);
+
+ void addLink(NodeOperationOutput *from, NodeOperationInput *to);
+ void removeInputLink(NodeOperationInput *to);
+
+ /** Add a preview operation for a operation output */
+ void addPreview(NodeOperationOutput *output);
+ /** Add a preview operation for a node input */
+ void addNodeInputPreview(NodeInput *input);
+
+protected:
+ static NodeInput *find_node_input(const InputSocketMap &map, NodeOperationInput *op_input);
+ static const OpInputs &find_operation_inputs(const OpInputInverseMap &map, NodeInput *node_input);
+ static NodeOperationOutput *find_operation_output(const OutputSocketMap &map, NodeOutput *node_output);
+
+ /** Add datatype conversion where needed */
+ void add_datatype_conversions();
+
+ /** Construct a constant value operation for every unconnected input */
+ void add_operation_input_constants();
+ void add_input_constant_value(NodeOperationInput *input, NodeInput *node_input);
+
+ /** Replace proxy operations with direct links */
+ void resolve_proxies();
+
+ /** Calculate resolution for each operation */
+ void determineResolutions();
+
+ /** Helper function to store connected inputs for replacement */
+ OpInputs cache_output_links(NodeOperationOutput *output) const;
+ /** Find a connected write buffer operation to an OpOutput */
+ WriteBufferOperation *find_attached_write_buffer_operation(NodeOperationOutput *output) const;
+ /** Add read/write buffer operations around complex operations */
+ void add_complex_operation_buffers();
+ void add_input_buffers(NodeOperation *operation, NodeOperationInput *input);
+ void add_output_buffers(NodeOperation *operation, NodeOperationOutput *output);
+
+ /** Remove unreachable operations */
+ void prune_operations();
+
+ /** Sort operations by link dependencies */
+ void sort_operations();
+
+ /** Create execution groups */
+ void group_operations();
+ ExecutionGroup *make_group(NodeOperation *op);
+
+private:
+ PreviewOperation *make_preview_operation() const;
+
+#ifdef WITH_CXX_GUARDEDALLOC
+ MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeCompilerImpl")
+#endif
+};
+
+#endif /* _COM_NodeCompilerImpl_h */
diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.cpp b/source/blender/compositor/intern/COM_OpenCLDevice.cpp
index 58cc8584ffd..9f3d6ed6a64 100644
--- a/source/blender/compositor/intern/COM_OpenCLDevice.cpp
+++ b/source/blender/compositor/intern/COM_OpenCLDevice.cpp
@@ -25,16 +25,16 @@
typedef enum COM_VendorID {NVIDIA = 0x10DE, AMD = 0x1002} COM_VendorID;
const cl_image_format IMAGE_FORMAT_COLOR = {
- CL_RGBA,
- CL_FLOAT
+ CL_RGBA,
+ CL_FLOAT
};
const cl_image_format IMAGE_FORMAT_VECTOR = {
- CL_RGB,
- CL_FLOAT
+ CL_RGB,
+ CL_FLOAT
};
const cl_image_format IMAGE_FORMAT_VALUE = {
- CL_R,
- CL_FLOAT
+ CL_R,
+ CL_FLOAT
};
OpenCLDevice::OpenCLDevice(cl_context context, cl_device_id device, cl_program program, cl_int vendorId)
@@ -70,7 +70,7 @@ void OpenCLDevice::execute(WorkPackage *work)
MemoryBuffer **inputBuffers = executionGroup->getInputBuffersOpenCL(chunkNumber);
MemoryBuffer *outputBuffer = executionGroup->allocateOutputBuffer(chunkNumber, &rect);
- executionGroup->getOutputNodeOperation()->executeOpenCLRegion(this, &rect,
+ executionGroup->getOutputOperation()->executeOpenCLRegion(this, &rect,
chunkNumber, inputBuffers, outputBuffer);
delete outputBuffer;
@@ -86,17 +86,17 @@ cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel,
const cl_image_format* OpenCLDevice::determineImageFormat(MemoryBuffer *memoryBuffer)
{
- const cl_image_format *imageFormat;
- int no_channels = memoryBuffer->get_no_channels();
- if (no_channels == 1) {
- imageFormat = &IMAGE_FORMAT_VALUE;
- } else if (no_channels == 3) {
- imageFormat = &IMAGE_FORMAT_VECTOR;
- } else {
- imageFormat = &IMAGE_FORMAT_COLOR;
- }
-
- return imageFormat;
+ const cl_image_format *imageFormat;
+ int no_channels = memoryBuffer->get_no_channels();
+ if (no_channels == 1) {
+ imageFormat = &IMAGE_FORMAT_VALUE;
+ } else if (no_channels == 3) {
+ imageFormat = &IMAGE_FORMAT_VECTOR;
+ } else {
+ imageFormat = &IMAGE_FORMAT_COLOR;
+ }
+
+ return imageFormat;
}
cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, int offsetIndex,
@@ -107,9 +107,9 @@ cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel,
MemoryBuffer *result = reader->getInputMemoryBuffer(inputMemoryBuffers);
- const cl_image_format *imageFormat = determineImageFormat(result);
+ const cl_image_format *imageFormat = determineImageFormat(result);
- cl_mem clBuffer = clCreateImage2D(this->m_context, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, imageFormat, result->getWidth(),
+ cl_mem clBuffer = clCreateImage2D(this->m_context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, imageFormat, result->getWidth(),
result->getHeight(), 0, result->getBuffer(), &error);
if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
@@ -216,5 +216,4 @@ cl_kernel OpenCLDevice::COM_clCreateKernel(const char *kernelname, list<cl_kerne
if (clKernelsToCleanUp) clKernelsToCleanUp->push_back(kernel);
}
return kernel;
-
}
diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.h b/source/blender/compositor/intern/COM_OpenCLDevice.h
index 1c2a204689d..e3fd9002e49 100644
--- a/source/blender/compositor/intern/COM_OpenCLDevice.h
+++ b/source/blender/compositor/intern/COM_OpenCLDevice.h
@@ -30,6 +30,8 @@ class OpenCLDevice;
#include "COM_WorkScheduler.h"
#include "COM_ReadBufferOperation.h"
+using std::list;
+
/**
* @brief device representing an GPU OpenCL device.
* an instance of this class represents a single cl_device
diff --git a/source/blender/compositor/intern/COM_OutputSocket.cpp b/source/blender/compositor/intern/COM_OutputSocket.cpp
deleted file mode 100644
index 50e9b75b072..00000000000
--- a/source/blender/compositor/intern/COM_OutputSocket.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the 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:
- * Jeroen Bakker
- * Monique Dewanchand
- */
-
-#include "COM_Socket.h"
-#include "COM_Node.h"
-#include "COM_SocketConnection.h"
-#include "COM_NodeOperation.h"
-
-OutputSocket::OutputSocket(DataType datatype) : Socket(datatype)
-{
- /* pass */
-}
-
-int OutputSocket::isOutputSocket() const { return true; }
-const int OutputSocket::isConnected() const { return this->m_connections.size() != 0; }
-
-void OutputSocket::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
-{
- NodeBase *node = this->getNode();
- if (node->isOperation()) {
- NodeOperation *operation = (NodeOperation *)node;
- if (operation->isResolutionSet()) {
- resolution[0] = operation->getWidth();
- resolution[1] = operation->getHeight();
- }
- else {
- operation->determineResolution(resolution, preferredResolution);
- operation->setResolution(resolution);
- }
- }
-}
-
-void OutputSocket::addConnection(SocketConnection *connection)
-{
- this->m_connections.push_back(connection);
-}
-
-void OutputSocket::removeConnection(SocketConnection *connection)
-{
- for (vector<SocketConnection *>::iterator it = m_connections.begin(); it != m_connections.end(); ++it) {
- if (*it == connection) {
- m_connections.erase(it);
- return;
- }
- }
-}
-
-void OutputSocket::relinkConnections(OutputSocket *relinkToSocket, bool single)
-{
- if (isConnected()) {
- if (single) {
- SocketConnection *connection = this->m_connections[0];
- connection->setFromSocket(relinkToSocket);
- relinkToSocket->addConnection(connection);
- this->m_connections.erase(this->m_connections.begin());
- }
- else {
- unsigned int index;
- for (index = 0; index < this->m_connections.size(); index++) {
- SocketConnection *connection = this->m_connections[index];
- connection->setFromSocket(relinkToSocket);
- relinkToSocket->addConnection(connection);
- }
- this->m_connections.clear();
- }
- }
-}
-void OutputSocket::removeFirstConnection()
-{
- SocketConnection *connection = this->m_connections[0];
- InputSocket *inputSocket = connection->getToSocket();
- if (inputSocket != NULL) {
- inputSocket->setConnection(NULL);
- }
- this->m_connections.erase(this->m_connections.begin());
-}
-
-void OutputSocket::clearConnections()
-{
- while (this->isConnected()) {
- removeFirstConnection();
- }
-}
-
-WriteBufferOperation *OutputSocket::findAttachedWriteBufferOperation() const
-{
- unsigned int index;
- for (index = 0; index < this->m_connections.size(); index++) {
- SocketConnection *connection = this->m_connections[index];
- NodeBase *node = connection->getToNode();
- if (node->isOperation()) {
- NodeOperation *operation = (NodeOperation *)node;
- if (operation->isWriteBufferOperation()) {
- return (WriteBufferOperation *)operation;
- }
- }
- }
- return NULL;
-}
-
diff --git a/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.cpp b/source/blender/compositor/intern/COM_SingleThreadedOperation.cpp
index 7d1184cb356..c300a85bfa3 100644
--- a/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.cpp
+++ b/source/blender/compositor/intern/COM_SingleThreadedOperation.cpp
@@ -20,25 +20,25 @@
* Monique Dewanchand
*/
-#include "COM_SingleThreadedNodeOperation.h"
+#include "COM_SingleThreadedOperation.h"
-SingleThreadedNodeOperation::SingleThreadedNodeOperation() : NodeOperation()
+SingleThreadedOperation::SingleThreadedOperation() : NodeOperation()
{
this->m_cachedInstance = NULL;
setComplex(true);
}
-void SingleThreadedNodeOperation::initExecution()
+void SingleThreadedOperation::initExecution()
{
initMutex();
}
-void SingleThreadedNodeOperation::executePixel(float output[4], int x, int y, void *data)
+void SingleThreadedOperation::executePixel(float output[4], int x, int y, void *data)
{
this->m_cachedInstance->readNoCheck(output, x, y);
}
-void SingleThreadedNodeOperation::deinitExecution()
+void SingleThreadedOperation::deinitExecution()
{
deinitMutex();
if (this->m_cachedInstance) {
@@ -46,7 +46,7 @@ void SingleThreadedNodeOperation::deinitExecution()
this->m_cachedInstance = NULL;
}
}
-void *SingleThreadedNodeOperation::initializeTileData(rcti *rect)
+void *SingleThreadedOperation::initializeTileData(rcti *rect)
{
if (this->m_cachedInstance) return this->m_cachedInstance;
diff --git a/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.h b/source/blender/compositor/intern/COM_SingleThreadedOperation.h
index 45325be18a9..a6b2f777cb5 100644
--- a/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.h
+++ b/source/blender/compositor/intern/COM_SingleThreadedOperation.h
@@ -20,11 +20,11 @@
* Monique Dewanchand
*/
-#ifndef _COM_SingleThreadedNodeOperation_h
-#define _COM_SingleThreadedNodeOperation_h
+#ifndef _COM_SingleThreadedOperation_h
+#define _COM_SingleThreadedOperation_h
#include "COM_NodeOperation.h"
-class SingleThreadedNodeOperation : public NodeOperation {
+class SingleThreadedOperation : public NodeOperation {
private:
MemoryBuffer *m_cachedInstance;
@@ -34,7 +34,7 @@ protected:
}
public:
- SingleThreadedNodeOperation();
+ SingleThreadedOperation();
/**
* the inner loop of this program
diff --git a/source/blender/compositor/intern/COM_Socket.cpp b/source/blender/compositor/intern/COM_Socket.cpp
deleted file mode 100644
index 3465fa6f56d..00000000000
--- a/source/blender/compositor/intern/COM_Socket.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the 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:
- * Jeroen Bakker
- * Monique Dewanchand
- */
-
-#include "COM_Socket.h"
-#include "COM_Node.h"
-#include "COM_SocketConnection.h"
-
-extern "C" {
-#include "RNA_access.h"
-}
-
-Socket::Socket(DataType datatype)
-{
- this->m_datatype = datatype;
- this->m_editorSocket = NULL;
- this->m_node = NULL;
-}
-
-DataType Socket::getDataType() const
-{
- return this->m_datatype;
-}
-
-int Socket::isInputSocket() const { return false; }
-int Socket::isOutputSocket() const { return false; }
-const int Socket::isConnected() const { return false; }
-void Socket::setNode(NodeBase *node) { this->m_node = node; }
-NodeBase *Socket::getNode() const { return this->m_node; }
-
-float Socket::getEditorValueFloat()
-{
- PointerRNA ptr;
- RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr);
- return RNA_float_get(&ptr, "default_value");
-}
-
-void Socket::getEditorValueColor(float *value)
-{
- PointerRNA ptr;
- RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr);
- return RNA_float_get_array(&ptr, "default_value", value);
-}
-
-void Socket::getEditorValueVector(float *value)
-{
- PointerRNA ptr;
- RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr);
- return RNA_float_get_array(&ptr, "default_value", value);
-}
diff --git a/source/blender/compositor/intern/COM_Socket.h b/source/blender/compositor/intern/COM_Socket.h
deleted file mode 100644
index 6532864a4d9..00000000000
--- a/source/blender/compositor/intern/COM_Socket.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the 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:
- * Jeroen Bakker
- * Monique Dewanchand
- */
-
-#ifndef _COM_Socket_h
-#define _COM_Socket_h
-
-#include <vector>
-#include "BKE_text.h"
-#include <string>
-#include "DNA_node_types.h"
-#include "COM_defines.h"
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-using namespace std;
-class SocketConnection;
-class NodeBase;
-struct PointerRNA;
-
-/**
- * @brief Base class for InputSocket and OutputSocket.
- *
- * A socket are the points on an node where the user can make a connection between.
- * Sockets are always part of a node or an operation.
- *
- * @see InputSocket
- * @see OutputSocket
- * @see SocketConnection - a connection between an InputSocket and an OutputSocket
- * @ingroup Model
- */
-class Socket {
-private:
- /**
- * Reference to the node where this Socket belongs to
- */
- NodeBase *m_node;
-
- /**
- * the datatype of this socket. Is used for automatically data transformation.
- * @section data-conversion
- */
- DataType m_datatype;
-
- bNodeSocket *m_editorSocket;
-
-protected:
- /**
- * @brief Declaration of the virtual destructor
- * @note resolve warning gcc 4.7
- */
- virtual ~Socket() {}
-
-public:
- Socket(DataType datatype);
-
- DataType getDataType() const;
- void setNode(NodeBase *node);
- NodeBase *getNode() const;
-
-
- const virtual int isConnected() const;
- int isInputSocket() const;
- int isOutputSocket() const;
- virtual void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]) {}
-
- void setEditorSocket(bNodeSocket *editorSocket) { this->m_editorSocket = editorSocket; }
- bNodeSocket *getbNodeSocket() const { return this->m_editorSocket; }
-
- float getEditorValueFloat();
- void getEditorValueColor(float *value);
- void getEditorValueVector(float *value);
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("COM:Socket")
-#endif
-};
-
-
-#endif
diff --git a/source/blender/compositor/intern/COM_SocketConnection.cpp b/source/blender/compositor/intern/COM_SocketConnection.cpp
deleted file mode 100644
index 1f2cba72dc0..00000000000
--- a/source/blender/compositor/intern/COM_SocketConnection.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the 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:
- * Jeroen Bakker
- * Monique Dewanchand
- */
-
-#include "COM_SocketConnection.h"
-#include "COM_NodeOperation.h"
-
-SocketConnection::SocketConnection()
-{
- this->m_fromSocket = NULL;
- this->m_toSocket = NULL;
- this->setIgnoreResizeCheck(false);
-}
-
-void SocketConnection::setFromSocket(OutputSocket *fromsocket)
-{
- if (fromsocket == NULL) {
- throw "ERROR";
- }
- this->m_fromSocket = fromsocket;
-}
-
-OutputSocket *SocketConnection::getFromSocket() const { return this->m_fromSocket; }
-void SocketConnection::setToSocket(InputSocket *tosocket)
-{
- if (tosocket == NULL) {
- throw "ERROR";
- }
- this->m_toSocket = tosocket;
-}
-
-InputSocket *SocketConnection::getToSocket() const { return this->m_toSocket; }
-
-NodeBase *SocketConnection::getFromNode() const
-{
- if (this->getFromSocket() == NULL) {
- return NULL;
- }
- else {
- return this->getFromSocket()->getNode();
- }
-}
-NodeBase *SocketConnection::getToNode() const
-{
- if (this->getToSocket() == NULL) {
- return NULL;
- }
- else {
- return this->getToSocket()->getNode();
- }
-}
-bool SocketConnection::isValid() const
-{
- if ((this->getToSocket() != NULL && this->getFromSocket() != NULL)) {
- if (this->getFromNode()->isOperation() && this->getToNode()->isOperation()) {
- return true;
- }
- }
- return false;
-}
-
-bool SocketConnection::needsResolutionConversion() const
-{
- if (this->m_ignoreResizeCheck) { return false; }
- NodeOperation *fromOperation = (NodeOperation *)this->getFromNode();
- NodeOperation *toOperation = (NodeOperation *)this->getToNode();
- if (this->m_toSocket->getResizeMode() == COM_SC_NO_RESIZE) { return false; }
- const unsigned int fromWidth = fromOperation->getWidth();
- const unsigned int fromHeight = fromOperation->getHeight();
- const unsigned int toWidth = toOperation->getWidth();
- const unsigned int toHeight = toOperation->getHeight();
-
- if (fromWidth == toWidth && fromHeight == toHeight) {
- return false;
- }
- return true;
-}
diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp
index 76a3d92eb6c..d60f9cb7f10 100644
--- a/source/blender/compositor/intern/COM_WorkScheduler.cpp
+++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp
@@ -81,12 +81,17 @@ static int g_highlightIndex;
static void **g_highlightedNodes;
static void **g_highlightedNodesRead;
+/* XXX highlighting disabled for now
+ * This requires pointers back to DNA data (bNodeTree/bNode) in operations, which is bad!
+ * Instead IF we want to keep this feature it should use a weak reference such as bNodeInstanceKey
+ */
+#if 0
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
#define HIGHLIGHT(wp) \
{ \
ExecutionGroup *group = wp->getExecutionGroup(); \
if (group->isComplex()) { \
- NodeOperation *operation = group->getOutputNodeOperation(); \
+ NodeOperation *operation = group->getOutputOperation(); \
if (operation->isWriteBufferOperation()) { \
WriteBufferOperation *writeOperation = (WriteBufferOperation *)operation; \
NodeOperation *complexOperation = writeOperation->getInput(); \
@@ -105,6 +110,9 @@ static void **g_highlightedNodesRead;
} \
}
#endif /* COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE */
+#else
+#define HIGHLIGHT(wp) {}
+#endif
void COM_startReadHighlights()
{
@@ -327,7 +335,7 @@ void WorkScheduler::initialize(bool use_opencl, int num_cpu_threads)
error = clGetPlatformIDs(0, 0, &numberOfPlatforms);
if (error == -1001) { } /* GPU not supported */
else if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
- if (G.f & G_DEBUG) printf("%d number of platforms\n", numberOfPlatforms);
+ if (G.f & G_DEBUG) printf("%u number of platforms\n", numberOfPlatforms);
cl_platform_id *platforms = (cl_platform_id *)MEM_mallocN(sizeof(cl_platform_id) * numberOfPlatforms, __func__);
error = clGetPlatformIDs(numberOfPlatforms, platforms, 0);
unsigned int indexPlatform;
diff --git a/source/blender/compositor/nodes/COM_AlphaOverNode.cpp b/source/blender/compositor/nodes/COM_AlphaOverNode.cpp
index bf081cae097..0306d636c8b 100644
--- a/source/blender/compositor/nodes/COM_AlphaOverNode.cpp
+++ b/source/blender/compositor/nodes/COM_AlphaOverNode.cpp
@@ -27,16 +27,13 @@
#include "COM_AlphaOverMixedOperation.h"
#include "COM_AlphaOverPremultiplyOperation.h"
-#include "COM_ExecutionSystem.h"
#include "COM_SetValueOperation.h"
#include "DNA_material_types.h" // the ramp types
-void AlphaOverNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void AlphaOverNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *valueSocket = this->getInputSocket(0);
- InputSocket *color1Socket = this->getInputSocket(1);
- InputSocket *color2Socket = this->getInputSocket(2);
- OutputSocket *outputSocket = this->getOutputSocket(0);
+ NodeInput *color1Socket = this->getInputSocket(1);
+ NodeInput *color2Socket = this->getInputSocket(2);
bNode *editorNode = this->getbNode();
MixBaseOperation *convertProg;
@@ -55,18 +52,19 @@ void AlphaOverNode::convertToOperations(ExecutionSystem *graph, CompositorContex
}
convertProg->setUseValueAlphaMultiply(false);
- if (color1Socket->isConnected()) {
+ if (color1Socket->isLinked()) {
convertProg->setResolutionInputSocketIndex(1);
}
- else if (color2Socket->isConnected()) {
+ else if (color2Socket->isLinked()) {
convertProg->setResolutionInputSocketIndex(2);
}
else {
convertProg->setResolutionInputSocketIndex(0);
}
- valueSocket->relinkConnections(convertProg->getInputSocket(0), 0, graph);
- color1Socket->relinkConnections(convertProg->getInputSocket(1), 1, graph);
- color2Socket->relinkConnections(convertProg->getInputSocket(2), 2, graph);
- outputSocket->relinkConnections(convertProg->getOutputSocket(0));
- graph->addOperation(convertProg);
+
+ converter.addOperation(convertProg);
+ converter.mapInputSocket(getInputSocket(0), convertProg->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(1), convertProg->getInputSocket(1));
+ converter.mapInputSocket(getInputSocket(2), convertProg->getInputSocket(2));
+ converter.mapOutputSocket(getOutputSocket(0), convertProg->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_AlphaOverNode.h b/source/blender/compositor/nodes/COM_AlphaOverNode.h
index e25e9e11975..45febd62683 100644
--- a/source/blender/compositor/nodes/COM_AlphaOverNode.h
+++ b/source/blender/compositor/nodes/COM_AlphaOverNode.h
@@ -32,7 +32,7 @@
class AlphaOverNode : public Node {
public:
AlphaOverNode(bNode *editorNode) : Node(editorNode) {}
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp b/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp
index 399d2adf0be..90ff4ecf235 100644
--- a/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp
@@ -30,15 +30,15 @@ BilateralBlurNode::BilateralBlurNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void BilateralBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void BilateralBlurNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
NodeBilateralBlurData *data = (NodeBilateralBlurData *)this->getbNode()->storage;
BilateralBlurOperation *operation = new BilateralBlurOperation();
- operation->setbNode(this->getbNode());
- operation->setQuality(context->getQuality());
+ operation->setQuality(context.getQuality());
operation->setData(data);
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
- graph->addOperation(operation);
+
+ converter.addOperation(operation);
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_BilateralBlurNode.h b/source/blender/compositor/nodes/COM_BilateralBlurNode.h
index e6f9242fa32..dfd7361dabe 100644
--- a/source/blender/compositor/nodes/COM_BilateralBlurNode.h
+++ b/source/blender/compositor/nodes/COM_BilateralBlurNode.h
@@ -32,7 +32,7 @@
class BilateralBlurNode : public Node {
public:
BilateralBlurNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_BlurNode.cpp b/source/blender/compositor/nodes/COM_BlurNode.cpp
index a8de2aed526..b8421dcb102 100644
--- a/source/blender/compositor/nodes/COM_BlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_BlurNode.cpp
@@ -38,84 +38,85 @@ BlurNode::BlurNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void BlurNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
bNode *editorNode = this->getbNode();
NodeBlurData *data = (NodeBlurData *)editorNode->storage;
- InputSocket *inputSizeSocket = this->getInputSocket(1);
- bool connectedSizeSocket = inputSizeSocket->isConnected();
+ NodeInput *inputSizeSocket = this->getInputSocket(1);
+ bool connectedSizeSocket = inputSizeSocket->isLinked();
const float size = this->getInputSocket(1)->getEditorValueFloat();
- CompositorQuality quality = context->getQuality();
+ CompositorQuality quality = context.getQuality();
NodeOperation *input_operation = NULL, *output_operation = NULL;
if (data->filtertype == R_FILTER_FAST_GAUSS) {
FastGaussianBlurOperation *operationfgb = new FastGaussianBlurOperation();
operationfgb->setData(data);
- operationfgb->setChunksize(context->getChunksize());
- operationfgb->setbNode(editorNode);
- this->getInputSocket(1)->relinkConnections(operationfgb->getInputSocket(1), 1, graph);
- graph->addOperation(operationfgb);
-
+ operationfgb->setChunksize(context.getChunksize());
+ converter.addOperation(operationfgb);
+
+ converter.mapInputSocket(getInputSocket(1), operationfgb->getInputSocket(1));
+
input_operation = operationfgb;
output_operation = operationfgb;
}
else if (editorNode->custom1 & CMP_NODEFLAG_BLUR_VARIABLE_SIZE) {
MathAddOperation *clamp = new MathAddOperation();
SetValueOperation *zero = new SetValueOperation();
- addLink(graph, zero->getOutputSocket(), clamp->getInputSocket(1));
- this->getInputSocket(1)->relinkConnections(clamp->getInputSocket(0), 1, graph);
zero->setValue(0.0f);
clamp->setUseClamp(true);
- graph->addOperation(clamp);
- graph->addOperation(zero);
-
+
+ converter.addOperation(clamp);
+ converter.addOperation(zero);
+ converter.mapInputSocket(getInputSocket(1), clamp->getInputSocket(0));
+ converter.addLink(zero->getOutputSocket(), clamp->getInputSocket(1));
+
GaussianAlphaXBlurOperation *operationx = new GaussianAlphaXBlurOperation();
operationx->setData(data);
- operationx->setbNode(editorNode);
operationx->setQuality(quality);
operationx->setSize(1.0f);
operationx->setFalloff(PROP_SMOOTH);
operationx->setSubtract(false);
- addLink(graph, clamp->getOutputSocket(), operationx->getInputSocket(0));
- graph->addOperation(operationx);
-
+
+ converter.addOperation(operationx);
+ converter.addLink(clamp->getOutputSocket(), operationx->getInputSocket(0));
+
GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation();
operationy->setData(data);
- operationy->setbNode(editorNode);
operationy->setQuality(quality);
operationy->setSize(1.0f);
operationy->setFalloff(PROP_SMOOTH);
operationy->setSubtract(false);
- addLink(graph, operationx->getOutputSocket(), operationy->getInputSocket(0));
- graph->addOperation(operationy);
-
+
+ converter.addOperation(operationy);
+ converter.addLink(operationx->getOutputSocket(), operationy->getInputSocket(0));
+
GaussianBlurReferenceOperation *operation = new GaussianBlurReferenceOperation();
operation->setData(data);
- operation->setbNode(editorNode);
operation->setQuality(quality);
- addLink(graph, operationy->getOutputSocket(), operation->getInputSocket(1));
- graph->addOperation(operation);
-
+
+ converter.addOperation(operation);
+ converter.addLink(operationy->getOutputSocket(), operation->getInputSocket(1));
+
output_operation = operation;
input_operation = operation;
}
else if (!data->bokeh) {
GaussianXBlurOperation *operationx = new GaussianXBlurOperation();
operationx->setData(data);
- operationx->setbNode(editorNode);
operationx->setQuality(quality);
- this->getInputSocket(1)->relinkConnections(operationx->getInputSocket(1), 1, graph);
- graph->addOperation(operationx);
+
+ converter.addOperation(operationx);
+ converter.mapInputSocket(getInputSocket(1), operationx->getInputSocket(1));
+
GaussianYBlurOperation *operationy = new GaussianYBlurOperation();
operationy->setData(data);
- operationy->setbNode(editorNode);
operationy->setQuality(quality);
- graph->addOperation(operationy);
- addLink(graph, operationx->getOutputSocket(), operationy->getInputSocket(0));
- addLink(graph, operationx->getInputSocket(1)->getConnection()->getFromSocket(), operationy->getInputSocket(1));
+ converter.addOperation(operationy);
+ converter.mapInputSocket(getInputSocket(1), operationy->getInputSocket(1));
+ converter.addLink(operationx->getOutputSocket(), operationy->getInputSocket(0));
if (!connectedSizeSocket) {
operationx->setSize(size);
@@ -128,10 +129,10 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
else {
GaussianBokehBlurOperation *operation = new GaussianBokehBlurOperation();
operation->setData(data);
- operation->setbNode(editorNode);
- this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
operation->setQuality(quality);
- graph->addOperation(operation);
+
+ converter.addOperation(operation);
+ converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
if (!connectedSizeSocket) {
operation->setSize(size);
@@ -144,19 +145,20 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
if (data->gamma) {
GammaCorrectOperation *correct = new GammaCorrectOperation();
GammaUncorrectOperation *inverse = new GammaUncorrectOperation();
-
- this->getInputSocket(0)->relinkConnections(correct->getInputSocket(0), 0, graph);
- addLink(graph, correct->getOutputSocket(), input_operation->getInputSocket(0));
- addLink(graph, output_operation->getOutputSocket(), inverse->getInputSocket(0));
- this->getOutputSocket()->relinkConnections(inverse->getOutputSocket());
- graph->addOperation(correct);
- graph->addOperation(inverse);
-
- addPreviewOperation(graph, context, inverse->getOutputSocket());
+ converter.addOperation(correct);
+ converter.addOperation(inverse);
+
+ converter.mapInputSocket(getInputSocket(0), correct->getInputSocket(0));
+ converter.addLink(correct->getOutputSocket(), input_operation->getInputSocket(0));
+ converter.addLink(output_operation->getOutputSocket(), inverse->getInputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(), inverse->getOutputSocket());
+
+ converter.addPreview(inverse->getOutputSocket());
}
else {
- this->getInputSocket(0)->relinkConnections(input_operation->getInputSocket(0), 0, graph);
- this->getOutputSocket()->relinkConnections(output_operation->getOutputSocket());
- addPreviewOperation(graph, context, output_operation->getOutputSocket());
+ converter.mapInputSocket(getInputSocket(0), input_operation->getInputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(), output_operation->getOutputSocket());
+
+ converter.addPreview(output_operation->getOutputSocket());
}
}
diff --git a/source/blender/compositor/nodes/COM_BlurNode.h b/source/blender/compositor/nodes/COM_BlurNode.h
index 95b0516dae0..68844ca3d78 100644
--- a/source/blender/compositor/nodes/COM_BlurNode.h
+++ b/source/blender/compositor/nodes/COM_BlurNode.h
@@ -32,7 +32,7 @@
class BlurNode : public Node {
public:
BlurNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_BokehBlurNode.cpp b/source/blender/compositor/nodes/COM_BokehBlurNode.cpp
index 5725bc6cb32..636660bc96c 100644
--- a/source/blender/compositor/nodes/COM_BokehBlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_BokehBlurNode.cpp
@@ -34,40 +34,37 @@ BokehBlurNode::BokehBlurNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void BokehBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void BokehBlurNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
bNode *b_node = this->getbNode();
- InputSocket *inputSizeSocket = this->getInputSocket(2);
+ NodeInput *inputSizeSocket = this->getInputSocket(2);
- bool connectedSizeSocket = inputSizeSocket->isConnected();
+ bool connectedSizeSocket = inputSizeSocket->isLinked();
if ((b_node->custom1 & CMP_NODEFLAG_BLUR_VARIABLE_SIZE) && connectedSizeSocket) {
VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation();
-
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
- this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), 2, graph);
- operation->setQuality(context->getQuality());
- operation->setbNode(this->getbNode());
- graph->addOperation(operation);
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
-
+ operation->setQuality(context.getQuality());
operation->setThreshold(0.0f);
operation->setMaxBlur(b_node->custom4);
operation->setDoScaleSize(true);
+
+ converter.addOperation(operation);
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
+ converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
}
else {
BokehBlurOperation *operation = new BokehBlurOperation();
-
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
- this->getInputSocket(2)->relinkConnections(operation->getInputSocket(3), 2, graph);
- this->getInputSocket(3)->relinkConnections(operation->getInputSocket(2), 3, graph);
- operation->setQuality(context->getQuality());
- operation->setbNode(this->getbNode());
- graph->addOperation(operation);
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
+ operation->setQuality(context.getQuality());
+
+ converter.addOperation(operation);
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
+ converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2));
+ converter.mapInputSocket(getInputSocket(3), operation->getInputSocket(3));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
if (!connectedSizeSocket) {
operation->setSize(this->getInputSocket(2)->getEditorValueFloat());
diff --git a/source/blender/compositor/nodes/COM_BokehBlurNode.h b/source/blender/compositor/nodes/COM_BokehBlurNode.h
index c2bc7552ac0..60ba79bed78 100644
--- a/source/blender/compositor/nodes/COM_BokehBlurNode.h
+++ b/source/blender/compositor/nodes/COM_BokehBlurNode.h
@@ -32,7 +32,7 @@
class BokehBlurNode : public Node {
public:
BokehBlurNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_BokehImageNode.cpp b/source/blender/compositor/nodes/COM_BokehImageNode.cpp
index a89ed9e0c64..c75e9b16336 100644
--- a/source/blender/compositor/nodes/COM_BokehImageNode.cpp
+++ b/source/blender/compositor/nodes/COM_BokehImageNode.cpp
@@ -29,11 +29,13 @@ BokehImageNode::BokehImageNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void BokehImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void BokehImageNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
BokehImageOperation *operation = new BokehImageOperation();
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
operation->setData((NodeBokehImage *)this->getbNode()->storage);
- addPreviewOperation(graph, context, operation->getOutputSocket(0));
+
+ converter.addOperation(operation);
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
+
+ converter.addPreview(operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_BokehImageNode.h b/source/blender/compositor/nodes/COM_BokehImageNode.h
index a4bfe2bedc0..6768bf0e88f 100644
--- a/source/blender/compositor/nodes/COM_BokehImageNode.h
+++ b/source/blender/compositor/nodes/COM_BokehImageNode.h
@@ -32,7 +32,7 @@
class BokehImageNode : public Node {
public:
BokehImageNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_BoxMaskNode.cpp b/source/blender/compositor/nodes/COM_BoxMaskNode.cpp
index e3fb6ecc704..b8bf23b8549 100644
--- a/source/blender/compositor/nodes/COM_BoxMaskNode.cpp
+++ b/source/blender/compositor/nodes/COM_BoxMaskNode.cpp
@@ -32,47 +32,43 @@ BoxMaskNode::BoxMaskNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void BoxMaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void BoxMaskNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
+ NodeInput *inputSocket = this->getInputSocket(0);
+ NodeOutput *outputSocket = this->getOutputSocket(0);
+
BoxMaskOperation *operation;
operation = new BoxMaskOperation();
operation->setData((NodeBoxMask *)this->getbNode()->storage);
-
- InputSocket *inputSocket = this->getInputSocket(0);
- OutputSocket *outputSocket = this->getOutputSocket(0);
-
- if (inputSocket->isConnected()) {
- inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
- outputSocket->relinkConnections(operation->getOutputSocket());
+ operation->setMaskType(this->getbNode()->custom1);
+ converter.addOperation(operation);
+
+ if (inputSocket->isLinked()) {
+ converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket());
}
else {
/* Value operation to produce original transparent image */
SetValueOperation *valueOperation = new SetValueOperation();
valueOperation->setValue(0.0f);
- graph->addOperation(valueOperation);
+ converter.addOperation(valueOperation);
/* Scale that image up to render resolution */
- const RenderData *rd = context->getRenderData();
+ const RenderData *rd = context.getRenderData();
ScaleFixedSizeOperation *scaleOperation = new ScaleFixedSizeOperation();
scaleOperation->setIsAspect(false);
scaleOperation->setIsCrop(false);
scaleOperation->setOffset(0.0f, 0.0f);
-
scaleOperation->setNewWidth(rd->xsch * rd->size / 100.0f);
scaleOperation->setNewHeight(rd->ysch * rd->size / 100.0f);
+ scaleOperation->getInputSocket(0)->setResizeMode(COM_SC_NO_RESIZE);
+ converter.addOperation(scaleOperation);
- addLink(graph, valueOperation->getOutputSocket(0), scaleOperation->getInputSocket(0));
- addLink(graph, scaleOperation->getOutputSocket(0), operation->getInputSocket(0));
- outputSocket->relinkConnections(operation->getOutputSocket(0));
-
- scaleOperation->getInputSocket(0)->getConnection()->setIgnoreResizeCheck(true);
-
- graph->addOperation(scaleOperation);
+ converter.addLink(valueOperation->getOutputSocket(0), scaleOperation->getInputSocket(0));
+ converter.addLink(scaleOperation->getOutputSocket(0), operation->getInputSocket(0));
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
}
- this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
- operation->setMaskType(this->getbNode()->custom1);
-
- graph->addOperation(operation);
+ converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
}
diff --git a/source/blender/compositor/nodes/COM_BoxMaskNode.h b/source/blender/compositor/nodes/COM_BoxMaskNode.h
index 9ebe2cc755a..3f466ef798e 100644
--- a/source/blender/compositor/nodes/COM_BoxMaskNode.h
+++ b/source/blender/compositor/nodes/COM_BoxMaskNode.h
@@ -32,7 +32,7 @@
class BoxMaskNode : public Node {
public:
BoxMaskNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_BrightnessNode.cpp b/source/blender/compositor/nodes/COM_BrightnessNode.cpp
index cd230a23a5c..e684b569945 100644
--- a/source/blender/compositor/nodes/COM_BrightnessNode.cpp
+++ b/source/blender/compositor/nodes/COM_BrightnessNode.cpp
@@ -29,12 +29,13 @@ BrightnessNode::BrightnessNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void BrightnessNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void BrightnessNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
BrightnessOperation *operation = new BrightnessOperation();
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
- this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), 2, graph);
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
+ converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_BrightnessNode.h b/source/blender/compositor/nodes/COM_BrightnessNode.h
index a10372049f0..bd414b84e95 100644
--- a/source/blender/compositor/nodes/COM_BrightnessNode.h
+++ b/source/blender/compositor/nodes/COM_BrightnessNode.h
@@ -32,7 +32,7 @@
class BrightnessNode : public Node {
public:
BrightnessNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp b/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
index 4c136583936..f356c74cd49 100644
--- a/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
@@ -30,15 +30,15 @@ ChannelMatteNode::ChannelMatteNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void ChannelMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void ChannelMatteNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *inputSocketImage = this->getInputSocket(0);
- OutputSocket *outputSocketImage = this->getOutputSocket(0);
- OutputSocket *outputSocketMatte = this->getOutputSocket(1);
-
- NodeOperation *convert = NULL;
bNode *node = this->getbNode();
-
+
+ NodeInput *inputSocketImage = this->getInputSocket(0);
+ NodeOutput *outputSocketImage = this->getOutputSocket(0);
+ NodeOutput *outputSocketMatte = this->getOutputSocket(1);
+
+ NodeOperation *convert = NULL;
/* colorspace */
switch (node->custom1) {
case CMP_NODE_CHANNEL_MATTE_CS_RGB:
@@ -56,35 +56,31 @@ void ChannelMatteNode::convertToOperations(ExecutionSystem *graph, CompositorCon
default:
break;
}
-
+
ChannelMatteOperation *operation = new ChannelMatteOperation();
/* pass the ui properties to the operation */
operation->setSettings((NodeChroma *)node->storage, node->custom2);
-
+ converter.addOperation(operation);
+
SetAlphaOperation *operationAlpha = new SetAlphaOperation();
-
+ converter.addOperation(operationAlpha);
+
if (convert) {
- inputSocketImage->relinkConnections(convert->getInputSocket(0), 0, graph);
- addLink(graph, convert->getOutputSocket(), operation->getInputSocket(0));
- addLink(graph, convert->getInputSocket(0)->getConnection()->getFromSocket(), operationAlpha->getInputSocket(0));
- graph->addOperation(convert);
+ converter.addOperation(convert);
+
+ converter.mapInputSocket(inputSocketImage, convert->getInputSocket(0));
+ converter.addLink(convert->getOutputSocket(), operation->getInputSocket(0));
+ converter.addLink(convert->getOutputSocket(), operationAlpha->getInputSocket(0));
}
else {
- inputSocketImage->relinkConnections(operation->getInputSocket(0), 0, graph);
- addLink(graph, operation->getInputSocket(0)->getConnection()->getFromSocket(), operationAlpha->getInputSocket(0));
- }
-
- if (outputSocketMatte->isConnected()) {
- outputSocketMatte->relinkConnections(operation->getOutputSocket(0));
- }
-
- graph->addOperation(operation);
- graph->addOperation(operationAlpha);
-
- addLink(graph, operation->getOutputSocket(), operationAlpha->getInputSocket(1));
- addPreviewOperation(graph, context, operationAlpha->getOutputSocket());
-
- if (outputSocketImage->isConnected()) {
- outputSocketImage->relinkConnections(operationAlpha->getOutputSocket());
+ converter.mapInputSocket(inputSocketImage, operation->getInputSocket(0));
+ converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0));
}
+
+ converter.mapOutputSocket(outputSocketMatte, operation->getOutputSocket(0));
+
+ converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1));
+ converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket());
+
+ converter.addPreview(operationAlpha->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_ChannelMatteNode.h b/source/blender/compositor/nodes/COM_ChannelMatteNode.h
index 29c6000a245..f528578e6dd 100644
--- a/source/blender/compositor/nodes/COM_ChannelMatteNode.h
+++ b/source/blender/compositor/nodes/COM_ChannelMatteNode.h
@@ -31,7 +31,7 @@
class ChannelMatteNode : public Node {
public:
ChannelMatteNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif /* COM_ChannelMatteNODE_H */
diff --git a/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp b/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp
index c23f242ca5c..90de9358587 100644
--- a/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp
@@ -30,44 +30,38 @@ ChromaMatteNode::ChromaMatteNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void ChromaMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void ChromaMatteNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *inputSocketImage = this->getInputSocket(0);
- InputSocket *inputSocketKey = this->getInputSocket(1);
- OutputSocket *outputSocketImage = this->getOutputSocket(0);
- OutputSocket *outputSocketMatte = this->getOutputSocket(1);
-
+ bNode *editorsnode = getbNode();
+
+ NodeInput *inputSocketImage = this->getInputSocket(0);
+ NodeInput *inputSocketKey = this->getInputSocket(1);
+ NodeOutput *outputSocketImage = this->getOutputSocket(0);
+ NodeOutput *outputSocketMatte = this->getOutputSocket(1);
+
ConvertRGBToYCCOperation *operationRGBToYCC_Image = new ConvertRGBToYCCOperation();
ConvertRGBToYCCOperation *operationRGBToYCC_Key = new ConvertRGBToYCCOperation();
operationRGBToYCC_Image->setMode(0); /* BLI_YCC_ITU_BT601 */
operationRGBToYCC_Key->setMode(0); /* BLI_YCC_ITU_BT601 */
-
+ converter.addOperation(operationRGBToYCC_Image);
+ converter.addOperation(operationRGBToYCC_Key);
+
ChromaMatteOperation *operation = new ChromaMatteOperation();
- bNode *editorsnode = getbNode();
operation->setSettings((NodeChroma *)editorsnode->storage);
-
- inputSocketImage->relinkConnections(operationRGBToYCC_Image->getInputSocket(0), 0, graph);
- inputSocketKey->relinkConnections(operationRGBToYCC_Key->getInputSocket(0), 1, graph);
-
- addLink(graph, operationRGBToYCC_Image->getOutputSocket(), operation->getInputSocket(0));
- addLink(graph, operationRGBToYCC_Key->getOutputSocket(), operation->getInputSocket(1));
-
- graph->addOperation(operationRGBToYCC_Image);
- graph->addOperation(operationRGBToYCC_Key);
- graph->addOperation(operation);
-
- if (outputSocketMatte->isConnected()) {
- outputSocketMatte->relinkConnections(operation->getOutputSocket());
- }
-
+ converter.addOperation(operation);
+
SetAlphaOperation *operationAlpha = new SetAlphaOperation();
- addLink(graph, operationRGBToYCC_Image->getInputSocket(0)->getConnection()->getFromSocket(), operationAlpha->getInputSocket(0));
- addLink(graph, operation->getOutputSocket(), operationAlpha->getInputSocket(1));
-
- graph->addOperation(operationAlpha);
- addPreviewOperation(graph, context, operationAlpha->getOutputSocket());
-
- if (outputSocketImage->isConnected()) {
- outputSocketImage->relinkConnections(operationAlpha->getOutputSocket());
- }
+ converter.addOperation(operationAlpha);
+
+ converter.mapInputSocket(inputSocketImage, operationRGBToYCC_Image->getInputSocket(0));
+ converter.mapInputSocket(inputSocketKey, operationRGBToYCC_Key->getInputSocket(0));
+ converter.addLink(operationRGBToYCC_Image->getOutputSocket(), operation->getInputSocket(0));
+ converter.addLink(operationRGBToYCC_Key->getOutputSocket(), operation->getInputSocket(1));
+ converter.mapOutputSocket(outputSocketMatte, operation->getOutputSocket());
+
+ converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0));
+ converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1));
+ converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket());
+
+ converter.addPreview(operationAlpha->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_ChromaMatteNode.h b/source/blender/compositor/nodes/COM_ChromaMatteNode.h
index bf5302ccdbb..d1eb3a907ef 100644
--- a/source/blender/compositor/nodes/COM_ChromaMatteNode.h
+++ b/source/blender/compositor/nodes/COM_ChromaMatteNode.h
@@ -31,7 +31,7 @@
class ChromaMatteNode : public Node {
public:
ChromaMatteNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif /* COM_ChromaMatteNODE_H */
diff --git a/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp b/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp
index 2b396fb9861..fc0df046e86 100644
--- a/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp
@@ -32,14 +32,15 @@ ColorBalanceNode::ColorBalanceNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void ColorBalanceNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void ColorBalanceNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *inputSocket = this->getInputSocket(0);
- InputSocket *inputImageSocket = this->getInputSocket(1);
- OutputSocket *outputSocket = this->getOutputSocket(0);
-
bNode *node = this->getbNode();
NodeColorBalance *n = (NodeColorBalance *)node->storage;
+
+ NodeInput *inputSocket = this->getInputSocket(0);
+ NodeInput *inputImageSocket = this->getInputSocket(1);
+ NodeOutput *outputSocket = this->getOutputSocket(0);
+
NodeOperation *operation;
if (node->custom1 == 0) {
ColorBalanceLGGOperation *operationLGG = new ColorBalanceLGGOperation();
@@ -62,9 +63,9 @@ void ColorBalanceNode::convertToOperations(ExecutionSystem *graph, CompositorCon
operationCDL->setSlope(n->slope);
operation = operationCDL;
}
+ converter.addOperation(operation);
- inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
- inputImageSocket->relinkConnections(operation->getInputSocket(1), 1, graph);
- outputSocket->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
+ converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
+ converter.mapInputSocket(inputImageSocket, operation->getInputSocket(1));
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_ColorBalanceNode.h b/source/blender/compositor/nodes/COM_ColorBalanceNode.h
index 30d22ef2e63..f0b9694ec77 100644
--- a/source/blender/compositor/nodes/COM_ColorBalanceNode.h
+++ b/source/blender/compositor/nodes/COM_ColorBalanceNode.h
@@ -32,7 +32,7 @@
class ColorBalanceNode : public Node {
public:
ColorBalanceNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif /* COM_ColorBalanceNODE_H */
diff --git a/source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp b/source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp
index a05abaf17d3..728b51b8dc1 100644
--- a/source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp
@@ -29,16 +29,18 @@ ColorCorrectionNode::ColorCorrectionNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void ColorCorrectionNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void ColorCorrectionNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- ColorCorrectionOperation *operation = new ColorCorrectionOperation();
bNode *editorNode = getbNode();
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
+
+ ColorCorrectionOperation *operation = new ColorCorrectionOperation();
operation->setData((NodeColorCorrection *)editorNode->storage);
operation->setRedChannelEnabled((editorNode->custom1 & 1) > 0);
operation->setGreenChannelEnabled((editorNode->custom1 & 2) > 0);
operation->setBlueChannelEnabled((editorNode->custom1 & 4) > 0);
- graph->addOperation(operation);
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_ColorCorrectionNode.h b/source/blender/compositor/nodes/COM_ColorCorrectionNode.h
index f1b0f69bec5..aa2c475734d 100644
--- a/source/blender/compositor/nodes/COM_ColorCorrectionNode.h
+++ b/source/blender/compositor/nodes/COM_ColorCorrectionNode.h
@@ -32,7 +32,7 @@
class ColorCorrectionNode : public Node {
public:
ColorCorrectionNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ColorCurveNode.cpp b/source/blender/compositor/nodes/COM_ColorCurveNode.cpp
index 103fbf26c7d..6dc936302f4 100644
--- a/source/blender/compositor/nodes/COM_ColorCurveNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorCurveNode.cpp
@@ -29,36 +29,32 @@ ColorCurveNode::ColorCurveNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void ColorCurveNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void ColorCurveNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- if (this->getInputSocket(2)->isConnected() || this->getInputSocket(3)->isConnected()) {
+ if (this->getInputSocket(2)->isLinked() || this->getInputSocket(3)->isLinked()) {
ColorCurveOperation *operation = new ColorCurveOperation();
-
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
- this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), 2, graph);
- this->getInputSocket(3)->relinkConnections(operation->getInputSocket(3), 3, graph);
-
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
-
operation->setCurveMapping((CurveMapping *)this->getbNode()->storage);
-
- graph->addOperation(operation);
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
+ converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2));
+ converter.mapInputSocket(getInputSocket(3), operation->getInputSocket(3));
+
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
}
else {
ConstantLevelColorCurveOperation *operation = new ConstantLevelColorCurveOperation();
-
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
float col[4];
this->getInputSocket(2)->getEditorValueColor(col);
operation->setBlackLevel(col);
this->getInputSocket(3)->getEditorValueColor(col);
operation->setWhiteLevel(col);
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
-
operation->setCurveMapping((CurveMapping *)this->getbNode()->storage);
-
- graph->addOperation(operation);
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
}
}
diff --git a/source/blender/compositor/nodes/COM_ColorCurveNode.h b/source/blender/compositor/nodes/COM_ColorCurveNode.h
index ecfae1f86f8..5420058ea64 100644
--- a/source/blender/compositor/nodes/COM_ColorCurveNode.h
+++ b/source/blender/compositor/nodes/COM_ColorCurveNode.h
@@ -32,7 +32,7 @@
class ColorCurveNode : public Node {
public:
ColorCurveNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ColorMatteNode.cpp b/source/blender/compositor/nodes/COM_ColorMatteNode.cpp
index 8ab93a58a1d..def3b18e0fe 100644
--- a/source/blender/compositor/nodes/COM_ColorMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorMatteNode.cpp
@@ -30,41 +30,36 @@ ColorMatteNode::ColorMatteNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void ColorMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void ColorMatteNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *inputSocketImage = this->getInputSocket(0);
- InputSocket *inputSocketKey = this->getInputSocket(1);
- OutputSocket *outputSocketImage = this->getOutputSocket(0);
- OutputSocket *outputSocketMatte = this->getOutputSocket(1);
-
+ bNode *editorsnode = getbNode();
+
+ NodeInput *inputSocketImage = this->getInputSocket(0);
+ NodeInput *inputSocketKey = this->getInputSocket(1);
+ NodeOutput *outputSocketImage = this->getOutputSocket(0);
+ NodeOutput *outputSocketMatte = this->getOutputSocket(1);
+
ConvertRGBToHSVOperation *operationRGBToHSV_Image = new ConvertRGBToHSVOperation();
ConvertRGBToHSVOperation *operationRGBToHSV_Key = new ConvertRGBToHSVOperation();
-
+ converter.addOperation(operationRGBToHSV_Image);
+ converter.addOperation(operationRGBToHSV_Key);
+
ColorMatteOperation *operation = new ColorMatteOperation();
- bNode *editorsnode = getbNode();
operation->setSettings((NodeChroma *)editorsnode->storage);
-
- inputSocketImage->relinkConnections(operationRGBToHSV_Image->getInputSocket(0), 0, graph);
- inputSocketKey->relinkConnections(operationRGBToHSV_Key->getInputSocket(0), 1, graph);
-
- addLink(graph, operationRGBToHSV_Image->getOutputSocket(), operation->getInputSocket(0));
- addLink(graph, operationRGBToHSV_Key->getOutputSocket(), operation->getInputSocket(1));
-
- if (outputSocketMatte->isConnected()) {
- outputSocketMatte->relinkConnections(operation->getOutputSocket(0));
- }
-
- graph->addOperation(operationRGBToHSV_Image);
- graph->addOperation(operationRGBToHSV_Key);
- graph->addOperation(operation);
-
+ converter.addOperation(operation);
+
SetAlphaOperation *operationAlpha = new SetAlphaOperation();
- addLink(graph, operationRGBToHSV_Image->getInputSocket(0)->getConnection()->getFromSocket(), operationAlpha->getInputSocket(0));
- addLink(graph, operation->getOutputSocket(), operationAlpha->getInputSocket(1));
- graph->addOperation(operationAlpha);
- addPreviewOperation(graph, context, operationAlpha->getOutputSocket());
-
- if (outputSocketImage->isConnected()) {
- outputSocketImage->relinkConnections(operationAlpha->getOutputSocket());
- }
+ converter.addOperation(operationAlpha);
+
+ converter.mapInputSocket(inputSocketImage, operationRGBToHSV_Image->getInputSocket(0));
+ converter.mapInputSocket(inputSocketKey, operationRGBToHSV_Key->getInputSocket(0));
+ converter.addLink(operationRGBToHSV_Image->getOutputSocket(), operation->getInputSocket(0));
+ converter.addLink(operationRGBToHSV_Key->getOutputSocket(), operation->getInputSocket(1));
+ converter.mapOutputSocket(outputSocketMatte, operation->getOutputSocket(0));
+
+ converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0));
+ converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1));
+ converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket());
+
+ converter.addPreview(operationAlpha->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_ColorMatteNode.h b/source/blender/compositor/nodes/COM_ColorMatteNode.h
index 3386476bc85..c17d3eb6c4e 100644
--- a/source/blender/compositor/nodes/COM_ColorMatteNode.h
+++ b/source/blender/compositor/nodes/COM_ColorMatteNode.h
@@ -31,7 +31,7 @@
class ColorMatteNode : public Node {
public:
ColorMatteNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif /* COM_ColorMatteNODE_H */
diff --git a/source/blender/compositor/nodes/COM_ColorNode.cpp b/source/blender/compositor/nodes/COM_ColorNode.cpp
index fc2566e5a47..4106cb64798 100644
--- a/source/blender/compositor/nodes/COM_ColorNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorNode.cpp
@@ -29,13 +29,14 @@ ColorNode::ColorNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void ColorNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void ColorNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
SetColorOperation *operation = new SetColorOperation();
- OutputSocket *output = this->getOutputSocket(0);
- output->relinkConnections(operation->getOutputSocket());
+ NodeOutput *output = this->getOutputSocket(0);
float col[4];
output->getEditorValueColor(col);
operation->setChannels(col);
- graph->addOperation(operation);
+ converter.addOperation(operation);
+
+ converter.mapOutputSocket(output, operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_ColorNode.h b/source/blender/compositor/nodes/COM_ColorNode.h
index 3e3df63e90a..ac8c6c221b9 100644
--- a/source/blender/compositor/nodes/COM_ColorNode.h
+++ b/source/blender/compositor/nodes/COM_ColorNode.h
@@ -32,7 +32,7 @@
class ColorNode : public Node {
public:
ColorNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ColorRampNode.cpp b/source/blender/compositor/nodes/COM_ColorRampNode.cpp
index 6f715a8f278..a61ddffbf35 100644
--- a/source/blender/compositor/nodes/COM_ColorRampNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorRampNode.cpp
@@ -32,23 +32,24 @@ ColorRampNode::ColorRampNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void ColorRampNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void ColorRampNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *inputSocket = this->getInputSocket(0);
- OutputSocket *outputSocket = this->getOutputSocket(0);
- OutputSocket *outputSocketAlpha = this->getOutputSocket(1);
+ NodeInput *inputSocket = this->getInputSocket(0);
+ NodeOutput *outputSocket = this->getOutputSocket(0);
+ NodeOutput *outputSocketAlpha = this->getOutputSocket(1);
bNode *editorNode = this->getbNode();
ColorRampOperation *operation = new ColorRampOperation();
- outputSocket->relinkConnections(operation->getOutputSocket(0));
- if (outputSocketAlpha->isConnected()) {
- SeparateChannelOperation *operation2 = new SeparateChannelOperation();
- outputSocketAlpha->relinkConnections(operation2->getOutputSocket());
- addLink(graph, operation->getOutputSocket(), operation2->getInputSocket(0));
- operation2->setChannel(3);
- graph->addOperation(operation2);
- }
operation->setColorBand((ColorBand *)editorNode->storage);
- inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
- graph->addOperation(operation);
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
+
+ SeparateChannelOperation *operation2 = new SeparateChannelOperation();
+ operation2->setChannel(3);
+ converter.addOperation(operation2);
+
+ converter.addLink(operation->getOutputSocket(), operation2->getInputSocket(0));
+ converter.mapOutputSocket(outputSocketAlpha, operation2->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_ColorRampNode.h b/source/blender/compositor/nodes/COM_ColorRampNode.h
index 3f00e1c2190..d303616a417 100644
--- a/source/blender/compositor/nodes/COM_ColorRampNode.h
+++ b/source/blender/compositor/nodes/COM_ColorRampNode.h
@@ -32,7 +32,7 @@
class ColorRampNode : public Node {
public:
ColorRampNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif /* COM_ColorRampNODE_H */
diff --git a/source/blender/compositor/nodes/COM_ColorSpillNode.cpp b/source/blender/compositor/nodes/COM_ColorSpillNode.cpp
index 0e586955ff8..82454ba7979 100644
--- a/source/blender/compositor/nodes/COM_ColorSpillNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorSpillNode.cpp
@@ -29,14 +29,13 @@ ColorSpillNode::ColorSpillNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void ColorSpillNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void ColorSpillNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *inputSocketImage = this->getInputSocket(0);
- InputSocket *inputSocketFac = this->getInputSocket(1);
- OutputSocket *outputSocketImage = this->getOutputSocket(0);
-
bNode *editorsnode = getbNode();
-
+
+ NodeInput *inputSocketImage = this->getInputSocket(0);
+ NodeInput *inputSocketFac = this->getInputSocket(1);
+ NodeOutput *outputSocketImage = this->getOutputSocket(0);
ColorSpillOperation *operation;
if (editorsnode->custom2 == 0) {
@@ -49,11 +48,9 @@ void ColorSpillNode::convertToOperations(ExecutionSystem *graph, CompositorConte
}
operation->setSettings((NodeColorspill *)editorsnode->storage);
operation->setSpillChannel(editorsnode->custom1 - 1); // Channel for spilling
+ converter.addOperation(operation);
-
- inputSocketImage->relinkConnections(operation->getInputSocket(0), 0, graph);
- inputSocketFac->relinkConnections(operation->getInputSocket(1), 1, graph);
-
- outputSocketImage->relinkConnections(operation->getOutputSocket());
- graph->addOperation(operation);
+ converter.mapInputSocket(inputSocketImage, operation->getInputSocket(0));
+ converter.mapInputSocket(inputSocketFac, operation->getInputSocket(1));
+ converter.mapOutputSocket(outputSocketImage, operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_ColorSpillNode.h b/source/blender/compositor/nodes/COM_ColorSpillNode.h
index 01722fac826..7442d2b0261 100644
--- a/source/blender/compositor/nodes/COM_ColorSpillNode.h
+++ b/source/blender/compositor/nodes/COM_ColorSpillNode.h
@@ -32,7 +32,7 @@
class ColorSpillNode : public Node {
public:
ColorSpillNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif /* COM_ColorSpillNODE_H */
diff --git a/source/blender/compositor/nodes/COM_ColorToBWNode.cpp b/source/blender/compositor/nodes/COM_ColorToBWNode.cpp
index 07be93dab86..a1616a61b4b 100644
--- a/source/blender/compositor/nodes/COM_ColorToBWNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorToBWNode.cpp
@@ -30,13 +30,14 @@ ColorToBWNode::ColorToBWNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void ColorToBWNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void ColorToBWNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *colorSocket = this->getInputSocket(0);
- OutputSocket *valueSocket = this->getOutputSocket(0);
+ NodeInput *colorSocket = this->getInputSocket(0);
+ NodeOutput *valueSocket = this->getOutputSocket(0);
ConvertColorToBWOperation *convertProg = new ConvertColorToBWOperation();
- colorSocket->relinkConnections(convertProg->getInputSocket(0), 0, graph);
- valueSocket->relinkConnections(convertProg->getOutputSocket(0));
- graph->addOperation(convertProg);
+ converter.addOperation(convertProg);
+
+ converter.mapInputSocket(colorSocket, convertProg->getInputSocket(0));
+ converter.mapOutputSocket(valueSocket, convertProg->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_ColorToBWNode.h b/source/blender/compositor/nodes/COM_ColorToBWNode.h
index f21c6ecef52..6932c153c0c 100644
--- a/source/blender/compositor/nodes/COM_ColorToBWNode.h
+++ b/source/blender/compositor/nodes/COM_ColorToBWNode.h
@@ -32,6 +32,6 @@
class ColorToBWNode : public Node {
public:
ColorToBWNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_CombineColorNode.cpp b/source/blender/compositor/nodes/COM_CombineColorNode.cpp
new file mode 100644
index 00000000000..c7a3baf809d
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_CombineColorNode.cpp
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the 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:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Lukas Toenne
+ */
+
+#include "COM_CombineColorNode.h"
+
+#include "COM_ConvertOperation.h"
+
+
+CombineColorNode::CombineColorNode(bNode *editorNode) :
+ Node(editorNode)
+{
+}
+
+void CombineColorNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+{
+ NodeInput *inputRSocket = this->getInputSocket(0);
+ NodeInput *inputGSocket = this->getInputSocket(1);
+ NodeInput *inputBSocket = this->getInputSocket(2);
+ NodeInput *inputASocket = this->getInputSocket(3);
+ NodeOutput *outputSocket = this->getOutputSocket(0);
+
+ CombineChannelsOperation *operation = new CombineChannelsOperation();
+ if (inputRSocket->isLinked()) {
+ operation->setResolutionInputSocketIndex(0);
+ }
+ else if (inputGSocket->isLinked()) {
+ operation->setResolutionInputSocketIndex(1);
+ }
+ else if (inputBSocket->isLinked()) {
+ operation->setResolutionInputSocketIndex(2);
+ }
+ else {
+ operation->setResolutionInputSocketIndex(3);
+ }
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(inputRSocket, operation->getInputSocket(0));
+ converter.mapInputSocket(inputGSocket, operation->getInputSocket(1));
+ converter.mapInputSocket(inputBSocket, operation->getInputSocket(2));
+ converter.mapInputSocket(inputASocket, operation->getInputSocket(3));
+
+ NodeOperation *color_conv = getColorConverter(context);
+ if (color_conv) {
+ converter.addOperation(color_conv);
+
+ converter.addLink(operation->getOutputSocket(), color_conv->getInputSocket(0));
+ converter.mapOutputSocket(outputSocket, color_conv->getOutputSocket());
+ }
+ else {
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket());
+ }
+}
+
+
+NodeOperation *CombineRGBANode::getColorConverter(const CompositorContext &context) const
+{
+ return NULL; /* no conversion needed */
+}
+
+NodeOperation *CombineHSVANode::getColorConverter(const CompositorContext &context) const
+{
+ return new ConvertHSVToRGBOperation();
+}
+
+NodeOperation *CombineYCCANode::getColorConverter(const CompositorContext &context) const
+{
+ ConvertYCCToRGBOperation *operation = new ConvertYCCToRGBOperation();
+ bNode *editorNode = this->getbNode();
+ operation->setMode(editorNode->custom1);
+ return operation;
+}
+
+NodeOperation *CombineYUVANode::getColorConverter(const CompositorContext &context) const
+{
+ return new ConvertYUVToRGBOperation();
+}
diff --git a/source/blender/compositor/nodes/COM_CombineColorNode.h b/source/blender/compositor/nodes/COM_CombineColorNode.h
new file mode 100644
index 00000000000..2eff1a28f20
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_CombineColorNode.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the 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:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Lukas Toenne
+ */
+
+#ifndef _COM_CombineColorNode_h_
+#define _COM_CombineColorNode_h_
+
+#include "COM_Node.h"
+
+class CombineColorNode : public Node {
+public:
+ CombineColorNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+
+protected:
+ virtual NodeOperation *getColorConverter(const CompositorContext &context) const = 0;
+};
+
+class CombineRGBANode : public CombineColorNode {
+public:
+ CombineRGBANode(bNode *editorNode) :
+ CombineColorNode(editorNode)
+ {}
+
+ NodeOperation *getColorConverter(const CompositorContext &context) const;
+};
+
+class CombineHSVANode : public CombineColorNode {
+public:
+ CombineHSVANode(bNode *editorNode) :
+ CombineColorNode(editorNode)
+ {}
+
+ NodeOperation *getColorConverter(const CompositorContext &context) const;
+};
+
+class CombineYCCANode : public CombineColorNode {
+public:
+ CombineYCCANode(bNode *editorNode) :
+ CombineColorNode(editorNode)
+ {}
+
+ NodeOperation *getColorConverter(const CompositorContext &context) const;
+};
+
+class CombineYUVANode : public CombineColorNode {
+public:
+ CombineYUVANode(bNode *editorNode) :
+ CombineColorNode(editorNode)
+ {}
+
+ NodeOperation *getColorConverter(const CompositorContext &context) const;
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_CombineHSVANode.cpp b/source/blender/compositor/nodes/COM_CombineHSVANode.cpp
deleted file mode 100644
index 9f6614ed8c3..00000000000
--- a/source/blender/compositor/nodes/COM_CombineHSVANode.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the 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:
- * Jeroen Bakker
- * Monique Dewanchand
- */
-
-#include "COM_CombineHSVANode.h"
-
-#include "COM_ConvertOperation.h"
-
-#include "COM_ExecutionSystem.h"
-#include "COM_SetValueOperation.h"
-#include "COM_ConvertOperation.h"
-
-CombineHSVANode::CombineHSVANode(bNode *editorNode) : CombineRGBANode(editorNode)
-{
- /* pass */
-}
-
-void CombineHSVANode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
-{
- ConvertHSVToRGBOperation *operation = new ConvertHSVToRGBOperation();
- OutputSocket *outputSocket = this->getOutputSocket(0);
- if (outputSocket->isConnected()) {
- outputSocket->relinkConnections(operation->getOutputSocket());
- addLink(graph, outputSocket, operation->getInputSocket(0));
- }
- graph->addOperation(operation);
- CombineRGBANode::convertToOperations(graph, context);
-}
diff --git a/source/blender/compositor/nodes/COM_CombineHSVANode.h b/source/blender/compositor/nodes/COM_CombineHSVANode.h
deleted file mode 100644
index 95d3cf9ecdd..00000000000
--- a/source/blender/compositor/nodes/COM_CombineHSVANode.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the 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:
- * Jeroen Bakker
- * Monique Dewanchand
- */
-
-#ifndef _COM_CombineHSVANode_h_
-#define _COM_CombineHSVANode_h_
-
-#include "COM_Node.h"
-#include "DNA_node_types.h"
-#include "COM_CombineRGBANode.h"
-/**
- * @brief CombineHSVANode
- * @ingroup Node
- */
-class CombineHSVANode : public CombineRGBANode {
-public:
- CombineHSVANode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
-};
-#endif
diff --git a/source/blender/compositor/nodes/COM_CombineRGBANode.cpp b/source/blender/compositor/nodes/COM_CombineRGBANode.cpp
deleted file mode 100644
index 8dfded049e5..00000000000
--- a/source/blender/compositor/nodes/COM_CombineRGBANode.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the 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:
- * Jeroen Bakker
- * Monique Dewanchand
- */
-
-#include "COM_CombineRGBANode.h"
-
-#include "COM_ConvertOperation.h"
-
-#include "COM_ExecutionSystem.h"
-#include "COM_SetValueOperation.h"
-#include "DNA_material_types.h" // the ramp types
-
-
-CombineRGBANode::CombineRGBANode(bNode *editorNode) : Node(editorNode)
-{
- /* pass */
-}
-
-void CombineRGBANode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
-{
- InputSocket *inputRSocket = this->getInputSocket(0);
- InputSocket *inputGSocket = this->getInputSocket(1);
- InputSocket *inputBSocket = this->getInputSocket(2);
- InputSocket *inputASocket = this->getInputSocket(3);
- OutputSocket *outputSocket = this->getOutputSocket(0);
-
- CombineChannelsOperation *operation = new CombineChannelsOperation();
- if (inputRSocket->isConnected()) {
- operation->setResolutionInputSocketIndex(0);
- }
- else if (inputGSocket->isConnected()) {
- operation->setResolutionInputSocketIndex(1);
- }
- else if (inputBSocket->isConnected()) {
- operation->setResolutionInputSocketIndex(2);
- }
- else {
- operation->setResolutionInputSocketIndex(3);
- }
- inputRSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
- inputGSocket->relinkConnections(operation->getInputSocket(1), 1, graph);
- inputBSocket->relinkConnections(operation->getInputSocket(2), 2, graph);
- inputASocket->relinkConnections(operation->getInputSocket(3), 3, graph);
- outputSocket->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
-}
diff --git a/source/blender/compositor/nodes/COM_CombineYCCANode.cpp b/source/blender/compositor/nodes/COM_CombineYCCANode.cpp
deleted file mode 100644
index ee787a4f9c1..00000000000
--- a/source/blender/compositor/nodes/COM_CombineYCCANode.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the 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:
- * Dalai Felinto
- */
-
-#include "COM_CombineYCCANode.h"
-#include "COM_ConvertOperation.h"
-
-CombineYCCANode::CombineYCCANode(bNode *editorNode) : CombineRGBANode(editorNode)
-{
- /* pass */
-}
-
-void CombineYCCANode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
-{
- ConvertYCCToRGBOperation *operation = new ConvertYCCToRGBOperation();
- OutputSocket *outputSocket = this->getOutputSocket(0);
-
- bNode *node = this->getbNode();
- operation->setMode(node->custom1);
-
- if (outputSocket->isConnected()) {
- outputSocket->relinkConnections(operation->getOutputSocket());
- addLink(graph, outputSocket, operation->getInputSocket(0));
- }
-
- graph->addOperation(operation);
- CombineRGBANode::convertToOperations(graph, context);
-}
diff --git a/source/blender/compositor/nodes/COM_CombineYCCANode.h b/source/blender/compositor/nodes/COM_CombineYCCANode.h
deleted file mode 100644
index 6ff2938c161..00000000000
--- a/source/blender/compositor/nodes/COM_CombineYCCANode.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the 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:
- * Dalai Felinto
- */
-
-#ifndef _COM_CombineYCCANode_h_
-#define _COM_CombineYCCANode_h_
-
-#include "COM_Node.h"
-#include "DNA_node_types.h"
-#include "COM_CombineRGBANode.h"
-/**
- * @brief CombineYCCANode
- * @ingroup Node
- */
-class CombineYCCANode : public CombineRGBANode {
-public:
- CombineYCCANode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
-};
-#endif
diff --git a/source/blender/compositor/nodes/COM_CombineYUVANode.cpp b/source/blender/compositor/nodes/COM_CombineYUVANode.cpp
deleted file mode 100644
index feee443cf05..00000000000
--- a/source/blender/compositor/nodes/COM_CombineYUVANode.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the 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:
- * Dalai Felinto
- */
-
-#include "COM_CombineYUVANode.h"
-#include "COM_ConvertOperation.h"
-
-CombineYUVANode::CombineYUVANode(bNode *editorNode) : CombineRGBANode(editorNode)
-{
- /* pass */
-}
-
-void CombineYUVANode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
-{
- ConvertYUVToRGBOperation *operation = new ConvertYUVToRGBOperation();
- OutputSocket *outputSocket = this->getOutputSocket(0);
- if (outputSocket->isConnected()) {
- outputSocket->relinkConnections(operation->getOutputSocket());
- addLink(graph, outputSocket, operation->getInputSocket(0));
- }
- graph->addOperation(operation);
- CombineRGBANode::convertToOperations(graph, context);
-}
diff --git a/source/blender/compositor/nodes/COM_CombineYUVANode.h b/source/blender/compositor/nodes/COM_CombineYUVANode.h
deleted file mode 100644
index e3d8f36a5dd..00000000000
--- a/source/blender/compositor/nodes/COM_CombineYUVANode.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the 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:
- * Dalai Felinto
- */
-
-#ifndef _COM_CombineYUVANode_h_
-#define _COM_CombineYUVANode_h_
-
-#include "COM_Node.h"
-#include "DNA_node_types.h"
-#include "COM_CombineRGBANode.h"
-/**
- * @brief CombineYUVANode
- * @ingroup Node
- */
-class CombineYUVANode : public CombineRGBANode {
-public:
- CombineYUVANode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
-};
-#endif
diff --git a/source/blender/compositor/nodes/COM_CompositorNode.cpp b/source/blender/compositor/nodes/COM_CompositorNode.cpp
index 7e192af0cd9..3d79eb693ea 100644
--- a/source/blender/compositor/nodes/COM_CompositorNode.cpp
+++ b/source/blender/compositor/nodes/COM_CompositorNode.cpp
@@ -29,26 +29,33 @@ CompositorNode::CompositorNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void CompositorNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void CompositorNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
bNode *editorNode = this->getbNode();
bool is_active = (editorNode->flag & NODE_DO_OUTPUT_RECALC) ||
- context->isRendering();
+ context.isRendering();
+ bool ignore_alpha = editorNode->custom2 & CMP_NODE_OUTPUT_IGNORE_ALPHA;
- InputSocket *imageSocket = this->getInputSocket(0);
- InputSocket *alphaSocket = this->getInputSocket(1);
- InputSocket *depthSocket = this->getInputSocket(2);
+ NodeInput *imageSocket = this->getInputSocket(0);
+ NodeInput *alphaSocket = this->getInputSocket(1);
+ NodeInput *depthSocket = this->getInputSocket(2);
CompositorOperation *compositorOperation = new CompositorOperation();
- compositorOperation->setSceneName(context->getScene()->id.name);
- compositorOperation->setRenderData(context->getRenderData());
- compositorOperation->setbNodeTree(context->getbNodeTree());
- compositorOperation->setIgnoreAlpha(editorNode->custom2 & CMP_NODE_OUTPUT_IGNORE_ALPHA);
+ compositorOperation->setSceneName(context.getScene()->id.name);
+ compositorOperation->setRenderData(context.getRenderData());
+ compositorOperation->setbNodeTree(context.getbNodeTree());
+ /* alpha socket gives either 1 or a custom alpha value if "use alpha" is enabled */
+ compositorOperation->setUseAlphaInput(ignore_alpha || alphaSocket->isLinked());
compositorOperation->setActive(is_active);
- imageSocket->relinkConnections(compositorOperation->getInputSocket(0), 0, graph);
- alphaSocket->relinkConnections(compositorOperation->getInputSocket(1));
- depthSocket->relinkConnections(compositorOperation->getInputSocket(2));
- graph->addOperation(compositorOperation);
-
- addPreviewOperation(graph, context, compositorOperation->getInputSocket(0));
+
+ converter.addOperation(compositorOperation);
+ converter.mapInputSocket(imageSocket, compositorOperation->getInputSocket(0));
+ /* only use alpha link if "use alpha" is enabled */
+ if (ignore_alpha)
+ converter.addInputValue(compositorOperation->getInputSocket(1), 1.0f);
+ else
+ converter.mapInputSocket(alphaSocket, compositorOperation->getInputSocket(1));
+ converter.mapInputSocket(depthSocket, compositorOperation->getInputSocket(2));
+
+ converter.addNodeInputPreview(imageSocket);
}
diff --git a/source/blender/compositor/nodes/COM_CompositorNode.h b/source/blender/compositor/nodes/COM_CompositorNode.h
index 54d52d7db9e..aa9a4cdd8bb 100644
--- a/source/blender/compositor/nodes/COM_CompositorNode.h
+++ b/source/blender/compositor/nodes/COM_CompositorNode.h
@@ -32,6 +32,6 @@
class CompositorNode : public Node {
public:
CompositorNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp b/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp
index 72f3ed07fd5..ba31ed6e89c 100644
--- a/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp
+++ b/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp
@@ -23,7 +23,7 @@
#include "COM_ConvertOperation.h"
#include "COM_ExecutionSystem.h"
-void ConvertAlphaNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void ConvertAlphaNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
NodeOperation *operation = NULL;
bNode *node = this->getbNode();
@@ -35,9 +35,9 @@ void ConvertAlphaNode::convertToOperations(ExecutionSystem *graph, CompositorCon
else {
operation = new ConvertStraightToPremulOperation();
}
-
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
-
- graph->addOperation(operation);
+
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_ConvertAlphaNode.h b/source/blender/compositor/nodes/COM_ConvertAlphaNode.h
index a80f8de1607..5bc5169b6d9 100644
--- a/source/blender/compositor/nodes/COM_ConvertAlphaNode.h
+++ b/source/blender/compositor/nodes/COM_ConvertAlphaNode.h
@@ -31,7 +31,7 @@
class ConvertAlphaNode : public Node {
public:
ConvertAlphaNode(bNode *editorNode) : Node(editorNode) {}
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_CornerPinNode.cpp b/source/blender/compositor/nodes/COM_CornerPinNode.cpp
index 1f4f485f90a..ea9f22f2840 100644
--- a/source/blender/compositor/nodes/COM_CornerPinNode.cpp
+++ b/source/blender/compositor/nodes/COM_CornerPinNode.cpp
@@ -28,9 +28,9 @@ CornerPinNode::CornerPinNode(bNode *editorNode) : Node(editorNode)
{
}
-void CornerPinNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void CornerPinNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *input_image = this->getInputSocket(0);
+ NodeInput *input_image = this->getInputSocket(0);
/* note: socket order differs between UI node and operations:
* bNode uses intuitive order following top-down layout:
* upper-left, upper-right, lower-left, lower-right
@@ -39,29 +39,20 @@ void CornerPinNode::convertToOperations(ExecutionSystem *graph, CompositorContex
*/
const int node_corner_index[4] = { 3, 4, 2, 1 };
- OutputSocket *output_warped_image = this->getOutputSocket(0);
- OutputSocket *output_plane = this->getOutputSocket(1);
+ NodeOutput *output_warped_image = this->getOutputSocket(0);
+ NodeOutput *output_plane = this->getOutputSocket(1);
PlaneCornerPinWarpImageOperation *warp_image_operation = new PlaneCornerPinWarpImageOperation();
+ converter.addOperation(warp_image_operation);
+ PlaneCornerPinMaskOperation *plane_mask_operation = new PlaneCornerPinMaskOperation();
+ converter.addOperation(plane_mask_operation);
- input_image->relinkConnections(warp_image_operation->getInputSocket(0), 0, graph);
+ converter.mapInputSocket(input_image, warp_image_operation->getInputSocket(0));
for (int i = 0; i < 4; ++i) {
- int node_index = node_corner_index[i];
- getInputSocket(node_index)->relinkConnections(warp_image_operation->getInputSocket(i + 1),
- node_index, graph);
+ NodeInput *corner_input = getInputSocket(node_corner_index[i]);
+ converter.mapInputSocket(corner_input, warp_image_operation->getInputSocket(i + 1));
+ converter.mapInputSocket(corner_input, plane_mask_operation->getInputSocket(i));
}
- output_warped_image->relinkConnections(warp_image_operation->getOutputSocket());
-
- graph->addOperation(warp_image_operation);
-
- PlaneCornerPinMaskOperation *plane_mask_operation = new PlaneCornerPinMaskOperation();
-
- /* connect mask op inputs to the same sockets as the warp image op */
- for (int i = 0; i < 4; ++i)
- addLink(graph,
- warp_image_operation->getInputSocket(i + 1)->getConnection()->getFromSocket(),
- plane_mask_operation->getInputSocket(i));
- output_plane->relinkConnections(plane_mask_operation->getOutputSocket());
-
- graph->addOperation(plane_mask_operation);
+ converter.mapOutputSocket(output_warped_image, warp_image_operation->getOutputSocket());
+ converter.mapOutputSocket(output_plane, plane_mask_operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_CornerPinNode.h b/source/blender/compositor/nodes/COM_CornerPinNode.h
index b8b8a16384c..70e48e41d6b 100644
--- a/source/blender/compositor/nodes/COM_CornerPinNode.h
+++ b/source/blender/compositor/nodes/COM_CornerPinNode.h
@@ -35,7 +35,7 @@ extern "C" {
class CornerPinNode : public Node {
public:
CornerPinNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif /* _COM_CornerPinNode_h */
diff --git a/source/blender/compositor/nodes/COM_CropNode.cpp b/source/blender/compositor/nodes/COM_CropNode.cpp
index f09bb7e1c26..6c3dc93481b 100644
--- a/source/blender/compositor/nodes/COM_CropNode.cpp
+++ b/source/blender/compositor/nodes/COM_CropNode.cpp
@@ -29,7 +29,7 @@ CropNode::CropNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void CropNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void CropNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
bNode *node = getbNode();
NodeTwoXYs *cropSettings = (NodeTwoXYs *)node->storage;
@@ -44,7 +44,8 @@ void CropNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
}
operation->setCropSettings(cropSettings);
operation->setRelative(relative);
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- this->getOutputSocket()->relinkConnections(operation->getOutputSocket());
- graph->addOperation(operation);
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(), operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_CropNode.h b/source/blender/compositor/nodes/COM_CropNode.h
index 1003728a9d4..c1b84247ba2 100644
--- a/source/blender/compositor/nodes/COM_CropNode.h
+++ b/source/blender/compositor/nodes/COM_CropNode.h
@@ -32,7 +32,7 @@
class CropNode : public Node {
public:
CropNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_DefocusNode.cpp b/source/blender/compositor/nodes/COM_DefocusNode.cpp
index c2d25bbccd8..d2ea385fde0 100644
--- a/source/blender/compositor/nodes/COM_DefocusNode.cpp
+++ b/source/blender/compositor/nodes/COM_DefocusNode.cpp
@@ -39,11 +39,11 @@ DefocusNode::DefocusNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void DefocusNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
bNode *node = this->getbNode();
NodeDefocus *data = (NodeDefocus *)node->storage;
- Scene *scene = node->id ? (Scene *)node->id : context->getScene();
+ Scene *scene = node->id ? (Scene *)node->id : context.getScene();
Object *camob = scene ? scene->camera : NULL;
NodeOperation *radiusOperation;
@@ -54,36 +54,39 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext
SetValueOperation *maxRadius = new SetValueOperation();
maxRadius->setValue(data->maxblur);
MathMinimumOperation *minimize = new MathMinimumOperation();
- this->getInputSocket(1)->relinkConnections(multiply->getInputSocket(0), 1, graph);
- addLink(graph, multiplier->getOutputSocket(), multiply->getInputSocket(1));
- addLink(graph, maxRadius->getOutputSocket(), minimize->getInputSocket(1));
- addLink(graph, multiply->getOutputSocket(), minimize->getInputSocket(0));
- graph->addOperation(multiply);
- graph->addOperation(multiplier);
- graph->addOperation(maxRadius);
- graph->addOperation(minimize);
+ converter.addOperation(multiply);
+ converter.addOperation(multiplier);
+ converter.addOperation(maxRadius);
+ converter.addOperation(minimize);
+
+ converter.mapInputSocket(getInputSocket(1), multiply->getInputSocket(0));
+ converter.addLink(multiplier->getOutputSocket(), multiply->getInputSocket(1));
+ converter.addLink(multiply->getOutputSocket(), minimize->getInputSocket(0));
+ converter.addLink(maxRadius->getOutputSocket(), minimize->getInputSocket(1));
+
radiusOperation = minimize;
}
else {
- ConvertDepthToRadiusOperation *converter = new ConvertDepthToRadiusOperation();
- converter->setCameraObject(camob);
- converter->setfStop(data->fstop);
- converter->setMaxRadius(data->maxblur);
- this->getInputSocket(1)->relinkConnections(converter->getInputSocket(0), 1, graph);
- graph->addOperation(converter);
+ ConvertDepthToRadiusOperation *radius_op = new ConvertDepthToRadiusOperation();
+ radius_op->setCameraObject(camob);
+ radius_op->setfStop(data->fstop);
+ radius_op->setMaxRadius(data->maxblur);
+ converter.addOperation(radius_op);
+
+ converter.mapInputSocket(getInputSocket(1), radius_op->getInputSocket(0));
FastGaussianBlurValueOperation *blur = new FastGaussianBlurValueOperation();
- addLink(graph, converter->getOutputSocket(0), blur->getInputSocket(0));
- graph->addOperation(blur);
- radiusOperation = blur;
- converter->setPostBlur(blur);
-
/* maintain close pixels so far Z values don't bleed into the foreground */
blur->setOverlay(FAST_GAUSS_OVERLAY_MIN);
+ converter.addOperation(blur);
+
+ converter.addLink(radius_op->getOutputSocket(0), blur->getInputSocket(0));
+ radius_op->setPostBlur(blur);
+
+ radiusOperation = blur;
}
- BokehImageOperation *bokeh = new BokehImageOperation();
NodeBokehImage *bokehdata = new NodeBokehImage();
bokehdata->angle = data->rotation;
bokehdata->rounding = 0.0f;
@@ -95,44 +98,47 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext
bokehdata->catadioptric = 0.0f;
bokehdata->lensshift = 0.0f;
+ BokehImageOperation *bokeh = new BokehImageOperation();
bokeh->setData(bokehdata);
bokeh->deleteDataOnFinish();
- graph->addOperation(bokeh);
-
-#ifdef COM_DEFOCUS_SEARCH
+ converter.addOperation(bokeh);
+
+#ifdef COM_DEFOCUS_SEARCH
InverseSearchRadiusOperation *search = new InverseSearchRadiusOperation();
- addLink(graph, radiusOperation->getOutputSocket(0), search->getInputSocket(0));
search->setMaxBlur(data->maxblur);
- graph->addOperation(search);
+ converter.addOperation(search);
+
+ converter.addLink(radiusOperation->getOutputSocket(0), search->getInputSocket(0));
#endif
+
VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation();
- if (data->preview) {
+ if (data->preview)
operation->setQuality(COM_QUALITY_LOW);
- }
- else {
- operation->setQuality(context->getQuality());
- }
+ else
+ operation->setQuality(context.getQuality());
operation->setMaxBlur(data->maxblur);
- operation->setbNode(node);
operation->setThreshold(data->bthresh);
- addLink(graph, bokeh->getOutputSocket(), operation->getInputSocket(1));
- addLink(graph, radiusOperation->getOutputSocket(), operation->getInputSocket(2));
+ converter.addOperation(operation);
+
+ converter.addLink(bokeh->getOutputSocket(), operation->getInputSocket(1));
+ converter.addLink(radiusOperation->getOutputSocket(), operation->getInputSocket(2));
#ifdef COM_DEFOCUS_SEARCH
- addLink(graph, search->getOutputSocket(), operation->getInputSocket(3));
+ converter.addLink(search->getOutputSocket(), operation->getInputSocket(3));
#endif
+
if (data->gamco) {
GammaCorrectOperation *correct = new GammaCorrectOperation();
+ converter.addOperation(correct);
GammaUncorrectOperation *inverse = new GammaUncorrectOperation();
- this->getInputSocket(0)->relinkConnections(correct->getInputSocket(0), 0, graph);
- addLink(graph, correct->getOutputSocket(), operation->getInputSocket(0));
- addLink(graph, operation->getOutputSocket(), inverse->getInputSocket(0));
- this->getOutputSocket()->relinkConnections(inverse->getOutputSocket());
- graph->addOperation(correct);
- graph->addOperation(inverse);
+ converter.addOperation(inverse);
+
+ converter.mapInputSocket(getInputSocket(0), correct->getInputSocket(0));
+ converter.addLink(correct->getOutputSocket(), operation->getInputSocket(0));
+ converter.addLink(operation->getOutputSocket(), inverse->getInputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(), inverse->getOutputSocket());
}
else {
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- this->getOutputSocket()->relinkConnections(operation->getOutputSocket());
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(), operation->getOutputSocket());
}
- graph->addOperation(operation);
}
diff --git a/source/blender/compositor/nodes/COM_DefocusNode.h b/source/blender/compositor/nodes/COM_DefocusNode.h
index 7d69b6413bb..8c607f0737e 100644
--- a/source/blender/compositor/nodes/COM_DefocusNode.h
+++ b/source/blender/compositor/nodes/COM_DefocusNode.h
@@ -32,7 +32,7 @@
class DefocusNode : public Node {
public:
DefocusNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_DespeckleNode.cpp b/source/blender/compositor/nodes/COM_DespeckleNode.cpp
index 9894dc7b9ac..bac6337374f 100644
--- a/source/blender/compositor/nodes/COM_DespeckleNode.cpp
+++ b/source/blender/compositor/nodes/COM_DespeckleNode.cpp
@@ -29,22 +29,21 @@ DespeckleNode::DespeckleNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void DespeckleNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void DespeckleNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
bNode *editorNode = this->getbNode();
- InputSocket *inputSocket = this->getInputSocket(0);
- InputSocket *inputImageSocket = this->getInputSocket(1);
- OutputSocket *outputSocket = this->getOutputSocket(0);
+ NodeInput *inputSocket = this->getInputSocket(0);
+ NodeInput *inputImageSocket = this->getInputSocket(1);
+ NodeOutput *outputSocket = this->getOutputSocket(0);
+
DespeckleOperation *operation = new DespeckleOperation();
-
- operation->setbNode(editorNode);
operation->setThreshold(editorNode->custom3);
operation->setThresholdNeighbor(editorNode->custom4);
-
- inputImageSocket->relinkConnections(operation->getInputSocket(0), 1, graph);
- inputSocket->relinkConnections(operation->getInputSocket(1), 0, graph);
- outputSocket->relinkConnections(operation->getOutputSocket());
- addPreviewOperation(graph, context, operation->getOutputSocket(0));
-
- graph->addOperation(operation);
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(inputImageSocket, operation->getInputSocket(0));
+ converter.mapInputSocket(inputSocket, operation->getInputSocket(1));
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket());
+
+ converter.addPreview(operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_DespeckleNode.h b/source/blender/compositor/nodes/COM_DespeckleNode.h
index 2b8ab9d0226..64d99db7ded 100644
--- a/source/blender/compositor/nodes/COM_DespeckleNode.h
+++ b/source/blender/compositor/nodes/COM_DespeckleNode.h
@@ -30,7 +30,7 @@
class DespeckleNode : public Node {
public:
DespeckleNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp b/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp
index b5ad07be319..8870badab09 100644
--- a/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp
@@ -30,26 +30,28 @@ DifferenceMatteNode::DifferenceMatteNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void DifferenceMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void DifferenceMatteNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *inputSocket = this->getInputSocket(0);
- InputSocket *inputSocket2 = this->getInputSocket(1);
- OutputSocket *outputSocketImage = this->getOutputSocket(0);
- OutputSocket *outputSocketMatte = this->getOutputSocket(1);
+ NodeInput *inputSocket = this->getInputSocket(0);
+ NodeInput *inputSocket2 = this->getInputSocket(1);
+ NodeOutput *outputSocketImage = this->getOutputSocket(0);
+ NodeOutput *outputSocketMatte = this->getOutputSocket(1);
bNode *editorNode = this->getbNode();
DifferenceMatteOperation *operationSet = new DifferenceMatteOperation();
operationSet->setSettings((NodeChroma *)editorNode->storage);
- inputSocket->relinkConnections(operationSet->getInputSocket(0), 0, graph);
- inputSocket2->relinkConnections(operationSet->getInputSocket(1), 1, graph);
-
- outputSocketMatte->relinkConnections(operationSet->getOutputSocket(0));
- graph->addOperation(operationSet);
+ converter.addOperation(operationSet);
+
+ converter.mapInputSocket(inputSocket, operationSet->getInputSocket(0));
+ converter.mapInputSocket(inputSocket2, operationSet->getInputSocket(1));
+ converter.mapOutputSocket(outputSocketMatte, operationSet->getOutputSocket(0));
SetAlphaOperation *operation = new SetAlphaOperation();
- addLink(graph, operationSet->getInputSocket(0)->getConnection()->getFromSocket(), operation->getInputSocket(0));
- addLink(graph, operationSet->getOutputSocket(), operation->getInputSocket(1));
- outputSocketImage->relinkConnections(operation->getOutputSocket());
- graph->addOperation(operation);
- addPreviewOperation(graph, context, operation->getOutputSocket());
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
+ converter.addLink(operationSet->getOutputSocket(), operation->getInputSocket(1));
+ converter.mapOutputSocket(outputSocketImage, operation->getOutputSocket());
+
+ converter.addPreview(operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_DifferenceMatteNode.h b/source/blender/compositor/nodes/COM_DifferenceMatteNode.h
index 0b571889571..e221d43180b 100644
--- a/source/blender/compositor/nodes/COM_DifferenceMatteNode.h
+++ b/source/blender/compositor/nodes/COM_DifferenceMatteNode.h
@@ -32,7 +32,7 @@
class DifferenceMatteNode : public Node {
public:
DifferenceMatteNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif /* COM_DifferenceMatteNODE_H */
diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
index 0fb7ea7d264..933cb8365f9 100644
--- a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
+++ b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
@@ -30,85 +30,84 @@
DilateErodeNode::DilateErodeNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* initialize node data */
+ NodeBlurData *data = &m_alpha_blur;
+ memset(data, 0, sizeof(NodeBlurData));
+ data->filtertype = R_FILTER_GAUSS;
+
+ if (editorNode->custom2 > 0) {
+ data->sizex = data->sizey = editorNode->custom2;
+ }
+ else {
+ data->sizex = data->sizey = -editorNode->custom2;
+ }
}
-void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void DilateErodeNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
bNode *editorNode = this->getbNode();
if (editorNode->custom1 == CMP_NODE_DILATEERODE_DISTANCE_THRESH) {
DilateErodeThresholdOperation *operation = new DilateErodeThresholdOperation();
- operation->setbNode(editorNode);
operation->setDistance(editorNode->custom2);
operation->setInset(editorNode->custom3);
+ converter.addOperation(operation);
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
if (editorNode->custom3 < 2.0f) {
AntiAliasOperation *antiAlias = new AntiAliasOperation();
- addLink(graph, operation->getOutputSocket(), antiAlias->getInputSocket(0));
- this->getOutputSocket(0)->relinkConnections(antiAlias->getOutputSocket(0));
- graph->addOperation(antiAlias);
+ converter.addOperation(antiAlias);
+
+ converter.addLink(operation->getOutputSocket(), antiAlias->getInputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(0), antiAlias->getOutputSocket(0));
}
else {
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
}
- graph->addOperation(operation);
}
else if (editorNode->custom1 == CMP_NODE_DILATEERODE_DISTANCE) {
if (editorNode->custom2 > 0) {
DilateDistanceOperation *operation = new DilateDistanceOperation();
- operation->setbNode(editorNode);
operation->setDistance(editorNode->custom2);
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
}
else {
ErodeDistanceOperation *operation = new ErodeDistanceOperation();
- operation->setbNode(editorNode);
operation->setDistance(-editorNode->custom2);
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
}
}
else if (editorNode->custom1 == CMP_NODE_DILATEERODE_DISTANCE_FEATHER) {
/* this uses a modified gaussian blur function otherwise its far too slow */
- CompositorQuality quality = context->getQuality();
-
- /* initialize node data */
- NodeBlurData *data = &this->m_alpha_blur;
- memset(data, 0, sizeof(*data));
- data->filtertype = R_FILTER_GAUSS;
-
- if (editorNode->custom2 > 0) {
- data->sizex = data->sizey = editorNode->custom2;
- }
- else {
- data->sizex = data->sizey = -editorNode->custom2;
-
- }
+ CompositorQuality quality = context.getQuality();
GaussianAlphaXBlurOperation *operationx = new GaussianAlphaXBlurOperation();
- operationx->setbNode(editorNode);
- operationx->setData(data);
+ operationx->setData(&m_alpha_blur);
operationx->setQuality(quality);
operationx->setFalloff(PROP_SMOOTH);
- this->getInputSocket(0)->relinkConnections(operationx->getInputSocket(0), 0, graph);
- // this->getInputSocket(1)->relinkConnections(operationx->getInputSocket(1), 1, graph); // no size input yet
- graph->addOperation(operationx);
+ converter.addOperation(operationx);
+
+ converter.mapInputSocket(getInputSocket(0), operationx->getInputSocket(0));
+ // converter.mapInputSocket(getInputSocket(1), operationx->getInputSocket(1)); // no size input yet
+
GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation();
- operationy->setbNode(editorNode);
- operationy->setData(data);
+ operationy->setData(&m_alpha_blur);
operationy->setQuality(quality);
operationy->setFalloff(PROP_SMOOTH);
- this->getOutputSocket(0)->relinkConnections(operationy->getOutputSocket());
- graph->addOperation(operationy);
- addLink(graph, operationx->getOutputSocket(), operationy->getInputSocket(0));
- // addLink(graph, operationx->getInputSocket(1)->getConnection()->getFromSocket(), operationy->getInputSocket(1)); // no size input yet
- addPreviewOperation(graph, context, operationy->getOutputSocket());
+ converter.addOperation(operationy);
+
+ converter.addLink(operationx->getOutputSocket(), operationy->getInputSocket(0));
+ // converter.mapInputSocket(getInputSocket(1), operationy->getInputSocket(1)); // no size input yet
+ converter.mapOutputSocket(getOutputSocket(0), operationy->getOutputSocket());
+
+ converter.addPreview(operationy->getOutputSocket());
/* TODO? */
/* see gaussian blue node for original usage */
@@ -133,19 +132,19 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont
else {
if (editorNode->custom2 > 0) {
DilateStepOperation *operation = new DilateStepOperation();
- operation->setbNode(editorNode);
operation->setIterations(editorNode->custom2);
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
}
else {
ErodeStepOperation *operation = new ErodeStepOperation();
- operation->setbNode(editorNode);
operation->setIterations(-editorNode->custom2);
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
}
}
}
diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.h b/source/blender/compositor/nodes/COM_DilateErodeNode.h
index 4b02042ffc9..b69592f7fc1 100644
--- a/source/blender/compositor/nodes/COM_DilateErodeNode.h
+++ b/source/blender/compositor/nodes/COM_DilateErodeNode.h
@@ -33,7 +33,7 @@ class DilateErodeNode : public Node {
NodeBlurData m_alpha_blur; /* only used for blurring alpha, since the dilate/erode node doesnt have this */
public:
DilateErodeNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp b/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp
index eb30f6952ba..3d95a462117 100644
--- a/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp
@@ -30,14 +30,14 @@ DirectionalBlurNode::DirectionalBlurNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void DirectionalBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void DirectionalBlurNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
NodeDBlurData *data = (NodeDBlurData *)this->getbNode()->storage;
DirectionalBlurOperation *operation = new DirectionalBlurOperation();
- operation->setQuality(context->getQuality());
+ operation->setQuality(context.getQuality());
operation->setData(data);
- operation->setbNode(this->getbNode());
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
- graph->addOperation(operation);
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_DirectionalBlurNode.h b/source/blender/compositor/nodes/COM_DirectionalBlurNode.h
index d387ecf81dc..8c806aa5437 100644
--- a/source/blender/compositor/nodes/COM_DirectionalBlurNode.h
+++ b/source/blender/compositor/nodes/COM_DirectionalBlurNode.h
@@ -32,7 +32,7 @@
class DirectionalBlurNode : public Node {
public:
DirectionalBlurNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_DisplaceNode.cpp b/source/blender/compositor/nodes/COM_DisplaceNode.cpp
index 41fbfd61981..ffbb85882d5 100644
--- a/source/blender/compositor/nodes/COM_DisplaceNode.cpp
+++ b/source/blender/compositor/nodes/COM_DisplaceNode.cpp
@@ -29,19 +29,18 @@ DisplaceNode::DisplaceNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void DisplaceNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void DisplaceNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
NodeOperation *operation;
- if (context->getQuality() == COM_QUALITY_LOW)
+ if (context.getQuality() == COM_QUALITY_LOW)
operation = new DisplaceSimpleOperation();
else
operation = new DisplaceOperation();
+ converter.addOperation(operation);
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
- this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), 2, graph);
- this->getInputSocket(3)->relinkConnections(operation->getInputSocket(3), 3, graph);
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
-
- graph->addOperation(operation);
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
+ converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2));
+ converter.mapInputSocket(getInputSocket(3), operation->getInputSocket(3));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_DisplaceNode.h b/source/blender/compositor/nodes/COM_DisplaceNode.h
index af6afc25366..6eb894077fc 100644
--- a/source/blender/compositor/nodes/COM_DisplaceNode.h
+++ b/source/blender/compositor/nodes/COM_DisplaceNode.h
@@ -31,6 +31,6 @@
class DisplaceNode : public Node {
public:
DisplaceNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp b/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp
index 3c532fe0b1d..704c704c500 100644
--- a/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp
@@ -31,55 +31,58 @@ DistanceMatteNode::DistanceMatteNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void DistanceMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void DistanceMatteNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *inputSocketImage = this->getInputSocket(0);
- InputSocket *inputSocketKey = this->getInputSocket(1);
- OutputSocket *outputSocketImage = this->getOutputSocket(0);
- OutputSocket *outputSocketMatte = this->getOutputSocket(1);
-
- NodeOperation *operation;
bNode *editorsnode = getbNode();
NodeChroma *storage = (NodeChroma *)editorsnode->storage;
-
+
+ NodeInput *inputSocketImage = this->getInputSocket(0);
+ NodeInput *inputSocketKey = this->getInputSocket(1);
+ NodeOutput *outputSocketImage = this->getOutputSocket(0);
+ NodeOutput *outputSocketMatte = this->getOutputSocket(1);
+
+ SetAlphaOperation *operationAlpha = new SetAlphaOperation();
+ converter.addOperation(operationAlpha);
+
/* work in RGB color space */
+ NodeOperation *operation;
if (storage->channel == 1) {
- operation = new DistanceRGBMatteOperation();
- ((DistanceRGBMatteOperation *) operation)->setSettings(storage);
-
- inputSocketImage->relinkConnections(operation->getInputSocket(0), 0, graph);
- inputSocketKey->relinkConnections(operation->getInputSocket(1), 1, graph);
+ DistanceRGBMatteOperation *matte = new DistanceRGBMatteOperation();
+ matte->setSettings(storage);
+ converter.addOperation(matte);
+
+ converter.mapInputSocket(inputSocketImage, matte->getInputSocket(0));
+ converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0));
+
+ converter.mapInputSocket(inputSocketKey, matte->getInputSocket(1));
+
+ operation = matte;
}
/* work in YCbCr color space */
else {
- operation = new DistanceYCCMatteOperation();
- ((DistanceYCCMatteOperation *) operation)->setSettings(storage);
-
+ DistanceYCCMatteOperation *matte = new DistanceYCCMatteOperation();
+ matte->setSettings(storage);
+ converter.addOperation(matte);
+
ConvertRGBToYCCOperation *operationYCCImage = new ConvertRGBToYCCOperation();
- inputSocketImage->relinkConnections(operationYCCImage->getInputSocket(0), 0, graph);
- addLink(graph, operationYCCImage->getOutputSocket(), operation->getInputSocket(0));
- graph->addOperation(operationYCCImage);
-
ConvertRGBToYCCOperation *operationYCCMatte = new ConvertRGBToYCCOperation();
- inputSocketKey->relinkConnections(operationYCCMatte->getInputSocket(0), 1, graph);
- addLink(graph, operationYCCMatte->getOutputSocket(), operation->getInputSocket(1));
- graph->addOperation(operationYCCMatte);
- }
-
- if (outputSocketMatte->isConnected()) {
- outputSocketMatte->relinkConnections(operation->getOutputSocket());
- }
-
- graph->addOperation(operation);
-
- SetAlphaOperation *operationAlpha = new SetAlphaOperation();
- addLink(graph, operation->getInputSocket(0)->getConnection()->getFromSocket(), operationAlpha->getInputSocket(0));
- addLink(graph, operation->getOutputSocket(), operationAlpha->getInputSocket(1));
-
- graph->addOperation(operationAlpha);
- addPreviewOperation(graph, context, operationAlpha->getOutputSocket());
-
- if (outputSocketImage->isConnected()) {
- outputSocketImage->relinkConnections(operationAlpha->getOutputSocket());
+ converter.addOperation(operationYCCImage);
+ converter.addOperation(operationYCCMatte);
+
+ converter.mapInputSocket(inputSocketImage, operationYCCImage->getInputSocket(0));
+ converter.addLink(operationYCCImage->getOutputSocket(), matte->getInputSocket(0));
+ converter.addLink(operationYCCImage->getOutputSocket(), operationAlpha->getInputSocket(0));
+
+ converter.mapInputSocket(inputSocketKey, operationYCCMatte->getInputSocket(0));
+ converter.addLink(operationYCCMatte->getOutputSocket(), matte->getInputSocket(1));
+
+ operation = matte;
}
+
+ converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1));
+
+ converter.mapOutputSocket(outputSocketMatte, operation->getOutputSocket());
+ converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket());
+
+ converter.addPreview(operationAlpha->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_DistanceMatteNode.h b/source/blender/compositor/nodes/COM_DistanceMatteNode.h
index 46ceae7c4f4..e7a514b79c4 100644
--- a/source/blender/compositor/nodes/COM_DistanceMatteNode.h
+++ b/source/blender/compositor/nodes/COM_DistanceMatteNode.h
@@ -31,7 +31,7 @@
class DistanceMatteNode : public Node {
public:
DistanceMatteNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif /* COM_DistanceMatteNODE_H */
diff --git a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp
index 40a9d1fa275..1f80eeadf83 100644
--- a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp
+++ b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp
@@ -29,18 +29,17 @@ DoubleEdgeMaskNode::DoubleEdgeMaskNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void DoubleEdgeMaskNode::convertToOperations(ExecutionSystem *system, CompositorContext *context)
+void DoubleEdgeMaskNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
DoubleEdgeMaskOperation *operation;
bNode *bnode = this->getbNode();
operation = new DoubleEdgeMaskOperation();
- operation->setbNode(bnode);
operation->setAdjecentOnly(bnode->custom1);
operation->setKeepInside(bnode->custom2);
+ converter.addOperation(operation);
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, system);
- this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, system);
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
- system->addOperation(operation);
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h
index ebcddc06b05..8e5f81e5ba5 100644
--- a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h
+++ b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h
@@ -32,7 +32,7 @@
class DoubleEdgeMaskNode : public Node {
public:
DoubleEdgeMaskNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_EllipseMaskNode.cpp b/source/blender/compositor/nodes/COM_EllipseMaskNode.cpp
index fe0c85c173a..b0a45c4e2fc 100644
--- a/source/blender/compositor/nodes/COM_EllipseMaskNode.cpp
+++ b/source/blender/compositor/nodes/COM_EllipseMaskNode.cpp
@@ -32,48 +32,42 @@ EllipseMaskNode::EllipseMaskNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void EllipseMaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void EllipseMaskNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
+ NodeInput *inputSocket = this->getInputSocket(0);
+ NodeOutput *outputSocket = this->getOutputSocket(0);
+
EllipseMaskOperation *operation;
-
operation = new EllipseMaskOperation();
operation->setData((NodeEllipseMask *)this->getbNode()->storage);
-
- InputSocket *inputSocket = this->getInputSocket(0);
- OutputSocket *outputSocket = this->getOutputSocket(0);
-
- if (inputSocket->isConnected()) {
- inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
- outputSocket->relinkConnections(operation->getOutputSocket());
+ operation->setMaskType(this->getbNode()->custom1);
+ converter.addOperation(operation);
+
+ if (inputSocket->isLinked()) {
+ converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket());
}
else {
/* Value operation to produce original transparent image */
SetValueOperation *valueOperation = new SetValueOperation();
valueOperation->setValue(0.0f);
- graph->addOperation(valueOperation);
+ converter.addOperation(valueOperation);
/* Scale that image up to render resolution */
- const RenderData *rd = context->getRenderData();
+ const RenderData *rd = context.getRenderData();
ScaleFixedSizeOperation *scaleOperation = new ScaleFixedSizeOperation();
-
scaleOperation->setIsAspect(false);
scaleOperation->setIsCrop(false);
scaleOperation->setOffset(0.0f, 0.0f);
-
scaleOperation->setNewWidth(rd->xsch * rd->size / 100.0f);
scaleOperation->setNewHeight(rd->ysch * rd->size / 100.0f);
+ scaleOperation->getInputSocket(0)->setResizeMode(COM_SC_NO_RESIZE);
+ converter.addOperation(scaleOperation);
- addLink(graph, valueOperation->getOutputSocket(0), scaleOperation->getInputSocket(0));
- addLink(graph, scaleOperation->getOutputSocket(0), operation->getInputSocket(0));
- outputSocket->relinkConnections(operation->getOutputSocket(0));
-
- scaleOperation->getInputSocket(0)->getConnection()->setIgnoreResizeCheck(true);
-
- graph->addOperation(scaleOperation);
+ converter.addLink(valueOperation->getOutputSocket(0), scaleOperation->getInputSocket(0));
+ converter.addLink(scaleOperation->getOutputSocket(0), operation->getInputSocket(0));
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
}
-
- this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
- operation->setMaskType(this->getbNode()->custom1);
- graph->addOperation(operation);
+ converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
}
diff --git a/source/blender/compositor/nodes/COM_EllipseMaskNode.h b/source/blender/compositor/nodes/COM_EllipseMaskNode.h
index 3e534451b13..370f28f1ec2 100644
--- a/source/blender/compositor/nodes/COM_EllipseMaskNode.h
+++ b/source/blender/compositor/nodes/COM_EllipseMaskNode.h
@@ -32,7 +32,7 @@
class EllipseMaskNode : public Node {
public:
EllipseMaskNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_FilterNode.cpp b/source/blender/compositor/nodes/COM_FilterNode.cpp
index 3b75e3e0a1a..9f3a7ae795c 100644
--- a/source/blender/compositor/nodes/COM_FilterNode.cpp
+++ b/source/blender/compositor/nodes/COM_FilterNode.cpp
@@ -32,11 +32,11 @@ FilterNode::FilterNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void FilterNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void FilterNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *inputSocket = this->getInputSocket(0);
- InputSocket *inputImageSocket = this->getInputSocket(1);
- OutputSocket *outputSocket = this->getOutputSocket(0);
+ NodeInput *inputSocket = this->getInputSocket(0);
+ NodeInput *inputImageSocket = this->getInputSocket(1);
+ NodeOutput *outputSocket = this->getOutputSocket(0);
ConvolutionFilterOperation *operation = NULL;
switch (this->getbNode()->custom1) {
@@ -73,11 +73,11 @@ void FilterNode::convertToOperations(ExecutionSystem *graph, CompositorContext *
operation->set3x3Filter(0, 0, 0, 0, 1, 0, 0, 0, 0);
break;
}
- operation->setbNode(this->getbNode());
- inputImageSocket->relinkConnections(operation->getInputSocket(0), 1, graph);
- inputSocket->relinkConnections(operation->getInputSocket(1), 0, graph);
- outputSocket->relinkConnections(operation->getOutputSocket());
- addPreviewOperation(graph, context, operation->getOutputSocket(0));
+ converter.addOperation(operation);
- graph->addOperation(operation);
+ converter.mapInputSocket(inputImageSocket, operation->getInputSocket(0));
+ converter.mapInputSocket(inputSocket, operation->getInputSocket(1));
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket());
+
+ converter.addPreview(operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_FilterNode.h b/source/blender/compositor/nodes/COM_FilterNode.h
index 9be3bb02494..ef228c770de 100644
--- a/source/blender/compositor/nodes/COM_FilterNode.h
+++ b/source/blender/compositor/nodes/COM_FilterNode.h
@@ -32,7 +32,7 @@
class FilterNode : public Node {
public:
FilterNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif /* __COM_FILTERNODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_FlipNode.cpp b/source/blender/compositor/nodes/COM_FlipNode.cpp
index a50297aae1a..1dbcc97143e 100644
--- a/source/blender/compositor/nodes/COM_FlipNode.cpp
+++ b/source/blender/compositor/nodes/COM_FlipNode.cpp
@@ -30,10 +30,10 @@ FlipNode::FlipNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void FlipNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void FlipNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *inputSocket = this->getInputSocket(0);
- OutputSocket *outputSocket = this->getOutputSocket(0);
+ NodeInput *inputSocket = this->getInputSocket(0);
+ NodeOutput *outputSocket = this->getOutputSocket(0);
FlipOperation *operation = new FlipOperation();
switch (this->getbNode()->custom1) {
case 0: /// @TODO: I didn't find any constants in the old implementation, should I introduce them.
@@ -50,7 +50,7 @@ void FlipNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
break;
}
- inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
- outputSocket->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
+ converter.addOperation(operation);
+ converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_FlipNode.h b/source/blender/compositor/nodes/COM_FlipNode.h
index 1e372a80b57..3e7b2de4812 100644
--- a/source/blender/compositor/nodes/COM_FlipNode.h
+++ b/source/blender/compositor/nodes/COM_FlipNode.h
@@ -32,7 +32,7 @@
class FlipNode : public Node {
public:
FlipNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_GammaNode.cpp b/source/blender/compositor/nodes/COM_GammaNode.cpp
index 33a5cb282a1..046cd9e9a0d 100644
--- a/source/blender/compositor/nodes/COM_GammaNode.cpp
+++ b/source/blender/compositor/nodes/COM_GammaNode.cpp
@@ -29,12 +29,12 @@ GammaNode::GammaNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void GammaNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void GammaNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
GammaOperation *operation = new GammaOperation();
+ converter.addOperation(operation);
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_GammaNode.h b/source/blender/compositor/nodes/COM_GammaNode.h
index d4e1f0abd5a..858d21cad9e 100644
--- a/source/blender/compositor/nodes/COM_GammaNode.h
+++ b/source/blender/compositor/nodes/COM_GammaNode.h
@@ -32,7 +32,7 @@
class GammaNode : public Node {
public:
GammaNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_GlareNode.cpp b/source/blender/compositor/nodes/COM_GlareNode.cpp
index a6a83846623..0429a1a80cf 100644
--- a/source/blender/compositor/nodes/COM_GlareNode.cpp
+++ b/source/blender/compositor/nodes/COM_GlareNode.cpp
@@ -36,15 +36,13 @@ GlareNode::GlareNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void GlareNode::convertToOperations(ExecutionSystem *system, CompositorContext *context) \
- {
+void GlareNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+{
bNode *node = this->getbNode();
NodeGlare *glare = (NodeGlare *)node->storage;
GlareBaseOperation *glareoperation = NULL;
-
switch (glare->type) {
-
default:
case 3:
glareoperation = new GlareGhostOperation();
@@ -59,28 +57,30 @@ void GlareNode::convertToOperations(ExecutionSystem *system, CompositorContext *
glareoperation = new GlareSimpleStarOperation();
break;
}
+ BLI_assert(glareoperation);
+ glareoperation->setGlareSettings(glare);
+
GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation();
- SetValueOperation *mixvalueoperation = new SetValueOperation();
- MixGlareOperation *mixoperation = new MixGlareOperation();
- mixoperation->getInputSocket(2)->setResizeMode(COM_SC_FIT);
- thresholdOperation->setbNode(node);
- glareoperation->setbNode(node);
-
- this->getInputSocket(0)->relinkConnections(thresholdOperation->getInputSocket(0), 0, system);
- addLink(system, thresholdOperation->getOutputSocket(), glareoperation->getInputSocket(0));
- addLink(system, mixvalueoperation->getOutputSocket(), mixoperation->getInputSocket(0));
- addLink(system, glareoperation->getOutputSocket(), mixoperation->getInputSocket(2));
- addLink(system, thresholdOperation->getInputSocket(0)->getConnection()->getFromSocket(), mixoperation->getInputSocket(1));
- this->getOutputSocket()->relinkConnections(mixoperation->getOutputSocket());
-
thresholdOperation->setGlareSettings(glare);
- glareoperation->setGlareSettings(glare);
+
+ SetValueOperation *mixvalueoperation = new SetValueOperation();
mixvalueoperation->setValue(0.5f + glare->mix * 0.5f);
+
+ MixGlareOperation *mixoperation = new MixGlareOperation();
mixoperation->setResolutionInputSocketIndex(1);
+ mixoperation->getInputSocket(2)->setResizeMode(COM_SC_FIT);
+
+ converter.addOperation(glareoperation);
+ converter.addOperation(thresholdOperation);
+ converter.addOperation(mixvalueoperation);
+ converter.addOperation(mixoperation);
- system->addOperation(glareoperation);
- system->addOperation(thresholdOperation);
- system->addOperation(mixvalueoperation);
- system->addOperation(mixoperation);
+ converter.mapInputSocket(getInputSocket(0), thresholdOperation->getInputSocket(0));
+ converter.addLink(thresholdOperation->getOutputSocket(), glareoperation->getInputSocket(0));
- }
+ converter.addLink(mixvalueoperation->getOutputSocket(), mixoperation->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(0), mixoperation->getInputSocket(1));
+ converter.addLink(glareoperation->getOutputSocket(), mixoperation->getInputSocket(2));
+ converter.mapOutputSocket(getOutputSocket(), mixoperation->getOutputSocket());
+
+}
diff --git a/source/blender/compositor/nodes/COM_GlareNode.h b/source/blender/compositor/nodes/COM_GlareNode.h
index beb01db733a..1e19cc5510e 100644
--- a/source/blender/compositor/nodes/COM_GlareNode.h
+++ b/source/blender/compositor/nodes/COM_GlareNode.h
@@ -32,7 +32,7 @@
class GlareNode : public Node {
public:
GlareNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_GroupNode.cpp b/source/blender/compositor/nodes/COM_GroupNode.cpp
deleted file mode 100644
index 7c0499dc04e..00000000000
--- a/source/blender/compositor/nodes/COM_GroupNode.cpp
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the 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:
- * Jeroen Bakker
- * Monique Dewanchand
- */
-
-#include "BKE_node.h"
-
-#include "COM_GroupNode.h"
-#include "COM_SocketProxyNode.h"
-#include "COM_SetColorOperation.h"
-#include "COM_ExecutionSystemHelper.h"
-#include "COM_SetValueOperation.h"
-#include "COM_SetVectorOperation.h"
-#include "COM_SetColorOperation.h"
-
-extern "C" {
-#include "RNA_access.h"
-}
-
-GroupNode::GroupNode(bNode *editorNode) : Node(editorNode)
-{
- /* pass */
-}
-
-void GroupNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
-{
- if (this->getbNode()->id == NULL) {
- convertToOperations_invalid(graph, context);
- }
-}
-
-static int find_group_input(GroupNode *gnode, const char *identifier, InputSocket **r_sock)
-{
- int index;
- for (index = 0; index < gnode->getNumberOfInputSockets(); ++index) {
- InputSocket *sock = gnode->getInputSocket(index);
- if (STREQ(sock->getbNodeSocket()->identifier, identifier)) {
- *r_sock = sock;
- return index;
- }
- }
- *r_sock = NULL;
- return -1;
-}
-
-static int find_group_output(GroupNode *gnode, const char *identifier, OutputSocket **r_sock)
-{
- int index;
- for (index = 0; index < gnode->getNumberOfOutputSockets(); ++index) {
- OutputSocket *sock = gnode->getOutputSocket(index);
- if (STREQ(sock->getbNodeSocket()->identifier, identifier)) {
- *r_sock = sock;
- return index;
- }
- }
- *r_sock = NULL;
- return -1;
-}
-
-void GroupNode::ungroup(ExecutionSystem &system)
-{
- bNode *bnode = this->getbNode();
- bNodeTree *subtree = (bNodeTree *)bnode->id;
-
- /* get the node list size _before_ adding proxy nodes, so they are available for linking */
- int nodes_start = system.getNodes().size();
-
- /* missing node group datablock can happen with library linking */
- if (!subtree) {
- /* this error case its handled in convertToOperations() so we don't get un-convertred sockets */
- return;
- }
-
- const bool groupnodeBuffering = system.getContext().isGroupnodeBufferEnabled();
-
- bool has_output = false;
- /* create proxy nodes for group input/output nodes */
- for (bNode *bionode = (bNode *)subtree->nodes.first; bionode; bionode = bionode->next) {
- if (bionode->type == NODE_GROUP_INPUT) {
- for (bNodeSocket *bsock = (bNodeSocket *)bionode->outputs.first; bsock; bsock = bsock->next) {
- InputSocket *gsock;
- int gsock_index = find_group_input(this, bsock->identifier, &gsock);
- /* ignore virtual sockets */
- if (gsock) {
- SocketProxyNode *proxy = new SocketProxyNode(bionode, gsock->getbNodeSocket(), bsock, false);
- ExecutionSystemHelper::addNode(system.getNodes(), proxy);
-
- gsock->relinkConnectionsDuplicate(proxy->getInputSocket(0), gsock_index, &system);
- }
- }
- }
-
- if (bionode->type == NODE_GROUP_OUTPUT && (bionode->flag & NODE_DO_OUTPUT)) {
- has_output = true;
- for (bNodeSocket *bsock = (bNodeSocket *)bionode->inputs.first; bsock; bsock = bsock->next) {
- OutputSocket *gsock;
- find_group_output(this, bsock->identifier, &gsock);
- /* ignore virtual sockets */
- if (gsock) {
- SocketProxyNode *proxy = new SocketProxyNode(bionode, bsock, gsock->getbNodeSocket(), groupnodeBuffering);
- ExecutionSystemHelper::addNode(system.getNodes(), proxy);
-
- gsock->relinkConnections(proxy->getOutputSocket(0));
- }
- }
- }
- }
-
- /* in case no output node exists, add input value operations using defaults */
- if (!has_output) {
- for (int index = 0; index < getNumberOfOutputSockets(); ++index) {
- OutputSocket *output = getOutputSocket(index);
- addDefaultOutputOperation(system, output);
- }
- }
-
- /* unlink the group node itself, input links have been duplicated */
- for (int index = 0; index < this->getNumberOfInputSockets(); ++index) {
- InputSocket *sock = this->getInputSocket(index);
- sock->unlinkConnections(&system);
- }
- for (int index = 0; index < this->getNumberOfOutputSockets(); ++index) {
- OutputSocket *sock = this->getOutputSocket(index);
- sock->clearConnections();
- }
-
- ExecutionSystemHelper::addbNodeTree(system, nodes_start, subtree, this->getInstanceKey());
-}
-
-bNodeSocket *GroupNode::findInterfaceInput(InputSocket *socket)
-{
- bNode *bnode = this->getbNode();
- bNodeTree *subtree = (bNodeTree *)bnode->id;
- if (!subtree)
- return NULL;
-
- const char *identifier = socket->getbNodeSocket()->identifier;
- for (bNodeSocket *iosock = (bNodeSocket *)subtree->inputs.first; iosock; iosock = iosock->next)
- if (STREQ(iosock->identifier, identifier))
- return iosock;
- return NULL;
-}
-
-bNodeSocket *GroupNode::findInterfaceOutput(OutputSocket *socket)
-{
- bNode *bnode = this->getbNode();
- bNodeTree *subtree = (bNodeTree *)bnode->id;
- if (!subtree)
- return NULL;
-
- const char *identifier = socket->getbNodeSocket()->identifier;
- for (bNodeSocket *iosock = (bNodeSocket *)subtree->outputs.first; iosock; iosock = iosock->next)
- if (STREQ(iosock->identifier, identifier))
- return iosock;
- return NULL;
-}
-
-void GroupNode::addDefaultOutputOperation(ExecutionSystem &system, OutputSocket *outputsocket)
-{
- bNodeSocket *iosock = findInterfaceOutput(outputsocket);
- if (!iosock)
- return;
-
- PointerRNA ptr;
- RNA_pointer_create(&getbNodeTree()->id, &RNA_NodeSocket, iosock, &ptr);
-
- NodeOperation *operation = NULL;
- switch (iosock->typeinfo->type) {
- case SOCK_FLOAT:
- {
- float value = RNA_float_get(&ptr, "default_value");
- SetValueOperation *value_op = new SetValueOperation();
- value_op->setValue(value);
- operation = value_op;
- break;
- }
- case SOCK_VECTOR:
- {
- float vector[3];
- RNA_float_get_array(&ptr, "default_value", vector);
- SetVectorOperation *vector_op = new SetVectorOperation();
- vector_op->setVector(vector);
- operation = vector_op;
- break;
- }
- case SOCK_RGBA:
- {
- float color[4];
- RNA_float_get_array(&ptr, "default_value", color);
- SetColorOperation *color_op = new SetColorOperation();
- color_op->setChannels(color);
- operation = color_op;
- break;
- }
- }
-
- outputsocket->relinkConnections(operation->getOutputSocket());
- system.addOperation(operation);
-}
diff --git a/source/blender/compositor/nodes/COM_GroupNode.h b/source/blender/compositor/nodes/COM_GroupNode.h
deleted file mode 100644
index 02b63fe27e3..00000000000
--- a/source/blender/compositor/nodes/COM_GroupNode.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the 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:
- * Jeroen Bakker
- * Monique Dewanchand
- */
-
-#ifndef _COM_GroupNode_h_
-#define _COM_GroupNode_h_
-
-#include "COM_Node.h"
-#include "COM_ExecutionSystem.h"
-
-/**
- * @brief Represents a group node
- * @ingroup Node
- */
-class GroupNode : public Node {
-public:
- GroupNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
-
- /**
- * @brief check if this node a group node.
- * @returns true
- */
- bool isGroupNode() const { return true; }
-
- /**
- * @brief ungroup this group node.
- * during ungroup the subtree (internal nodes and links) of the group node
- * are added to the ExecutionSystem.
- *
- * Between the main tree and the subtree proxy nodes will be added
- * to translate between InputSocket and OutputSocket
- *
- * @param system the ExecutionSystem where to add the subtree
- */
- void ungroup(ExecutionSystem &system);
-
- bNodeSocket *findInterfaceInput(InputSocket *socket);
- bNodeSocket *findInterfaceOutput(OutputSocket *socket);
- void addDefaultOutputOperation(ExecutionSystem &system, OutputSocket *outputsocket);
-};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp
index 66b98b29d5e..003bc91edd3 100644
--- a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp
+++ b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp
@@ -36,33 +36,33 @@ HueSaturationValueCorrectNode::HueSaturationValueCorrectNode(bNode *editorNode)
/* pass */
}
-void HueSaturationValueCorrectNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void HueSaturationValueCorrectNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *valueSocket = this->getInputSocket(0);
- InputSocket *colorSocket = this->getInputSocket(1);
- OutputSocket *outputSocket = this->getOutputSocket(0);
+ NodeInput *valueSocket = this->getInputSocket(0);
+ NodeInput *colorSocket = this->getInputSocket(1);
+ NodeOutput *outputSocket = this->getOutputSocket(0);
bNode *editorsnode = getbNode();
CurveMapping *storage = (CurveMapping *)editorsnode->storage;
ConvertRGBToHSVOperation *rgbToHSV = new ConvertRGBToHSVOperation();
+ converter.addOperation(rgbToHSV);
+
ConvertHSVToRGBOperation *hsvToRGB = new ConvertHSVToRGBOperation();
+ converter.addOperation(hsvToRGB);
+
HueSaturationValueCorrectOperation *changeHSV = new HueSaturationValueCorrectOperation();
- MixBlendOperation *blend = new MixBlendOperation();
-
- colorSocket->relinkConnections(rgbToHSV->getInputSocket(0), 1, graph);
- addLink(graph, rgbToHSV->getOutputSocket(), changeHSV->getInputSocket(0));
- addLink(graph, changeHSV->getOutputSocket(), hsvToRGB->getInputSocket(0));
- addLink(graph, hsvToRGB->getOutputSocket(), blend->getInputSocket(2));
- addLink(graph, rgbToHSV->getInputSocket(0)->getConnection()->getFromSocket(), blend->getInputSocket(1));
- valueSocket->relinkConnections(blend->getInputSocket(0), 0, graph);
- outputSocket->relinkConnections(blend->getOutputSocket());
-
changeHSV->setCurveMapping(storage);
-
+ converter.addOperation(changeHSV);
+
+ MixBlendOperation *blend = new MixBlendOperation();
blend->setResolutionInputSocketIndex(1);
+ converter.addOperation(blend);
- graph->addOperation(rgbToHSV);
- graph->addOperation(hsvToRGB);
- graph->addOperation(changeHSV);
- graph->addOperation(blend);
+ converter.mapInputSocket(colorSocket, rgbToHSV->getInputSocket(0));
+ converter.addLink(rgbToHSV->getOutputSocket(), changeHSV->getInputSocket(0));
+ converter.addLink(changeHSV->getOutputSocket(), hsvToRGB->getInputSocket(0));
+ converter.addLink(hsvToRGB->getOutputSocket(), blend->getInputSocket(2));
+ converter.mapInputSocket(colorSocket, blend->getInputSocket(1));
+ converter.mapInputSocket(valueSocket, blend->getInputSocket(0));
+ converter.mapOutputSocket(outputSocket, blend->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h
index dd5f70f6579..099ea3d11ce 100644
--- a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h
+++ b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h
@@ -32,6 +32,6 @@
class HueSaturationValueCorrectNode : public Node {
public:
HueSaturationValueCorrectNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp b/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp
index 5001433513c..cdec1250c6e 100644
--- a/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp
+++ b/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp
@@ -35,35 +35,35 @@ HueSaturationValueNode::HueSaturationValueNode(bNode *editorNode) : Node(editorN
/* pass */
}
-void HueSaturationValueNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void HueSaturationValueNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *valueSocket = this->getInputSocket(0);
- InputSocket *colorSocket = this->getInputSocket(1);
- OutputSocket *outputSocket = this->getOutputSocket(0);
+ NodeInput *valueSocket = this->getInputSocket(0);
+ NodeInput *colorSocket = this->getInputSocket(1);
+ NodeOutput *outputSocket = this->getOutputSocket(0);
bNode *editorsnode = getbNode();
NodeHueSat *storage = (NodeHueSat *)editorsnode->storage;
ConvertRGBToHSVOperation *rgbToHSV = new ConvertRGBToHSVOperation();
+ converter.addOperation(rgbToHSV);
+
ConvertHSVToRGBOperation *hsvToRGB = new ConvertHSVToRGBOperation();
+ converter.addOperation(hsvToRGB);
+
ChangeHSVOperation *changeHSV = new ChangeHSVOperation();
- MixBlendOperation *blend = new MixBlendOperation();
-
- colorSocket->relinkConnections(rgbToHSV->getInputSocket(0), 1, graph);
- addLink(graph, rgbToHSV->getOutputSocket(), changeHSV->getInputSocket(0));
- addLink(graph, changeHSV->getOutputSocket(), hsvToRGB->getInputSocket(0));
- addLink(graph, hsvToRGB->getOutputSocket(), blend->getInputSocket(2));
- addLink(graph, rgbToHSV->getInputSocket(0)->getConnection()->getFromSocket(), blend->getInputSocket(1));
- valueSocket->relinkConnections(blend->getInputSocket(0), 0, graph);
- outputSocket->relinkConnections(blend->getOutputSocket());
-
changeHSV->setHue(storage->hue);
changeHSV->setSaturation(storage->sat);
changeHSV->setValue(storage->val);
-
+ converter.addOperation(changeHSV);
+
+ MixBlendOperation *blend = new MixBlendOperation();
blend->setResolutionInputSocketIndex(1);
+ converter.addOperation(blend);
- graph->addOperation(rgbToHSV);
- graph->addOperation(hsvToRGB);
- graph->addOperation(changeHSV);
- graph->addOperation(blend);
+ converter.mapInputSocket(colorSocket, rgbToHSV->getInputSocket(0));
+ converter.addLink(rgbToHSV->getOutputSocket(), changeHSV->getInputSocket(0));
+ converter.addLink(changeHSV->getOutputSocket(), hsvToRGB->getInputSocket(0));
+ converter.addLink(hsvToRGB->getOutputSocket(), blend->getInputSocket(2));
+ converter.mapInputSocket(colorSocket, blend->getInputSocket(1));
+ converter.mapInputSocket(valueSocket, blend->getInputSocket(0));
+ converter.mapOutputSocket(outputSocket, blend->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueNode.h b/source/blender/compositor/nodes/COM_HueSaturationValueNode.h
index 47b89a35269..a599781a3b1 100644
--- a/source/blender/compositor/nodes/COM_HueSaturationValueNode.h
+++ b/source/blender/compositor/nodes/COM_HueSaturationValueNode.h
@@ -32,6 +32,6 @@
class HueSaturationValueNode : public Node {
public:
HueSaturationValueNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_IDMaskNode.cpp b/source/blender/compositor/nodes/COM_IDMaskNode.cpp
index 12a508c75f5..2c16616dc59 100644
--- a/source/blender/compositor/nodes/COM_IDMaskNode.cpp
+++ b/source/blender/compositor/nodes/COM_IDMaskNode.cpp
@@ -29,23 +29,24 @@ IDMaskNode::IDMaskNode(bNode *editorNode) : Node(editorNode)
{
/* pass */
}
-void IDMaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void IDMaskNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
bNode *bnode = this->getbNode();
+
IDMaskOperation *operation;
operation = new IDMaskOperation();
operation->setObjectIndex(bnode->custom1);
+ converter.addOperation(operation);
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- if (bnode->custom2 == 0 || context->getRenderData()->scemode & R_FULL_SAMPLE) {
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ if (bnode->custom2 == 0 || context.getRenderData()->scemode & R_FULL_SAMPLE) {
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
}
else {
AntiAliasOperation *antiAliasOperation = new AntiAliasOperation();
- addLink(graph, operation->getOutputSocket(), antiAliasOperation->getInputSocket(0));
- this->getOutputSocket(0)->relinkConnections(antiAliasOperation->getOutputSocket(0));
- graph->addOperation(antiAliasOperation);
+ converter.addOperation(antiAliasOperation);
+
+ converter.addLink(operation->getOutputSocket(), antiAliasOperation->getInputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(0), antiAliasOperation->getOutputSocket(0));
}
- graph->addOperation(operation);
-
}
diff --git a/source/blender/compositor/nodes/COM_IDMaskNode.h b/source/blender/compositor/nodes/COM_IDMaskNode.h
index 9fd52be2120..a549a3e6ef8 100644
--- a/source/blender/compositor/nodes/COM_IDMaskNode.h
+++ b/source/blender/compositor/nodes/COM_IDMaskNode.h
@@ -32,7 +32,7 @@
class IDMaskNode : public Node {
public:
IDMaskNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ImageNode.cpp b/source/blender/compositor/nodes/COM_ImageNode.cpp
index 5571a186333..e105f530eb2 100644
--- a/source/blender/compositor/nodes/COM_ImageNode.cpp
+++ b/source/blender/compositor/nodes/COM_ImageNode.cpp
@@ -38,9 +38,10 @@ ImageNode::ImageNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-NodeOperation *ImageNode::doMultilayerCheck(ExecutionSystem *system, RenderLayer *rl, Image *image, ImageUser *user, int framenumber, int outputsocketIndex, int passindex, DataType datatype)
+NodeOperation *ImageNode::doMultilayerCheck(NodeConverter &converter, RenderLayer *rl, Image *image, ImageUser *user,
+ int framenumber, int outputsocketIndex, int passindex, DataType datatype) const
{
- OutputSocket *outputSocket = this->getOutputSocket(outputsocketIndex);
+ NodeOutput *outputSocket = this->getOutputSocket(outputsocketIndex);
MultilayerBaseOperation *operation = NULL;
switch (datatype) {
case COM_DT_VALUE:
@@ -59,22 +60,24 @@ NodeOperation *ImageNode::doMultilayerCheck(ExecutionSystem *system, RenderLayer
operation->setRenderLayer(rl);
operation->setImageUser(user);
operation->setFramenumber(framenumber);
- outputSocket->relinkConnections(operation->getOutputSocket());
- system->addOperation(operation);
+
+ converter.addOperation(operation);
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket());
+
return operation;
}
-void ImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void ImageNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
/// Image output
- OutputSocket *outputImage = this->getOutputSocket(0);
+ NodeOutput *outputImage = this->getOutputSocket(0);
bNode *editorNode = this->getbNode();
Image *image = (Image *)editorNode->id;
ImageUser *imageuser = (ImageUser *)editorNode->storage;
- int framenumber = context->getFramenumber();
+ int framenumber = context.getFramenumber();
int numberOfOutputs = this->getNumberOfOutputSockets();
bool outputStraightAlpha = (editorNode->custom1 & CMP_NODE_IMAGE_USE_STRAIGHT_OUTPUT) != 0;
- BKE_image_user_frame_calc(imageuser, context->getFramenumber(), 0);
+ BKE_image_user_frame_calc(imageuser, context.getFramenumber(), 0);
/* force a load, we assume iuser index will be set OK anyway */
if (image && image->type == IMA_TYPE_MULTILAYER) {
@@ -83,7 +86,7 @@ void ImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c
if (image->rr) {
RenderLayer *rl = (RenderLayer *)BLI_findlink(&image->rr->layers, imageuser->layer);
if (rl) {
- OutputSocket *socket;
+ NodeOutput *socket;
int index;
is_multilayer_ok = true;
@@ -91,50 +94,47 @@ void ImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c
for (index = 0; index < numberOfOutputs; index++) {
NodeOperation *operation = NULL;
socket = this->getOutputSocket(index);
- if (socket->isConnected() || index == 0) {
- bNodeSocket *bnodeSocket = socket->getbNodeSocket();
- /* Passes in the file can differ from passes stored in sockets (#36755).
- * Look up the correct file pass using the socket identifier instead.
- */
+ bNodeSocket *bnodeSocket = socket->getbNodeSocket();
+ /* Passes in the file can differ from passes stored in sockets (#36755).
+ * Look up the correct file pass using the socket identifier instead.
+ */
#if 0
- NodeImageLayer *storage = (NodeImageLayer *)bnodeSocket->storage;*/
- int passindex = storage->pass_index;*/
- RenderPass *rpass = (RenderPass *)BLI_findlink(&rl->passes, passindex);
+ NodeImageLayer *storage = (NodeImageLayer *)bnodeSocket->storage;*/
+ int passindex = storage->pass_index;*/
+ RenderPass *rpass = (RenderPass *)BLI_findlink(&rl->passes, passindex);
#endif
- int passindex;
- RenderPass *rpass;
- for (rpass = (RenderPass *)rl->passes.first, passindex = 0; rpass; rpass = rpass->next, ++passindex)
- if (STREQ(rpass->name, bnodeSocket->identifier))
+ int passindex;
+ RenderPass *rpass;
+ for (rpass = (RenderPass *)rl->passes.first, passindex = 0; rpass; rpass = rpass->next, ++passindex)
+ if (STREQ(rpass->name, bnodeSocket->identifier))
+ break;
+ if (rpass) {
+ imageuser->pass = passindex;
+ switch (rpass->channels) {
+ case 1:
+ operation = doMultilayerCheck(converter, rl, image, imageuser, framenumber, index, passindex, COM_DT_VALUE);
break;
- if (rpass) {
- imageuser->pass = passindex;
- switch (rpass->channels) {
- case 1:
- operation = doMultilayerCheck(graph, rl, image, imageuser, framenumber, index, passindex, COM_DT_VALUE);
- break;
/* using image operations for both 3 and 4 channels (RGB and RGBA respectively) */
/* XXX any way to detect actual vector images? */
- case 3:
- operation = doMultilayerCheck(graph, rl, image, imageuser, framenumber, index, passindex, COM_DT_VECTOR);
- break;
- case 4:
- operation = doMultilayerCheck(graph, rl, image, imageuser, framenumber, index, passindex, COM_DT_COLOR);
- break;
- default:
- /* dummy operation is added below */
- break;
- }
-
- if (index == 0 && operation) {
- addPreviewOperation(graph, context, operation->getOutputSocket());
- }
+ case 3:
+ operation = doMultilayerCheck(converter, rl, image, imageuser, framenumber, index, passindex, COM_DT_VECTOR);
+ break;
+ case 4:
+ operation = doMultilayerCheck(converter, rl, image, imageuser, framenumber, index, passindex, COM_DT_COLOR);
+ break;
+ default:
+ /* dummy operation is added below */
+ break;
+ }
+
+ if (index == 0 && operation) {
+ converter.addPreview(operation->getOutputSocket());
}
}
-
+
/* incase we can't load the layer */
- if (operation == NULL) {
- convertToOperations_invalid_index(graph, index);
- }
+ if (operation == NULL)
+ converter.setInvalidOutput(getOutputSocket(index));
}
}
}
@@ -142,66 +142,56 @@ void ImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c
/* without this, multilayer that fail to load will crash blender [#32490] */
if (is_multilayer_ok == false) {
- int index;
- vector<OutputSocket *> &outputsockets = this->getOutputSockets();
- for (index = 0; index < outputsockets.size(); index++) {
- const float warning_color[4] = {0.0f, 0.0f, 0.0f, 0.0f};
- SetColorOperation *operation = new SetColorOperation();
- operation->setChannels(warning_color);
-
- /* link the operation */
- this->getOutputSocket(index)->relinkConnections(operation->getOutputSocket());
- graph->addOperation(operation);
- }
+ for (int i = 0; i < getNumberOfOutputSockets(); ++i)
+ converter.setInvalidOutput(getOutputSocket(i));
}
}
else {
if (numberOfOutputs > 0) {
ImageOperation *operation = new ImageOperation();
- if (outputImage->isConnected()) {
- if (outputStraightAlpha) {
- NodeOperation *alphaConvertOperation = new ConvertPremulToStraightOperation();
- addLink(graph, operation->getOutputSocket(0), alphaConvertOperation->getInputSocket(0));
- outputImage->relinkConnections(alphaConvertOperation->getOutputSocket());
- graph->addOperation(alphaConvertOperation);
- }
- else {
- outputImage->relinkConnections(operation->getOutputSocket());
- }
- }
operation->setImage(image);
operation->setImageUser(imageuser);
operation->setFramenumber(framenumber);
- graph->addOperation(operation);
- addPreviewOperation(graph, context, operation->getOutputSocket());
+ converter.addOperation(operation);
+
+ if (outputStraightAlpha) {
+ NodeOperation *alphaConvertOperation = new ConvertPremulToStraightOperation();
+
+ converter.addOperation(alphaConvertOperation);
+ converter.mapOutputSocket(outputImage, alphaConvertOperation->getOutputSocket());
+ converter.addLink(operation->getOutputSocket(0), alphaConvertOperation->getInputSocket(0));
+ }
+ else {
+ converter.mapOutputSocket(outputImage, operation->getOutputSocket());
+ }
+
+ converter.addPreview(operation->getOutputSocket());
}
if (numberOfOutputs > 1) {
- OutputSocket *alphaImage = this->getOutputSocket(1);
- if (alphaImage->isConnected()) {
- ImageAlphaOperation *alphaOperation = new ImageAlphaOperation();
- alphaOperation->setImage(image);
- alphaOperation->setImageUser(imageuser);
- alphaOperation->setFramenumber(framenumber);
- alphaImage->relinkConnections(alphaOperation->getOutputSocket());
- graph->addOperation(alphaOperation);
- }
+ NodeOutput *alphaImage = this->getOutputSocket(1);
+ ImageAlphaOperation *alphaOperation = new ImageAlphaOperation();
+ alphaOperation->setImage(image);
+ alphaOperation->setImageUser(imageuser);
+ alphaOperation->setFramenumber(framenumber);
+ converter.addOperation(alphaOperation);
+
+ converter.mapOutputSocket(alphaImage, alphaOperation->getOutputSocket());
}
if (numberOfOutputs > 2) {
- OutputSocket *depthImage = this->getOutputSocket(2);
- if (depthImage->isConnected()) {
- ImageDepthOperation *depthOperation = new ImageDepthOperation();
- depthOperation->setImage(image);
- depthOperation->setImageUser(imageuser);
- depthOperation->setFramenumber(framenumber);
- depthImage->relinkConnections(depthOperation->getOutputSocket());
- graph->addOperation(depthOperation);
- }
+ NodeOutput *depthImage = this->getOutputSocket(2);
+ ImageDepthOperation *depthOperation = new ImageDepthOperation();
+ depthOperation->setImage(image);
+ depthOperation->setImageUser(imageuser);
+ depthOperation->setFramenumber(framenumber);
+ converter.addOperation(depthOperation);
+
+ converter.mapOutputSocket(depthImage, depthOperation->getOutputSocket());
}
if (numberOfOutputs > 3) {
/* happens when unlinking image datablock from multilayer node */
for (int i = 3; i < numberOfOutputs; i++) {
- OutputSocket *output = this->getOutputSocket(i);
+ NodeOutput *output = this->getOutputSocket(i);
NodeOperation *operation = NULL;
switch (output->getDataType()) {
case COM_DT_VALUE:
@@ -233,8 +223,8 @@ void ImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c
}
if (operation) {
- output->relinkConnections(operation->getOutputSocket());
- graph->addOperation(operation);
+ converter.addOperation(operation);
+ converter.mapOutputSocket(output, operation->getOutputSocket());
}
}
}
diff --git a/source/blender/compositor/nodes/COM_ImageNode.h b/source/blender/compositor/nodes/COM_ImageNode.h
index c8d53b405a0..1daa39a2a1f 100644
--- a/source/blender/compositor/nodes/COM_ImageNode.h
+++ b/source/blender/compositor/nodes/COM_ImageNode.h
@@ -35,9 +35,10 @@ extern "C" {
*/
class ImageNode : public Node {
private:
- NodeOperation *doMultilayerCheck(ExecutionSystem *system, RenderLayer *rl, Image *image, ImageUser *user, int framenumber, int outputsocketIndex, int passindex, DataType datatype);
+ NodeOperation *doMultilayerCheck(NodeConverter &converter, RenderLayer *rl, Image *image, ImageUser *user,
+ int framenumber, int outputsocketIndex, int passindex, DataType datatype) const;
public:
ImageNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
diff --git a/source/blender/compositor/nodes/COM_InpaintNode.cpp b/source/blender/compositor/nodes/COM_InpaintNode.cpp
index e90a3921edc..1371cdb5f1d 100644
--- a/source/blender/compositor/nodes/COM_InpaintNode.cpp
+++ b/source/blender/compositor/nodes/COM_InpaintNode.cpp
@@ -31,7 +31,7 @@ InpaintNode::InpaintNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void InpaintNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void InpaintNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
bNode *editorNode = this->getbNode();
@@ -39,10 +39,10 @@ void InpaintNode::convertToOperations(ExecutionSystem *graph, CompositorContext
/* if (editorNode->custom1 == CMP_NODE_INPAINT_SIMPLE) { */
if (true) {
InpaintSimpleOperation *operation = new InpaintSimpleOperation();
- operation->setbNode(editorNode);
operation->setIterations(editorNode->custom2);
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
}
}
diff --git a/source/blender/compositor/nodes/COM_InpaintNode.h b/source/blender/compositor/nodes/COM_InpaintNode.h
index 5837b979958..c5ef1c0549e 100644
--- a/source/blender/compositor/nodes/COM_InpaintNode.h
+++ b/source/blender/compositor/nodes/COM_InpaintNode.h
@@ -32,7 +32,7 @@
class InpaintNode : public Node {
public:
InpaintNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_InvertNode.cpp b/source/blender/compositor/nodes/COM_InvertNode.cpp
index 9c4e28a2971..ed4a21132ca 100644
--- a/source/blender/compositor/nodes/COM_InvertNode.cpp
+++ b/source/blender/compositor/nodes/COM_InvertNode.cpp
@@ -30,15 +30,15 @@ InvertNode::InvertNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void InvertNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void InvertNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
InvertOperation *operation = new InvertOperation();
bNode *node = this->getbNode();
operation->setColor(node->custom1 & CMP_CHAN_RGB);
operation->setAlpha(node->custom1 & CMP_CHAN_A);
+ converter.addOperation(operation);
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_InvertNode.h b/source/blender/compositor/nodes/COM_InvertNode.h
index d061f1c12bd..27f3da6cdca 100644
--- a/source/blender/compositor/nodes/COM_InvertNode.h
+++ b/source/blender/compositor/nodes/COM_InvertNode.h
@@ -32,7 +32,7 @@
class InvertNode : public Node {
public:
InvertNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_KeyingNode.cpp b/source/blender/compositor/nodes/COM_KeyingNode.cpp
index 786530bd3c4..e896b7144e5 100644
--- a/source/blender/compositor/nodes/COM_KeyingNode.cpp
+++ b/source/blender/compositor/nodes/COM_KeyingNode.cpp
@@ -47,83 +47,74 @@ KeyingNode::KeyingNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-OutputSocket *KeyingNode::setupPreBlur(ExecutionSystem *graph, InputSocket *inputImage, int size, OutputSocket **originalImage)
+NodeOperationOutput *KeyingNode::setupPreBlur(NodeConverter &converter, NodeInput *inputImage, int size) const
{
ConvertRGBToYCCOperation *convertRGBToYCCOperation = new ConvertRGBToYCCOperation();
convertRGBToYCCOperation->setMode(0); /* ITU 601 */
-
- inputImage->relinkConnections(convertRGBToYCCOperation->getInputSocket(0), 0, graph);
- graph->addOperation(convertRGBToYCCOperation);
-
+ converter.addOperation(convertRGBToYCCOperation);
+
+ converter.mapInputSocket(inputImage, convertRGBToYCCOperation->getInputSocket(0));
+
CombineChannelsOperation *combineOperation = new CombineChannelsOperation();
- graph->addOperation(combineOperation);
+ converter.addOperation(combineOperation);
for (int channel = 0; channel < 4; channel++) {
SeparateChannelOperation *separateOperation = new SeparateChannelOperation();
separateOperation->setChannel(channel);
- addLink(graph, convertRGBToYCCOperation->getOutputSocket(0), separateOperation->getInputSocket(0));
- graph->addOperation(separateOperation);
-
+ converter.addOperation(separateOperation);
+
+ converter.addLink(convertRGBToYCCOperation->getOutputSocket(0), separateOperation->getInputSocket(0));
+
if (channel == 0 || channel == 3) {
- addLink(graph, separateOperation->getOutputSocket(0), combineOperation->getInputSocket(channel));
+ converter.addLink(separateOperation->getOutputSocket(0), combineOperation->getInputSocket(channel));
}
else {
KeyingBlurOperation *blurXOperation = new KeyingBlurOperation();
- KeyingBlurOperation *blurYOperation = new KeyingBlurOperation();
-
blurXOperation->setSize(size);
blurXOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_X);
- blurXOperation->setbNode(this->getbNode());
-
+ converter.addOperation(blurXOperation);
+
+ KeyingBlurOperation *blurYOperation = new KeyingBlurOperation();
blurYOperation->setSize(size);
blurYOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_Y);
- blurYOperation->setbNode(this->getbNode());
-
- addLink(graph, separateOperation->getOutputSocket(), blurXOperation->getInputSocket(0));
- addLink(graph, blurXOperation->getOutputSocket(), blurYOperation->getInputSocket(0));
- addLink(graph, blurYOperation->getOutputSocket(0), combineOperation->getInputSocket(channel));
-
- graph->addOperation(blurXOperation);
- graph->addOperation(blurYOperation);
+ converter.addOperation(blurYOperation);
+
+ converter.addLink(separateOperation->getOutputSocket(), blurXOperation->getInputSocket(0));
+ converter.addLink(blurXOperation->getOutputSocket(), blurYOperation->getInputSocket(0));
+ converter.addLink(blurYOperation->getOutputSocket(0), combineOperation->getInputSocket(channel));
}
}
-
+
ConvertYCCToRGBOperation *convertYCCToRGBOperation = new ConvertYCCToRGBOperation();
convertYCCToRGBOperation->setMode(0); /* ITU 601 */
- addLink(graph, combineOperation->getOutputSocket(0), convertYCCToRGBOperation->getInputSocket(0));
- graph->addOperation(convertYCCToRGBOperation);
-
- *originalImage = convertRGBToYCCOperation->getInputSocket(0)->getConnection()->getFromSocket();
-
+ converter.addOperation(convertYCCToRGBOperation);
+
+ converter.addLink(combineOperation->getOutputSocket(0), convertYCCToRGBOperation->getInputSocket(0));
+
return convertYCCToRGBOperation->getOutputSocket(0);
}
-OutputSocket *KeyingNode::setupPostBlur(ExecutionSystem *graph, OutputSocket *postBlurInput, int size)
+NodeOperationOutput *KeyingNode::setupPostBlur(NodeConverter &converter, NodeOperationOutput *postBlurInput, int size) const
{
KeyingBlurOperation *blurXOperation = new KeyingBlurOperation();
- KeyingBlurOperation *blurYOperation = new KeyingBlurOperation();
-
blurXOperation->setSize(size);
blurXOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_X);
- blurXOperation->setbNode(this->getbNode());
-
+ converter.addOperation(blurXOperation);
+
+ KeyingBlurOperation *blurYOperation = new KeyingBlurOperation();
blurYOperation->setSize(size);
blurYOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_Y);
- blurYOperation->setbNode(this->getbNode());
-
- addLink(graph, postBlurInput, blurXOperation->getInputSocket(0));
- addLink(graph, blurXOperation->getOutputSocket(), blurYOperation->getInputSocket(0));
-
- graph->addOperation(blurXOperation);
- graph->addOperation(blurYOperation);
-
+ converter.addOperation(blurYOperation);
+
+ converter.addLink(postBlurInput, blurXOperation->getInputSocket(0));
+ converter.addLink(blurXOperation->getOutputSocket(), blurYOperation->getInputSocket(0));
+
return blurYOperation->getOutputSocket();
}
-OutputSocket *KeyingNode::setupDilateErode(ExecutionSystem *graph, OutputSocket *dilateErodeInput, int distance)
+NodeOperationOutput *KeyingNode::setupDilateErode(NodeConverter &converter, NodeOperationOutput *dilateErodeInput, int distance) const
{
DilateDistanceOperation *dilateErodeOperation;
-
if (distance > 0) {
dilateErodeOperation = new DilateDistanceOperation();
dilateErodeOperation->setDistance(distance);
@@ -132,211 +123,194 @@ OutputSocket *KeyingNode::setupDilateErode(ExecutionSystem *graph, OutputSocket
dilateErodeOperation = new ErodeDistanceOperation();
dilateErodeOperation->setDistance(-distance);
}
- dilateErodeOperation->setbNode(this->getbNode());
-
- addLink(graph, dilateErodeInput, dilateErodeOperation->getInputSocket(0));
-
- graph->addOperation(dilateErodeOperation);
-
+ converter.addOperation(dilateErodeOperation);
+
+ converter.addLink(dilateErodeInput, dilateErodeOperation->getInputSocket(0));
+
return dilateErodeOperation->getOutputSocket(0);
}
-OutputSocket *KeyingNode::setupFeather(ExecutionSystem *graph, CompositorContext *context,
- OutputSocket *featherInput, int falloff, int distance)
+NodeOperationOutput *KeyingNode::setupFeather(NodeConverter &converter, const CompositorContext &context,
+ NodeOperationOutput *featherInput, int falloff, int distance) const
{
/* this uses a modified gaussian blur function otherwise its far too slow */
- CompositorQuality quality = context->getQuality();
+ CompositorQuality quality = context.getQuality();
/* initialize node data */
- NodeBlurData *data = &this->m_alpha_blur;
- memset(data, 0, sizeof(*data));
- data->filtertype = R_FILTER_GAUSS;
-
+ NodeBlurData data;
+ memset(&data, 0, sizeof(NodeBlurData));
+ data.filtertype = R_FILTER_GAUSS;
if (distance > 0) {
- data->sizex = data->sizey = distance;
+ data.sizex = data.sizey = distance;
}
else {
- data->sizex = data->sizey = -distance;
+ data.sizex = data.sizey = -distance;
}
GaussianAlphaXBlurOperation *operationx = new GaussianAlphaXBlurOperation();
- operationx->setData(data);
+ operationx->setData(&data);
operationx->setQuality(quality);
operationx->setSize(1.0f);
operationx->setSubtract(distance < 0);
operationx->setFalloff(falloff);
- operationx->setbNode(this->getbNode());
- graph->addOperation(operationx);
+ converter.addOperation(operationx);
GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation();
- operationy->setData(data);
+ operationy->setData(&data);
operationy->setQuality(quality);
operationy->setSize(1.0f);
operationy->setSubtract(distance < 0);
operationy->setFalloff(falloff);
- operationy->setbNode(this->getbNode());
- graph->addOperation(operationy);
+ converter.addOperation(operationy);
- addLink(graph, featherInput, operationx->getInputSocket(0));
- addLink(graph, operationx->getOutputSocket(), operationy->getInputSocket(0));
+ converter.addLink(featherInput, operationx->getInputSocket(0));
+ converter.addLink(operationx->getOutputSocket(), operationy->getInputSocket(0));
return operationy->getOutputSocket();
}
-OutputSocket *KeyingNode::setupDespill(ExecutionSystem *graph, OutputSocket *despillInput, OutputSocket *inputScreen,
- float factor, float colorBalance)
+NodeOperationOutput *KeyingNode::setupDespill(NodeConverter &converter, NodeOperationOutput *despillInput, NodeInput *inputScreen,
+ float factor, float colorBalance) const
{
KeyingDespillOperation *despillOperation = new KeyingDespillOperation();
-
despillOperation->setDespillFactor(factor);
despillOperation->setColorBalance(colorBalance);
-
- addLink(graph, despillInput, despillOperation->getInputSocket(0));
- addLink(graph, inputScreen, despillOperation->getInputSocket(1));
-
- graph->addOperation(despillOperation);
-
+ converter.addOperation(despillOperation);
+
+ converter.addLink(despillInput, despillOperation->getInputSocket(0));
+ converter.mapInputSocket(inputScreen, despillOperation->getInputSocket(1));
+
return despillOperation->getOutputSocket(0);
}
-OutputSocket *KeyingNode::setupClip(ExecutionSystem *graph, OutputSocket *clipInput, int kernelRadius, float kernelTolerance,
- float clipBlack, float clipWhite, bool edgeMatte)
+NodeOperationOutput *KeyingNode::setupClip(NodeConverter &converter, NodeOperationOutput *clipInput, int kernelRadius, float kernelTolerance,
+ float clipBlack, float clipWhite, bool edgeMatte) const
{
KeyingClipOperation *clipOperation = new KeyingClipOperation();
-
clipOperation->setKernelRadius(kernelRadius);
clipOperation->setKernelTolerance(kernelTolerance);
-
clipOperation->setClipBlack(clipBlack);
clipOperation->setClipWhite(clipWhite);
clipOperation->setIsEdgeMatte(edgeMatte);
-
- addLink(graph, clipInput, clipOperation->getInputSocket(0));
-
- graph->addOperation(clipOperation);
-
+ converter.addOperation(clipOperation);
+
+ converter.addLink(clipInput, clipOperation->getInputSocket(0));
+
return clipOperation->getOutputSocket(0);
}
-void KeyingNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void KeyingNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *inputImage = this->getInputSocket(0);
- InputSocket *inputScreen = this->getInputSocket(1);
- InputSocket *inputGarbageMatte = this->getInputSocket(2);
- InputSocket *inputCoreMatte = this->getInputSocket(3);
- OutputSocket *outputImage = this->getOutputSocket(0);
- OutputSocket *outputMatte = this->getOutputSocket(1);
- OutputSocket *outputEdges = this->getOutputSocket(2);
- OutputSocket *postprocessedMatte = NULL, *postprocessedImage = NULL, *originalImage = NULL, *edgesMatte = NULL;
-
bNode *editorNode = this->getbNode();
NodeKeyingData *keying_data = (NodeKeyingData *) editorNode->storage;
-
+
+ NodeInput *inputImage = this->getInputSocket(0);
+ NodeInput *inputScreen = this->getInputSocket(1);
+ NodeInput *inputGarbageMatte = this->getInputSocket(2);
+ NodeInput *inputCoreMatte = this->getInputSocket(3);
+ NodeOutput *outputImage = this->getOutputSocket(0);
+ NodeOutput *outputMatte = this->getOutputSocket(1);
+ NodeOutput *outputEdges = this->getOutputSocket(2);
+ NodeOperationOutput *postprocessedMatte = NULL, *postprocessedImage = NULL, *edgesMatte = NULL;
+
/* keying operation */
KeyingOperation *keyingOperation = new KeyingOperation();
-
keyingOperation->setScreenBalance(keying_data->screen_balance);
-
- inputScreen->relinkConnections(keyingOperation->getInputSocket(1), 1, graph);
-
+ converter.addOperation(keyingOperation);
+
+ converter.mapInputSocket(inputScreen, keyingOperation->getInputSocket(1));
+
if (keying_data->blur_pre) {
/* chroma preblur operation for input of keying operation */
- OutputSocket *preBluredImage = setupPreBlur(graph, inputImage, keying_data->blur_pre, &originalImage);
- addLink(graph, preBluredImage, keyingOperation->getInputSocket(0));
+ NodeOperationOutput *preBluredImage = setupPreBlur(converter, inputImage, keying_data->blur_pre);
+ converter.addLink(preBluredImage, keyingOperation->getInputSocket(0));
}
else {
- inputImage->relinkConnections(keyingOperation->getInputSocket(0), 0, graph);
- originalImage = keyingOperation->getInputSocket(0)->getConnection()->getFromSocket();
+ converter.mapInputSocket(inputImage, keyingOperation->getInputSocket(0));
}
-
- graph->addOperation(keyingOperation);
-
+
postprocessedMatte = keyingOperation->getOutputSocket();
-
+
/* black / white clipping */
if (keying_data->clip_black > 0.0f || keying_data->clip_white < 1.0f) {
- postprocessedMatte = setupClip(graph, postprocessedMatte,
+ postprocessedMatte = setupClip(converter, postprocessedMatte,
keying_data->edge_kernel_radius, keying_data->edge_kernel_tolerance,
keying_data->clip_black, keying_data->clip_white, false);
}
-
+
/* output edge matte */
- if (outputEdges->isConnected()) {
- edgesMatte = setupClip(graph, postprocessedMatte,
- keying_data->edge_kernel_radius, keying_data->edge_kernel_tolerance,
- keying_data->clip_black, keying_data->clip_white, true);
- }
-
+ edgesMatte = setupClip(converter, postprocessedMatte,
+ keying_data->edge_kernel_radius, keying_data->edge_kernel_tolerance,
+ keying_data->clip_black, keying_data->clip_white, true);
+
/* apply garbage matte */
- if (inputGarbageMatte->isConnected()) {
+ if (inputGarbageMatte->isLinked()) {
SetValueOperation *valueOperation = new SetValueOperation();
+ valueOperation->setValue(1.0f);
+ converter.addOperation(valueOperation);
+
MathSubtractOperation *subtractOperation = new MathSubtractOperation();
+ converter.addOperation(subtractOperation);
+
MathMinimumOperation *minOperation = new MathMinimumOperation();
-
- valueOperation->setValue(1.0f);
-
- addLink(graph, valueOperation->getOutputSocket(), subtractOperation->getInputSocket(0));
- inputGarbageMatte->relinkConnections(subtractOperation->getInputSocket(1), 0, graph);
-
- addLink(graph, subtractOperation->getOutputSocket(), minOperation->getInputSocket(0));
- addLink(graph, postprocessedMatte, minOperation->getInputSocket(1));
-
+ converter.addOperation(minOperation);
+
+ converter.addLink(valueOperation->getOutputSocket(), subtractOperation->getInputSocket(0));
+ converter.mapInputSocket(inputGarbageMatte, subtractOperation->getInputSocket(1));
+
+ converter.addLink(subtractOperation->getOutputSocket(), minOperation->getInputSocket(0));
+ converter.addLink(postprocessedMatte, minOperation->getInputSocket(1));
+
postprocessedMatte = minOperation->getOutputSocket();
-
- graph->addOperation(valueOperation);
- graph->addOperation(subtractOperation);
- graph->addOperation(minOperation);
}
-
+
/* apply core matte */
- if (inputCoreMatte->isConnected()) {
+ if (inputCoreMatte->isLinked()) {
MathMaximumOperation *maxOperation = new MathMaximumOperation();
-
- inputCoreMatte->relinkConnections(maxOperation->getInputSocket(0), 0, graph);
-
- addLink(graph, postprocessedMatte, maxOperation->getInputSocket(1));
-
+ converter.addOperation(maxOperation);
+
+ converter.mapInputSocket(inputCoreMatte, maxOperation->getInputSocket(0));
+ converter.addLink(postprocessedMatte, maxOperation->getInputSocket(1));
+
postprocessedMatte = maxOperation->getOutputSocket();
-
- graph->addOperation(maxOperation);
}
-
+
/* apply blur on matte if needed */
if (keying_data->blur_post)
- postprocessedMatte = setupPostBlur(graph, postprocessedMatte, keying_data->blur_post);
+ postprocessedMatte = setupPostBlur(converter, postprocessedMatte, keying_data->blur_post);
/* matte dilate/erode */
if (keying_data->dilate_distance != 0) {
- postprocessedMatte = setupDilateErode(graph, postprocessedMatte, keying_data->dilate_distance);
+ postprocessedMatte = setupDilateErode(converter, postprocessedMatte, keying_data->dilate_distance);
}
/* matte feather */
if (keying_data->feather_distance != 0) {
- postprocessedMatte = setupFeather(graph, context, postprocessedMatte, keying_data->feather_falloff,
+ postprocessedMatte = setupFeather(converter, context, postprocessedMatte, keying_data->feather_falloff,
keying_data->feather_distance);
}
/* set alpha channel to output image */
SetAlphaOperation *alphaOperation = new SetAlphaOperation();
- addLink(graph, originalImage, alphaOperation->getInputSocket(0));
- addLink(graph, postprocessedMatte, alphaOperation->getInputSocket(1));
+ converter.addOperation(alphaOperation);
+
+ converter.mapInputSocket(inputImage, alphaOperation->getInputSocket(0));
+ converter.addLink(postprocessedMatte, alphaOperation->getInputSocket(1));
postprocessedImage = alphaOperation->getOutputSocket();
/* despill output image */
if (keying_data->despill_factor > 0.0f) {
- postprocessedImage = setupDespill(graph, postprocessedImage,
- keyingOperation->getInputSocket(1)->getConnection()->getFromSocket(),
+ postprocessedImage = setupDespill(converter, postprocessedImage,
+ inputScreen,
keying_data->despill_factor,
keying_data->despill_balance);
}
/* connect result to output sockets */
- outputImage->relinkConnections(postprocessedImage);
- outputMatte->relinkConnections(postprocessedMatte);
+ converter.mapOutputSocket(outputImage, postprocessedImage);
+ converter.mapOutputSocket(outputMatte, postprocessedMatte);
if (edgesMatte)
- outputEdges->relinkConnections(edgesMatte);
-
- graph->addOperation(alphaOperation);
+ converter.mapOutputSocket(outputEdges, edgesMatte);
}
diff --git a/source/blender/compositor/nodes/COM_KeyingNode.h b/source/blender/compositor/nodes/COM_KeyingNode.h
index 6ab6a60a44d..f4a6c02aa56 100644
--- a/source/blender/compositor/nodes/COM_KeyingNode.h
+++ b/source/blender/compositor/nodes/COM_KeyingNode.h
@@ -29,19 +29,17 @@
*/
class KeyingNode : public Node {
protected:
- NodeBlurData m_alpha_blur; /* only used for blurring alpha, since the dilate/erode node doesnt have this */
-
- OutputSocket *setupPreBlur(ExecutionSystem *graph, InputSocket *inputImage, int size, OutputSocket **originalImage);
- OutputSocket *setupPostBlur(ExecutionSystem *graph, OutputSocket *postBlurInput, int size);
- OutputSocket *setupDilateErode(ExecutionSystem *graph, OutputSocket *dilateErodeInput, int distance);
- OutputSocket *setupFeather(ExecutionSystem *graph, CompositorContext *context, OutputSocket *featherInput,
- int falloff, int distance);
- OutputSocket *setupDespill(ExecutionSystem *graph, OutputSocket *despillInput, OutputSocket *inputSrceen,
- float factor, float colorBalance);
- OutputSocket *setupClip(ExecutionSystem *graph, OutputSocket *clipInput, int kernelRadius, float kernelTolerance,
- float clipBlack, float clipWhite, bool edgeMatte);
+ NodeOperationOutput *setupPreBlur(NodeConverter &converter, NodeInput *inputImage, int size) const;
+ NodeOperationOutput *setupPostBlur(NodeConverter &converter, NodeOperationOutput *postBlurInput, int size) const;
+ NodeOperationOutput *setupDilateErode(NodeConverter &converter, NodeOperationOutput *dilateErodeInput, int distance) const;
+ NodeOperationOutput *setupFeather(NodeConverter &converter, const CompositorContext &context, NodeOperationOutput *featherInput,
+ int falloff, int distance) const;
+ NodeOperationOutput *setupDespill(NodeConverter &converter, NodeOperationOutput *despillInput, NodeInput *inputSrceen,
+ float factor, float colorBalance) const;
+ NodeOperationOutput *setupClip(NodeConverter &converter, NodeOperationOutput *clipInput, int kernelRadius, float kernelTolerance,
+ float clipBlack, float clipWhite, bool edgeMatte) const;
public:
KeyingNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
diff --git a/source/blender/compositor/nodes/COM_KeyingScreenNode.cpp b/source/blender/compositor/nodes/COM_KeyingScreenNode.cpp
index 59d889d0c84..70b3b696e37 100644
--- a/source/blender/compositor/nodes/COM_KeyingScreenNode.cpp
+++ b/source/blender/compositor/nodes/COM_KeyingScreenNode.cpp
@@ -34,26 +34,20 @@ KeyingScreenNode::KeyingScreenNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void KeyingScreenNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void KeyingScreenNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- OutputSocket *outputScreen = this->getOutputSocket(0);
-
bNode *editorNode = this->getbNode();
MovieClip *clip = (MovieClip *) editorNode->id;
-
NodeKeyingScreenData *keyingscreen_data = (NodeKeyingScreenData *) editorNode->storage;
-
+
+ NodeOutput *outputScreen = this->getOutputSocket(0);
+
// always connect the output image
KeyingScreenOperation *operation = new KeyingScreenOperation();
- operation->setbNode(editorNode);
-
- if (outputScreen->isConnected()) {
- outputScreen->relinkConnections(operation->getOutputSocket());
- }
-
operation->setMovieClip(clip);
operation->setTrackingObject(keyingscreen_data->tracking_object);
- operation->setFramenumber(context->getFramenumber());
-
- graph->addOperation(operation);
+ operation->setFramenumber(context.getFramenumber());
+ converter.addOperation(operation);
+
+ converter.mapOutputSocket(outputScreen, operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_KeyingScreenNode.h b/source/blender/compositor/nodes/COM_KeyingScreenNode.h
index 9b8ac88bb6e..be29b939690 100644
--- a/source/blender/compositor/nodes/COM_KeyingScreenNode.h
+++ b/source/blender/compositor/nodes/COM_KeyingScreenNode.h
@@ -31,6 +31,6 @@
class KeyingScreenNode : public Node {
public:
KeyingScreenNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
diff --git a/source/blender/compositor/nodes/COM_LensDistortionNode.cpp b/source/blender/compositor/nodes/COM_LensDistortionNode.cpp
index 9af1fceaae0..32db452e6c2 100644
--- a/source/blender/compositor/nodes/COM_LensDistortionNode.cpp
+++ b/source/blender/compositor/nodes/COM_LensDistortionNode.cpp
@@ -30,38 +30,33 @@ LensDistortionNode::LensDistortionNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void LensDistortionNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void LensDistortionNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
bNode *editorNode = this->getbNode();
NodeLensDist *data = (NodeLensDist *)editorNode->storage;
if (data->proj) {
ProjectorLensDistortionOperation *operation = new ProjectorLensDistortionOperation();
- operation->setbNode(editorNode);
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- this->getInputSocket(2)->relinkConnections(operation->getInputSocket(1), 2, graph);
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
-
- graph->addOperation(operation);
-
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(1));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
}
else {
ScreenLensDistortionOperation *operation = new ScreenLensDistortionOperation();
- operation->setbNode(editorNode);
operation->setFit(data->fit);
operation->setJitter(data->jit);
- if (!getInputSocket(1)->isConnected())
+ if (!getInputSocket(1)->isLinked())
operation->setDistortion(getInputSocket(1)->getEditorValueFloat());
- if (!getInputSocket(2)->isConnected())
+ if (!getInputSocket(2)->isLinked())
operation->setDispersion(getInputSocket(2)->getEditorValueFloat());
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
- this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), 2, graph);
-
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
-
- graph->addOperation(operation);
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
+ converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
}
-
}
diff --git a/source/blender/compositor/nodes/COM_LensDistortionNode.h b/source/blender/compositor/nodes/COM_LensDistortionNode.h
index 52529823441..4d5dc2e2705 100644
--- a/source/blender/compositor/nodes/COM_LensDistortionNode.h
+++ b/source/blender/compositor/nodes/COM_LensDistortionNode.h
@@ -32,7 +32,7 @@
class LensDistortionNode : public Node {
public:
LensDistortionNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp b/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp
index b1e6967ba42..e23ec243ff4 100644
--- a/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp
@@ -30,34 +30,29 @@ LuminanceMatteNode::LuminanceMatteNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void LuminanceMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void LuminanceMatteNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *inputSocket = this->getInputSocket(0);
- OutputSocket *outputSocketImage = this->getOutputSocket(0);
- OutputSocket *outputSocketMatte = this->getOutputSocket(1);
+ bNode *editorsnode = getbNode();
+ NodeInput *inputSocket = this->getInputSocket(0);
+ NodeOutput *outputSocketImage = this->getOutputSocket(0);
+ NodeOutput *outputSocketMatte = this->getOutputSocket(1);
ConvertRGBToYUVOperation *rgbToYUV = new ConvertRGBToYUVOperation();
LuminanceMatteOperation *operationSet = new LuminanceMatteOperation();
- bNode *editorsnode = getbNode();
operationSet->setSettings((NodeChroma *)editorsnode->storage);
+ converter.addOperation(rgbToYUV);
+ converter.addOperation(operationSet);
- inputSocket->relinkConnections(rgbToYUV->getInputSocket(0), 0, graph);
- addLink(graph, rgbToYUV->getOutputSocket(), operationSet->getInputSocket(0));
-
- if (outputSocketMatte->isConnected()) {
- outputSocketMatte->relinkConnections(operationSet->getOutputSocket(0));
- }
-
- graph->addOperation(rgbToYUV);
- graph->addOperation(operationSet);
+ converter.mapInputSocket(inputSocket, rgbToYUV->getInputSocket(0));
+ converter.addLink(rgbToYUV->getOutputSocket(), operationSet->getInputSocket(0));
+ converter.mapOutputSocket(outputSocketMatte, operationSet->getOutputSocket(0));
SetAlphaOperation *operation = new SetAlphaOperation();
- addLink(graph, rgbToYUV->getInputSocket(0)->getConnection()->getFromSocket(), operation->getInputSocket(0));
- addLink(graph, operationSet->getOutputSocket(), operation->getInputSocket(1));
- graph->addOperation(operation);
- addPreviewOperation(graph, context, operation->getOutputSocket());
-
- if (outputSocketImage->isConnected()) {
- outputSocketImage->relinkConnections(operation->getOutputSocket());
- }
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
+ converter.addLink(operationSet->getOutputSocket(), operation->getInputSocket(1));
+ converter.mapOutputSocket(outputSocketImage, operation->getOutputSocket());
+
+ converter.addPreview(operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_LuminanceMatteNode.h b/source/blender/compositor/nodes/COM_LuminanceMatteNode.h
index a71e68cf636..a36e6f2e732 100644
--- a/source/blender/compositor/nodes/COM_LuminanceMatteNode.h
+++ b/source/blender/compositor/nodes/COM_LuminanceMatteNode.h
@@ -31,7 +31,7 @@
class LuminanceMatteNode : public Node {
public:
LuminanceMatteNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif /* __COM_LUMINANCEMATTENODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_MapRangeNode.cpp b/source/blender/compositor/nodes/COM_MapRangeNode.cpp
index 232be3d41b0..2c164cfad32 100644
--- a/source/blender/compositor/nodes/COM_MapRangeNode.cpp
+++ b/source/blender/compositor/nodes/COM_MapRangeNode.cpp
@@ -30,25 +30,23 @@ MapRangeNode::MapRangeNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void MapRangeNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void MapRangeNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *valueSocket = this->getInputSocket(0);
- InputSocket *sourceMinSocket = this->getInputSocket(1);
- InputSocket *sourceMaxSocket = this->getInputSocket(2);
- InputSocket *destMinSocket = this->getInputSocket(3);
- InputSocket *destMaxSocket = this->getInputSocket(4);
- OutputSocket *outputSocket = this->getOutputSocket(0);
-
+ NodeInput *valueSocket = this->getInputSocket(0);
+ NodeInput *sourceMinSocket = this->getInputSocket(1);
+ NodeInput *sourceMaxSocket = this->getInputSocket(2);
+ NodeInput *destMinSocket = this->getInputSocket(3);
+ NodeInput *destMaxSocket = this->getInputSocket(4);
+ NodeOutput *outputSocket = this->getOutputSocket(0);
+
MapRangeOperation *operation = new MapRangeOperation();
-
- valueSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
- sourceMinSocket->relinkConnections(operation->getInputSocket(1), 1, graph);
- sourceMaxSocket->relinkConnections(operation->getInputSocket(2), 2, graph);
- destMinSocket->relinkConnections(operation->getInputSocket(3), 3, graph);
- destMaxSocket->relinkConnections(operation->getInputSocket(4), 4, graph);
- outputSocket->relinkConnections(operation->getOutputSocket(0));
-
operation->setUseClamp(this->getbNode()->custom1);
-
- graph->addOperation(operation);
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(valueSocket, operation->getInputSocket(0));
+ converter.mapInputSocket(sourceMinSocket, operation->getInputSocket(1));
+ converter.mapInputSocket(sourceMaxSocket, operation->getInputSocket(2));
+ converter.mapInputSocket(destMinSocket, operation->getInputSocket(3));
+ converter.mapInputSocket(destMaxSocket, operation->getInputSocket(4));
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_MapRangeNode.h b/source/blender/compositor/nodes/COM_MapRangeNode.h
index 6667720be3d..0ef4309602d 100644
--- a/source/blender/compositor/nodes/COM_MapRangeNode.h
+++ b/source/blender/compositor/nodes/COM_MapRangeNode.h
@@ -32,7 +32,7 @@
class MapRangeNode : public Node {
public:
MapRangeNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif /* __COM_MAPRANGENODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_MapUVNode.cpp b/source/blender/compositor/nodes/COM_MapUVNode.cpp
index 447b8239a93..25ca7b8b8c6 100644
--- a/source/blender/compositor/nodes/COM_MapUVNode.cpp
+++ b/source/blender/compositor/nodes/COM_MapUVNode.cpp
@@ -28,17 +28,16 @@ MapUVNode::MapUVNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void MapUVNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void MapUVNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- MapUVOperation *operation = new MapUVOperation();
-
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
-
bNode *node = this->getbNode();
+
+ MapUVOperation *operation = new MapUVOperation();
operation->setAlpha((float)node->custom1);
operation->setResolutionInputSocketIndex(1);
+ converter.addOperation(operation);
- graph->addOperation(operation);
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_MapUVNode.h b/source/blender/compositor/nodes/COM_MapUVNode.h
index 2e5616e0bd0..286ec4205f1 100644
--- a/source/blender/compositor/nodes/COM_MapUVNode.h
+++ b/source/blender/compositor/nodes/COM_MapUVNode.h
@@ -31,6 +31,6 @@
class MapUVNode : public Node {
public:
MapUVNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_MapValueNode.cpp b/source/blender/compositor/nodes/COM_MapValueNode.cpp
index ac57ffed9da..d7ee4e6a38b 100644
--- a/source/blender/compositor/nodes/COM_MapValueNode.cpp
+++ b/source/blender/compositor/nodes/COM_MapValueNode.cpp
@@ -30,14 +30,17 @@ MapValueNode::MapValueNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void MapValueNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void MapValueNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *colorSocket = this->getInputSocket(0);
- OutputSocket *valueSocket = this->getOutputSocket(0);
TexMapping *storage = (TexMapping *)this->getbNode()->storage;
+
+ NodeInput *colorSocket = this->getInputSocket(0);
+ NodeOutput *valueSocket = this->getOutputSocket(0);
+
MapValueOperation *convertProg = new MapValueOperation();
convertProg->setSettings(storage);
- colorSocket->relinkConnections(convertProg->getInputSocket(0), 0, graph);
- valueSocket->relinkConnections(convertProg->getOutputSocket(0));
- graph->addOperation(convertProg);
+ converter.addOperation(convertProg);
+
+ converter.mapInputSocket(colorSocket, convertProg->getInputSocket(0));
+ converter.mapOutputSocket(valueSocket, convertProg->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_MapValueNode.h b/source/blender/compositor/nodes/COM_MapValueNode.h
index bd8e3d08e9c..8b82b31350d 100644
--- a/source/blender/compositor/nodes/COM_MapValueNode.h
+++ b/source/blender/compositor/nodes/COM_MapValueNode.h
@@ -32,7 +32,7 @@
class MapValueNode : public Node {
public:
MapValueNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif /* __COM_MAPVALUENODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_MaskNode.cpp b/source/blender/compositor/nodes/COM_MaskNode.cpp
index 65ff443b55b..be05840f601 100644
--- a/source/blender/compositor/nodes/COM_MaskNode.cpp
+++ b/source/blender/compositor/nodes/COM_MaskNode.cpp
@@ -34,11 +34,11 @@ MaskNode::MaskNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void MaskNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- const RenderData *rd = context->getRenderData();
+ const RenderData *rd = context.getRenderData();
- OutputSocket *outputMask = this->getOutputSocket(0);
+ NodeOutput *outputMask = this->getOutputSocket(0);
bNode *editorNode = this->getbNode();
NodeMask *data = (NodeMask *)editorNode->storage;
@@ -46,7 +46,6 @@ void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
// always connect the output image
MaskOperation *operation = new MaskOperation();
- operation->setbNode(editorNode);
if (editorNode->custom1 & CMP_NODEFLAG_MASK_FIXED) {
operation->setMaskWidth(data->size_x);
@@ -61,12 +60,8 @@ void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
operation->setMaskHeight(rd->ysch * rd->size / 100.0f);
}
- if (outputMask->isConnected()) {
- outputMask->relinkConnections(operation->getOutputSocket());
- }
-
operation->setMask(mask);
- operation->setFramenumber(context->getFramenumber());
+ operation->setFramenumber(context.getFramenumber());
operation->setSmooth((bool)(editorNode->custom1 & CMP_NODEFLAG_MASK_AA) != 0);
operation->setFeather((bool)(editorNode->custom1 & CMP_NODEFLAG_MASK_NO_FEATHER) == 0);
@@ -78,5 +73,6 @@ void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
operation->setMotionBlurShutter(editorNode->custom3);
}
- graph->addOperation(operation);
+ converter.addOperation(operation);
+ converter.mapOutputSocket(outputMask, operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_MaskNode.h b/source/blender/compositor/nodes/COM_MaskNode.h
index 9ef3e5deb50..834c421ac08 100644
--- a/source/blender/compositor/nodes/COM_MaskNode.h
+++ b/source/blender/compositor/nodes/COM_MaskNode.h
@@ -34,7 +34,7 @@
class MaskNode : public Node {
public:
MaskNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
diff --git a/source/blender/compositor/nodes/COM_MathNode.cpp b/source/blender/compositor/nodes/COM_MathNode.cpp
index 23e9a9d623d..ef7046b8165 100644
--- a/source/blender/compositor/nodes/COM_MathNode.cpp
+++ b/source/blender/compositor/nodes/COM_MathNode.cpp
@@ -24,7 +24,7 @@
#include "COM_MathBaseOperation.h"
#include "COM_ExecutionSystem.h"
-void MathNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void MathNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
MathBaseOperation *operation = NULL;
@@ -83,17 +83,18 @@ void MathNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
case 17: /* Modulo */
operation = new MathModuloOperation();
break;
+ case 18: /* Absolute Value */
+ operation = new MathAbsoluteOperation();
+ break;
}
- if (operation != NULL) {
- bool useClamp = this->getbNode()->custom2;
-
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
-
+ if (operation) {
+ bool useClamp = getbNode()->custom2;
operation->setUseClamp(useClamp);
-
- graph->addOperation(operation);
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
}
}
diff --git a/source/blender/compositor/nodes/COM_MathNode.h b/source/blender/compositor/nodes/COM_MathNode.h
index 4f8e64754e7..72403e7059f 100644
--- a/source/blender/compositor/nodes/COM_MathNode.h
+++ b/source/blender/compositor/nodes/COM_MathNode.h
@@ -32,7 +32,7 @@
class MathNode : public Node {
public:
MathNode(bNode *editorNode) : Node(editorNode) {}
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_MixNode.cpp b/source/blender/compositor/nodes/COM_MixNode.cpp
index 42217243fdf..b12dfc02ed7 100644
--- a/source/blender/compositor/nodes/COM_MixNode.cpp
+++ b/source/blender/compositor/nodes/COM_MixNode.cpp
@@ -34,18 +34,17 @@ MixNode::MixNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void MixNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void MixNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *valueSocket = this->getInputSocket(0);
- InputSocket *color1Socket = this->getInputSocket(1);
- InputSocket *color2Socket = this->getInputSocket(2);
- OutputSocket *outputSocket = this->getOutputSocket(0);
+ NodeInput *valueSocket = this->getInputSocket(0);
+ NodeInput *color1Socket = this->getInputSocket(1);
+ NodeInput *color2Socket = this->getInputSocket(2);
+ NodeOutput *outputSocket = this->getOutputSocket(0);
bNode *editorNode = this->getbNode();
bool useAlphaPremultiply = this->getbNode()->custom2 & 1;
bool useClamp = this->getbNode()->custom2 & 2;
MixBaseOperation *convertProg;
-
switch (editorNode->custom1) {
case MA_RAMP_ADD:
convertProg = new MixAddOperation();
@@ -106,14 +105,12 @@ void MixNode::convertToOperations(ExecutionSystem *graph, CompositorContext *con
}
convertProg->setUseValueAlphaMultiply(useAlphaPremultiply);
convertProg->setUseClamp(useClamp);
-
- valueSocket->relinkConnections(convertProg->getInputSocket(0), 0, graph);
- color1Socket->relinkConnections(convertProg->getInputSocket(1), 1, graph);
- color2Socket->relinkConnections(convertProg->getInputSocket(2), 2, graph);
- outputSocket->relinkConnections(convertProg->getOutputSocket(0));
- addPreviewOperation(graph, context, convertProg->getOutputSocket(0));
+ converter.addOperation(convertProg);
- convertProg->getInputSocket(2)->setResizeMode(color2Socket->getResizeMode());
+ converter.mapInputSocket(valueSocket, convertProg->getInputSocket(0));
+ converter.mapInputSocket(color1Socket, convertProg->getInputSocket(1));
+ converter.mapInputSocket(color2Socket, convertProg->getInputSocket(2));
+ converter.mapOutputSocket(outputSocket, convertProg->getOutputSocket(0));
- graph->addOperation(convertProg);
+ converter.addPreview(convertProg->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_MixNode.h b/source/blender/compositor/nodes/COM_MixNode.h
index 76076d01427..3e61a855d31 100644
--- a/source/blender/compositor/nodes/COM_MixNode.h
+++ b/source/blender/compositor/nodes/COM_MixNode.h
@@ -32,6 +32,6 @@
class MixNode : public Node {
public:
MixNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_MovieClipNode.cpp b/source/blender/compositor/nodes/COM_MovieClipNode.cpp
index 041fa9f7c4c..933223dacac 100644
--- a/source/blender/compositor/nodes/COM_MovieClipNode.cpp
+++ b/source/blender/compositor/nodes/COM_MovieClipNode.cpp
@@ -38,19 +38,19 @@ MovieClipNode::MovieClipNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void MovieClipNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void MovieClipNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- OutputSocket *outputMovieClip = this->getOutputSocket(0);
- OutputSocket *alphaMovieClip = this->getOutputSocket(1);
- OutputSocket *offsetXMovieClip = this->getOutputSocket(2);
- OutputSocket *offsetYMovieClip = this->getOutputSocket(3);
- OutputSocket *scaleMovieClip = this->getOutputSocket(4);
- OutputSocket *angleMovieClip = this->getOutputSocket(5);
+ NodeOutput *outputMovieClip = this->getOutputSocket(0);
+ NodeOutput *alphaMovieClip = this->getOutputSocket(1);
+ NodeOutput *offsetXMovieClip = this->getOutputSocket(2);
+ NodeOutput *offsetYMovieClip = this->getOutputSocket(3);
+ NodeOutput *scaleMovieClip = this->getOutputSocket(4);
+ NodeOutput *angleMovieClip = this->getOutputSocket(5);
bNode *editorNode = this->getbNode();
MovieClip *movieClip = (MovieClip *)editorNode->id;
MovieClipUser *movieClipUser = (MovieClipUser *)editorNode->storage;
- bool cacheFrame = !context->isRendering();
+ bool cacheFrame = !context.isRendering();
ImBuf *ibuf = NULL;
if (movieClip) {
@@ -62,27 +62,23 @@ void MovieClipNode::convertToOperations(ExecutionSystem *graph, CompositorContex
// always connect the output image
MovieClipOperation *operation = new MovieClipOperation();
-
- addPreviewOperation(graph, context, operation->getOutputSocket());
- if (outputMovieClip->isConnected()) {
- outputMovieClip->relinkConnections(operation->getOutputSocket());
- }
-
operation->setMovieClip(movieClip);
operation->setMovieClipUser(movieClipUser);
- operation->setFramenumber(context->getFramenumber());
+ operation->setFramenumber(context.getFramenumber());
operation->setCacheFrame(cacheFrame);
- graph->addOperation(operation);
- if (alphaMovieClip->isConnected()) {
- MovieClipAlphaOperation *alphaOperation = new MovieClipAlphaOperation();
- alphaOperation->setMovieClip(movieClip);
- alphaOperation->setMovieClipUser(movieClipUser);
- alphaOperation->setFramenumber(context->getFramenumber());
- alphaOperation->setCacheFrame(cacheFrame);
- alphaMovieClip->relinkConnections(alphaOperation->getOutputSocket());
- graph->addOperation(alphaOperation);
- }
+ converter.addOperation(operation);
+ converter.mapOutputSocket(outputMovieClip, operation->getOutputSocket());
+ converter.addPreview(operation->getOutputSocket());
+
+ MovieClipAlphaOperation *alphaOperation = new MovieClipAlphaOperation();
+ alphaOperation->setMovieClip(movieClip);
+ alphaOperation->setMovieClipUser(movieClipUser);
+ alphaOperation->setFramenumber(context.getFramenumber());
+ alphaOperation->setCacheFrame(cacheFrame);
+
+ converter.addOperation(alphaOperation);
+ converter.mapOutputSocket(alphaMovieClip, alphaOperation->getOutputSocket());
MovieTrackingStabilization *stab = &movieClip->tracking.stabilization;
float loc[2], scale, angle;
@@ -93,37 +89,17 @@ void MovieClipNode::convertToOperations(ExecutionSystem *graph, CompositorContex
if (ibuf) {
if (stab->flag & TRACKING_2D_STABILIZATION) {
- int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(movieClip, context->getFramenumber());
+ int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(movieClip, context.getFramenumber());
BKE_tracking_stabilization_data_get(&movieClip->tracking, clip_framenr, ibuf->x, ibuf->y, loc, &scale, &angle);
}
}
- if (offsetXMovieClip->isConnected()) {
- SetValueOperation *operationSetValue = new SetValueOperation();
- operationSetValue->setValue(loc[0]);
- offsetXMovieClip->relinkConnections(operationSetValue->getOutputSocket());
- graph->addOperation(operationSetValue);
- }
- if (offsetYMovieClip->isConnected()) {
- SetValueOperation *operationSetValue = new SetValueOperation();
- operationSetValue->setValue(loc[1]);
- offsetYMovieClip->relinkConnections(operationSetValue->getOutputSocket());
- graph->addOperation(operationSetValue);
- }
- if (scaleMovieClip->isConnected()) {
- SetValueOperation *operationSetValue = new SetValueOperation();
- operationSetValue->setValue(scale);
- scaleMovieClip->relinkConnections(operationSetValue->getOutputSocket());
- graph->addOperation(operationSetValue);
- }
- if (angleMovieClip->isConnected()) {
- SetValueOperation *operationSetValue = new SetValueOperation();
- operationSetValue->setValue(angle);
- angleMovieClip->relinkConnections(operationSetValue->getOutputSocket());
- graph->addOperation(operationSetValue);
- }
-
+ converter.addOutputValue(offsetXMovieClip, loc[0]);
+ converter.addOutputValue(offsetYMovieClip, loc[1]);
+ converter.addOutputValue(scaleMovieClip, scale);
+ converter.addOutputValue(angleMovieClip, angle);
+
if (ibuf) {
IMB_freeImBuf(ibuf);
}
diff --git a/source/blender/compositor/nodes/COM_MovieClipNode.h b/source/blender/compositor/nodes/COM_MovieClipNode.h
index 2fb38860a34..ff7b2869f05 100644
--- a/source/blender/compositor/nodes/COM_MovieClipNode.h
+++ b/source/blender/compositor/nodes/COM_MovieClipNode.h
@@ -33,7 +33,7 @@
class MovieClipNode : public Node {
public:
MovieClipNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif /* __COM_MOVIECLIPNODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_MovieDistortionNode.cpp b/source/blender/compositor/nodes/COM_MovieDistortionNode.cpp
index c29bc27cd80..fd907465984 100644
--- a/source/blender/compositor/nodes/COM_MovieDistortionNode.cpp
+++ b/source/blender/compositor/nodes/COM_MovieDistortionNode.cpp
@@ -31,18 +31,19 @@ MovieDistortionNode::MovieDistortionNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void MovieDistortionNode::convertToOperations(ExecutionSystem *system, CompositorContext *context)
+void MovieDistortionNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *inputSocket = this->getInputSocket(0);
- OutputSocket *outputSocket = this->getOutputSocket(0);
bNode *bnode = this->getbNode();
MovieClip *clip = (MovieClip *)bnode->id;
+ NodeInput *inputSocket = this->getInputSocket(0);
+ NodeOutput *outputSocket = this->getOutputSocket(0);
+
MovieDistortionOperation *operation = new MovieDistortionOperation(bnode->custom1 == 1);
operation->setMovieClip(clip);
- operation->setFramenumber(context->getFramenumber());
+ operation->setFramenumber(context.getFramenumber());
+ converter.addOperation(operation);
- inputSocket->relinkConnections(operation->getInputSocket(0), 0, system);
- outputSocket->relinkConnections(operation->getOutputSocket(0));
- system->addOperation(operation);
+ converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_MovieDistortionNode.h b/source/blender/compositor/nodes/COM_MovieDistortionNode.h
index b97600bb64e..6ff0295083f 100644
--- a/source/blender/compositor/nodes/COM_MovieDistortionNode.h
+++ b/source/blender/compositor/nodes/COM_MovieDistortionNode.h
@@ -32,7 +32,7 @@
class MovieDistortionNode : public Node {
public:
MovieDistortionNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_MuteNode.cpp b/source/blender/compositor/nodes/COM_MuteNode.cpp
deleted file mode 100644
index 5155b55a2ec..00000000000
--- a/source/blender/compositor/nodes/COM_MuteNode.cpp
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the 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:
- * Jeroen Bakker
- * Monique Dewanchand
- */
-
-#include "COM_MuteNode.h"
-#include "COM_SocketConnection.h"
-#include "COM_SetValueOperation.h"
-#include "COM_SetVectorOperation.h"
-#include "COM_SetColorOperation.h"
-
-extern "C" {
-# include "BLI_listbase.h"
-}
-
-MuteNode::MuteNode(bNode *editorNode) : Node(editorNode)
-{
- /* pass */
-}
-
-void MuteNode::reconnect(ExecutionSystem *graph, OutputSocket *output)
-{
- vector<InputSocket *> &inputsockets = this->getInputSockets();
- for (unsigned int index = 0; index < inputsockets.size(); index++) {
- InputSocket *input = inputsockets[index];
- if (input->getDataType() == output->getDataType()) {
- if (input->isConnected()) {
- output->relinkConnections(input->getConnection()->getFromSocket(), false);
- /* output connections have been redirected,
- * remove the input connection to completely unlink the node.
- */
- input->unlinkConnections(graph);
- return;
- }
- }
- }
-
- createDefaultOutput(graph, output);
-}
-
-void MuteNode::createDefaultOutput(ExecutionSystem *graph, OutputSocket *output)
-{
- NodeOperation *operation = NULL;
- switch (output->getDataType()) {
- case COM_DT_VALUE:
- {
- SetValueOperation *valueoperation = new SetValueOperation();
- valueoperation->setValue(0.0f);
- operation = valueoperation;
- break;
- }
- case COM_DT_VECTOR:
- {
- SetVectorOperation *vectoroperation = new SetVectorOperation();
- vectoroperation->setX(0.0f);
- vectoroperation->setY(0.0f);
- vectoroperation->setW(0.0f);
- operation = vectoroperation;
- break;
- }
- case COM_DT_COLOR:
- {
- SetColorOperation *coloroperation = new SetColorOperation();
- coloroperation->setChannel1(0.0f);
- coloroperation->setChannel2(0.0f);
- coloroperation->setChannel3(0.0f);
- coloroperation->setChannel4(0.0f);
- operation = coloroperation;
- break;
- }
- }
-
- if (operation) {
- output->relinkConnections(operation->getOutputSocket(), false);
- graph->addOperation(operation);
- }
-
- output->clearConnections();
-}
-
-template<class SocketType> void MuteNode::fillSocketMap(vector<SocketType *> &sockets, SocketMap &socketMap)
-{
- for (typename vector<SocketType *>::iterator it = sockets.begin(); it != sockets.end(); it++) {
- Socket *socket = (Socket *) *it;
-
- socketMap.insert(std::pair<bNodeSocket *, Socket *>(socket->getbNodeSocket(), socket));
- }
-}
-
-void MuteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
-{
- bNode *editorNode = this->getbNode();
- vector<OutputSocket *> &outputsockets = this->getOutputSockets();
-
- /* mute node is also used for unknown nodes and couple of nodes in fast mode
- * can't use generic routines in that case
- */
- if (editorNode->flag & NODE_MUTED) {
- vector<InputSocket *> &inputsockets = this->getInputSockets();
- vector<OutputSocket *> relinkedsockets;
- SocketMap socketMap;
- bNodeLink *link;
-
- this->fillSocketMap<OutputSocket>(outputsockets, socketMap);
- this->fillSocketMap<InputSocket>(inputsockets, socketMap);
-
- for (link = (bNodeLink *) editorNode->internal_links.first; link; link = link->next) {
- if (link->fromnode == editorNode) {
- InputSocket *fromSocket = (InputSocket *) socketMap.find(link->fromsock)->second;
- OutputSocket *toSocket = (OutputSocket *) socketMap.find(link->tosock)->second;
-
- if (toSocket->isConnected()) {
- if (fromSocket->isConnected()) {
- toSocket->relinkConnections(fromSocket->getConnection()->getFromSocket(), false);
- }
- else {
- createDefaultOutput(graph, toSocket);
- }
-
- relinkedsockets.push_back(toSocket);
- }
- }
- }
-
- /* in some cases node could be marked as muted, but it wouldn't have internal connections
- * this happens in such cases as muted render layer node
- *
- * to deal with such cases create default operation for not-relinked output sockets
- */
-
- for (unsigned int index = 0; index < outputsockets.size(); index++) {
- OutputSocket *output = outputsockets[index];
-
- if (output->isConnected()) {
- bool relinked = false;
- vector<OutputSocket *>::iterator it;
-
- for (it = relinkedsockets.begin(); it != relinkedsockets.end(); it++) {
- if (*it == output) {
- relinked = true;
- break;
- }
- }
-
- if (!relinked)
- createDefaultOutput(graph, output);
- }
- }
- }
- else {
- for (unsigned int index = 0; index < outputsockets.size(); index++) {
- OutputSocket *output = outputsockets[index];
- if (output->isConnected()) {
- reconnect(graph, output);
- }
- }
- }
-}
diff --git a/source/blender/compositor/nodes/COM_MuteNode.h b/source/blender/compositor/nodes/COM_MuteNode.h
deleted file mode 100644
index 7b0f1c2c298..00000000000
--- a/source/blender/compositor/nodes/COM_MuteNode.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the 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:
- * Jeroen Bakker
- * Monique Dewanchand
- */
-
-#ifndef _COM_MuteNode_h_
-#define _COM_MuteNode_h_
-
-#include <map>
-
-#include "COM_Node.h"
-
-extern "C" {
-# include "BKE_node.h"
-}
-
-/**
- * @brief MuteNode
- * @ingroup Node
- */
-class MuteNode : public Node {
-public:
- MuteNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
-private:
- typedef std::map<bNodeSocket *, Socket *> SocketMap;
-
- void reconnect(ExecutionSystem *graph, OutputSocket *output);
- void createDefaultOutput(ExecutionSystem *graph, OutputSocket *output);
-
- template<class SocketType> void fillSocketMap(vector<SocketType *> &sockets, SocketMap &socketMap);
-};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_NormalNode.cpp b/source/blender/compositor/nodes/COM_NormalNode.cpp
index 41b91f61328..d7c3fd11844 100644
--- a/source/blender/compositor/nodes/COM_NormalNode.cpp
+++ b/source/blender/compositor/nodes/COM_NormalNode.cpp
@@ -31,32 +31,29 @@ NormalNode::NormalNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void NormalNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void NormalNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *inputSocket = this->getInputSocket(0);
- OutputSocket *outputSocket = this->getOutputSocket(0);
- OutputSocket *outputSocketDotproduct = this->getOutputSocket(1);
+ NodeInput *inputSocket = this->getInputSocket(0);
+ NodeOutput *outputSocket = this->getOutputSocket(0);
+ NodeOutput *outputSocketDotproduct = this->getOutputSocket(1);
SetVectorOperation *operationSet = new SetVectorOperation();
float normal[3];
outputSocket->getEditorValueVector(normal);
-
/* animation can break normalization, this restores it */
normalize_v3(normal);
-
operationSet->setX(normal[0]);
operationSet->setY(normal[1]);
operationSet->setZ(normal[2]);
operationSet->setW(0.0f);
+ converter.addOperation(operationSet);
+
+ converter.mapOutputSocket(outputSocket, operationSet->getOutputSocket(0));
- outputSocket->relinkConnections(operationSet->getOutputSocket(0));
- graph->addOperation(operationSet);
+ DotproductOperation *operation = new DotproductOperation();
+ converter.addOperation(operation);
- if (outputSocketDotproduct->isConnected()) {
- DotproductOperation *operation = new DotproductOperation();
- outputSocketDotproduct->relinkConnections(operation->getOutputSocket(0));
- inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
- addLink(graph, operationSet->getOutputSocket(0), operation->getInputSocket(1));
- graph->addOperation(operation);
- }
+ converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
+ converter.addLink(operationSet->getOutputSocket(0), operation->getInputSocket(1));
+ converter.mapOutputSocket(outputSocketDotproduct, operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_NormalNode.h b/source/blender/compositor/nodes/COM_NormalNode.h
index 64d4e3a3656..5cccaab5875 100644
--- a/source/blender/compositor/nodes/COM_NormalNode.h
+++ b/source/blender/compositor/nodes/COM_NormalNode.h
@@ -32,7 +32,7 @@
class NormalNode : public Node {
public:
NormalNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif /* COM_NormalNODE_H */
diff --git a/source/blender/compositor/nodes/COM_NormalizeNode.cpp b/source/blender/compositor/nodes/COM_NormalizeNode.cpp
index 7c1c695f8b6..f6e919c168f 100644
--- a/source/blender/compositor/nodes/COM_NormalizeNode.cpp
+++ b/source/blender/compositor/nodes/COM_NormalizeNode.cpp
@@ -28,12 +28,11 @@ NormalizeNode::NormalizeNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void NormalizeNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void NormalizeNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
NormalizeOperation *operation = new NormalizeOperation();
+ converter.addOperation(operation);
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
-
- graph->addOperation(operation);
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_NormalizeNode.h b/source/blender/compositor/nodes/COM_NormalizeNode.h
index ea1497efdc6..a0eb7c9f5a9 100644
--- a/source/blender/compositor/nodes/COM_NormalizeNode.h
+++ b/source/blender/compositor/nodes/COM_NormalizeNode.h
@@ -31,7 +31,7 @@
class NormalizeNode : public Node {
public:
NormalizeNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.cpp b/source/blender/compositor/nodes/COM_OutputFileNode.cpp
index 94e5efe77e0..92fa74b9a2e 100644
--- a/source/blender/compositor/nodes/COM_OutputFileNode.cpp
+++ b/source/blender/compositor/nodes/COM_OutputFileNode.cpp
@@ -32,52 +32,47 @@ OutputFileNode::OutputFileNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void OutputFileNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void OutputFileNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
NodeImageMultiFile *storage = (NodeImageMultiFile *)this->getbNode()->storage;
- if (!context->isRendering()) {
+ if (!context.isRendering()) {
/* only output files when rendering a sequence -
* otherwise, it overwrites the output files just
* scrubbing through the timeline when the compositor updates.
*/
-
- /* still, need to unlink input sockets to remove the node from the graph completely */
- int num_inputs = getNumberOfInputSockets();
- for (int i = 0; i < num_inputs; ++i) {
- getInputSocket(i)->unlinkConnections(graph);
- }
return;
}
if (storage->format.imtype == R_IMF_IMTYPE_MULTILAYER) {
/* single output operation for the multilayer file */
OutputOpenExrMultiLayerOperation *outputOperation = new OutputOpenExrMultiLayerOperation(
- context->getRenderData(), context->getbNodeTree(), storage->base_path, storage->format.exr_codec);
+ context.getRenderData(), context.getbNodeTree(), storage->base_path, storage->format.exr_codec);
+ converter.addOperation(outputOperation);
int num_inputs = getNumberOfInputSockets();
- bool hasConnections = false;
+ bool previewAdded = false;
for (int i = 0; i < num_inputs; ++i) {
- InputSocket *input = getInputSocket(i);
+ NodeInput *input = getInputSocket(i);
NodeImageMultiFileSocket *sockdata = (NodeImageMultiFileSocket *)input->getbNodeSocket()->storage;
- outputOperation->add_layer(sockdata->layer, input->getDataType());
+ /* note: layer becomes an empty placeholder if the input is not linked */
+ outputOperation->add_layer(sockdata->layer, input->getDataType(), input->isLinked());
- if (input->isConnected()) {
- hasConnections = true;
- input->relinkConnections(outputOperation->getInputSocket(i));
+ converter.mapInputSocket(input, outputOperation->getInputSocket(i));
+
+ if (!previewAdded) {
+ converter.addNodeInputPreview(input);
+ previewAdded = true;
}
}
- if (hasConnections) addPreviewOperation(graph, context, outputOperation->getInputSocket(0));
-
- graph->addOperation(outputOperation);
}
else { /* single layer format */
int num_inputs = getNumberOfInputSockets();
bool previewAdded = false;
for (int i = 0; i < num_inputs; ++i) {
- InputSocket *input = getInputSocket(i);
- if (input->isConnected()) {
+ NodeInput *input = getInputSocket(i);
+ if (input->isLinked()) {
NodeImageMultiFileSocket *sockdata = (NodeImageMultiFileSocket *)input->getbNodeSocket()->storage;
ImageFormatData *format = (sockdata->use_node_format ? &storage->format : &sockdata->format);
char path[FILE_MAX];
@@ -86,16 +81,17 @@ void OutputFileNode::convertToOperations(ExecutionSystem *graph, CompositorConte
BLI_join_dirfile(path, FILE_MAX, storage->base_path, sockdata->path);
OutputSingleLayerOperation *outputOperation = new OutputSingleLayerOperation(
- context->getRenderData(), context->getbNodeTree(), input->getDataType(), format, path,
- context->getViewSettings(), context->getDisplaySettings());
- input->relinkConnections(outputOperation->getInputSocket(0));
- graph->addOperation(outputOperation);
+ context.getRenderData(), context.getbNodeTree(), input->getDataType(), format, path,
+ context.getViewSettings(), context.getDisplaySettings());
+ converter.addOperation(outputOperation);
+
+ converter.mapInputSocket(input, outputOperation->getInputSocket(0));
+
if (!previewAdded) {
- addPreviewOperation(graph, context, outputOperation->getInputSocket(0));
+ converter.addNodeInputPreview(input);
previewAdded = true;
}
}
}
}
}
-
diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.h b/source/blender/compositor/nodes/COM_OutputFileNode.h
index e3194436f7f..54e29417c14 100644
--- a/source/blender/compositor/nodes/COM_OutputFileNode.h
+++ b/source/blender/compositor/nodes/COM_OutputFileNode.h
@@ -34,7 +34,7 @@
class OutputFileNode : public Node {
public:
OutputFileNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_PixelateNode.cpp b/source/blender/compositor/nodes/COM_PixelateNode.cpp
index b751c9a6e9f..da3cd74e771 100644
--- a/source/blender/compositor/nodes/COM_PixelateNode.cpp
+++ b/source/blender/compositor/nodes/COM_PixelateNode.cpp
@@ -30,19 +30,20 @@ PixelateNode::PixelateNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void PixelateNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void PixelateNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *inputSocket = this->getInputSocket(0);
- OutputSocket *outputSocket = this->getOutputSocket(0);
+ NodeInput *inputSocket = this->getInputSocket(0);
+ NodeOutput *outputSocket = this->getOutputSocket(0);
DataType datatype = inputSocket->getDataType();
- if (inputSocket->isConnected()) {
- SocketConnection *connection = inputSocket->getConnection();
- OutputSocket *otherOutputSocket = connection->getFromSocket();
- datatype = otherOutputSocket->getDataType();
+
+ if (inputSocket->isLinked()) {
+ NodeOutput *link = inputSocket->getLink();
+ datatype = link->getDataType();
}
PixelateOperation *operation = new PixelateOperation(datatype);
- inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
- outputSocket->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_PixelateNode.h b/source/blender/compositor/nodes/COM_PixelateNode.h
index c142d2d7a5b..a5e73eb3683 100644
--- a/source/blender/compositor/nodes/COM_PixelateNode.h
+++ b/source/blender/compositor/nodes/COM_PixelateNode.h
@@ -32,7 +32,7 @@
class PixelateNode : public Node {
public:
PixelateNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.cpp b/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.cpp
index 944e04e4f4f..9b69bc5a46e 100644
--- a/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.cpp
+++ b/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.cpp
@@ -37,44 +37,34 @@ PlaneTrackDeformNode::PlaneTrackDeformNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void PlaneTrackDeformNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void PlaneTrackDeformNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *input_image = this->getInputSocket(0);
-
- OutputSocket *output_warped_image = this->getOutputSocket(0);
- OutputSocket *output_plane = this->getOutputSocket(1);
-
bNode *editorNode = this->getbNode();
MovieClip *clip = (MovieClip *) editorNode->id;
-
NodePlaneTrackDeformData *data = (NodePlaneTrackDeformData *) editorNode->storage;
-
- int frame_number = context->getFramenumber();
-
- if (output_warped_image->isConnected()) {
- PlaneTrackWarpImageOperation *warp_image_operation = new PlaneTrackWarpImageOperation();
-
- warp_image_operation->setMovieClip(clip);
- warp_image_operation->setTrackingObject(data->tracking_object);
- warp_image_operation->setPlaneTrackName(data->plane_track_name);
- warp_image_operation->setFramenumber(frame_number);
-
- input_image->relinkConnections(warp_image_operation->getInputSocket(0), 0, graph);
- output_warped_image->relinkConnections(warp_image_operation->getOutputSocket());
-
- graph->addOperation(warp_image_operation);
- }
-
- if (output_plane->isConnected()) {
- PlaneTrackMaskOperation *plane_mask_operation = new PlaneTrackMaskOperation();
-
- plane_mask_operation->setMovieClip(clip);
- plane_mask_operation->setTrackingObject(data->tracking_object);
- plane_mask_operation->setPlaneTrackName(data->plane_track_name);
- plane_mask_operation->setFramenumber(frame_number);
-
- output_plane->relinkConnections(plane_mask_operation->getOutputSocket());
-
- graph->addOperation(plane_mask_operation);
- }
+
+ int frame_number = context.getFramenumber();
+
+ NodeInput *input_image = this->getInputSocket(0);
+ NodeOutput *output_warped_image = this->getOutputSocket(0);
+ NodeOutput *output_plane = this->getOutputSocket(1);
+
+ PlaneTrackWarpImageOperation *warp_image_operation = new PlaneTrackWarpImageOperation();
+ warp_image_operation->setMovieClip(clip);
+ warp_image_operation->setTrackingObject(data->tracking_object);
+ warp_image_operation->setPlaneTrackName(data->plane_track_name);
+ warp_image_operation->setFramenumber(frame_number);
+ converter.addOperation(warp_image_operation);
+
+ converter.mapInputSocket(input_image, warp_image_operation->getInputSocket(0));
+ converter.mapOutputSocket(output_warped_image, warp_image_operation->getOutputSocket());
+
+ PlaneTrackMaskOperation *plane_mask_operation = new PlaneTrackMaskOperation();
+ plane_mask_operation->setMovieClip(clip);
+ plane_mask_operation->setTrackingObject(data->tracking_object);
+ plane_mask_operation->setPlaneTrackName(data->plane_track_name);
+ plane_mask_operation->setFramenumber(frame_number);
+ converter.addOperation(plane_mask_operation);
+
+ converter.mapOutputSocket(output_plane, plane_mask_operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.h b/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.h
index 3c37f4474dd..71e6ab12dfc 100644
--- a/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.h
+++ b/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.h
@@ -34,5 +34,5 @@ extern "C" {
class PlaneTrackDeformNode : public Node {
public:
PlaneTrackDeformNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
diff --git a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
index 512f8eec90f..cc66c688379 100644
--- a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
+++ b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
@@ -21,7 +21,6 @@
*/
#include "COM_RenderLayersNode.h"
-#include "COM_ExecutionSystem.h"
#include "COM_RenderLayersProg.h"
#include "COM_TranslateOperation.h"
#include "COM_RotateOperation.h"
@@ -33,69 +32,57 @@ RenderLayersNode::RenderLayersNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void RenderLayersNode::testSocketConnection(ExecutionSystem *system, CompositorContext *context, int outputSocketNumber, RenderLayersBaseProg *operation)
+void RenderLayersNode::testSocketLink(NodeConverter &converter, const CompositorContext &context,
+ int outputSocketNumber, RenderLayersBaseProg *operation) const
{
- OutputSocket *outputSocket = this->getOutputSocket(outputSocketNumber);
+ NodeOutput *outputSocket = this->getOutputSocket(outputSocketNumber);
Scene *scene = (Scene *)this->getbNode()->id;
short layerId = this->getbNode()->custom1;
- if (outputSocket->isConnected()) {
- operation->setScene(scene);
- operation->setLayerId(layerId);
- operation->setRenderData(context->getRenderData());
- outputSocket->relinkConnections(operation->getOutputSocket());
- system->addOperation(operation);
- if (outputSocketNumber == 0) { // only do for image socket if connected
- addPreviewOperation(system, context, operation->getOutputSocket());
- }
- }
- else {
- if (outputSocketNumber == 0) {
- system->addOperation(operation);
- operation->setScene(scene);
- operation->setLayerId(layerId);
- operation->setRenderData(context->getRenderData());
- addPreviewOperation(system, context, operation->getOutputSocket());
- }
- else {
- delete operation;
- }
- }
+ operation->setScene(scene);
+ operation->setLayerId(layerId);
+ operation->setRenderData(context.getRenderData());
+
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket());
+ converter.addOperation(operation);
+
+ if (outputSocketNumber == 0) /* only for image socket */
+ converter.addPreview(operation->getOutputSocket());
}
-void RenderLayersNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void RenderLayersNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- testSocketConnection(graph, context, 0, new RenderLayersColorProg());
- testSocketConnection(graph, context, 1, new RenderLayersAlphaProg());
- testSocketConnection(graph, context, 2, new RenderLayersDepthProg());
- testSocketConnection(graph, context, 3, new RenderLayersNormalOperation());
- testSocketConnection(graph, context, 4, new RenderLayersUVOperation());
- testSocketConnection(graph, context, 5, new RenderLayersSpeedOperation());
- testSocketConnection(graph, context, 6, new RenderLayersColorOperation());
- testSocketConnection(graph, context, 7, new RenderLayersDiffuseOperation());
- testSocketConnection(graph, context, 8, new RenderLayersSpecularOperation());
- testSocketConnection(graph, context, 9, new RenderLayersShadowOperation());
- testSocketConnection(graph, context, 10, new RenderLayersAOOperation());
- testSocketConnection(graph, context, 11, new RenderLayersReflectionOperation());
- testSocketConnection(graph, context, 12, new RenderLayersRefractionOperation());
- testSocketConnection(graph, context, 13, new RenderLayersIndirectOperation());
- testSocketConnection(graph, context, 14, new RenderLayersObjectIndexOperation());
- testSocketConnection(graph, context, 15, new RenderLayersMaterialIndexOperation());
- testSocketConnection(graph, context, 16, new RenderLayersMistOperation());
- testSocketConnection(graph, context, 17, new RenderLayersEmitOperation());
- testSocketConnection(graph, context, 18, new RenderLayersEnvironmentOperation());
+ testSocketLink(converter, context, 0, new RenderLayersColorProg());
+ testSocketLink(converter, context, 1, new RenderLayersAlphaProg());
+ testSocketLink(converter, context, 2, new RenderLayersDepthProg());
+ testSocketLink(converter, context, 3, new RenderLayersNormalOperation());
+ testSocketLink(converter, context, 4, new RenderLayersUVOperation());
+ testSocketLink(converter, context, 5, new RenderLayersSpeedOperation());
+ testSocketLink(converter, context, 6, new RenderLayersColorOperation());
+ testSocketLink(converter, context, 7, new RenderLayersDiffuseOperation());
+ testSocketLink(converter, context, 8, new RenderLayersSpecularOperation());
+ testSocketLink(converter, context, 9, new RenderLayersShadowOperation());
+ testSocketLink(converter, context, 10, new RenderLayersAOOperation());
+ testSocketLink(converter, context, 11, new RenderLayersReflectionOperation());
+ testSocketLink(converter, context, 12, new RenderLayersRefractionOperation());
+ testSocketLink(converter, context, 13, new RenderLayersIndirectOperation());
+ testSocketLink(converter, context, 14, new RenderLayersObjectIndexOperation());
+ testSocketLink(converter, context, 15, new RenderLayersMaterialIndexOperation());
+ testSocketLink(converter, context, 16, new RenderLayersMistOperation());
+ testSocketLink(converter, context, 17, new RenderLayersEmitOperation());
+ testSocketLink(converter, context, 18, new RenderLayersEnvironmentOperation());
// cycles passes
- testSocketConnection(graph, context, 19, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_DIRECT));
- testSocketConnection(graph, context, 20, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_INDIRECT));
- testSocketConnection(graph, context, 21, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_COLOR));
- testSocketConnection(graph, context, 22, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_DIRECT));
- testSocketConnection(graph, context, 23, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_INDIRECT));
- testSocketConnection(graph, context, 24, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_COLOR));
- testSocketConnection(graph, context, 25, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_DIRECT));
- testSocketConnection(graph, context, 26, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_INDIRECT));
- testSocketConnection(graph, context, 27, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_COLOR));
- testSocketConnection(graph, context, 28, new RenderLayersCyclesOperation(SCE_PASS_SUBSURFACE_DIRECT));
- testSocketConnection(graph, context, 29, new RenderLayersCyclesOperation(SCE_PASS_SUBSURFACE_INDIRECT));
- testSocketConnection(graph, context, 30, new RenderLayersCyclesOperation(SCE_PASS_SUBSURFACE_COLOR));
+ testSocketLink(converter, context, 19, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_DIRECT));
+ testSocketLink(converter, context, 20, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_INDIRECT));
+ testSocketLink(converter, context, 21, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_COLOR));
+ testSocketLink(converter, context, 22, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_DIRECT));
+ testSocketLink(converter, context, 23, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_INDIRECT));
+ testSocketLink(converter, context, 24, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_COLOR));
+ testSocketLink(converter, context, 25, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_DIRECT));
+ testSocketLink(converter, context, 26, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_INDIRECT));
+ testSocketLink(converter, context, 27, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_COLOR));
+ testSocketLink(converter, context, 28, new RenderLayersCyclesOperation(SCE_PASS_SUBSURFACE_DIRECT));
+ testSocketLink(converter, context, 29, new RenderLayersCyclesOperation(SCE_PASS_SUBSURFACE_INDIRECT));
+ testSocketLink(converter, context, 30, new RenderLayersCyclesOperation(SCE_PASS_SUBSURFACE_COLOR));
}
diff --git a/source/blender/compositor/nodes/COM_RenderLayersNode.h b/source/blender/compositor/nodes/COM_RenderLayersNode.h
index 0c769d32aea..5863cbb390c 100644
--- a/source/blender/compositor/nodes/COM_RenderLayersNode.h
+++ b/source/blender/compositor/nodes/COM_RenderLayersNode.h
@@ -31,7 +31,7 @@
class RenderLayersNode : public Node {
public:
RenderLayersNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
private:
- void testSocketConnection(ExecutionSystem *graph, CompositorContext *context, int outputSocketNumber, RenderLayersBaseProg *operation);
+ void testSocketLink(NodeConverter &converter, const CompositorContext &context, int outputSocketNumber, RenderLayersBaseProg *operation) const;
};
diff --git a/source/blender/compositor/nodes/COM_RotateNode.cpp b/source/blender/compositor/nodes/COM_RotateNode.cpp
index d7712323a27..c5fe88b3636 100644
--- a/source/blender/compositor/nodes/COM_RotateNode.cpp
+++ b/source/blender/compositor/nodes/COM_RotateNode.cpp
@@ -31,21 +31,20 @@ RotateNode::RotateNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void RotateNode::convertToOperations(ExecutionSystem *system, CompositorContext *context)
+void RotateNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *inputSocket = this->getInputSocket(0);
- InputSocket *inputDegreeSocket = this->getInputSocket(1);
- OutputSocket *outputSocket = this->getOutputSocket(0);
+ NodeInput *inputSocket = this->getInputSocket(0);
+ NodeInput *inputDegreeSocket = this->getInputSocket(1);
+ NodeOutput *outputSocket = this->getOutputSocket(0);
RotateOperation *operation = new RotateOperation();
SetSamplerOperation *sampler = new SetSamplerOperation();
-
sampler->setSampler((PixelSampler)this->getbNode()->custom1);
- addLink(system, sampler->getOutputSocket(), operation->getInputSocket(0));
- inputSocket->relinkConnections(sampler->getInputSocket(0), 0, system);
- inputDegreeSocket->relinkConnections(operation->getInputSocket(1), 1, system);
- outputSocket->relinkConnections(operation->getOutputSocket(0));
- system->addOperation(sampler);
- system->addOperation(operation);
+ converter.addOperation(sampler);
+ converter.addOperation(operation);
+ converter.addLink(sampler->getOutputSocket(), operation->getInputSocket(0));
+ converter.mapInputSocket(inputSocket, sampler->getInputSocket(0));
+ converter.mapInputSocket(inputDegreeSocket, operation->getInputSocket(1));
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_RotateNode.h b/source/blender/compositor/nodes/COM_RotateNode.h
index 6e3801e5353..f192fa8db25 100644
--- a/source/blender/compositor/nodes/COM_RotateNode.h
+++ b/source/blender/compositor/nodes/COM_RotateNode.h
@@ -32,7 +32,7 @@
class RotateNode : public Node {
public:
RotateNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ScaleNode.cpp b/source/blender/compositor/nodes/COM_ScaleNode.cpp
index e139eb83e04..61eea9227dc 100644
--- a/source/blender/compositor/nodes/COM_ScaleNode.cpp
+++ b/source/blender/compositor/nodes/COM_ScaleNode.cpp
@@ -33,71 +33,70 @@ ScaleNode::ScaleNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void ScaleNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void ScaleNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *inputSocket = this->getInputSocket(0);
- InputSocket *inputXSocket = this->getInputSocket(1);
- InputSocket *inputYSocket = this->getInputSocket(2);
- OutputSocket *outputSocket = this->getOutputSocket(0);
- BaseScaleOperation *scaleoperation = NULL;
bNode *bnode = this->getbNode();
+
+ NodeInput *inputSocket = this->getInputSocket(0);
+ NodeInput *inputXSocket = this->getInputSocket(1);
+ NodeInput *inputYSocket = this->getInputSocket(2);
+ NodeOutput *outputSocket = this->getOutputSocket(0);
switch (bnode->custom1) {
case CMP_SCALE_RELATIVE:
{
ScaleOperation *operation = new ScaleOperation();
-
- inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
- inputXSocket->relinkConnections(operation->getInputSocket(1), 1, graph);
- inputYSocket->relinkConnections(operation->getInputSocket(2), 2, graph);
-
- scaleoperation = operation;
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
+ converter.mapInputSocket(inputXSocket, operation->getInputSocket(1));
+ converter.mapInputSocket(inputYSocket, operation->getInputSocket(2));
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
break;
}
case CMP_SCALE_SCENEPERCENT:
{
SetValueOperation *scaleFactorOperation = new SetValueOperation();
- scaleFactorOperation->setValue(context->getRenderData()->size / 100.0f);
+ scaleFactorOperation->setValue(context.getRenderData()->size / 100.0f);
+ converter.addOperation(scaleFactorOperation);
+
ScaleOperation *operation = new ScaleOperation();
- inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
- addLink(graph, scaleFactorOperation->getOutputSocket(), operation->getInputSocket(1));
- addLink(graph, scaleFactorOperation->getOutputSocket(), operation->getInputSocket(2));
- graph->addOperation(scaleFactorOperation);
-
- scaleoperation = operation;
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
+ converter.addLink(scaleFactorOperation->getOutputSocket(), operation->getInputSocket(1));
+ converter.addLink(scaleFactorOperation->getOutputSocket(), operation->getInputSocket(2));
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
break;
}
case CMP_SCALE_RENDERPERCENT:
{
- const RenderData *rd = context->getRenderData();
+ const RenderData *rd = context.getRenderData();
ScaleFixedSizeOperation *operation = new ScaleFixedSizeOperation();
-
/* framing options */
operation->setIsAspect((bnode->custom2 & CMP_SCALE_RENDERSIZE_FRAME_ASPECT) != 0);
operation->setIsCrop((bnode->custom2 & CMP_SCALE_RENDERSIZE_FRAME_CROP) != 0);
operation->setOffset(bnode->custom3, bnode->custom4);
-
operation->setNewWidth(rd->xsch * rd->size / 100.0f);
operation->setNewHeight(rd->ysch * rd->size / 100.0f);
- inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
- operation->getInputSocket(0)->getConnection()->setIgnoreResizeCheck(true);
-
- scaleoperation = operation;
+ operation->getInputSocket(0)->setResizeMode(COM_SC_NO_RESIZE);
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
break;
}
case CMP_SCALE_ABSOLUTE:
{
- ScaleAbsoluteOperation *operation = new ScaleAbsoluteOperation(); // TODO: what is the use of this one.... perhaps some issues when the ui was updated....
-
- inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
- inputXSocket->relinkConnections(operation->getInputSocket(1), 1, graph);
- inputYSocket->relinkConnections(operation->getInputSocket(2), 2, graph);
-
- scaleoperation = operation;
+ /* TODO: what is the use of this one.... perhaps some issues when the ui was updated... */
+ ScaleAbsoluteOperation *operation = new ScaleAbsoluteOperation();
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
+ converter.mapInputSocket(inputXSocket, operation->getInputSocket(1));
+ converter.mapInputSocket(inputYSocket, operation->getInputSocket(2));
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
break;
}
}
-
- outputSocket->relinkConnections(scaleoperation->getOutputSocket(0));
- graph->addOperation(scaleoperation);
}
diff --git a/source/blender/compositor/nodes/COM_ScaleNode.h b/source/blender/compositor/nodes/COM_ScaleNode.h
index 17c7b672a59..d009b3f6781 100644
--- a/source/blender/compositor/nodes/COM_ScaleNode.h
+++ b/source/blender/compositor/nodes/COM_ScaleNode.h
@@ -32,7 +32,7 @@
class ScaleNode : public Node {
public:
ScaleNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_SeparateColorNode.cpp b/source/blender/compositor/nodes/COM_SeparateColorNode.cpp
new file mode 100644
index 00000000000..a6fa9065364
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_SeparateColorNode.cpp
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the 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:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Lukas Toenne
+ */
+
+#include "COM_SeparateColorNode.h"
+
+#include "COM_ConvertOperation.h"
+
+
+SeparateColorNode::SeparateColorNode(bNode *editorNode) :
+ Node(editorNode)
+{
+}
+
+void SeparateColorNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+{
+ NodeInput *imageSocket = this->getInputSocket(0);
+ NodeOutput *outputRSocket = this->getOutputSocket(0);
+ NodeOutput *outputGSocket = this->getOutputSocket(1);
+ NodeOutput *outputBSocket = this->getOutputSocket(2);
+ NodeOutput *outputASocket = this->getOutputSocket(3);
+
+ NodeOperation *color_conv = getColorConverter(context);
+ if (color_conv) {
+ converter.addOperation(color_conv);
+
+ converter.mapInputSocket(imageSocket, color_conv->getInputSocket(0));
+ }
+
+ {
+ SeparateChannelOperation *operation = new SeparateChannelOperation();
+ operation->setChannel(0);
+ converter.addOperation(operation);
+
+ if (color_conv)
+ converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0));
+ else
+ converter.mapInputSocket(imageSocket, operation->getInputSocket(0));
+ converter.mapOutputSocket(outputRSocket, operation->getOutputSocket(0));
+ }
+
+ {
+ SeparateChannelOperation *operation = new SeparateChannelOperation();
+ operation->setChannel(1);
+ converter.addOperation(operation);
+
+ if (color_conv)
+ converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0));
+ else
+ converter.mapInputSocket(imageSocket, operation->getInputSocket(0));
+ converter.mapOutputSocket(outputGSocket, operation->getOutputSocket(0));
+ }
+
+ {
+ SeparateChannelOperation *operation = new SeparateChannelOperation();
+ operation->setChannel(2);
+ converter.addOperation(operation);
+
+ if (color_conv)
+ converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0));
+ else
+ converter.mapInputSocket(imageSocket, operation->getInputSocket(0));
+ converter.mapOutputSocket(outputBSocket, operation->getOutputSocket(0));
+ }
+
+ {
+ SeparateChannelOperation *operation = new SeparateChannelOperation();
+ operation->setChannel(3);
+ converter.addOperation(operation);
+
+ if (color_conv)
+ converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0));
+ else
+ converter.mapInputSocket(imageSocket, operation->getInputSocket(0));
+ converter.mapOutputSocket(outputASocket, operation->getOutputSocket(0));
+ }
+}
+
+
+NodeOperation *SeparateRGBANode::getColorConverter(const CompositorContext &context) const
+{
+ return NULL; /* no conversion needed */
+}
+
+NodeOperation *SeparateHSVANode::getColorConverter(const CompositorContext &context) const
+{
+ return new ConvertRGBToHSVOperation();
+}
+
+NodeOperation *SeparateYCCANode::getColorConverter(const CompositorContext &context) const
+{
+ ConvertRGBToYCCOperation *operation = new ConvertRGBToYCCOperation();
+ bNode *editorNode = this->getbNode();
+ operation->setMode(editorNode->custom1);
+ return operation;
+}
+
+NodeOperation *SeparateYUVANode::getColorConverter(const CompositorContext &context) const
+{
+ return new ConvertRGBToYUVOperation();
+}
diff --git a/source/blender/compositor/nodes/COM_SeparateColorNode.h b/source/blender/compositor/nodes/COM_SeparateColorNode.h
new file mode 100644
index 00000000000..6730e471e06
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_SeparateColorNode.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the 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:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Lukas Toenne
+ */
+
+#ifndef _COM_SeparateColorNode_h_
+#define _COM_SeparateColorNode_h_
+
+#include "COM_Node.h"
+
+class SeparateColorNode : public Node {
+public:
+ SeparateColorNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+
+protected:
+ virtual NodeOperation *getColorConverter(const CompositorContext &context) const = 0;
+};
+
+class SeparateRGBANode : public SeparateColorNode {
+public:
+ SeparateRGBANode(bNode *editorNode) :
+ SeparateColorNode(editorNode)
+ {}
+
+ NodeOperation *getColorConverter(const CompositorContext &context) const;
+};
+
+class SeparateHSVANode : public SeparateColorNode {
+public:
+ SeparateHSVANode(bNode *editorNode) :
+ SeparateColorNode(editorNode)
+ {}
+
+ NodeOperation *getColorConverter(const CompositorContext &context) const;
+};
+
+class SeparateYCCANode : public SeparateColorNode {
+public:
+ SeparateYCCANode(bNode *editorNode) :
+ SeparateColorNode(editorNode)
+ {}
+
+ NodeOperation *getColorConverter(const CompositorContext &context) const;
+};
+
+class SeparateYUVANode : public SeparateColorNode {
+public:
+ SeparateYUVANode(bNode *editorNode) :
+ SeparateColorNode(editorNode)
+ {}
+
+ NodeOperation *getColorConverter(const CompositorContext &context) const;
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_SeparateHSVANode.cpp b/source/blender/compositor/nodes/COM_SeparateHSVANode.cpp
deleted file mode 100644
index 4cd77d4bae6..00000000000
--- a/source/blender/compositor/nodes/COM_SeparateHSVANode.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the 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:
- * Jeroen Bakker
- * Monique Dewanchand
- */
-
-#include "COM_SeparateHSVANode.h"
-
-#include "COM_ExecutionSystem.h"
-#include "COM_SetValueOperation.h"
-#include "COM_ConvertOperation.h"
-
-SeparateHSVANode::SeparateHSVANode(bNode *editorNode) : SeparateRGBANode(editorNode)
-{
- /* pass */
-}
-
-void SeparateHSVANode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
-{
- ConvertRGBToHSVOperation *operation = new ConvertRGBToHSVOperation();
- InputSocket *inputSocket = this->getInputSocket(0);
- if (inputSocket->isConnected()) {
- inputSocket->relinkConnections(operation->getInputSocket(0));
- addLink(graph, operation->getOutputSocket(), inputSocket);
- }
- graph->addOperation(operation);
- SeparateRGBANode::convertToOperations(graph, context);
-}
diff --git a/source/blender/compositor/nodes/COM_SeparateRGBANode.cpp b/source/blender/compositor/nodes/COM_SeparateRGBANode.cpp
deleted file mode 100644
index 7d9bff30a93..00000000000
--- a/source/blender/compositor/nodes/COM_SeparateRGBANode.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the 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:
- * Jeroen Bakker
- * Monique Dewanchand
- */
-
-#include "COM_SeparateRGBANode.h"
-
-#include "COM_ConvertOperation.h"
-#include "COM_ExecutionSystem.h"
-#include "COM_SetValueOperation.h"
-#include "DNA_material_types.h" // the ramp types
-
-
-SeparateRGBANode::SeparateRGBANode(bNode *editorNode) : Node(editorNode)
-{
- /* pass */
-}
-
-
-void SeparateRGBANode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
-{
- InputSocket *imageSocket = this->getInputSocket(0);
- OutputSocket *outputRSocket = this->getOutputSocket(0);
- OutputSocket *outputGSocket = this->getOutputSocket(1);
- OutputSocket *outputBSocket = this->getOutputSocket(2);
- OutputSocket *outputASocket = this->getOutputSocket(3);
-
- if (outputRSocket->isConnected()) {
- SeparateChannelOperation *operation = new SeparateChannelOperation();
- operation->setChannel(0);
- imageSocket->relinkConnectionsDuplicate(operation->getInputSocket(0), 0, graph);
- outputRSocket->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
- }
- if (outputGSocket->isConnected()) {
- SeparateChannelOperation *operation = new SeparateChannelOperation();
- operation->setChannel(1);
- imageSocket->relinkConnectionsDuplicate(operation->getInputSocket(0), 0, graph);
- outputGSocket->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
- }
- if (outputBSocket->isConnected()) {
- SeparateChannelOperation *operation = new SeparateChannelOperation();
- operation->setChannel(2);
- imageSocket->relinkConnectionsDuplicate(operation->getInputSocket(0), 0, graph);
- outputBSocket->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
- }
- if (outputASocket->isConnected()) {
- SeparateChannelOperation *operation = new SeparateChannelOperation();
- operation->setChannel(3);
- imageSocket->relinkConnectionsDuplicate(operation->getInputSocket(0), 0, graph);
- outputASocket->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
- }
-
- /* remove the original connection to the node, this has been duplicated for all operations */
- imageSocket->unlinkConnections(graph);
-}
diff --git a/source/blender/compositor/nodes/COM_SeparateYCCANode.cpp b/source/blender/compositor/nodes/COM_SeparateYCCANode.cpp
deleted file mode 100644
index 797cd49316a..00000000000
--- a/source/blender/compositor/nodes/COM_SeparateYCCANode.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the 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:
- * Dalai Felinto
- */
-
-#include "COM_SeparateYCCANode.h"
-#include "COM_ExecutionSystem.h"
-#include "COM_SetValueOperation.h"
-#include "COM_ConvertOperation.h"
-
-SeparateYCCANode::SeparateYCCANode(bNode *editorNode) : SeparateRGBANode(editorNode)
-{
- /* pass */
-}
-
-void SeparateYCCANode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
-{
- ConvertRGBToYCCOperation *operation = new ConvertRGBToYCCOperation();
- InputSocket *inputSocket = this->getInputSocket(0);
-
- bNode *node = this->getbNode();
- operation->setMode(node->custom1);
-
- if (inputSocket->isConnected()) {
- inputSocket->relinkConnections(operation->getInputSocket(0));
- addLink(graph, operation->getOutputSocket(), inputSocket);
- }
- graph->addOperation(operation);
- SeparateRGBANode::convertToOperations(graph, context);
-}
diff --git a/source/blender/compositor/nodes/COM_SeparateYUVANode.cpp b/source/blender/compositor/nodes/COM_SeparateYUVANode.cpp
deleted file mode 100644
index 9a6ec20fa80..00000000000
--- a/source/blender/compositor/nodes/COM_SeparateYUVANode.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the 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:
- * Dalai Felinto
- */
-
-#include "COM_SeparateYUVANode.h"
-#include "COM_ExecutionSystem.h"
-#include "COM_SetValueOperation.h"
-#include "COM_ConvertOperation.h"
-
-SeparateYUVANode::SeparateYUVANode(bNode *editorNode) : SeparateRGBANode(editorNode)
-{
- /* pass */
-}
-
-void SeparateYUVANode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
-{
- ConvertRGBToYUVOperation *operation = new ConvertRGBToYUVOperation();
- InputSocket *inputSocket = this->getInputSocket(0);
- if (inputSocket->isConnected()) {
- inputSocket->relinkConnections(operation->getInputSocket(0));
- addLink(graph, operation->getOutputSocket(), inputSocket);
- }
- graph->addOperation(operation);
- SeparateRGBANode::convertToOperations(graph, context);
-}
diff --git a/source/blender/compositor/nodes/COM_SeparateYUVANode.h b/source/blender/compositor/nodes/COM_SeparateYUVANode.h
deleted file mode 100644
index e51c0ce4fa6..00000000000
--- a/source/blender/compositor/nodes/COM_SeparateYUVANode.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the 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:
- * Dalai Felinto
- */
-
-#ifndef _COM_SeparateYUVANode_h_
-#define _COM_SeparateYUVANode_h_
-
-#include "COM_Node.h"
-#include "DNA_node_types.h"
-#include "COM_SeparateRGBANode.h"
-
-/**
- * @brief SeparateYUVANode
- * @ingroup Node
- */
-class SeparateYUVANode : public SeparateRGBANode {
-public:
- SeparateYUVANode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
-};
-#endif
diff --git a/source/blender/compositor/nodes/COM_SetAlphaNode.cpp b/source/blender/compositor/nodes/COM_SetAlphaNode.cpp
index dd3ff5fbaa7..22ddd5bb157 100644
--- a/source/blender/compositor/nodes/COM_SetAlphaNode.cpp
+++ b/source/blender/compositor/nodes/COM_SetAlphaNode.cpp
@@ -24,17 +24,17 @@
#include "COM_SetAlphaOperation.h"
#include "COM_ExecutionSystem.h"
-void SetAlphaNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void SetAlphaNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
SetAlphaOperation *operation = new SetAlphaOperation();
-
- if (!this->getInputSocket(0)->isConnected() && this->getInputSocket(1)->isConnected()) {
+
+ if (!this->getInputSocket(0)->isLinked() && this->getInputSocket(1)->isLinked()) {
operation->setResolutionInputSocketIndex(1);
}
-
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
- graph->addOperation(operation);
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_SetAlphaNode.h b/source/blender/compositor/nodes/COM_SetAlphaNode.h
index e82fa210a89..6dbc7ebed04 100644
--- a/source/blender/compositor/nodes/COM_SetAlphaNode.h
+++ b/source/blender/compositor/nodes/COM_SetAlphaNode.h
@@ -32,7 +32,7 @@
class SetAlphaNode : public Node {
public:
SetAlphaNode(bNode *editorNode) : Node(editorNode) {}
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_SocketProxyNode.cpp b/source/blender/compositor/nodes/COM_SocketProxyNode.cpp
index f8f11a6c72f..756b6d60f40 100644
--- a/source/blender/compositor/nodes/COM_SocketProxyNode.cpp
+++ b/source/blender/compositor/nodes/COM_SocketProxyNode.cpp
@@ -21,7 +21,6 @@
*/
#include "COM_SocketProxyNode.h"
-#include "COM_SocketConnection.h"
#include "COM_SocketProxyOperation.h"
#include "COM_ExecutionSystem.h"
#include "COM_SetValueOperation.h"
@@ -30,15 +29,14 @@
#include "COM_WriteBufferOperation.h"
#include "COM_ReadBufferOperation.h"
-SocketProxyNode::SocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput, bool buffer) : Node(editorNode, false)
+SocketProxyNode::SocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput) : Node(editorNode, false)
{
DataType dt;
- this->m_buffer = buffer;
dt = COM_DT_VALUE;
if (editorInput->type == SOCK_RGBA) dt = COM_DT_COLOR;
if (editorInput->type == SOCK_VECTOR) dt = COM_DT_VECTOR;
- this->addInputSocket(dt, (InputSocketResizeMode)editorInput->resizemode, editorInput);
+ this->addInputSocket(dt, editorInput);
dt = COM_DT_VALUE;
if (editorOutput->type == SOCK_RGBA) dt = COM_DT_COLOR;
@@ -46,60 +44,40 @@ SocketProxyNode::SocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bN
this->addOutputSocket(dt, editorOutput);
}
-void SocketProxyNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void SocketProxyNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- OutputSocket *outputsocket = this->getOutputSocket(0);
- InputSocket *inputsocket = this->getInputSocket(0);
- if (inputsocket->isConnected()) {
- SocketProxyOperation *operation = new SocketProxyOperation(this->getOutputSocket()->getDataType());
- inputsocket->relinkConnections(operation->getInputSocket(0));
- outputsocket->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
-
- if (m_buffer) {
- OutputSocket * osocket = operation->getOutputSocket();
- WriteBufferOperation *writeOperation = new WriteBufferOperation(osocket->getDataType());
- ReadBufferOperation *readOperation = new ReadBufferOperation(osocket->getDataType());
- readOperation->setMemoryProxy(writeOperation->getMemoryProxy());
-
- osocket->relinkConnections(readOperation->getOutputSocket());
- addLink(graph, osocket, writeOperation->getInputSocket(0));
-
- graph->addOperation(writeOperation);
- graph->addOperation(readOperation);
- }
- }
- else if (outputsocket->isConnected()) {
- /* If input is not connected, add a constant value operation instead */
- switch (outputsocket->getDataType()) {
- case COM_DT_VALUE:
- {
- SetValueOperation *operation = new SetValueOperation();
- operation->setValue(inputsocket->getEditorValueFloat());
- outputsocket->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
- break;
- }
- case COM_DT_COLOR:
- {
- SetColorOperation *operation = new SetColorOperation();
- float col[4];
- inputsocket->getEditorValueColor(col);
- operation->setChannels(col);
- outputsocket->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
- break;
- }
- case COM_DT_VECTOR:
- {
- SetVectorOperation *operation = new SetVectorOperation();
- float vec[3];
- inputsocket->getEditorValueVector(vec);
- operation->setVector(vec);
- outputsocket->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
- break;
- }
- }
- }
+ NodeOperationOutput *proxy_output = converter.addInputProxy(getInputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(), proxy_output);
+}
+
+
+SocketBufferNode::SocketBufferNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput) : Node(editorNode, false)
+{
+ DataType dt;
+
+ dt = COM_DT_VALUE;
+ if (editorInput->type == SOCK_RGBA) dt = COM_DT_COLOR;
+ if (editorInput->type == SOCK_VECTOR) dt = COM_DT_VECTOR;
+ this->addInputSocket(dt, editorInput);
+
+ dt = COM_DT_VALUE;
+ if (editorOutput->type == SOCK_RGBA) dt = COM_DT_COLOR;
+ if (editorOutput->type == SOCK_VECTOR) dt = COM_DT_VECTOR;
+ this->addOutputSocket(dt, editorOutput);
+}
+
+void SocketBufferNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+{
+ NodeOutput *output = this->getOutputSocket(0);
+ NodeInput *input = this->getInputSocket(0);
+
+ DataType datatype = output->getDataType();
+ WriteBufferOperation *writeOperation = new WriteBufferOperation(datatype);
+ ReadBufferOperation *readOperation = new ReadBufferOperation(datatype);
+ readOperation->setMemoryProxy(writeOperation->getMemoryProxy());
+ converter.addOperation(writeOperation);
+ converter.addOperation(readOperation);
+
+ converter.mapInputSocket(input, writeOperation->getInputSocket(0));
+ converter.mapOutputSocket(output, readOperation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_SocketProxyNode.h b/source/blender/compositor/nodes/COM_SocketProxyNode.h
index b679901ba2c..2fbaa71421c 100644
--- a/source/blender/compositor/nodes/COM_SocketProxyNode.h
+++ b/source/blender/compositor/nodes/COM_SocketProxyNode.h
@@ -30,13 +30,16 @@
* @ingroup Node
*/
class SocketProxyNode : public Node {
-private:
- bool m_buffer;
public:
- SocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput, bool buffer);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ SocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+};
+
- virtual bool isProxyNode() const { return true; }
+class SocketBufferNode : public Node {
+public:
+ SocketBufferNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_SplitViewerNode.cpp b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp
index 6fb8467674b..8eb1b76e890 100644
--- a/source/blender/compositor/nodes/COM_SplitViewerNode.cpp
+++ b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp
@@ -32,14 +32,14 @@ SplitViewerNode::SplitViewerNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void SplitViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void SplitViewerNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
bNode *editorNode = this->getbNode();
- bool is_active = ((editorNode->flag & NODE_DO_OUTPUT_RECALC || context->isRendering()) &&
+ bool is_active = ((editorNode->flag & NODE_DO_OUTPUT_RECALC || context.isRendering()) &&
(editorNode->flag & NODE_DO_OUTPUT) && this->isInActiveGroup());
- InputSocket *image1Socket = this->getInputSocket(0);
- InputSocket *image2Socket = this->getInputSocket(1);
+ NodeInput *image1Socket = this->getInputSocket(0);
+ NodeInput *image2Socket = this->getInputSocket(1);
Image *image = (Image *)this->getbNode()->id;
ImageUser *imageUser = (ImageUser *) this->getbNode()->storage;
@@ -47,15 +47,16 @@ void SplitViewerNode::convertToOperations(ExecutionSystem *graph, CompositorCont
splitViewerOperation->setSplitPercentage(this->getbNode()->custom1);
splitViewerOperation->setXSplit(!this->getbNode()->custom2);
- image1Socket->relinkConnections(splitViewerOperation->getInputSocket(0), 0, graph);
- image2Socket->relinkConnections(splitViewerOperation->getInputSocket(1), 1, graph);
+ converter.addOperation(splitViewerOperation);
+ converter.mapInputSocket(image1Socket, splitViewerOperation->getInputSocket(0));
+ converter.mapInputSocket(image2Socket, splitViewerOperation->getInputSocket(1));
ViewerOperation *viewerOperation = new ViewerOperation();
viewerOperation->setImage(image);
viewerOperation->setImageUser(imageUser);
viewerOperation->setActive(is_active);
- viewerOperation->setViewSettings(context->getViewSettings());
- viewerOperation->setDisplaySettings(context->getDisplaySettings());
+ viewerOperation->setViewSettings(context.getViewSettings());
+ viewerOperation->setDisplaySettings(context.getDisplaySettings());
/* defaults - the viewer node has these options but not exposed for split view
* we could use the split to define an area of interest on one axis at least */
@@ -63,10 +64,8 @@ void SplitViewerNode::convertToOperations(ExecutionSystem *graph, CompositorCont
viewerOperation->setCenterX(0.5f);
viewerOperation->setCenterY(0.5f);
- addLink(graph, splitViewerOperation->getOutputSocket(), viewerOperation->getInputSocket(0));
+ converter.addOperation(viewerOperation);
+ converter.addLink(splitViewerOperation->getOutputSocket(), viewerOperation->getInputSocket(0));
- addPreviewOperation(graph, context, viewerOperation->getInputSocket(0));
-
- graph->addOperation(splitViewerOperation);
- graph->addOperation(viewerOperation);
+ converter.addPreview(splitViewerOperation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_SplitViewerNode.h b/source/blender/compositor/nodes/COM_SplitViewerNode.h
index f17cfd57cbf..1cc0c4cb9a8 100644
--- a/source/blender/compositor/nodes/COM_SplitViewerNode.h
+++ b/source/blender/compositor/nodes/COM_SplitViewerNode.h
@@ -32,6 +32,6 @@
class SplitViewerNode : public Node {
public:
SplitViewerNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp b/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp
index 8f17c4d9345..d1babcc8103 100644
--- a/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp
+++ b/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp
@@ -38,60 +38,59 @@ Stabilize2dNode::Stabilize2dNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void Stabilize2dNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void Stabilize2dNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *imageInput = this->getInputSocket(0);
+ NodeInput *imageInput = this->getInputSocket(0);
MovieClip *clip = (MovieClip *)getbNode()->id;
ScaleOperation *scaleOperation = new ScaleOperation();
+ scaleOperation->setSampler((PixelSampler)this->getbNode()->custom1);
RotateOperation *rotateOperation = new RotateOperation();
+ rotateOperation->setDoDegree2RadConversion(false);
TranslateOperation *translateOperation = new TranslateOperation();
MovieClipAttributeOperation *scaleAttribute = new MovieClipAttributeOperation();
MovieClipAttributeOperation *angleAttribute = new MovieClipAttributeOperation();
MovieClipAttributeOperation *xAttribute = new MovieClipAttributeOperation();
MovieClipAttributeOperation *yAttribute = new MovieClipAttributeOperation();
SetSamplerOperation *psoperation = new SetSamplerOperation();
-
+ psoperation->setSampler((PixelSampler)this->getbNode()->custom1);
+
scaleAttribute->setAttribute(MCA_SCALE);
- scaleAttribute->setFramenumber(context->getFramenumber());
+ scaleAttribute->setFramenumber(context.getFramenumber());
scaleAttribute->setMovieClip(clip);
-
+
angleAttribute->setAttribute(MCA_ANGLE);
- angleAttribute->setFramenumber(context->getFramenumber());
+ angleAttribute->setFramenumber(context.getFramenumber());
angleAttribute->setMovieClip(clip);
-
+
xAttribute->setAttribute(MCA_X);
- xAttribute->setFramenumber(context->getFramenumber());
+ xAttribute->setFramenumber(context.getFramenumber());
xAttribute->setMovieClip(clip);
yAttribute->setAttribute(MCA_Y);
- yAttribute->setFramenumber(context->getFramenumber());
+ yAttribute->setFramenumber(context.getFramenumber());
yAttribute->setMovieClip(clip);
- imageInput->relinkConnections(scaleOperation->getInputSocket(0), 0, graph);
- addLink(graph, scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(1));
- addLink(graph, scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(2));
+ converter.addOperation(scaleAttribute);
+ converter.addOperation(angleAttribute);
+ converter.addOperation(xAttribute);
+ converter.addOperation(yAttribute);
+ converter.addOperation(scaleOperation);
+ converter.addOperation(translateOperation);
+ converter.addOperation(rotateOperation);
+ converter.addOperation(psoperation);
- scaleOperation->setSampler((PixelSampler)this->getbNode()->custom1);
+ converter.mapInputSocket(imageInput, scaleOperation->getInputSocket(0));
+ converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(1));
+ converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(2));
- addLink(graph, scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0));
- addLink(graph, angleAttribute->getOutputSocket(), rotateOperation->getInputSocket(1));
- rotateOperation->setDoDegree2RadConversion(false);
+ converter.addLink(scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0));
+ converter.addLink(angleAttribute->getOutputSocket(), rotateOperation->getInputSocket(1));
- addLink(graph, rotateOperation->getOutputSocket(), translateOperation->getInputSocket(0));
- addLink(graph, xAttribute->getOutputSocket(), translateOperation->getInputSocket(1));
- addLink(graph, yAttribute->getOutputSocket(), translateOperation->getInputSocket(2));
-
- psoperation->setSampler((PixelSampler)this->getbNode()->custom1);
- addLink(graph, translateOperation->getOutputSocket(), psoperation->getInputSocket(0));
- this->getOutputSocket()->relinkConnections(psoperation->getOutputSocket());
+ converter.addLink(rotateOperation->getOutputSocket(), translateOperation->getInputSocket(0));
+ converter.addLink(xAttribute->getOutputSocket(), translateOperation->getInputSocket(1));
+ converter.addLink(yAttribute->getOutputSocket(), translateOperation->getInputSocket(2));
- graph->addOperation(scaleAttribute);
- graph->addOperation(angleAttribute);
- graph->addOperation(xAttribute);
- graph->addOperation(yAttribute);
- graph->addOperation(scaleOperation);
- graph->addOperation(translateOperation);
- graph->addOperation(rotateOperation);
- graph->addOperation(psoperation);
+ converter.addLink(translateOperation->getOutputSocket(), psoperation->getInputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(), psoperation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_Stabilize2dNode.h b/source/blender/compositor/nodes/COM_Stabilize2dNode.h
index 3363ff4142c..3b5890460c2 100644
--- a/source/blender/compositor/nodes/COM_Stabilize2dNode.h
+++ b/source/blender/compositor/nodes/COM_Stabilize2dNode.h
@@ -33,7 +33,7 @@
class Stabilize2dNode : public Node {
public:
Stabilize2dNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_SwitchNode.cpp b/source/blender/compositor/nodes/COM_SwitchNode.cpp
index 2a4616fcd3e..692b8d743f6 100644
--- a/source/blender/compositor/nodes/COM_SwitchNode.cpp
+++ b/source/blender/compositor/nodes/COM_SwitchNode.cpp
@@ -21,27 +21,21 @@
*/
#include "COM_SwitchNode.h"
-#include "COM_ExecutionSystem.h"
-#include "COM_SocketProxyOperation.h"
SwitchNode::SwitchNode(bNode *editorNode) : Node(editorNode)
{
/* pass */
}
-
-void SwitchNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void SwitchNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- SocketProxyOperation *operation = new SocketProxyOperation(COM_DT_COLOR);
- int switchFrame = this->getbNode()->custom1;
-
- if (!switchFrame) {
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- }
- else {
- this->getInputSocket(1)->relinkConnections(operation->getInputSocket(0), 1, graph);
- }
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
-
- graph->addOperation(operation);
+ bool condition = this->getbNode()->custom1;
+
+ NodeOperationOutput *result;
+ if (!condition)
+ result = converter.addInputProxy(getInputSocket(0));
+ else
+ result = converter.addInputProxy(getInputSocket(1));
+
+ converter.mapOutputSocket(getOutputSocket(0), result);
}
diff --git a/source/blender/compositor/nodes/COM_SwitchNode.h b/source/blender/compositor/nodes/COM_SwitchNode.h
index 16d9e18885b..4fedf4b0aa7 100644
--- a/source/blender/compositor/nodes/COM_SwitchNode.h
+++ b/source/blender/compositor/nodes/COM_SwitchNode.h
@@ -33,6 +33,6 @@
class SwitchNode : public Node {
public:
SwitchNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_TextureNode.cpp b/source/blender/compositor/nodes/COM_TextureNode.cpp
index 6f2baa63b0e..2ac027ca326 100644
--- a/source/blender/compositor/nodes/COM_TextureNode.cpp
+++ b/source/blender/compositor/nodes/COM_TextureNode.cpp
@@ -29,30 +29,31 @@ TextureNode::TextureNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void TextureNode::convertToOperations(ExecutionSystem *system, CompositorContext *context)
+void TextureNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
bNode *editorNode = this->getbNode();
Tex *texture = (Tex *)editorNode->id;
TextureOperation *operation = new TextureOperation();
- const ColorManagedDisplaySettings *displaySettings = context->getDisplaySettings();
+ const ColorManagedDisplaySettings *displaySettings = context.getDisplaySettings();
bool sceneColorManage = strcmp(displaySettings->display_device, "None") != 0;
- this->getOutputSocket(1)->relinkConnections(operation->getOutputSocket());
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, system);
- this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, system);
operation->setTexture(texture);
- operation->setRenderData(context->getRenderData());
+ operation->setRenderData(context.getRenderData());
operation->setSceneColorManage(sceneColorManage);
- system->addOperation(operation);
- addPreviewOperation(system, context, operation->getOutputSocket());
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
+ converter.mapOutputSocket(getOutputSocket(1), operation->getOutputSocket());
+
+ converter.addPreview(operation->getOutputSocket());
- if (this->getOutputSocket(0)->isConnected()) {
- TextureAlphaOperation *alphaOperation = new TextureAlphaOperation();
- this->getOutputSocket(0)->relinkConnections(alphaOperation->getOutputSocket());
- addLink(system, operation->getInputSocket(0)->getConnection()->getFromSocket(), alphaOperation->getInputSocket(0));
- addLink(system, operation->getInputSocket(1)->getConnection()->getFromSocket(), alphaOperation->getInputSocket(1));
- alphaOperation->setTexture(texture);
- alphaOperation->setRenderData(context->getRenderData());
- alphaOperation->setSceneColorManage(sceneColorManage);
- system->addOperation(alphaOperation);
- }
+ TextureAlphaOperation *alphaOperation = new TextureAlphaOperation();
+ alphaOperation->setTexture(texture);
+ alphaOperation->setRenderData(context.getRenderData());
+ alphaOperation->setSceneColorManage(sceneColorManage);
+ converter.addOperation(alphaOperation);
+
+ converter.mapInputSocket(getInputSocket(0), alphaOperation->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(1), alphaOperation->getInputSocket(1));
+ converter.mapOutputSocket(getOutputSocket(0), alphaOperation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_TextureNode.h b/source/blender/compositor/nodes/COM_TextureNode.h
index e0d931c65da..8d0fb467b1b 100644
--- a/source/blender/compositor/nodes/COM_TextureNode.h
+++ b/source/blender/compositor/nodes/COM_TextureNode.h
@@ -30,5 +30,5 @@
class TextureNode : public Node {
public:
TextureNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
diff --git a/source/blender/compositor/nodes/COM_TimeNode.cpp b/source/blender/compositor/nodes/COM_TimeNode.cpp
index 83f99a16d9f..b5e8ece9028 100644
--- a/source/blender/compositor/nodes/COM_TimeNode.cpp
+++ b/source/blender/compositor/nodes/COM_TimeNode.cpp
@@ -33,15 +33,14 @@ TimeNode::TimeNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void TimeNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void TimeNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
SetValueOperation *operation = new SetValueOperation();
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
bNode *node = this->getbNode();
/* stack order output: fac */
float fac = 0.0f;
- const int framenumber = context->getFramenumber();
+ const int framenumber = context.getFramenumber();
if (framenumber < node->custom1) {
fac = 0.0f;
@@ -50,11 +49,13 @@ void TimeNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
fac = 1.0f;
}
else if (node->custom1 < node->custom2) {
- fac = (context->getFramenumber() - node->custom1) / (float)(node->custom2 - node->custom1);
+ fac = (context.getFramenumber() - node->custom1) / (float)(node->custom2 - node->custom1);
}
curvemapping_initialize((CurveMapping *)node->storage);
fac = curvemapping_evaluateF((CurveMapping *)node->storage, 0, fac);
operation->setValue(CLAMPIS(fac, 0.0f, 1.0f));
- graph->addOperation(operation);
+ converter.addOperation(operation);
+
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_TimeNode.h b/source/blender/compositor/nodes/COM_TimeNode.h
index df3cf024714..078720f7150 100644
--- a/source/blender/compositor/nodes/COM_TimeNode.h
+++ b/source/blender/compositor/nodes/COM_TimeNode.h
@@ -32,7 +32,7 @@
class TimeNode : public Node {
public:
TimeNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_TonemapNode.cpp b/source/blender/compositor/nodes/COM_TonemapNode.cpp
index 440e6b62414..5ac73b9f9c2 100644
--- a/source/blender/compositor/nodes/COM_TonemapNode.cpp
+++ b/source/blender/compositor/nodes/COM_TonemapNode.cpp
@@ -29,13 +29,14 @@ TonemapNode::TonemapNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void TonemapNode::convertToOperations(ExecutionSystem *system, CompositorContext *context)
+void TonemapNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
NodeTonemap *data = (NodeTonemap *)this->getbNode()->storage;
+
TonemapOperation *operation = data->type == 1 ? new PhotoreceptorTonemapOperation() : new TonemapOperation();
- operation->setbNode(this->getbNode());
operation->setData(data);
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, system);
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
- system->addOperation(operation);
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_TonemapNode.h b/source/blender/compositor/nodes/COM_TonemapNode.h
index ad0d218826a..4a8636fd041 100644
--- a/source/blender/compositor/nodes/COM_TonemapNode.h
+++ b/source/blender/compositor/nodes/COM_TonemapNode.h
@@ -32,7 +32,7 @@
class TonemapNode : public Node {
public:
TonemapNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_TrackPositionNode.cpp b/source/blender/compositor/nodes/COM_TrackPositionNode.cpp
index bb8cecc60ad..75c8c786ae8 100644
--- a/source/blender/compositor/nodes/COM_TrackPositionNode.cpp
+++ b/source/blender/compositor/nodes/COM_TrackPositionNode.cpp
@@ -36,27 +36,24 @@ TrackPositionNode::TrackPositionNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void TrackPositionNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void TrackPositionNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- OutputSocket *outputX = this->getOutputSocket(0);
- OutputSocket *outputY = this->getOutputSocket(1);
-
bNode *editorNode = this->getbNode();
MovieClip *clip = (MovieClip *) editorNode->id;
-
NodeTrackPosData *trackpos_data = (NodeTrackPosData *) editorNode->storage;
+
+ NodeOutput *outputX = this->getOutputSocket(0);
+ NodeOutput *outputY = this->getOutputSocket(1);
int frame_number;
if (editorNode->custom1 == CMP_TRACKPOS_ABSOLUTE_FRAME) {
frame_number = editorNode->custom2;
}
else {
- frame_number = context->getFramenumber();
+ frame_number = context.getFramenumber();
}
TrackPositionOperation *operationX = new TrackPositionOperation();
- TrackPositionOperation *operationY = new TrackPositionOperation();
-
operationX->setMovieClip(clip);
operationX->setTrackingObject(trackpos_data->tracking_object);
operationX->setTrackName(trackpos_data->track_name);
@@ -64,7 +61,9 @@ void TrackPositionNode::convertToOperations(ExecutionSystem *graph, CompositorCo
operationX->setAxis(0);
operationX->setPosition(editorNode->custom1);
operationX->setRelativeFrame(editorNode->custom2);
-
+ converter.addOperation(operationX);
+
+ TrackPositionOperation *operationY = new TrackPositionOperation();
operationY->setMovieClip(clip);
operationY->setTrackingObject(trackpos_data->tracking_object);
operationY->setTrackName(trackpos_data->track_name);
@@ -72,10 +71,8 @@ void TrackPositionNode::convertToOperations(ExecutionSystem *graph, CompositorCo
operationY->setAxis(1);
operationY->setPosition(editorNode->custom1);
operationY->setRelativeFrame(editorNode->custom2);
-
- outputX->relinkConnections(operationX->getOutputSocket());
- outputY->relinkConnections(operationY->getOutputSocket());
-
- graph->addOperation(operationX);
- graph->addOperation(operationY);
+ converter.addOperation(operationY);
+
+ converter.mapOutputSocket(outputX, operationX->getOutputSocket());
+ converter.mapOutputSocket(outputY, operationY->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_TrackPositionNode.h b/source/blender/compositor/nodes/COM_TrackPositionNode.h
index 3d92ec3978c..375e28b6f8f 100644
--- a/source/blender/compositor/nodes/COM_TrackPositionNode.h
+++ b/source/blender/compositor/nodes/COM_TrackPositionNode.h
@@ -31,6 +31,6 @@
class TrackPositionNode : public Node {
public:
TrackPositionNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
diff --git a/source/blender/compositor/nodes/COM_TransformNode.cpp b/source/blender/compositor/nodes/COM_TransformNode.cpp
index 154761665cf..f1d5771bab3 100644
--- a/source/blender/compositor/nodes/COM_TransformNode.cpp
+++ b/source/blender/compositor/nodes/COM_TransformNode.cpp
@@ -33,38 +33,39 @@ TransformNode::TransformNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void TransformNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void TransformNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *imageInput = this->getInputSocket(0);
- InputSocket *xInput = this->getInputSocket(1);
- InputSocket *yInput = this->getInputSocket(2);
- InputSocket *angleInput = this->getInputSocket(3);
- InputSocket *scaleInput = this->getInputSocket(4);
+ NodeInput *imageInput = this->getInputSocket(0);
+ NodeInput *xInput = this->getInputSocket(1);
+ NodeInput *yInput = this->getInputSocket(2);
+ NodeInput *angleInput = this->getInputSocket(3);
+ NodeInput *scaleInput = this->getInputSocket(4);
ScaleOperation *scaleOperation = new ScaleOperation();
+ converter.addOperation(scaleOperation);
+
RotateOperation *rotateOperation = new RotateOperation();
+ rotateOperation->setDoDegree2RadConversion(false);
+ converter.addOperation(rotateOperation);
+
TranslateOperation *translateOperation = new TranslateOperation();
+ converter.addOperation(translateOperation);
+
SetSamplerOperation *sampler = new SetSamplerOperation();
-
sampler->setSampler((PixelSampler)this->getbNode()->custom1);
+ converter.addOperation(sampler);
- imageInput->relinkConnections(sampler->getInputSocket(0), 0, graph);
- addLink(graph, sampler->getOutputSocket(), scaleOperation->getInputSocket(0));
- scaleInput->relinkConnections(scaleOperation->getInputSocket(1), 4, graph);
- addLink(graph, scaleOperation->getInputSocket(1)->getConnection()->getFromSocket(), scaleOperation->getInputSocket(2)); // xscale = yscale
+ converter.mapInputSocket(imageInput, sampler->getInputSocket(0));
+ converter.addLink(sampler->getOutputSocket(), scaleOperation->getInputSocket(0));
+ converter.mapInputSocket(scaleInput, scaleOperation->getInputSocket(1));
+ converter.mapInputSocket(scaleInput, scaleOperation->getInputSocket(2)); // xscale = yscale
- addLink(graph, scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0));
- rotateOperation->setDoDegree2RadConversion(false);
- angleInput->relinkConnections(rotateOperation->getInputSocket(1), 3, graph);
-
- addLink(graph, rotateOperation->getOutputSocket(), translateOperation->getInputSocket(0));
- xInput->relinkConnections(translateOperation->getInputSocket(1), 1, graph);
- yInput->relinkConnections(translateOperation->getInputSocket(2), 2, graph);
+ converter.addLink(scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0));
+ converter.mapInputSocket(angleInput, rotateOperation->getInputSocket(1));
- this->getOutputSocket()->relinkConnections(translateOperation->getOutputSocket());
+ converter.addLink(rotateOperation->getOutputSocket(), translateOperation->getInputSocket(0));
+ converter.mapInputSocket(xInput, translateOperation->getInputSocket(1));
+ converter.mapInputSocket(yInput, translateOperation->getInputSocket(2));
- graph->addOperation(sampler);
- graph->addOperation(scaleOperation);
- graph->addOperation(rotateOperation);
- graph->addOperation(translateOperation);
+ converter.mapOutputSocket(getOutputSocket(), translateOperation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_TransformNode.h b/source/blender/compositor/nodes/COM_TransformNode.h
index 666f2da775e..6e210d266de 100644
--- a/source/blender/compositor/nodes/COM_TransformNode.h
+++ b/source/blender/compositor/nodes/COM_TransformNode.h
@@ -33,7 +33,7 @@
class TransformNode : public Node {
public:
TransformNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif /* __COM_TRANSFORMNODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_TranslateNode.cpp b/source/blender/compositor/nodes/COM_TranslateNode.cpp
index 8d8c663375b..4bd60f1a1c8 100644
--- a/source/blender/compositor/nodes/COM_TranslateNode.cpp
+++ b/source/blender/compositor/nodes/COM_TranslateNode.cpp
@@ -32,44 +32,43 @@ TranslateNode::TranslateNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void TranslateNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void TranslateNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *inputSocket = this->getInputSocket(0);
- InputSocket *inputXSocket = this->getInputSocket(1);
- InputSocket *inputYSocket = this->getInputSocket(2);
- OutputSocket *outputSocket = this->getOutputSocket(0);
- TranslateOperation *operation = new TranslateOperation();
-
bNode *bnode = this->getbNode();
NodeTranslateData *data = (NodeTranslateData *)bnode->storage;
-
+
+ NodeInput *inputSocket = this->getInputSocket(0);
+ NodeInput *inputXSocket = this->getInputSocket(1);
+ NodeInput *inputYSocket = this->getInputSocket(2);
+ NodeOutput *outputSocket = this->getOutputSocket(0);
+
+ TranslateOperation *operation = new TranslateOperation();
+ if (data->relative) {
+ const RenderData *rd = context.getRenderData();
+ float fx = rd->xsch * rd->size / 100.0f;
+ float fy = rd->ysch * rd->size / 100.0f;
+
+ operation->setFactorXY(fx, fy);
+ }
+
+ converter.addOperation(operation);
+ converter.mapInputSocket(inputXSocket, operation->getInputSocket(1));
+ converter.mapInputSocket(inputYSocket, operation->getInputSocket(2));
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
+
if (data->wrap_axis) {
WriteBufferOperation *writeOperation = new WriteBufferOperation(COM_DT_COLOR);
WrapOperation *wrapOperation = new WrapOperation(COM_DT_COLOR);
wrapOperation->setMemoryProxy(writeOperation->getMemoryProxy());
wrapOperation->setWrapping(data->wrap_axis);
- inputSocket->relinkConnections(writeOperation->getInputSocket(0), 0, graph);
- addLink(graph, wrapOperation->getOutputSocket(), operation->getInputSocket(0));
-
- graph->addOperation(writeOperation);
- graph->addOperation(wrapOperation);
+ converter.addOperation(writeOperation);
+ converter.addOperation(wrapOperation);
+ converter.mapInputSocket(inputSocket, writeOperation->getInputSocket(0));
+ converter.addLink(wrapOperation->getOutputSocket(), operation->getInputSocket(0));
}
else {
- inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
+ converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
}
-
- if (data->relative) {
- const RenderData *rd = context->getRenderData();
- float fx = rd->xsch * rd->size / 100.0f;
- float fy = rd->ysch * rd->size / 100.0f;
-
- operation->setFactorXY(fx, fy);
- }
-
- inputXSocket->relinkConnections(operation->getInputSocket(1), 1, graph);
- inputYSocket->relinkConnections(operation->getInputSocket(2), 2, graph);
- outputSocket->relinkConnections(operation->getOutputSocket(0));
- graph->addOperation(operation);
}
diff --git a/source/blender/compositor/nodes/COM_TranslateNode.h b/source/blender/compositor/nodes/COM_TranslateNode.h
index 8c350e9cfb3..160da410aff 100644
--- a/source/blender/compositor/nodes/COM_TranslateNode.h
+++ b/source/blender/compositor/nodes/COM_TranslateNode.h
@@ -32,7 +32,7 @@
class TranslateNode : public Node {
public:
TranslateNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ValueNode.cpp b/source/blender/compositor/nodes/COM_ValueNode.cpp
index ed4440aa099..62a312da67c 100644
--- a/source/blender/compositor/nodes/COM_ValueNode.cpp
+++ b/source/blender/compositor/nodes/COM_ValueNode.cpp
@@ -29,11 +29,12 @@ ValueNode::ValueNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void ValueNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void ValueNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
SetValueOperation *operation = new SetValueOperation();
- OutputSocket *output = this->getOutputSocket(0);
- output->relinkConnections(operation->getOutputSocket());
+ NodeOutput *output = this->getOutputSocket(0);
operation->setValue(output->getEditorValueFloat());
- graph->addOperation(operation);
+ converter.addOperation(operation);
+
+ converter.mapOutputSocket(output, operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_ValueNode.h b/source/blender/compositor/nodes/COM_ValueNode.h
index 4f478ae93af..e5b80fb4c60 100644
--- a/source/blender/compositor/nodes/COM_ValueNode.h
+++ b/source/blender/compositor/nodes/COM_ValueNode.h
@@ -32,7 +32,7 @@
class ValueNode : public Node {
public:
ValueNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_VectorBlurNode.cpp b/source/blender/compositor/nodes/COM_VectorBlurNode.cpp
index 07c8120b1d2..cbe02388f90 100644
--- a/source/blender/compositor/nodes/COM_VectorBlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_VectorBlurNode.cpp
@@ -29,17 +29,18 @@ VectorBlurNode::VectorBlurNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void VectorBlurNode::convertToOperations(ExecutionSystem *system, CompositorContext *context)
+void VectorBlurNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
bNode *node = this->getbNode();
NodeBlurData *vectorBlurSettings = (NodeBlurData *)node->storage;
+
VectorBlurOperation *operation = new VectorBlurOperation();
- operation->setbNode(node);
operation->setVectorBlurSettings(vectorBlurSettings);
- operation->setQuality(context->getQuality());
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, system);
- this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, system);
- this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), 2, system);
- this->getOutputSocket()->relinkConnections(operation->getOutputSocket());
- system->addOperation(operation);
+ operation->setQuality(context.getQuality());
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
+ converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2));
+ converter.mapOutputSocket(getOutputSocket(), operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_VectorBlurNode.h b/source/blender/compositor/nodes/COM_VectorBlurNode.h
index 6b5d277a54b..f402aee9670 100644
--- a/source/blender/compositor/nodes/COM_VectorBlurNode.h
+++ b/source/blender/compositor/nodes/COM_VectorBlurNode.h
@@ -32,7 +32,7 @@
class VectorBlurNode : public Node {
public:
VectorBlurNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_VectorCurveNode.cpp b/source/blender/compositor/nodes/COM_VectorCurveNode.cpp
index dcf1059ece6..197b2c8bd0c 100644
--- a/source/blender/compositor/nodes/COM_VectorCurveNode.cpp
+++ b/source/blender/compositor/nodes/COM_VectorCurveNode.cpp
@@ -29,14 +29,12 @@ VectorCurveNode::VectorCurveNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void VectorCurveNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void VectorCurveNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
VectorCurveOperation *operation = new VectorCurveOperation();
-
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
-
operation->setCurveMapping((CurveMapping *)this->getbNode()->storage);
-
- graph->addOperation(operation);
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_VectorCurveNode.h b/source/blender/compositor/nodes/COM_VectorCurveNode.h
index 3201090df14..8499bbf99df 100644
--- a/source/blender/compositor/nodes/COM_VectorCurveNode.h
+++ b/source/blender/compositor/nodes/COM_VectorCurveNode.h
@@ -32,7 +32,7 @@
class VectorCurveNode : public Node {
public:
VectorCurveNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp b/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp
index a515bfc7f47..30f51794e8d 100644
--- a/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp
+++ b/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp
@@ -31,52 +31,34 @@ ViewLevelsNode::ViewLevelsNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void ViewLevelsNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void ViewLevelsNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- InputSocket *input = this->getInputSocket(0);
- bool firstOperationConnected = false;
- if (input->isConnected()) {
- OutputSocket *inputSocket = input->getConnection()->getFromSocket();
+ NodeInput *input = this->getInputSocket(0);
+ if (input->isLinked()) {
// add preview to inputSocket;
- OutputSocket *socket = this->getOutputSocket(0);
- if (socket->isConnected()) {
- // calculate mean operation
+ /* calculate mean operation */
+ {
CalculateMeanOperation *operation = new CalculateMeanOperation();
- input->relinkConnections(operation->getInputSocket(0), 0, graph);
- firstOperationConnected = true;
operation->setSetting(this->getbNode()->custom1);
- socket->relinkConnections(operation->getOutputSocket());
- graph->addOperation(operation);
+
+ converter.addOperation(operation);
+ converter.mapInputSocket(input, operation->getInputSocket(0));
+ converter.mapOutputSocket(this->getOutputSocket(0), operation->getOutputSocket());
}
- socket = this->getOutputSocket(1);
- if (socket->isConnected()) {
- // calculate standard deviation operation
+ /* calculate standard deviation operation */
+ {
CalculateStandardDeviationOperation *operation = new CalculateStandardDeviationOperation();
- if (firstOperationConnected) {
- addLink(graph, inputSocket, operation->getInputSocket(0));
- }
- else {
- input->relinkConnections(operation->getInputSocket(0), 0, graph);
- }
operation->setSetting(this->getbNode()->custom1);
- socket->relinkConnections(operation->getOutputSocket());
- graph->addOperation(operation);
+
+ converter.addOperation(operation);
+ converter.mapInputSocket(input, operation->getInputSocket(0));
+ converter.mapOutputSocket(this->getOutputSocket(1), operation->getOutputSocket());
}
}
else {
- SetValueOperation *meanOutput = new SetValueOperation();
- SetValueOperation *stdDevOutput = new SetValueOperation();
-
- meanOutput->setValue(0.0f);
- stdDevOutput->setValue(0.0f);
-
- this->getOutputSocket(0)->relinkConnections(meanOutput->getOutputSocket());
- this->getOutputSocket(1)->relinkConnections(stdDevOutput->getOutputSocket());
-
- graph->addOperation(meanOutput);
- graph->addOperation(stdDevOutput);
+ converter.addOutputValue(getOutputSocket(0), 0.0f);
+ converter.addOutputValue(getOutputSocket(1), 0.0f);
}
}
-
diff --git a/source/blender/compositor/nodes/COM_ViewLevelsNode.h b/source/blender/compositor/nodes/COM_ViewLevelsNode.h
index 2ac84fad22f..dbcc770f88a 100644
--- a/source/blender/compositor/nodes/COM_ViewLevelsNode.h
+++ b/source/blender/compositor/nodes/COM_ViewLevelsNode.h
@@ -32,7 +32,7 @@
class ViewLevelsNode : public Node {
public:
ViewLevelsNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ViewerNode.cpp b/source/blender/compositor/nodes/COM_ViewerNode.cpp
index 531fa4158bc..09a3cea2da1 100644
--- a/source/blender/compositor/nodes/COM_ViewerNode.cpp
+++ b/source/blender/compositor/nodes/COM_ViewerNode.cpp
@@ -31,41 +31,47 @@ ViewerNode::ViewerNode(bNode *editorNode) : Node(editorNode)
/* pass */
}
-void ViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+void ViewerNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
bNode *editorNode = this->getbNode();
- bool is_active = (editorNode->flag & NODE_DO_OUTPUT_RECALC || context->isRendering()) &&
+ bool is_active = (editorNode->flag & NODE_DO_OUTPUT_RECALC || context.isRendering()) &&
((editorNode->flag & NODE_DO_OUTPUT) && this->isInActiveGroup());
+ bool ignore_alpha = editorNode->custom2 & CMP_NODE_OUTPUT_IGNORE_ALPHA;
- InputSocket *imageSocket = this->getInputSocket(0);
- InputSocket *alphaSocket = this->getInputSocket(1);
- InputSocket *depthSocket = this->getInputSocket(2);
+ NodeInput *imageSocket = this->getInputSocket(0);
+ NodeInput *alphaSocket = this->getInputSocket(1);
+ NodeInput *depthSocket = this->getInputSocket(2);
Image *image = (Image *)this->getbNode()->id;
ImageUser *imageUser = (ImageUser *) this->getbNode()->storage;
ViewerOperation *viewerOperation = new ViewerOperation();
- viewerOperation->setbNodeTree(context->getbNodeTree());
+ viewerOperation->setbNodeTree(context.getbNodeTree());
viewerOperation->setImage(image);
viewerOperation->setImageUser(imageUser);
viewerOperation->setActive(is_active);
viewerOperation->setChunkOrder((OrderOfChunks)editorNode->custom1);
viewerOperation->setCenterX(editorNode->custom3);
viewerOperation->setCenterY(editorNode->custom4);
- viewerOperation->setIgnoreAlpha(editorNode->custom2 & CMP_NODE_OUTPUT_IGNORE_ALPHA);
+ /* alpha socket gives either 1 or a custom alpha value if "use alpha" is enabled */
+ viewerOperation->setUseAlphaInput(ignore_alpha || alphaSocket->isLinked());
- viewerOperation->setViewSettings(context->getViewSettings());
- viewerOperation->setDisplaySettings(context->getDisplaySettings());
+ viewerOperation->setViewSettings(context.getViewSettings());
+ viewerOperation->setDisplaySettings(context.getDisplaySettings());
viewerOperation->setResolutionInputSocketIndex(0);
- if (!imageSocket->isConnected()) {
- if (alphaSocket->isConnected()) {
+ if (!imageSocket->isLinked()) {
+ if (alphaSocket->isLinked()) {
viewerOperation->setResolutionInputSocketIndex(1);
}
}
- imageSocket->relinkConnections(viewerOperation->getInputSocket(0), 0, graph);
- alphaSocket->relinkConnections(viewerOperation->getInputSocket(1));
- depthSocket->relinkConnections(viewerOperation->getInputSocket(2));
- graph->addOperation(viewerOperation);
+ converter.addOperation(viewerOperation);
+ converter.mapInputSocket(imageSocket, viewerOperation->getInputSocket(0));
+ /* only use alpha link if "use alpha" is enabled */
+ if (ignore_alpha)
+ converter.addInputValue(viewerOperation->getInputSocket(1), 1.0f);
+ else
+ converter.mapInputSocket(alphaSocket, viewerOperation->getInputSocket(1));
+ converter.mapInputSocket(depthSocket, viewerOperation->getInputSocket(2));
- addPreviewOperation(graph, context, viewerOperation->getInputSocket(0));
+ converter.addNodeInputPreview(imageSocket);
}
diff --git a/source/blender/compositor/nodes/COM_ViewerNode.h b/source/blender/compositor/nodes/COM_ViewerNode.h
index 3a9954b8aea..289c2650342 100644
--- a/source/blender/compositor/nodes/COM_ViewerNode.h
+++ b/source/blender/compositor/nodes/COM_ViewerNode.h
@@ -32,6 +32,6 @@
class ViewerNode : public Node {
public:
ViewerNode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ZCombineNode.cpp b/source/blender/compositor/nodes/COM_ZCombineNode.cpp
index 685c9695eec..d46600cc368 100644
--- a/source/blender/compositor/nodes/COM_ZCombineNode.cpp
+++ b/source/blender/compositor/nodes/COM_ZCombineNode.cpp
@@ -32,79 +32,71 @@
#include "DNA_material_types.h" // the ramp types
-void ZCombineNode::convertToOperations(ExecutionSystem *system, CompositorContext *context)
+void ZCombineNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
- if ((context->getRenderData()->scemode & R_FULL_SAMPLE) || this->getbNode()->custom2) {
- if (this->getOutputSocket(0)->isConnected()) {
- ZCombineOperation *operation = NULL;
- if (this->getbNode()->custom1) {
- operation = new ZCombineAlphaOperation();
- }
- else {
- operation = new ZCombineOperation();
- }
-
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, system);
- this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, system);
- this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), 2, system);
- this->getInputSocket(3)->relinkConnections(operation->getInputSocket(3), 3, system);
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
- system->addOperation(operation);
- if (this->getOutputSocket(1)->isConnected()) {
- MathMinimumOperation *zoperation = new MathMinimumOperation();
- addLink(system, operation->getInputSocket(1)->getConnection()->getFromSocket(), zoperation->getInputSocket(0));
- addLink(system, operation->getInputSocket(3)->getConnection()->getFromSocket(), zoperation->getInputSocket(1));
- this->getOutputSocket(1)->relinkConnections(zoperation->getOutputSocket());
- system->addOperation(zoperation);
- }
+ if ((context.getRenderData()->scemode & R_FULL_SAMPLE) || this->getbNode()->custom2) {
+ ZCombineOperation *operation = NULL;
+ if (this->getbNode()->custom1) {
+ operation = new ZCombineAlphaOperation();
}
else {
- if (this->getOutputSocket(1)->isConnected()) {
- MathMinimumOperation *zoperation = new MathMinimumOperation();
- this->getInputSocket(1)->relinkConnections(zoperation->getInputSocket(0), 1, system);
- this->getInputSocket(3)->relinkConnections(zoperation->getInputSocket(1), 3, system);
- this->getOutputSocket(1)->relinkConnections(zoperation->getOutputSocket());
- system->addOperation(zoperation);
- }
+ operation = new ZCombineOperation();
}
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
+ converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2));
+ converter.mapInputSocket(getInputSocket(3), operation->getInputSocket(3));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
+
+ MathMinimumOperation *zoperation = new MathMinimumOperation();
+ converter.addOperation(zoperation);
+
+ converter.mapInputSocket(getInputSocket(1), zoperation->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(3), zoperation->getInputSocket(1));
+ converter.mapOutputSocket(getOutputSocket(1), zoperation->getOutputSocket());
}
else {
+ /* XXX custom1 is "use_alpha", what on earth is this supposed to do here?!? */
// not full anti alias, use masking for Z combine. be aware it uses anti aliasing.
// step 1 create mask
NodeOperation *maskoperation;
-
if (this->getbNode()->custom1) {
maskoperation = new MathGreaterThanOperation();
- this->getInputSocket(1)->relinkConnections(maskoperation->getInputSocket(0), 3, system);
- this->getInputSocket(3)->relinkConnections(maskoperation->getInputSocket(1), 1, system);
+ converter.addOperation(maskoperation);
+
+ converter.mapInputSocket(getInputSocket(1), maskoperation->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(3), maskoperation->getInputSocket(1));
}
else {
maskoperation = new MathLessThanOperation();
- this->getInputSocket(1)->relinkConnections(maskoperation->getInputSocket(0), 1, system);
- this->getInputSocket(3)->relinkConnections(maskoperation->getInputSocket(1), 3, system);
+ converter.addOperation(maskoperation);
+
+ converter.mapInputSocket(getInputSocket(1), maskoperation->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(3), maskoperation->getInputSocket(1));
}
// step 2 anti alias mask bit of an expensive operation, but does the trick
AntiAliasOperation *antialiasoperation = new AntiAliasOperation();
- addLink(system, maskoperation->getOutputSocket(), antialiasoperation->getInputSocket(0));
+ converter.addOperation(antialiasoperation);
+
+ converter.addLink(maskoperation->getOutputSocket(), antialiasoperation->getInputSocket(0));
// use mask to blend between the input colors.
ZCombineMaskOperation *zcombineoperation = this->getbNode()->custom1 ? new ZCombineMaskAlphaOperation() : new ZCombineMaskOperation();
- addLink(system, antialiasoperation->getOutputSocket(), zcombineoperation->getInputSocket(0));
- this->getInputSocket(0)->relinkConnections(zcombineoperation->getInputSocket(1), 0, system);
- this->getInputSocket(2)->relinkConnections(zcombineoperation->getInputSocket(2), 2, system);
- this->getOutputSocket(0)->relinkConnections(zcombineoperation->getOutputSocket());
+ converter.addOperation(zcombineoperation);
+
+ converter.addLink(antialiasoperation->getOutputSocket(), zcombineoperation->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(0), zcombineoperation->getInputSocket(1));
+ converter.mapInputSocket(getInputSocket(2), zcombineoperation->getInputSocket(2));
+ converter.mapOutputSocket(getOutputSocket(0), zcombineoperation->getOutputSocket());
- system->addOperation(maskoperation);
- system->addOperation(antialiasoperation);
- system->addOperation(zcombineoperation);
-
- if (this->getOutputSocket(1)->isConnected()) {
- MathMinimumOperation *zoperation = new MathMinimumOperation();
- addLink(system, maskoperation->getInputSocket(0)->getConnection()->getFromSocket(), zoperation->getInputSocket(0));
- addLink(system, maskoperation->getInputSocket(1)->getConnection()->getFromSocket(), zoperation->getInputSocket(1));
- this->getOutputSocket(1)->relinkConnections(zoperation->getOutputSocket());
- system->addOperation(zoperation);
- }
+ MathMinimumOperation *zoperation = new MathMinimumOperation();
+ converter.addOperation(zoperation);
+
+ converter.mapInputSocket(getInputSocket(1), zoperation->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(3), zoperation->getInputSocket(1));
+ converter.mapOutputSocket(getOutputSocket(1), zoperation->getOutputSocket());
}
}
diff --git a/source/blender/compositor/nodes/COM_ZCombineNode.h b/source/blender/compositor/nodes/COM_ZCombineNode.h
index 61f4037be90..474be8db6ba 100644
--- a/source/blender/compositor/nodes/COM_ZCombineNode.h
+++ b/source/blender/compositor/nodes/COM_ZCombineNode.h
@@ -32,7 +32,7 @@
class ZCombineNode : public Node {
public:
ZCombineNode(bNode *editorNode) : Node(editorNode) {}
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
index 0f7afe484b1..e7af9319f88 100644
--- a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
@@ -36,30 +36,29 @@ BlurBaseOperation::BlurBaseOperation(DataType data_type) : NodeOperation()
this->addOutputSocket(data_type);
this->setComplex(true);
this->m_inputProgram = NULL;
- this->m_data = NULL;
+ memset(&m_data, 0, sizeof(NodeBlurData));
this->m_size = 1.0f;
- this->m_deleteData = false;
this->m_sizeavailable = false;
}
void BlurBaseOperation::initExecution()
{
this->m_inputProgram = this->getInputSocketReader(0);
this->m_inputSize = this->getInputSocketReader(1);
- this->m_data->image_in_width = this->getWidth();
- this->m_data->image_in_height = this->getHeight();
- if (this->m_data->relative) {
- switch (this->m_data->aspect) {
+ this->m_data.image_in_width = this->getWidth();
+ this->m_data.image_in_height = this->getHeight();
+ if (this->m_data.relative) {
+ switch (this->m_data.aspect) {
case CMP_NODE_BLUR_ASPECT_NONE:
- this->m_data->sizex = (int)(this->m_data->percentx * 0.01f * this->m_data->image_in_width);
- this->m_data->sizey = (int)(this->m_data->percenty * 0.01f * this->m_data->image_in_height);
+ this->m_data.sizex = (int)(this->m_data.percentx * 0.01f * this->m_data.image_in_width);
+ this->m_data.sizey = (int)(this->m_data.percenty * 0.01f * this->m_data.image_in_height);
break;
case CMP_NODE_BLUR_ASPECT_Y:
- this->m_data->sizex = (int)(this->m_data->percentx * 0.01f * this->m_data->image_in_width);
- this->m_data->sizey = (int)(this->m_data->percenty * 0.01f * this->m_data->image_in_width);
+ this->m_data.sizex = (int)(this->m_data.percentx * 0.01f * this->m_data.image_in_width);
+ this->m_data.sizey = (int)(this->m_data.percenty * 0.01f * this->m_data.image_in_width);
break;
case CMP_NODE_BLUR_ASPECT_X:
- this->m_data->sizex = (int)(this->m_data->percentx * 0.01f * this->m_data->image_in_height);
- this->m_data->sizey = (int)(this->m_data->percenty * 0.01f * this->m_data->image_in_height);
+ this->m_data.sizex = (int)(this->m_data.percentx * 0.01f * this->m_data.image_in_height);
+ this->m_data.sizey = (int)(this->m_data.percenty * 0.01f * this->m_data.image_in_height);
break;
}
}
@@ -80,7 +79,7 @@ float *BlurBaseOperation::make_gausstab(float rad, int size)
sum = 0.0f;
float fac = (rad > 0.0f ? 1.0f / rad : 0.0f);
for (i = -size; i <= size; i++) {
- val = RE_filter_value(this->m_data->filtertype, (float)i * fac);
+ val = RE_filter_value(this->m_data.filtertype, (float)i * fac);
sum += val;
gausstab[i + size] = val;
}
@@ -144,10 +143,11 @@ void BlurBaseOperation::deinitExecution()
{
this->m_inputProgram = NULL;
this->m_inputSize = NULL;
- if (this->m_deleteData) {
- delete this->m_data;
- }
- this->m_data = NULL;
+}
+
+void BlurBaseOperation::setData(const NodeBlurData *data)
+{
+ memcpy(&m_data, data, sizeof(NodeBlurData));
}
void BlurBaseOperation::updateSize()
diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.h b/source/blender/compositor/operations/COM_BlurBaseOperation.h
index c5d89b1bc91..052a525ef2c 100644
--- a/source/blender/compositor/operations/COM_BlurBaseOperation.h
+++ b/source/blender/compositor/operations/COM_BlurBaseOperation.h
@@ -43,10 +43,9 @@ protected:
*/
SocketReader *m_inputProgram;
SocketReader *m_inputSize;
- NodeBlurData *m_data;
+ NodeBlurData m_data;
float m_size;
- bool m_deleteData;
bool m_sizeavailable;
public:
@@ -60,9 +59,7 @@ public:
*/
void deinitExecution();
- void setData(NodeBlurData *data) { this->m_data = data; }
-
- void deleteDataWhenFinished() { this->m_deleteData = true; }
+ void setData(const NodeBlurData *data);
void setSize(float size) { this->m_size = size; this->m_sizeavailable = true; }
};
diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cpp b/source/blender/compositor/operations/COM_CompositorOperation.cpp
index 9bb653c1319..5f6e4e9d3c3 100644
--- a/source/blender/compositor/operations/COM_CompositorOperation.cpp
+++ b/source/blender/compositor/operations/COM_CompositorOperation.cpp
@@ -21,7 +21,6 @@
*/
#include "COM_CompositorOperation.h"
-#include "COM_SocketConnection.h"
#include "BLI_listbase.h"
#include "BKE_image.h"
@@ -49,7 +48,7 @@ CompositorOperation::CompositorOperation() : NodeOperation()
this->m_alphaInput = NULL;
this->m_depthInput = NULL;
- this->m_ignoreAlpha = false;
+ this->m_useAlphaInput = false;
this->m_active = false;
this->m_sceneName[0] = '\0';
@@ -189,21 +188,14 @@ void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber)
int input_x = x + dx, input_y = y + dy;
this->m_imageInput->readSampled(color, input_x, input_y, COM_PS_NEAREST);
- if (this->m_ignoreAlpha) {
- color[3] = 1.0f;
- }
- else {
- if (this->m_alphaInput != NULL) {
- this->m_alphaInput->readSampled(&(color[3]), input_x, input_y, COM_PS_NEAREST);
- }
+ if (this->m_useAlphaInput) {
+ this->m_alphaInput->readSampled(&(color[3]), input_x, input_y, COM_PS_NEAREST);
}
copy_v4_v4(buffer + offset4, color);
- if (this->m_depthInput != NULL) {
- this->m_depthInput->readSampled(color, input_x, input_y, COM_PS_NEAREST);
- zbuffer[offset] = color[0];
- }
+ this->m_depthInput->readSampled(color, input_x, input_y, COM_PS_NEAREST);
+ zbuffer[offset] = color[0];
offset4 += COM_NO_CHANNELS_COLOR;
offset++;
if (isBreaked()) {
diff --git a/source/blender/compositor/operations/COM_CompositorOperation.h b/source/blender/compositor/operations/COM_CompositorOperation.h
index d33e89ed742..771c32ffd12 100644
--- a/source/blender/compositor/operations/COM_CompositorOperation.h
+++ b/source/blender/compositor/operations/COM_CompositorOperation.h
@@ -69,7 +69,7 @@ private:
/**
* @brief Ignore any alpha input
*/
- bool m_ignoreAlpha;
+ bool m_useAlphaInput;
/**
* @brief operation is active for calculating final compo result
@@ -86,7 +86,7 @@ public:
void deinitExecution();
const CompositorPriority getRenderPriority() const { return COM_PRIORITY_MEDIUM; }
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
- void setIgnoreAlpha(bool value) { this->m_ignoreAlpha = value; }
+ void setUseAlphaInput(bool value) { this->m_useAlphaInput = value; }
void setActive(bool active) { this->m_active = active; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
index 4e1195bf731..00b6ce8f33a 100644
--- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
@@ -45,13 +45,13 @@ void FastGaussianBlurOperation::executePixel(float output[4], int x, int y, void
// the whole image.
bool FastGaussianBlurOperation::getDAI(rcti *rect, rcti *output)
{
- // m_data->sizex * m_size should be enough? For some reason there
+ // m_data.sizex * m_size should be enough? For some reason there
// seem to be errors in the boundary between tiles.
float size = this->m_size * COM_FAST_GAUSSIAN_MULTIPLIER;
- int sx = this->m_data->sizex * size;
+ int sx = this->m_data.sizex * size;
if (sx < 1)
sx = 1;
- int sy = this->m_data->sizey * size;
+ int sy = this->m_data.sizey * size;
if (sy < 1)
sy = 1;
@@ -125,8 +125,8 @@ void *FastGaussianBlurOperation::initializeTileData(rcti *rect)
updateSize();
int c;
- this->m_sx = this->m_data->sizex * this->m_size / 2.0f;
- this->m_sy = this->m_data->sizey * this->m_size / 2.0f;
+ this->m_sx = this->m_data.sizex * this->m_size / 2.0f;
+ this->m_sy = this->m_data.sizey * this->m_size / 2.0f;
if ((this->m_sx == this->m_sy) && (this->m_sx > 0.f)) {
for (c = 0; c < COM_NO_CHANNELS_COLOR; ++c)
@@ -174,8 +174,8 @@ void *FastGaussianBlurOperation::initializeTileData(rcti *rect)
tile->copyContentFrom(buffer);
int c;
- float sx = this->m_data->sizex * this->m_size / 2.0f;
- float sy = this->m_data->sizey * this->m_size / 2.0f;
+ float sx = this->m_data.sizex * this->m_size / 2.0f;
+ float sy = this->m_data.sizey * this->m_size / 2.0f;
if ((sx == sy) && (sx > 0.f)) {
for (c = 0; c < COM_NO_CHANNELS_COLOR; ++c)
diff --git a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp
index 1709d1feba3..f0d28b93ecb 100644
--- a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp
@@ -54,7 +54,7 @@ void GaussianAlphaXBlurOperation::initExecution()
initMutex();
if (this->m_sizeavailable) {
- float rad = max_ff(m_size * m_data->sizex, 0.0f);
+ float rad = max_ff(m_size * m_data.sizex, 0.0f);
m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
@@ -66,7 +66,7 @@ void GaussianAlphaXBlurOperation::updateGauss()
{
if (this->m_gausstab == NULL) {
updateSize();
- float rad = max_ff(m_size * m_data->sizex, 0.0f);
+ float rad = max_ff(m_size * m_data.sizex, 0.0f);
m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
@@ -74,7 +74,7 @@ void GaussianAlphaXBlurOperation::updateGauss()
if (this->m_distbuf_inv == NULL) {
updateSize();
- float rad = max_ff(m_size * m_data->sizex, 0.0f);
+ float rad = max_ff(m_size * m_data.sizex, 0.0f);
m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, m_filtersize, m_falloff);
diff --git a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
index 30e4d7b77fb..c33f99ce55e 100644
--- a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
@@ -54,7 +54,7 @@ void GaussianAlphaYBlurOperation::initExecution()
initMutex();
if (this->m_sizeavailable) {
- float rad = max_ff(m_size * m_data->sizey, 0.0f);
+ float rad = max_ff(m_size * m_data.sizey, 0.0f);
m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
@@ -66,7 +66,7 @@ void GaussianAlphaYBlurOperation::updateGauss()
{
if (this->m_gausstab == NULL) {
updateSize();
- float rad = max_ff(m_size * m_data->sizey, 0.0f);
+ float rad = max_ff(m_size * m_data.sizey, 0.0f);
m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
@@ -74,7 +74,7 @@ void GaussianAlphaYBlurOperation::updateGauss()
if (this->m_distbuf_inv == NULL) {
updateSize();
- float rad = max_ff(m_size * m_data->sizey, 0.0f);
+ float rad = max_ff(m_size * m_data.sizey, 0.0f);
m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, m_filtersize, m_falloff);
diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
index 476ec9fc043..ecbd17911fc 100644
--- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
@@ -68,11 +68,11 @@ void GaussianBokehBlurOperation::updateGauss()
if (!this->m_sizeavailable) {
updateSize();
}
- radxf = this->m_size * (float)this->m_data->sizex;
+ radxf = this->m_size * (float)this->m_data.sizex;
CLAMP(radxf, 0.0f, width / 2.0f);
/* vertical */
- radyf = this->m_size * (float)this->m_data->sizey;
+ radyf = this->m_size * (float)this->m_data.sizey;
CLAMP(radyf, 0.0f, height / 2.0f);
this->m_radx = ceil(radxf);
@@ -93,7 +93,7 @@ void GaussianBokehBlurOperation::updateGauss()
float fj = (float)j * facy;
float fi = (float)i * facx;
float dist = sqrt(fj * fj + fi * fi);
- *dgauss = RE_filter_value(this->m_data->filtertype, dist);
+ *dgauss = RE_filter_value(this->m_data.filtertype, dist);
sum += *dgauss;
}
@@ -212,28 +212,28 @@ void GaussianBlurReferenceOperation::initExecution()
{
BlurBaseOperation::initExecution();
// setup gaustab
- this->m_data->image_in_width = this->getWidth();
- this->m_data->image_in_height = this->getHeight();
- if (this->m_data->relative) {
- switch (this->m_data->aspect) {
+ this->m_data.image_in_width = this->getWidth();
+ this->m_data.image_in_height = this->getHeight();
+ if (this->m_data.relative) {
+ switch (this->m_data.aspect) {
case CMP_NODE_BLUR_ASPECT_NONE:
- this->m_data->sizex = (int)(this->m_data->percentx * 0.01f * this->m_data->image_in_width);
- this->m_data->sizey = (int)(this->m_data->percenty * 0.01f * this->m_data->image_in_height);
+ this->m_data.sizex = (int)(this->m_data.percentx * 0.01f * this->m_data.image_in_width);
+ this->m_data.sizey = (int)(this->m_data.percenty * 0.01f * this->m_data.image_in_height);
break;
case CMP_NODE_BLUR_ASPECT_Y:
- this->m_data->sizex = (int)(this->m_data->percentx * 0.01f * this->m_data->image_in_width);
- this->m_data->sizey = (int)(this->m_data->percenty * 0.01f * this->m_data->image_in_width);
+ this->m_data.sizex = (int)(this->m_data.percentx * 0.01f * this->m_data.image_in_width);
+ this->m_data.sizey = (int)(this->m_data.percenty * 0.01f * this->m_data.image_in_width);
break;
case CMP_NODE_BLUR_ASPECT_X:
- this->m_data->sizex = (int)(this->m_data->percentx * 0.01f * this->m_data->image_in_height);
- this->m_data->sizey = (int)(this->m_data->percenty * 0.01f * this->m_data->image_in_height);
+ this->m_data.sizex = (int)(this->m_data.percentx * 0.01f * this->m_data.image_in_height);
+ this->m_data.sizey = (int)(this->m_data.percenty * 0.01f * this->m_data.image_in_height);
break;
}
}
/* horizontal */
- m_filtersizex = (float)this->m_data->sizex;
+ m_filtersizex = (float)this->m_data.sizex;
int imgx = getWidth() / 2;
if (m_filtersizex > imgx)
m_filtersizex = imgx;
@@ -242,7 +242,7 @@ void GaussianBlurReferenceOperation::initExecution()
m_radx = (float)m_filtersizex;
/* vertical */
- m_filtersizey = (float)this->m_data->sizey;
+ m_filtersizey = (float)this->m_data.sizey;
int imgy = getHeight() / 2;
if (m_filtersizey > imgy)
m_filtersizey = imgy;
@@ -342,8 +342,8 @@ bool GaussianBlurReferenceOperation::determineDependingAreaOfInterest(rcti *inpu
return true;
}
else {
- int addx = this->m_data->sizex + 2;
- int addy = this->m_data->sizey + 2;
+ int addx = this->m_data.sizex + 2;
+ int addy = this->m_data.sizey + 2;
newInput.xmax = input->xmax + addx;
newInput.xmin = input->xmin - addx;
newInput.ymax = input->ymax + addy;
diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
index 127417bf701..815b89ae8d9 100644
--- a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
@@ -52,7 +52,7 @@ void GaussianXBlurOperation::initExecution()
initMutex();
if (this->m_sizeavailable) {
- float rad = max_ff(m_size * m_data->sizex, 0.0f);
+ float rad = max_ff(m_size * m_data.sizex, 0.0f);
m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
this->m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
@@ -63,7 +63,7 @@ void GaussianXBlurOperation::updateGauss()
{
if (this->m_gausstab == NULL) {
updateSize();
- float rad = max_ff(m_size * m_data->sizex, 0.0f);
+ float rad = max_ff(m_size * m_data.sizex, 0.0f);
m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
this->m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
diff --git a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
index 583305a0fc4..47c031757fb 100644
--- a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
@@ -52,7 +52,7 @@ void GaussianYBlurOperation::initExecution()
initMutex();
if (this->m_sizeavailable) {
- float rad = max_ff(m_size * m_data->sizey, 0.0f);
+ float rad = max_ff(m_size * m_data.sizey, 0.0f);
m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
this->m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
@@ -63,7 +63,7 @@ void GaussianYBlurOperation::updateGauss()
{
if (this->m_gausstab == NULL) {
updateSize();
- float rad = max_ff(m_size * m_data->sizey, 0.0f);
+ float rad = max_ff(m_size * m_data.sizey, 0.0f);
m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
this->m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
diff --git a/source/blender/compositor/operations/COM_GlareBaseOperation.cpp b/source/blender/compositor/operations/COM_GlareBaseOperation.cpp
index e2d6e2c8a16..34a0eda70af 100644
--- a/source/blender/compositor/operations/COM_GlareBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareBaseOperation.cpp
@@ -23,7 +23,7 @@
#include "COM_GlareBaseOperation.h"
#include "BLI_math.h"
-GlareBaseOperation::GlareBaseOperation() : SingleThreadedNodeOperation()
+GlareBaseOperation::GlareBaseOperation() : SingleThreadedOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
@@ -31,14 +31,14 @@ GlareBaseOperation::GlareBaseOperation() : SingleThreadedNodeOperation()
}
void GlareBaseOperation::initExecution()
{
- SingleThreadedNodeOperation::initExecution();
+ SingleThreadedOperation::initExecution();
this->m_inputProgram = getInputSocketReader(0);
}
void GlareBaseOperation::deinitExecution()
{
this->m_inputProgram = NULL;
- SingleThreadedNodeOperation::deinitExecution();
+ SingleThreadedOperation::deinitExecution();
}
MemoryBuffer *GlareBaseOperation::createMemoryBuffer(rcti *rect2)
diff --git a/source/blender/compositor/operations/COM_GlareBaseOperation.h b/source/blender/compositor/operations/COM_GlareBaseOperation.h
index f6a8f6879da..3f0893d895f 100644
--- a/source/blender/compositor/operations/COM_GlareBaseOperation.h
+++ b/source/blender/compositor/operations/COM_GlareBaseOperation.h
@@ -23,7 +23,7 @@
#ifndef _COM_GlareBaseOperation_h
#define _COM_GlareBaseOperation_h
-#include "COM_SingleThreadedNodeOperation.h"
+#include "COM_SingleThreadedOperation.h"
#include "DNA_node_types.h"
@@ -36,7 +36,7 @@ typedef float fRGB[4];
#define fRGB_rgbmult(c, r, g, b) { c[0] *= (r); c[1] *= (g); c[2] *= (b); } (void)0
-class GlareBaseOperation : public SingleThreadedNodeOperation {
+class GlareBaseOperation : public SingleThreadedOperation {
private:
/**
* @brief Cached reference to the inputProgram
diff --git a/source/blender/compositor/operations/COM_MaskOperation.cpp b/source/blender/compositor/operations/COM_MaskOperation.cpp
index 112b5912ad3..8c8ba93327d 100644
--- a/source/blender/compositor/operations/COM_MaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_MaskOperation.cpp
@@ -129,8 +129,9 @@ void MaskOperation::determineResolution(unsigned int resolution[2], unsigned int
void MaskOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
- const float xy[2] = {x * this->m_maskWidthInv,
- y * this->m_maskHeightInv};
+ const float xy[2] = {
+ (x * this->m_maskWidthInv) + this->m_mask_px_ofs[0],
+ (y * this->m_maskHeightInv) + this->m_mask_px_ofs[1]};
if (this->m_rasterMaskHandleTot == 1) {
if (this->m_rasterMaskHandles[0]) {
diff --git a/source/blender/compositor/operations/COM_MaskOperation.h b/source/blender/compositor/operations/COM_MaskOperation.h
index 18d7e594104..522b873e167 100644
--- a/source/blender/compositor/operations/COM_MaskOperation.h
+++ b/source/blender/compositor/operations/COM_MaskOperation.h
@@ -43,6 +43,7 @@ protected:
int m_maskHeight;
float m_maskWidthInv; /* 1 / m_maskWidth */
float m_maskHeightInv; /* 1 / m_maskHeight */
+ float m_mask_px_ofs[2];
float m_frame_shutter;
int m_frame_number;
@@ -70,11 +71,13 @@ public:
{
this->m_maskWidth = width;
this->m_maskWidthInv = 1.0f / (float)width;
+ this->m_mask_px_ofs[0] = this->m_maskWidthInv * 0.5f;
}
void setMaskHeight(int height)
{
this->m_maskHeight = height;
this->m_maskHeightInv = 1.0f / (float)height;
+ this->m_mask_px_ofs[1] = this->m_maskHeightInv * 0.5f;
}
void setFramenumber(int frame_number) { this->m_frame_number = frame_number; }
void setSmooth(bool smooth) { this->m_do_smooth = smooth; }
diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.cpp b/source/blender/compositor/operations/COM_MathBaseOperation.cpp
index cc7511bb9fc..cbc60b5091d 100644
--- a/source/blender/compositor/operations/COM_MathBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_MathBaseOperation.cpp
@@ -50,7 +50,7 @@ void MathBaseOperation::deinitExecution()
void MathBaseOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
{
- InputSocket *socket;
+ NodeOperationInput *socket;
unsigned int tempPreferredResolution[2] = {0, 0};
unsigned int tempResolution[2];
@@ -333,3 +333,14 @@ void MathModuloOperation::executePixelSampled(float output[4], float x, float y,
clampIfNeeded(output);
}
+void MathAbsoluteOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+{
+ float inputValue1[4];
+
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+
+ output[0] = fabs(inputValue1[0]);
+
+ clampIfNeeded(output);
+}
+
diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.h b/source/blender/compositor/operations/COM_MathBaseOperation.h
index 4ea7c43a67d..05d2bb054d3 100644
--- a/source/blender/compositor/operations/COM_MathBaseOperation.h
+++ b/source/blender/compositor/operations/COM_MathBaseOperation.h
@@ -163,4 +163,10 @@ public:
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
+class MathAbsoluteOperation : public MathBaseOperation {
+public:
+ MathAbsoluteOperation() : MathBaseOperation() {}
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+};
+
#endif
diff --git a/source/blender/compositor/operations/COM_MixOperation.cpp b/source/blender/compositor/operations/COM_MixOperation.cpp
index 125de842892..04025329ad4 100644
--- a/source/blender/compositor/operations/COM_MixOperation.cpp
+++ b/source/blender/compositor/operations/COM_MixOperation.cpp
@@ -71,7 +71,7 @@ void MixBaseOperation::executePixelSampled(float output[4], float x, float y, Pi
void MixBaseOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
{
- InputSocket *socket;
+ NodeOperationInput *socket;
unsigned int tempPreferredResolution[2] = {0, 0};
unsigned int tempResolution[2];
@@ -292,17 +292,9 @@ void MixDarkenOperation::executePixelSampled(float output[4], float x, float y,
value *= inputColor2[3];
}
float valuem = 1.0f - value;
- float tmp;
- tmp = inputColor2[0] + ((1.0f - inputColor2[0]) * valuem);
- if (tmp < inputColor1[0]) output[0] = tmp;
- else output[0] = inputColor1[0];
- tmp = inputColor2[1] + ((1.0f - inputColor2[1]) * valuem);
- if (tmp < inputColor1[1]) output[1] = tmp;
- else output[1] = inputColor1[1];
- tmp = inputColor2[2] + ((1.0f - inputColor2[2]) * valuem);
- if (tmp < inputColor1[2]) output[2] = tmp;
- else output[2] = inputColor1[2];
-
+ output[0] = min_ff(inputColor1[0], inputColor2[0]) * value + inputColor1[0] * valuem;
+ output[1] = min_ff(inputColor1[1], inputColor2[1]) * value + inputColor1[1] * valuem;
+ output[2] = min_ff(inputColor1[2], inputColor2[2]) * value + inputColor1[2] * valuem;
output[3] = inputColor1[3];
clampIfNeeded(output);
diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cpp b/source/blender/compositor/operations/COM_OutputFileOperation.cpp
index 75b36d7672a..92e8f309ea1 100644
--- a/source/blender/compositor/operations/COM_OutputFileOperation.cpp
+++ b/source/blender/compositor/operations/COM_OutputFileOperation.cpp
@@ -22,7 +22,6 @@
*/
#include "COM_OutputFileOperation.h"
-#include "COM_SocketConnection.h"
#include <string.h>
#include "BLI_listbase.h"
#include "BLI_path_util.h"
@@ -156,10 +155,12 @@ void OutputSingleLayerOperation::deinitExecution()
}
-OutputOpenExrLayer::OutputOpenExrLayer(const char *name_, DataType datatype_)
+OutputOpenExrLayer::OutputOpenExrLayer(const char *name_, DataType datatype_, bool use_layer_)
{
BLI_strncpy(this->name, name_, sizeof(this->name));
this->datatype = datatype_;
+ this->use_layer = use_layer_;
+
/* these are created in initExecution */
this->outputBuffer = 0;
this->imageInput = 0;
@@ -175,21 +176,20 @@ OutputOpenExrMultiLayerOperation::OutputOpenExrMultiLayerOperation(
this->m_exr_codec = exr_codec;
}
-void OutputOpenExrMultiLayerOperation::add_layer(const char *name, DataType datatype)
+void OutputOpenExrMultiLayerOperation::add_layer(const char *name, DataType datatype, bool use_layer)
{
this->addInputSocket(datatype);
- this->m_layers.push_back(OutputOpenExrLayer(name, datatype));
+ this->m_layers.push_back(OutputOpenExrLayer(name, datatype, use_layer));
}
void OutputOpenExrMultiLayerOperation::initExecution()
{
for (unsigned int i = 0; i < this->m_layers.size(); ++i) {
- SocketReader *reader = getInputSocketReader(i);
- this->m_layers[i].imageInput = reader;
- if (reader)
+ if (this->m_layers[i].use_layer) {
+ SocketReader *reader = getInputSocketReader(i);
+ this->m_layers[i].imageInput = reader;
this->m_layers[i].outputBuffer = init_buffer(this->getWidth(), this->getHeight(), this->m_layers[i].datatype);
- else
- this->m_layers[i].outputBuffer = NULL;
+ }
}
}
diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.h b/source/blender/compositor/operations/COM_OutputFileOperation.h
index ada40bba014..03278c5b149 100644
--- a/source/blender/compositor/operations/COM_OutputFileOperation.h
+++ b/source/blender/compositor/operations/COM_OutputFileOperation.h
@@ -57,16 +57,19 @@ public:
void deinitExecution();
const CompositorPriority getRenderPriority() const { return COM_PRIORITY_LOW; }
- bool isFileOutputOperation() { return true; }
+ bool isFileOutputOperation() const { return true; }
};
/* extra info for OpenEXR layers */
struct OutputOpenExrLayer {
- OutputOpenExrLayer(const char *name, DataType datatype);
+ OutputOpenExrLayer(const char *name, DataType datatype, bool use_layer);
char name[EXR_TOT_MAXNAME - 2];
- float *outputBuffer;
DataType datatype;
+ bool use_layer;
+
+ /* internals */
+ float *outputBuffer;
SocketReader *imageInput;
};
@@ -85,7 +88,7 @@ private:
public:
OutputOpenExrMultiLayerOperation(const RenderData *rd, const bNodeTree *tree, const char *path, char exr_codec);
- void add_layer(const char *name, DataType datatype);
+ void add_layer(const char *name, DataType datatype, bool use_layer);
void executeRegion(rcti *rect, unsigned int tileNumber);
bool isOutputOperation(bool rendering) const { return true; }
@@ -93,7 +96,7 @@ public:
void deinitExecution();
const CompositorPriority getRenderPriority() const { return COM_PRIORITY_LOW; }
- bool isFileOutputOperation() { return true; }
+ bool isFileOutputOperation() const { return true; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_PlaneTrackOperation.h b/source/blender/compositor/operations/COM_PlaneTrackOperation.h
index fdca760650a..3c5dd783542 100644
--- a/source/blender/compositor/operations/COM_PlaneTrackOperation.h
+++ b/source/blender/compositor/operations/COM_PlaneTrackOperation.h
@@ -68,6 +68,9 @@ public:
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
{
PlaneTrackCommon::determineResolution(resolution, preferredResolution);
+
+ unsigned int temp[2];
+ NodeOperation::determineResolution(temp, resolution);
}
};
@@ -84,6 +87,9 @@ public:
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
{
PlaneTrackCommon::determineResolution(resolution, preferredResolution);
+
+ unsigned int temp[2];
+ NodeOperation::determineResolution(temp, resolution);
}
};
diff --git a/source/blender/compositor/operations/COM_PreviewOperation.cpp b/source/blender/compositor/operations/COM_PreviewOperation.cpp
index 85c7f449fd5..69290cd7c3c 100644
--- a/source/blender/compositor/operations/COM_PreviewOperation.cpp
+++ b/source/blender/compositor/operations/COM_PreviewOperation.cpp
@@ -21,7 +21,6 @@
*/
#include "COM_PreviewOperation.h"
-#include "COM_SocketConnection.h"
#include "BLI_listbase.h"
#include "BKE_image.h"
#include "WM_api.h"
diff --git a/source/blender/compositor/operations/COM_PreviewOperation.h b/source/blender/compositor/operations/COM_PreviewOperation.h
index bb60dfa0420..3e97acec7bb 100644
--- a/source/blender/compositor/operations/COM_PreviewOperation.h
+++ b/source/blender/compositor/operations/COM_PreviewOperation.h
@@ -53,7 +53,7 @@ public:
void executeRegion(rcti *rect, unsigned int tileNumber);
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- bool isPreviewOperation() { return true; }
+ bool isPreviewOperation() const { return true; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.h b/source/blender/compositor/operations/COM_ReadBufferOperation.h
index 819d7d057fd..46cf3331659 100644
--- a/source/blender/compositor/operations/COM_ReadBufferOperation.h
+++ b/source/blender/compositor/operations/COM_ReadBufferOperation.h
@@ -34,7 +34,6 @@ private:
MemoryBuffer *m_buffer;
public:
ReadBufferOperation(DataType type);
- int isBufferOperation() { return true; }
void setMemoryProxy(MemoryProxy *memoryProxy) { this->m_memoryProxy = memoryProxy; }
MemoryProxy *getMemoryProxy() { return this->m_memoryProxy; }
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.cpp b/source/blender/compositor/operations/COM_RenderLayersProg.cpp
index f4137349e22..0eec02776fc 100644
--- a/source/blender/compositor/operations/COM_RenderLayersProg.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersProg.cpp
@@ -138,15 +138,15 @@ void RenderLayersBaseProg::executePixelSampled(float output[4], float x, float y
#endif
if (this->m_inputBuffer == NULL) {
- int elemsize = this->m_elementsize;
- if (elemsize == 1) {
- output[0] = 0.0f;
- }
- else if (elemsize == 3) {
- zero_v3(output);
- } else {
- zero_v4(output);
- }
+ int elemsize = this->m_elementsize;
+ if (elemsize == 1) {
+ output[0] = 0.0f;
+ }
+ else if (elemsize == 3) {
+ zero_v3(output);
+ } else {
+ zero_v4(output);
+ }
}
else {
doInterpolation(output, ix, iy, sampler);
diff --git a/source/blender/compositor/operations/COM_SetVectorOperation.h b/source/blender/compositor/operations/COM_SetVectorOperation.h
index 6fd1b9768fc..d29ca726056 100644
--- a/source/blender/compositor/operations/COM_SetVectorOperation.h
+++ b/source/blender/compositor/operations/COM_SetVectorOperation.h
@@ -59,7 +59,7 @@ public:
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
bool isSetOperation() const { return true; }
- void setVector(float vector[3]) {
+ void setVector(const float vector[3]) {
setX(vector[0]);
setY(vector[1]);
setZ(vector[2]);
diff --git a/source/blender/compositor/operations/COM_SocketProxyOperation.cpp b/source/blender/compositor/operations/COM_SocketProxyOperation.cpp
index d047198ac93..da345b282fd 100644
--- a/source/blender/compositor/operations/COM_SocketProxyOperation.cpp
+++ b/source/blender/compositor/operations/COM_SocketProxyOperation.cpp
@@ -26,22 +26,4 @@ SocketProxyOperation::SocketProxyOperation(DataType type) : NodeOperation()
{
this->addInputSocket(type);
this->addOutputSocket(type);
- this->m_inputOperation = NULL;
-}
-
-void SocketProxyOperation::initExecution()
-{
- this->m_inputOperation = this->getInputSocketReader(0);
-}
-
-void SocketProxyOperation::deinitExecution()
-{
- this->m_inputOperation = NULL;
-}
-
-void SocketProxyOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
-{
- if (this->m_inputOperation) {
- this->m_inputOperation->readSampled(output, x, y, sampler);
- }
}
diff --git a/source/blender/compositor/operations/COM_SocketProxyOperation.h b/source/blender/compositor/operations/COM_SocketProxyOperation.h
index 6a6a0b351b0..9733a1fbeec 100644
--- a/source/blender/compositor/operations/COM_SocketProxyOperation.h
+++ b/source/blender/compositor/operations/COM_SocketProxyOperation.h
@@ -26,14 +26,10 @@
#include "COM_NodeOperation.h"
class SocketProxyOperation : public NodeOperation {
-private:
- SocketReader *m_inputOperation;
public:
SocketProxyOperation(DataType type);
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- void initExecution();
- void deinitExecution();
+ bool isProxyOperation() const { return true; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_SplitOperation.cpp b/source/blender/compositor/operations/COM_SplitOperation.cpp
index 9278f1c3ec4..367c7eefa25 100644
--- a/source/blender/compositor/operations/COM_SplitOperation.cpp
+++ b/source/blender/compositor/operations/COM_SplitOperation.cpp
@@ -21,7 +21,6 @@
*/
#include "COM_SplitOperation.h"
-#include "COM_SocketConnection.h"
#include "BLI_listbase.h"
#include "BKE_image.h"
#include "BLI_utildefines.h"
diff --git a/source/blender/compositor/operations/COM_TextureOperation.cpp b/source/blender/compositor/operations/COM_TextureOperation.cpp
index 20d527fe70b..45eaef9f83f 100644
--- a/source/blender/compositor/operations/COM_TextureOperation.cpp
+++ b/source/blender/compositor/operations/COM_TextureOperation.cpp
@@ -25,7 +25,7 @@
#include "BLI_listbase.h"
#include "BKE_image.h"
-TextureBaseOperation::TextureBaseOperation() : SingleThreadedNodeOperation()
+TextureBaseOperation::TextureBaseOperation() : SingleThreadedOperation()
{
this->addInputSocket(COM_DT_VECTOR); //offset
this->addInputSocket(COM_DT_VECTOR); //size
@@ -50,7 +50,7 @@ void TextureBaseOperation::initExecution()
this->m_inputOffset = getInputSocketReader(0);
this->m_inputSize = getInputSocketReader(1);
this->m_pool = BKE_image_pool_new();
- SingleThreadedNodeOperation::initExecution();
+ SingleThreadedOperation::initExecution();
}
void TextureBaseOperation::deinitExecution()
{
@@ -58,7 +58,7 @@ void TextureBaseOperation::deinitExecution()
this->m_inputOffset = NULL;
BKE_image_pool_free(this->m_pool);
this->m_pool = NULL;
- SingleThreadedNodeOperation::deinitExecution();
+ SingleThreadedOperation::deinitExecution();
}
void TextureBaseOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
diff --git a/source/blender/compositor/operations/COM_TextureOperation.h b/source/blender/compositor/operations/COM_TextureOperation.h
index 114cee00530..47ef40882c5 100644
--- a/source/blender/compositor/operations/COM_TextureOperation.h
+++ b/source/blender/compositor/operations/COM_TextureOperation.h
@@ -24,7 +24,7 @@
#ifndef _COM_TextureOperation_h
#define _COM_TextureOperation_h
-#include "COM_SingleThreadedNodeOperation.h"
+#include "COM_SingleThreadedOperation.h"
#include "DNA_texture_types.h"
#include "BLI_listbase.h"
extern "C" {
@@ -39,7 +39,7 @@ extern "C" {
*
* @todo: rename to operation.
*/
-class TextureBaseOperation : public SingleThreadedNodeOperation {
+class TextureBaseOperation : public SingleThreadedOperation {
private:
Tex *m_texture;
const RenderData *m_rd;
diff --git a/source/blender/compositor/operations/COM_TonemapOperation.cpp b/source/blender/compositor/operations/COM_TonemapOperation.cpp
index 2d944b70f75..e8a578fa131 100644
--- a/source/blender/compositor/operations/COM_TonemapOperation.cpp
+++ b/source/blender/compositor/operations/COM_TonemapOperation.cpp
@@ -24,8 +24,6 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
-
-
TonemapOperation::TonemapOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cpp b/source/blender/compositor/operations/COM_ViewerOperation.cpp
index c54a4971e54..53c0acd781a 100644
--- a/source/blender/compositor/operations/COM_ViewerOperation.cpp
+++ b/source/blender/compositor/operations/COM_ViewerOperation.cpp
@@ -21,7 +21,6 @@
*/
#include "COM_ViewerOperation.h"
-#include "COM_SocketConnection.h"
#include "BLI_listbase.h"
#include "BKE_image.h"
#include "WM_api.h"
@@ -49,7 +48,7 @@ ViewerOperation::ViewerOperation() : NodeOperation()
this->m_doDepthBuffer = false;
this->m_viewSettings = NULL;
this->m_displaySettings = NULL;
- this->m_ignoreAlpha = false;
+ this->m_useAlphaInput = false;
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
@@ -102,19 +101,12 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber)
for (y = y1; y < y2 && (!breaked); y++) {
for (x = x1; x < x2; x++) {
this->m_imageInput->readSampled(&(buffer[offset4]), x, y, COM_PS_NEAREST);
- if (this->m_ignoreAlpha) {
- buffer[offset4 + 3] = 1.0f;
- }
- else {
- if (this->m_alphaInput != NULL) {
- this->m_alphaInput->readSampled(alpha, x, y, COM_PS_NEAREST);
- buffer[offset4 + 3] = alpha[0];
- }
- }
- if (m_depthInput) {
- this->m_depthInput->readSampled(depth, x, y, COM_PS_NEAREST);
- depthbuffer[offset] = depth[0];
+ if (this->m_useAlphaInput) {
+ this->m_alphaInput->readSampled(alpha, x, y, COM_PS_NEAREST);
+ buffer[offset4 + 3] = alpha[0];
}
+ this->m_depthInput->readSampled(depth, x, y, COM_PS_NEAREST);
+ depthbuffer[offset] = depth[0];
offset ++;
offset4 += 4;
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.h b/source/blender/compositor/operations/COM_ViewerOperation.h
index 0b8d08d3974..dcc7ffa3730 100644
--- a/source/blender/compositor/operations/COM_ViewerOperation.h
+++ b/source/blender/compositor/operations/COM_ViewerOperation.h
@@ -39,7 +39,7 @@ private:
OrderOfChunks m_chunkOrder;
bool m_doDepthBuffer;
ImBuf *m_ibuf;
- bool m_ignoreAlpha;
+ bool m_useAlphaInput;
const ColorManagedViewSettings *m_viewSettings;
const ColorManagedDisplaySettings *m_displaySettings;
@@ -65,8 +65,8 @@ public:
float getCenterY() const { return this->m_centerY; }
OrderOfChunks getChunkOrder() const { return this->m_chunkOrder; }
const CompositorPriority getRenderPriority() const;
- bool isViewerOperation() { return true; }
- void setIgnoreAlpha(bool value) { this->m_ignoreAlpha = value; }
+ bool isViewerOperation() const { return true; }
+ void setUseAlphaInput(bool value) { this->m_useAlphaInput = value; }
void setViewSettings(const ColorManagedViewSettings *viewSettings) { this->m_viewSettings = viewSettings; }
void setDisplaySettings(const ColorManagedDisplaySettings *displaySettings) { this->m_displaySettings = displaySettings; }
diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.h b/source/blender/compositor/operations/COM_WriteBufferOperation.h
index 2b677d23dad..bcff7eae781 100644
--- a/source/blender/compositor/operations/COM_WriteBufferOperation.h
+++ b/source/blender/compositor/operations/COM_WriteBufferOperation.h
@@ -27,7 +27,7 @@
#include "COM_MemoryProxy.h"
#include "COM_SocketReader.h"
/**
- * @brief Operation to write to a tile
+ * @brief NodeOperation to write to a tile
* @ingroup Operation
*/
class WriteBufferOperation : public NodeOperation {
@@ -37,7 +37,6 @@ class WriteBufferOperation : public NodeOperation {
public:
WriteBufferOperation(DataType type);
~WriteBufferOperation();
- int isBufferOperation() { return true; }
MemoryProxy *getMemoryProxy() { return this->m_memoryProxy; }
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
const bool isWriteBufferOperation() const { return true; }
diff --git a/source/blender/datatoc/datatoc_icon_split.py b/source/blender/datatoc/datatoc_icon_split.py
index 44d8e5fd0fb..55f0a5c5f6a 100755
--- a/source/blender/datatoc/datatoc_icon_split.py
+++ b/source/blender/datatoc/datatoc_icon_split.py
@@ -164,7 +164,6 @@ def dice(filepath, output, output_prefix, name_style,
minx_icon, miny_icon, maxx_icon, maxy_icon,
spacex_icon, spacey_icon,
):
- import struct
is_simple = (max(minx, miny, maxx, maxy,
minx_icon, miny_icon, maxx_icon, maxy_icon,
@@ -209,7 +208,7 @@ def dice(filepath, output, output_prefix, name_style,
# simple, no margins
if is_simple:
- sub_x = x * icon_x
+ sub_x = x * icon_w
sub_y = y * icon_h
else:
sub_x = minx + ((x * (icon_w + spacex_icon)) + minx_icon)
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index 44ac78ed358..1cd1a26678d 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -365,14 +365,14 @@ static bool acf_generic_idfill_name_prop(bAnimListElem *ale, PointerRNA *ptr, Pr
#if 0
/* channel type has no settings */
-static bool acf_generic_none_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting)
+static bool acf_generic_none_setting_valid(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting)
{
return false;
}
#endif
/* check if some setting exists for this object-based data-expander (datablock only) */
-static bool acf_generic_dataexpand_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale), int setting)
+static bool acf_generic_dataexpand_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale), eAnimChannel_Settings setting)
{
switch (setting) {
/* expand is always supported */
@@ -438,14 +438,14 @@ static int acf_summary_icon(bAnimListElem *UNUSED(ale))
}
/* check if some setting exists for this channel */
-static bool acf_summary_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting)
+static bool acf_summary_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), eAnimChannel_Settings setting)
{
/* only expanded is supported, as it is used for hiding all stuff which the summary covers */
return (setting == ACHANNEL_SETTING_EXPAND);
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_summary_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
+static int acf_summary_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
if (setting == ACHANNEL_SETTING_EXPAND) {
/* expanded */
@@ -460,7 +460,7 @@ static int acf_summary_setting_flag(bAnimContext *UNUSED(ac), int setting, bool
}
/* get pointer to the setting */
-static void *acf_summary_setting_ptr(bAnimListElem *ale, int setting, short *type)
+static void *acf_summary_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
bAnimContext *ac = (bAnimContext *)ale->data;
@@ -485,6 +485,7 @@ static void *acf_summary_setting_ptr(bAnimListElem *ale, int setting, short *typ
static bAnimChannelType ACF_SUMMARY =
{
"Summary", /* type name */
+ ACHANNEL_ROLE_EXPANDER, /* role */
acf_summary_color, /* backdrop color */
acf_summary_backdrop, /* backdrop */
@@ -509,7 +510,7 @@ static int acf_scene_icon(bAnimListElem *UNUSED(ale))
}
/* check if some setting exists for this channel */
-static bool acf_scene_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale), int setting)
+static bool acf_scene_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale), eAnimChannel_Settings setting)
{
switch (setting) {
/* muted only in NLA */
@@ -531,7 +532,7 @@ static bool acf_scene_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale)
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_scene_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
+static int acf_scene_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
*neg = false;
@@ -557,7 +558,7 @@ static int acf_scene_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *n
}
/* get pointer to the setting */
-static void *acf_scene_setting_ptr(bAnimListElem *ale, int setting, short *type)
+static void *acf_scene_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
Scene *scene = (Scene *)ale->data;
@@ -586,6 +587,7 @@ static void *acf_scene_setting_ptr(bAnimListElem *ale, int setting, short *type)
static bAnimChannelType ACF_SCENE =
{
"Scene", /* type name */
+ ACHANNEL_ROLE_EXPANDER, /* role */
acf_generic_root_color, /* backdrop color */
acf_generic_root_backdrop, /* backdrop */
@@ -649,7 +651,7 @@ static void acf_object_name(bAnimListElem *ale, char *name)
}
/* check if some setting exists for this channel */
-static bool acf_object_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting)
+static bool acf_object_setting_valid(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting)
{
Base *base = (Base *)ale->data;
Object *ob = base->object;
@@ -674,7 +676,7 @@ static bool acf_object_setting_valid(bAnimContext *ac, bAnimListElem *ale, int s
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_object_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
+static int acf_object_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
*neg = false;
@@ -700,7 +702,7 @@ static int acf_object_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *
}
/* get pointer to the setting */
-static void *acf_object_setting_ptr(bAnimListElem *ale, int setting, short *type)
+static void *acf_object_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
Base *base = (Base *)ale->data;
Object *ob = base->object;
@@ -730,6 +732,7 @@ static void *acf_object_setting_ptr(bAnimListElem *ale, int setting, short *type
static bAnimChannelType ACF_OBJECT =
{
"Object", /* type name */
+ ACHANNEL_ROLE_EXPANDER, /* role */
acf_generic_root_color, /* backdrop color */
acf_generic_root_backdrop, /* backdrop */
@@ -812,7 +815,7 @@ static bool acf_group_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA
}
/* check if some setting exists for this channel */
-static bool acf_group_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale), int setting)
+static bool acf_group_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale), eAnimChannel_Settings setting)
{
/* for now, all settings are supported, though some are only conditionally */
switch (setting) {
@@ -830,7 +833,7 @@ static bool acf_group_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale)
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_group_setting_flag(bAnimContext *ac, int setting, bool *neg)
+static int acf_group_setting_flag(bAnimContext *ac, eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
*neg = false;
@@ -859,14 +862,15 @@ static int acf_group_setting_flag(bAnimContext *ac, int setting, bool *neg)
case ACHANNEL_SETTING_VISIBLE: /* visibility - graph editor */
*neg = 1;
return AGRP_NOTVISIBLE;
+
+ default:
+ /* this shouldn't happen */
+ return 0;
}
-
- /* this shouldn't happen */
- return 0;
}
/* get pointer to the setting */
-static void *acf_group_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short *type)
+static void *acf_group_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type)
{
bActionGroup *agrp = (bActionGroup *)ale->data;
@@ -878,6 +882,7 @@ static void *acf_group_setting_ptr(bAnimListElem *ale, int UNUSED(setting), shor
static bAnimChannelType ACF_GROUP =
{
"Group", /* type name */
+ ACHANNEL_ROLE_CHANNEL, /* role */
acf_group_color, /* backdrop color */
acf_group_backdrop, /* backdrop */
@@ -923,7 +928,7 @@ static bool acf_fcurve_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRN
}
/* check if some setting exists for this channel */
-static bool acf_fcurve_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting)
+static bool acf_fcurve_setting_valid(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting)
{
FCurve *fcu = (FCurve *)ale->data;
@@ -950,7 +955,7 @@ static bool acf_fcurve_setting_valid(bAnimContext *ac, bAnimListElem *ale, int s
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_fcurve_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
+static int acf_fcurve_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
*neg = false;
@@ -974,7 +979,7 @@ static int acf_fcurve_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *
}
/* get pointer to the setting */
-static void *acf_fcurve_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short *type)
+static void *acf_fcurve_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type)
{
FCurve *fcu = (FCurve *)ale->data;
@@ -986,6 +991,7 @@ static void *acf_fcurve_setting_ptr(bAnimListElem *ale, int UNUSED(setting), sho
static bAnimChannelType ACF_FCURVE =
{
"F-Curve", /* type name */
+ ACHANNEL_ROLE_CHANNEL, /* role */
acf_generic_channel_color, /* backdrop color */
acf_generic_channel_backdrop, /* backdrop */
@@ -1010,7 +1016,7 @@ static int acf_fillactd_icon(bAnimListElem *UNUSED(ale))
}
/* check if some setting exists for this channel */
-static bool acf_fillactd_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting)
+static bool acf_fillactd_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), eAnimChannel_Settings setting)
{
switch (setting) {
/* only select and expand supported */
@@ -1024,7 +1030,7 @@ static bool acf_fillactd_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_fillactd_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
+static int acf_fillactd_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
*neg = false;
@@ -1043,7 +1049,7 @@ static int acf_fillactd_setting_flag(bAnimContext *UNUSED(ac), int setting, bool
}
/* get pointer to the setting */
-static void *acf_fillactd_setting_ptr(bAnimListElem *ale, int setting, short *type)
+static void *acf_fillactd_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
bAction *act = (bAction *)ale->data;
AnimData *adt = ale->adt;
@@ -1070,6 +1076,7 @@ static void *acf_fillactd_setting_ptr(bAnimListElem *ale, int setting, short *ty
static bAnimChannelType ACF_FILLACTD =
{
"Ob-Action Filler", /* type name */
+ ACHANNEL_ROLE_EXPANDER, /* role */
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
@@ -1100,7 +1107,7 @@ static void acf_filldrivers_name(bAnimListElem *UNUSED(ale), char *name)
/* check if some setting exists for this channel */
// TODO: this could be made more generic
-static bool acf_filldrivers_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting)
+static bool acf_filldrivers_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), eAnimChannel_Settings setting)
{
switch (setting) {
/* only expand supported */
@@ -1113,7 +1120,7 @@ static bool acf_filldrivers_setting_valid(bAnimContext *UNUSED(ac), bAnimListEle
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_filldrivers_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
+static int acf_filldrivers_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
*neg = false;
@@ -1129,7 +1136,7 @@ static int acf_filldrivers_setting_flag(bAnimContext *UNUSED(ac), int setting, b
}
/* get pointer to the setting */
-static void *acf_filldrivers_setting_ptr(bAnimListElem *ale, int setting, short *type)
+static void *acf_filldrivers_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
AnimData *adt = (AnimData *)ale->data;
@@ -1149,6 +1156,7 @@ static void *acf_filldrivers_setting_ptr(bAnimListElem *ale, int setting, short
static bAnimChannelType ACF_FILLDRIVERS =
{
"Drivers Filler", /* type name */
+ ACHANNEL_ROLE_EXPANDER, /* role */
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
@@ -1174,7 +1182,7 @@ static int acf_dsmat_icon(bAnimListElem *UNUSED(ale))
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dsmat_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
+static int acf_dsmat_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
*neg = false;
@@ -1199,7 +1207,7 @@ static int acf_dsmat_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *n
}
/* get pointer to the setting */
-static void *acf_dsmat_setting_ptr(bAnimListElem *ale, int setting, short *type)
+static void *acf_dsmat_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
Material *ma = (Material *)ale->data;
@@ -1226,6 +1234,7 @@ static void *acf_dsmat_setting_ptr(bAnimListElem *ale, int setting, short *type)
static bAnimChannelType ACF_DSMAT =
{
"Material Data Expander", /* type name */
+ ACHANNEL_ROLE_EXPANDER, /* role */
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
@@ -1250,7 +1259,7 @@ static int acf_dslam_icon(bAnimListElem *UNUSED(ale))
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dslam_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
+static int acf_dslam_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
*neg = false;
@@ -1275,7 +1284,7 @@ static int acf_dslam_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *n
}
/* get pointer to the setting */
-static void *acf_dslam_setting_ptr(bAnimListElem *ale, int setting, short *type)
+static void *acf_dslam_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
Lamp *la = (Lamp *)ale->data;
@@ -1302,6 +1311,7 @@ static void *acf_dslam_setting_ptr(bAnimListElem *ale, int setting, short *type)
static bAnimChannelType ACF_DSLAM =
{
"Lamp Expander", /* type name */
+ ACHANNEL_ROLE_EXPANDER, /* role */
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
@@ -1333,7 +1343,7 @@ static short acf_dstex_offset(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(al
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dstex_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
+static int acf_dstex_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
*neg = false;
@@ -1358,7 +1368,7 @@ static int acf_dstex_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *n
}
/* get pointer to the setting */
-static void *acf_dstex_setting_ptr(bAnimListElem *ale, int setting, short *type)
+static void *acf_dstex_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
Tex *tex = (Tex *)ale->data;
@@ -1385,6 +1395,7 @@ static void *acf_dstex_setting_ptr(bAnimListElem *ale, int setting, short *type)
static bAnimChannelType ACF_DSTEX =
{
"Texture Data Expander", /* type name */
+ ACHANNEL_ROLE_EXPANDER, /* role */
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
@@ -1409,7 +1420,7 @@ static int acf_dscam_icon(bAnimListElem *UNUSED(ale))
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dscam_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
+static int acf_dscam_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
*neg = false;
@@ -1434,7 +1445,7 @@ static int acf_dscam_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *n
}
/* get pointer to the setting */
-static void *acf_dscam_setting_ptr(bAnimListElem *ale, int setting, short *type)
+static void *acf_dscam_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
Camera *ca = (Camera *)ale->data;
@@ -1461,6 +1472,7 @@ static void *acf_dscam_setting_ptr(bAnimListElem *ale, int setting, short *type)
static bAnimChannelType ACF_DSCAM =
{
"Camera Expander", /* type name */
+ ACHANNEL_ROLE_EXPANDER, /* role */
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
@@ -1495,7 +1507,7 @@ static int acf_dscur_icon(bAnimListElem *ale)
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dscur_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
+static int acf_dscur_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
*neg = false;
@@ -1520,7 +1532,7 @@ static int acf_dscur_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *n
}
/* get pointer to the setting */
-static void *acf_dscur_setting_ptr(bAnimListElem *ale, int setting, short *type)
+static void *acf_dscur_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
Curve *cu = (Curve *)ale->data;
@@ -1547,6 +1559,7 @@ static void *acf_dscur_setting_ptr(bAnimListElem *ale, int setting, short *type)
static bAnimChannelType ACF_DSCUR =
{
"Curve Expander", /* type name */
+ ACHANNEL_ROLE_EXPANDER, /* role */
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
@@ -1571,7 +1584,7 @@ static int acf_dsskey_icon(bAnimListElem *UNUSED(ale))
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dsskey_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
+static int acf_dsskey_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
*neg = false;
@@ -1596,7 +1609,7 @@ static int acf_dsskey_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *
}
/* get pointer to the setting */
-static void *acf_dsskey_setting_ptr(bAnimListElem *ale, int setting, short *type)
+static void *acf_dsskey_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
Key *key = (Key *)ale->data;
@@ -1623,6 +1636,7 @@ static void *acf_dsskey_setting_ptr(bAnimListElem *ale, int setting, short *type
static bAnimChannelType ACF_DSSKEY =
{
"Shape Key Expander", /* type name */
+ ACHANNEL_ROLE_EXPANDER, /* role */
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
@@ -1647,7 +1661,7 @@ static int acf_dswor_icon(bAnimListElem *UNUSED(ale))
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dswor_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
+static int acf_dswor_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
*neg = false;
@@ -1672,7 +1686,7 @@ static int acf_dswor_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *n
}
/* get pointer to the setting */
-static void *acf_dswor_setting_ptr(bAnimListElem *ale, int setting, short *type)
+static void *acf_dswor_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
World *wo = (World *)ale->data;
@@ -1699,6 +1713,7 @@ static void *acf_dswor_setting_ptr(bAnimListElem *ale, int setting, short *type)
static bAnimChannelType ACF_DSWOR =
{
"World Expander", /* type name */
+ ACHANNEL_ROLE_EXPANDER, /* role */
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
@@ -1723,7 +1738,7 @@ static int acf_dspart_icon(bAnimListElem *UNUSED(ale))
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dspart_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
+static int acf_dspart_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
*neg = false;
@@ -1748,7 +1763,7 @@ static int acf_dspart_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *
}
/* get pointer to the setting */
-static void *acf_dspart_setting_ptr(bAnimListElem *ale, int setting, short *type)
+static void *acf_dspart_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
ParticleSettings *part = (ParticleSettings *)ale->data;
@@ -1775,6 +1790,7 @@ static void *acf_dspart_setting_ptr(bAnimListElem *ale, int setting, short *type
static bAnimChannelType ACF_DSPART =
{
"Particle Data Expander", /* type name */
+ ACHANNEL_ROLE_EXPANDER, /* role */
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
@@ -1799,7 +1815,7 @@ static int acf_dsmball_icon(bAnimListElem *UNUSED(ale))
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dsmball_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
+static int acf_dsmball_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
*neg = false;
@@ -1824,7 +1840,7 @@ static int acf_dsmball_setting_flag(bAnimContext *UNUSED(ac), int setting, bool
}
/* get pointer to the setting */
-static void *acf_dsmball_setting_ptr(bAnimListElem *ale, int setting, short *type)
+static void *acf_dsmball_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
MetaBall *mb = (MetaBall *)ale->data;
@@ -1851,6 +1867,7 @@ static void *acf_dsmball_setting_ptr(bAnimListElem *ale, int setting, short *typ
static bAnimChannelType ACF_DSMBALL =
{
"Metaball Expander", /* type name */
+ ACHANNEL_ROLE_EXPANDER, /* role */
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
@@ -1875,7 +1892,7 @@ static int acf_dsarm_icon(bAnimListElem *UNUSED(ale))
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dsarm_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
+static int acf_dsarm_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
*neg = false;
@@ -1900,7 +1917,7 @@ static int acf_dsarm_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *n
}
/* get pointer to the setting */
-static void *acf_dsarm_setting_ptr(bAnimListElem *ale, int setting, short *type)
+static void *acf_dsarm_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
bArmature *arm = (bArmature *)ale->data;
@@ -1927,6 +1944,7 @@ static void *acf_dsarm_setting_ptr(bAnimListElem *ale, int setting, short *type)
static bAnimChannelType ACF_DSARM =
{
"Armature Expander", /* type name */
+ ACHANNEL_ROLE_EXPANDER, /* role */
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
@@ -1962,7 +1980,7 @@ static short acf_dsntree_offset(bAnimContext *ac, bAnimListElem *ale)
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dsntree_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
+static int acf_dsntree_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
*neg = false;
@@ -1987,7 +2005,7 @@ static int acf_dsntree_setting_flag(bAnimContext *UNUSED(ac), int setting, bool
}
/* get pointer to the setting */
-static void *acf_dsntree_setting_ptr(bAnimListElem *ale, int setting, short *type)
+static void *acf_dsntree_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
bNodeTree *ntree = (bNodeTree *)ale->data;
@@ -2014,6 +2032,7 @@ static void *acf_dsntree_setting_ptr(bAnimListElem *ale, int setting, short *typ
static bAnimChannelType ACF_DSNTREE =
{
"Node Tree Expander", /* type name */
+ ACHANNEL_ROLE_EXPANDER, /* role */
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
@@ -2038,7 +2057,7 @@ static int acf_dslinestyle_icon(bAnimListElem *UNUSED(ale))
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dslinestyle_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
+static int acf_dslinestyle_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
*neg = false;
@@ -2063,7 +2082,7 @@ static int acf_dslinestyle_setting_flag(bAnimContext *UNUSED(ac), int setting, b
}
/* get pointer to the setting */
-static void *acf_dslinestyle_setting_ptr(bAnimListElem *ale, int setting, short *type)
+static void *acf_dslinestyle_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
FreestyleLineStyle *linestyle = (FreestyleLineStyle *)ale->data;
@@ -2090,6 +2109,7 @@ static void *acf_dslinestyle_setting_ptr(bAnimListElem *ale, int setting, short
static bAnimChannelType ACF_DSLINESTYLE =
{
"Line Style Expander", /* type name */
+ ACHANNEL_ROLE_EXPANDER, /* role */
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop,/* backdrop */
@@ -2114,7 +2134,7 @@ static int acf_dsmesh_icon(bAnimListElem *UNUSED(ale))
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dsmesh_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
+static int acf_dsmesh_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
*neg = false;
@@ -2139,7 +2159,7 @@ static int acf_dsmesh_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *
}
/* get pointer to the setting */
-static void *acf_dsmesh_setting_ptr(bAnimListElem *ale, int setting, short *type)
+static void *acf_dsmesh_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
Mesh *me = (Mesh *)ale->data;
@@ -2166,6 +2186,7 @@ static void *acf_dsmesh_setting_ptr(bAnimListElem *ale, int setting, short *type
static bAnimChannelType ACF_DSMESH =
{
"Mesh Expander", /* type name */
+ ACHANNEL_ROLE_EXPANDER, /* role */
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
@@ -2190,7 +2211,7 @@ static int acf_dslat_icon(bAnimListElem *UNUSED(ale))
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dslat_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
+static int acf_dslat_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
*neg = false;
@@ -2215,7 +2236,7 @@ static int acf_dslat_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *n
}
/* get pointer to the setting */
-static void *acf_dslat_setting_ptr(bAnimListElem *ale, int setting, short *type)
+static void *acf_dslat_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
Lattice *lt = (Lattice *)ale->data;
@@ -2242,6 +2263,7 @@ static void *acf_dslat_setting_ptr(bAnimListElem *ale, int setting, short *type)
static bAnimChannelType ACF_DSLAT =
{
"Lattice Expander", /* type name */
+ ACHANNEL_ROLE_EXPANDER, /* role */
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
@@ -2266,7 +2288,7 @@ static int acf_dsspk_icon(bAnimListElem *UNUSED(ale))
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_dsspk_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
+static int acf_dsspk_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
*neg = false;
@@ -2291,7 +2313,7 @@ static int acf_dsspk_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *n
}
/* get pointer to the setting */
-static void *acf_dsspk_setting_ptr(bAnimListElem *ale, int setting, short *type)
+static void *acf_dsspk_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
Speaker *spk = (Speaker *)ale->data;
@@ -2318,6 +2340,7 @@ static void *acf_dsspk_setting_ptr(bAnimListElem *ale, int setting, short *type)
static bAnimChannelType ACF_DSSPK =
{
"Speaker Expander", /* type name */
+ ACHANNEL_ROLE_EXPANDER, /* role */
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
@@ -2367,7 +2390,7 @@ static bool acf_shapekey_name_prop(bAnimListElem *ale, PointerRNA *ptr, Property
}
/* check if some setting exists for this channel */
-static bool acf_shapekey_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting)
+static bool acf_shapekey_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), eAnimChannel_Settings setting)
{
switch (setting) {
case ACHANNEL_SETTING_SELECT: /* selected */
@@ -2382,7 +2405,7 @@ static bool acf_shapekey_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_shapekey_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
+static int acf_shapekey_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
*neg = false;
@@ -2403,7 +2426,7 @@ static int acf_shapekey_setting_flag(bAnimContext *UNUSED(ac), int setting, bool
}
/* get pointer to the setting */
-static void *acf_shapekey_setting_ptr(bAnimListElem *ale, int setting, short *type)
+static void *acf_shapekey_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
{
KeyBlock *kb = (KeyBlock *)ale->data;
@@ -2425,6 +2448,7 @@ static void *acf_shapekey_setting_ptr(bAnimListElem *ale, int setting, short *ty
static bAnimChannelType ACF_SHAPEKEY =
{
"Shape Key", /* type name */
+ ACHANNEL_ROLE_CHANNEL, /* role */
acf_generic_channel_color, /* backdrop color */
acf_generic_channel_backdrop, /* backdrop */
@@ -2456,7 +2480,7 @@ static int acf_gpd_icon(bAnimListElem *UNUSED(ale))
}
/* check if some setting exists for this channel */
-static bool acf_gpd_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting)
+static bool acf_gpd_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), eAnimChannel_Settings setting)
{
switch (setting) {
/* only select and expand supported */
@@ -2470,7 +2494,7 @@ static bool acf_gpd_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSE
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_gpd_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
+static int acf_gpd_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
*neg = false;
@@ -2481,14 +2505,15 @@ static int acf_gpd_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg
case ACHANNEL_SETTING_EXPAND: /* expanded */
return GP_DATA_EXPAND;
+
+ default:
+ /* these shouldn't happen */
+ return 0;
}
-
- /* this shouldn't happen */
- return 0;
}
/* get pointer to the setting */
-static void *acf_gpd_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short *type)
+static void *acf_gpd_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type)
{
bGPdata *gpd = (bGPdata *)ale->data;
@@ -2500,6 +2525,7 @@ static void *acf_gpd_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short
static bAnimChannelType ACF_GPD =
{
"GPencil Datablock", /* type name */
+ ACHANNEL_ROLE_EXPANDER, /* role */
acf_gpd_color, /* backdrop color */
acf_group_backdrop, /* backdrop */
@@ -2540,7 +2566,7 @@ static bool acf_gpl_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA *
}
/* check if some setting exists for this channel */
-static bool acf_gpl_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting)
+static bool acf_gpl_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), eAnimChannel_Settings setting)
{
switch (setting) {
/* unsupported */
@@ -2556,7 +2582,7 @@ static bool acf_gpl_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSE
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_gpl_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
+static int acf_gpl_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
*neg = false;
@@ -2577,11 +2603,11 @@ static int acf_gpl_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg
}
/* get pointer to the setting */
-static void *acf_gpl_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short *type)
+static void *acf_gpl_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type)
{
bGPDlayer *gpl = (bGPDlayer *)ale->data;
- /* all flags are just in agrp->flag for now... */
+ /* all flags are just in gpl->flag for now... */
return GET_ACF_FLAG_PTR(gpl->flag, type);
}
@@ -2589,6 +2615,7 @@ static void *acf_gpl_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short
static bAnimChannelType ACF_GPL =
{
"GPencil Layer", /* type name */
+ ACHANNEL_ROLE_CHANNEL, /* role */
acf_generic_channel_color, /* backdrop color */
acf_generic_channel_backdrop, /* backdrop */
@@ -2621,7 +2648,7 @@ static int acf_mask_icon(bAnimListElem *UNUSED(ale))
}
/* check if some setting exists for this channel */
-static bool acf_mask_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting)
+static bool acf_mask_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), eAnimChannel_Settings setting)
{
switch (setting) {
/* only select and expand supported */
@@ -2635,7 +2662,7 @@ static bool acf_mask_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUS
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_mask_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
+static int acf_mask_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
*neg = false;
@@ -2646,14 +2673,15 @@ static int acf_mask_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *ne
case ACHANNEL_SETTING_EXPAND: /* expanded */
return MASK_ANIMF_EXPAND;
+
+ default:
+ /* this shouldn't happen */
+ return 0;
}
-
- /* this shouldn't happen */
- return 0;
}
/* get pointer to the setting */
-static void *acf_mask_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short *type)
+static void *acf_mask_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type)
{
Mask *mask = (Mask *)ale->data;
@@ -2665,6 +2693,7 @@ static void *acf_mask_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short
static bAnimChannelType ACF_MASKDATA =
{
"Mask Datablock", /* type name */
+ ACHANNEL_ROLE_EXPANDER, /* role */
acf_mask_color, /* backdrop color */
acf_group_backdrop, /* backdrop */
@@ -2705,7 +2734,7 @@ static bool acf_masklay_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyR
}
/* check if some setting exists for this channel */
-static bool acf_masklay_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting)
+static bool acf_masklay_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), eAnimChannel_Settings setting)
{
switch (setting) {
/* unsupported */
@@ -2721,7 +2750,7 @@ static bool acf_masklay_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *U
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_masklay_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
+static int acf_masklay_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
*neg = false;
@@ -2739,11 +2768,11 @@ static int acf_masklay_setting_flag(bAnimContext *UNUSED(ac), int setting, bool
}
/* get pointer to the setting */
-static void *acf_masklay_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short *type)
+static void *acf_masklay_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type)
{
MaskLayer *masklay = (MaskLayer *)ale->data;
- /* all flags are just in agrp->flag for now... */
+ /* all flags are just in masklay->flag for now... */
return GET_ACF_FLAG_PTR(masklay->flag, type);
}
@@ -2751,6 +2780,7 @@ static void *acf_masklay_setting_ptr(bAnimListElem *ale, int UNUSED(setting), sh
static bAnimChannelType ACF_MASKLAYER =
{
"Mask Layer", /* type name */
+ ACHANNEL_ROLE_CHANNEL, /* role */
acf_generic_channel_color, /* backdrop color */
acf_generic_channel_backdrop, /* backdrop */
@@ -2810,7 +2840,7 @@ static bool acf_nlatrack_name_prop(bAnimListElem *ale, PointerRNA *ptr, Property
}
/* check if some setting exists for this channel */
-static bool acf_nlatrack_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *ale, int setting)
+static bool acf_nlatrack_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *ale, eAnimChannel_Settings setting)
{
NlaTrack *nlt = (NlaTrack *)ale->data;
AnimData *adt = ale->adt;
@@ -2855,7 +2885,7 @@ static bool acf_nlatrack_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *
}
/* get the appropriate flag(s) for the setting when it is valid */
-static int acf_nlatrack_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg)
+static int acf_nlatrack_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
*neg = false;
@@ -2879,7 +2909,7 @@ static int acf_nlatrack_setting_flag(bAnimContext *UNUSED(ac), int setting, bool
}
/* get pointer to the setting */
-static void *acf_nlatrack_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short *type)
+static void *acf_nlatrack_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type)
{
NlaTrack *nlt = (NlaTrack *)ale->data;
return GET_ACF_FLAG_PTR(nlt->flag, type);
@@ -2889,6 +2919,7 @@ static void *acf_nlatrack_setting_ptr(bAnimListElem *ale, int UNUSED(setting), s
static bAnimChannelType ACF_NLATRACK =
{
"NLA Track", /* type name */
+ ACHANNEL_ROLE_CHANNEL, /* role */
acf_nlatrack_color, /* backdrop color */
acf_generic_channel_backdrop, /* backdrop */
@@ -2904,7 +2935,174 @@ static bAnimChannelType ACF_NLATRACK =
acf_nlatrack_setting_ptr /* pointer for setting */
};
+/* NLA Action ----------------------------------------------- */
+
+/* icon for action depends on whether it's in tweaking mode */
+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;
+ }
+ else {
+ return ICON_ACTION;
+ }
+}
+
+/* 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
+ * 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)
+{
+ bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
+ View2D *v2d = &ac->ar->v2d;
+ 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
+ * 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)) {
+ /* Yes, the color vector has 4 components, BUT we only want to be using 3 of them! */
+ glColor3fv(color);
+ }
+ else {
+ float alpha = (adt && (adt->flag & ADT_NLA_SOLO_TRACK)) ? 0.3f : 1.0f;
+ glColor4f(color[0], color[1], color[2], alpha);
+ }
+
+ /* only on top left corner, to show that this channel sits on top of the preceding ones
+ * while still linking into the action line strip to the right
+ */
+ uiSetRoundBox(UI_CNR_TOP_LEFT);
+
+ /* draw slightly shifted up vertically to look like it has more separation from other channels,
+ * but we then need to slightly shorten it so that it doesn't look like it overlaps
+ */
+ uiDrawBox(GL_POLYGON, offset, yminc + NLACHANNEL_SKIP, (float)v2d->cur.xmax, ymaxc + NLACHANNEL_SKIP - 1, 8);
+}
+
+/* name for nla action entries */
+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?
+ BLI_strncpy(name, act->id.name + 2, ANIM_CHAN_NAME_SIZE);
+ }
+ else {
+ BLI_strncpy(name, "<No Action>", ANIM_CHAN_NAME_SIZE);
+ }
+ }
+}
+
+/* name property for nla action entries */
+static bool acf_nlaaction_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
+{
+ 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;
+}
+
+/* check if some setting exists for this channel */
+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 */
+ case ACHANNEL_SETTING_PINNED: /* pinned - map/unmap */
+ if ((adt) && (adt->flag & ADT_NLA_EDIT_ON)) {
+ /* this should only appear in tweakmode */
+ return true;
+ }
+ else {
+ return false;
+ }
+
+ /* unsupported */
+ default:
+ return false;
+ }
+}
+
+/* get the appropriate flag(s) for the setting when it is valid */
+static int acf_nlaaction_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
+{
+ /* 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;
+ }
+}
+
+/* get pointer to the setting */
+static void *acf_nlaaction_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type)
+{
+ AnimData *adt = ale->adt;
+ return GET_ACF_FLAG_PTR(adt->flag, type);
+}
+/* nla action type define */
+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 */
+};
/* *********************************************** */
@@ -2965,9 +3163,7 @@ static void ANIM_init_channel_typeinfo_data(void)
animchannelTypeInfo[type++] = &ACF_MASKLAYER; /* Mask Layer */
animchannelTypeInfo[type++] = &ACF_NLATRACK; /* NLA Track */
-
- // TODO: this channel type still hasn't been ported over yet, since it requires special attention
- animchannelTypeInfo[type++] = NULL; /* NLA Action */
+ animchannelTypeInfo[type++] = &ACF_NLAACTION; /* NLA Action */
}
}
@@ -3043,7 +3239,7 @@ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, int setting
switch (ptrsize) {
case sizeof(int): /* integer pointer for setting */
{
- int *val = (int *)ptr;
+ const int *val = (int *)ptr;
if (negflag)
return ((*val) & flag) == 0;
@@ -3052,7 +3248,7 @@ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, int setting
}
case sizeof(short): /* short pointer for setting */
{
- short *val = (short *)ptr;
+ const short *val = (short *)ptr;
if (negflag)
return ((*val) & flag) == 0;
@@ -3061,7 +3257,7 @@ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, int setting
}
case sizeof(char): /* char pointer for setting */
{
- char *val = (char *)ptr;
+ const char *val = (char *)ptr;
if (negflag)
return ((*val) & flag) == 0;
@@ -3257,7 +3453,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
}
}
- /* step 6) draw backdrops behidn mute+protection toggles + (sliders) ....................... */
+ /* step 6) draw backdrops behind mute+protection toggles + (sliders) ....................... */
/* reset offset - now goes from RHS of panel */
offset = 0;
@@ -3265,6 +3461,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
if (v2d) {
short draw_sliders = 0;
+ float ymin_ofs = 0.0f;
float color[3];
/* get and set backdrop color */
@@ -3297,6 +3494,15 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
/* mute... */
if (acf->has_setting(ac, ale, ACHANNEL_SETTING_MUTE))
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
@@ -3314,7 +3520,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
* - starts from the point where the first toggle/slider starts,
* - ends past the space that might be reserved for a scroller
*/
- glRectf(v2d->cur.xmax - (float)offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc);
+ glRectf(v2d->cur.xmax - (float)offset, yminc + ymin_ofs, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc);
}
}
@@ -3541,10 +3747,28 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann
//icon = ((enabled) ? ICON_MUTE_IPO_ON : ICON_MUTE_IPO_OFF);
icon = ICON_MUTE_IPO_OFF;
- if (ale->type == ANIMTYPE_FCURVE)
+ if (ale->type == ANIMTYPE_FCURVE) {
tooltip = TIP_("Does F-Curve contribute to result");
- else
- tooltip = TIP_("Do channels contribute to result");
+ }
+ else if ((ac) && (ac->spacetype == SPACE_NLA) && (ale->type != ANIMTYPE_NLATRACK)) {
+ tooltip = TIP_("Temporarily disable NLA stack evaluation (i.e. only the active action is evaluated)");
+ }
+ else {
+ 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)");
+ }
+ else {
+ /* TODO: there are no other tools which require the 'pinning' concept yet */
+ tooltip = NULL;
+ }
break;
default:
@@ -3585,6 +3809,7 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann
case ACHANNEL_SETTING_VISIBLE: /* Graph Editor - 'visibility' toggles */
case ACHANNEL_SETTING_PROTECT: /* General - protection flags */
case ACHANNEL_SETTING_MUTE: /* General - muting flags */
+ case ACHANNEL_SETTING_PINNED: /* NLA Actions - 'map/nomap' */
uiButSetNFunc(but, achannel_setting_flush_widget_cb, MEM_dupallocN(ale), SET_INT_IN_POINTER(setting));
break;
@@ -3724,6 +3949,31 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale
offset += ICON_WIDTH;
draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax - offset, ymid, ACHANNEL_SETTING_MUTE);
}
+
+ /* ----------- */
+
+ /* 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;
+
+ uiBlockSetEmboss(block, UI_EMBOSS);
+
+ offset += UI_UNIT_X;
+ but = uiDefIconButO(block, 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 = uiButGetOperatorPtrRNA(but);
+ RNA_int_set(opptr_b, "channel_index", channel_index);
+
+ uiBlockSetEmboss(block, UI_EMBOSSN);
+ }
}
/* draw slider
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index 341e27a12bf..5d97b7be9f7 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -387,7 +387,7 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, short datatype, s
* - setting: type of setting to set
* - on: whether the visibility setting has been enabled or disabled
*/
-void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAnimListElem *ale_setting, int setting, short on)
+void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAnimListElem *ale_setting, int setting, short mode)
{
bAnimListElem *ale, *match = NULL;
int prevLevel = 0, matchLevel = 0;
@@ -437,8 +437,8 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn
* - only flush up if the current state is now disabled (negative 'off' state is default)
* (otherwise, it's too much work to force the parents to be active too)
*/
- if ( ((setting == ACHANNEL_SETTING_VISIBLE) && on) ||
- ((setting != ACHANNEL_SETTING_VISIBLE) && on == 0) )
+ if ( ((setting == ACHANNEL_SETTING_VISIBLE) && (mode != ACHANNEL_SETFLAG_CLEAR)) ||
+ ((setting != ACHANNEL_SETTING_VISIBLE) && (mode == ACHANNEL_SETFLAG_CLEAR)))
{
/* go backwards in the list, until the highest-ranking element (by indention has been covered) */
for (ale = match->prev; ale; ale = ale->prev) {
@@ -461,7 +461,7 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn
*/
if (level < prevLevel) {
/* flush the new status... */
- ANIM_channel_setting_set(ac, ale, setting, on);
+ ANIM_channel_setting_set(ac, ale, setting, mode);
/* store this level as the 'old' level now */
prevLevel = level;
@@ -502,7 +502,7 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn
* flush the new status...
*/
if (level > matchLevel)
- ANIM_channel_setting_set(ac, ale, setting, on);
+ ANIM_channel_setting_set(ac, ale, setting, mode);
/* however, if the level is 'less than or equal to' the channel that was changed,
* (i.e. the current channel is as important if not more important than the changed channel)
* then we should stop, since we've found the last one of the children we should flush
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index b1789d25b88..9c3f310a417 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -31,7 +31,6 @@
#include "BLI_sys_types.h"
#include "DNA_anim_types.h"
-#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_space_types.h"
#include "DNA_userdef_types.h"
@@ -40,7 +39,6 @@
#include "BLI_timecode.h"
#include "BKE_context.h"
-#include "BKE_blender.h"
#include "BKE_global.h"
#include "BKE_nla.h"
#include "BKE_object.h"
@@ -67,7 +65,7 @@ static void draw_cfra_number(Scene *scene, View2D *v2d, const float cfra, const
short slen;
/* because the frame number text is subject to the same scaling as the contents of the view */
- UI_view2d_getscale(v2d, &xscale, &yscale);
+ UI_view2d_scale_get(v2d, &xscale, &yscale);
glScalef(1.0f / xscale, 1.0f, 1.0f);
/* get timecode string
@@ -223,7 +221,7 @@ static short bezt_nlamapping_apply(KeyframeEditData *ked, BezTriple *bezt)
* - 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, short restore, short only_keys)
+void ANIM_nla_mapping_apply_fcurve(AnimData *adt, FCurve *fcu, bool restore, bool only_keys)
{
KeyframeEditData ked = {{NULL}};
KeyframeEditFunc map_cb;
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 9cba7d04c3e..04363f61fd6 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -322,7 +322,7 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag)
/* no time correction for framelen! space is drawn with old values */
ypixels = BLI_rcti_size_y(&v2d->mask);
- UI_view2d_getscale(v2d, &xscale, &yscale);
+ UI_view2d_scale_get(v2d, &xscale, &yscale);
glScalef(1.0f / xscale, 1.0f, 1.0f);
@@ -1024,22 +1024,18 @@ static int ed_marker_select(bContext *C, const wmEvent *event, bool extend, bool
ARegion *ar = CTX_wm_region(C);
View2D *v2d = UI_view2d_fromcontext(C);
float viewx;
- int x, y, cfra;
+ int x, cfra;
if (markers == NULL)
return OPERATOR_PASS_THROUGH;
x = event->x - ar->winrct.xmin;
- y = event->y - ar->winrct.ymin;
- UI_view2d_region_to_view(v2d, x, y, &viewx, NULL);
+ viewx = UI_view2d_region_to_view_x(v2d, x);
cfra = ED_markers_find_nearest_marker_time(markers, viewx);
- if (extend)
- select_timeline_marker_frame(markers, cfra, 1);
- else
- select_timeline_marker_frame(markers, cfra, 0);
+ select_timeline_marker_frame(markers, cfra, extend);
#ifdef DURIAN_CAMERA_SWITCH
@@ -1150,22 +1146,19 @@ static int ed_marker_border_select_exec(bContext *C, wmOperator *op)
View2D *v2d = UI_view2d_fromcontext(C);
ListBase *markers = ED_context_get_markers(C);
TimeMarker *marker;
- float xminf, xmaxf, yminf, ymaxf;
int gesture_mode = RNA_int_get(op->ptr, "gesture_mode");
bool extend = RNA_boolean_get(op->ptr, "extend");
- rcti rect;
+ rctf rect;
- WM_operator_properties_border_to_rcti(op, &rect);
-
- UI_view2d_region_to_view(v2d, rect.xmin, rect.ymin, &xminf, &yminf);
- UI_view2d_region_to_view(v2d, rect.xmax, rect.ymax, &xmaxf, &ymaxf);
+ 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 ((marker->frame > xminf) && (marker->frame <= xmaxf)) {
+ if (BLI_rctf_isect_x(&rect, marker->frame)) {
switch (gesture_mode) {
case GESTURE_MODAL_SELECT:
marker->flag |= SELECT;
@@ -1425,6 +1418,7 @@ static void MARKER_OT_make_links_scene(wmOperatorType *ot)
/* properties */
prop = RNA_def_enum(ot->srna, "scene", DummyRNA_NULL_items, 0, "Scene", "");
RNA_def_enum_funcs(prop, RNA_scene_itemf);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
ot->prop = prop;
}
diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c
index 072b4c4c201..88429aa3867 100644
--- a/source/blender/editors/animation/anim_ops.c
+++ b/source/blender/editors/animation/anim_ops.c
@@ -124,15 +124,15 @@ static int frame_from_event(bContext *C, const wmEvent *event)
int frame;
/* convert from region coordinates to View2D 'tot' space */
- UI_view2d_region_to_view(&region->v2d, event->mval[0], event->mval[1], &viewx, NULL);
+ viewx = UI_view2d_region_to_view_x(&region->v2d, event->mval[0]);
/* round result to nearest int (frames are ints!) */
frame = iroundf(viewx);
-
+
if (scene->r.flag & SCER_LOCK_FRAME_SELECTION) {
CLAMP(frame, PSFRA, PEFRA);
}
-
+
return frame;
}
@@ -212,8 +212,8 @@ static int previewrange_define_exec(bContext *C, wmOperator *op)
WM_operator_properties_border_to_rcti(op, &rect);
/* convert min/max values to frames (i.e. region to 'tot' rect) */
- UI_view2d_region_to_view(&ar->v2d, rect.xmin, 0, &sfra, NULL);
- UI_view2d_region_to_view(&ar->v2d, rect.xmax, 0, &efra, NULL);
+ 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
* - must clamp within allowable limits
diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c
index 8f3fa66552c..839284905ff 100644
--- a/source/blender/editors/animation/drivers.c
+++ b/source/blender/editors/animation/drivers.c
@@ -46,7 +46,6 @@
#include "DNA_space_types.h"
#include "BKE_animsys.h"
-#include "BKE_depsgraph.h"
#include "BKE_fcurve.h"
#include "BKE_context.h"
#include "BKE_report.h"
diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c
index 48611633592..7ce33e01747 100644
--- a/source/blender/editors/animation/fmodifier_ui.c
+++ b/source/blender/editors/animation/fmodifier_ui.c
@@ -705,9 +705,9 @@ void free_fmodifiers_copybuf(void)
* assuming that the buffer has been cleared already with free_fmodifiers_copybuf()
* - active: only copy the active modifier
*/
-short ANIM_fmodifiers_copy_to_buf(ListBase *modifiers, short active)
+bool ANIM_fmodifiers_copy_to_buf(ListBase *modifiers, bool active)
{
- short ok = 1;
+ bool ok = true;
/* sanity checks */
if (ELEM(NULL, modifiers, modifiers->first))
@@ -734,10 +734,10 @@ short ANIM_fmodifiers_copy_to_buf(ListBase *modifiers, short 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
*/
-short ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, short replace)
+bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace)
{
FModifier *fcm;
- short ok = 0;
+ bool ok = false;
/* sanity checks */
if (modifiers == NULL)
diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c
index 1dea1329f9f..e233608dea2 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -40,32 +40,16 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
-#include "BLI_math.h"
#include "BLI_dlrbTree.h"
#include "BLI_utildefines.h"
#include "DNA_anim_types.h"
-#include "DNA_armature_types.h"
-#include "DNA_camera_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
-#include "DNA_key_types.h"
-#include "DNA_lamp_types.h"
-#include "DNA_lattice_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_material_types.h"
-#include "DNA_meta_types.h"
-#include "DNA_node_types.h"
-#include "DNA_particle_types.h"
-#include "DNA_speaker_types.h"
-#include "DNA_world_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_mask_types.h"
-#include "BKE_key.h"
-#include "BKE_material.h"
-#include "BKE_global.h" // XXX remove me!
-
+#include "BKE_fcurve.h"
#include "BIF_gl.h"
@@ -84,11 +68,15 @@
short compare_ak_cfraPtr(void *node, void *data)
{
ActKeyColumn *ak = (ActKeyColumn *)node;
- float *cframe = data;
+ const float *cframe = data;
+ float val = *cframe;
+
+ if (IS_EQT(val, ak->cfra, BEZT_BINARYSEARCH_THRESH))
+ return 0;
- if (*cframe < ak->cfra)
+ if (val < ak->cfra)
return -1;
- else if (*cframe > ak->cfra)
+ else if (val > ak->cfra)
return 1;
else
return 0;
@@ -258,110 +246,6 @@ static void add_masklay_to_keycolumns_list(DLRBT_Tree *keys, MaskLayerShape *mas
BLI_dlrbTree_add(keys, compare_ak_masklayshape, nalloc_ak_masklayshape, nupdate_ak_masklayshape, masklay_shape);
}
-/* ActBeztColumns (Helpers for Long Keyframes) ------------------------------ */
-
-/* maximum size of default buffer for BezTriple columns */
-#define MAX_ABK_BUFSIZE 4
-
-/* BezTriple Container Node */
-// NOTE: only used internally while building Long Keyframes for now, but may be useful externally?
-typedef struct ActBeztColumn {
- /* Tree Node interface ---------------- */
- /* ListBase linkage */
- struct ActBeztColumn *next, *prev;
-
- /* sorting-tree linkage */
- struct ActBeztColumn *left, *right; /* 'children' of this node, less than and greater than it (respectively) */
- struct ActBeztColumn *parent; /* parent of this node in the tree */
- char tree_col; /* DLRB_BLACK or DLRB_RED */
- char pad;
-
- /* BezTriple Store -------------------- */
- short numBezts; /* number of BezTriples on this frame */
- float cfra; /* frame that the BezTriples occur on */
-
- BezTriple *bezts[MAX_ABK_BUFSIZE]; /* buffer of pointers to BezTriples on the same frame */
- //BezTriple **bezts_extra; /* secondary buffer of pointers if need be */
-} ActBeztColumn;
-
-/* --------------- */
-
-/* Comparator callback used for ActBeztColumns and BezTriple */
-static short compare_abk_bezt(void *node, void *data)
-{
- ActBeztColumn *abk = (ActBeztColumn *)node;
- BezTriple *bezt = (BezTriple *)data;
-
- if (bezt->vec[1][0] < abk->cfra)
- return -1;
- else if (bezt->vec[1][0] > abk->cfra)
- return 1;
- else
- return 0;
-}
-
-/* New node callback used for building ActBeztColumns from BezTriples */
-static DLRBT_Node *nalloc_abk_bezt(void *data)
-{
- ActBeztColumn *abk = MEM_callocN(sizeof(ActBeztColumn), "ActKeyColumn");
- BezTriple *bezt = (BezTriple *)data;
-
- /* store the BeztTriple in the buffer, and keep track of its frame number */
- abk->cfra = bezt->vec[1][0];
- abk->bezts[abk->numBezts++] = bezt;
-
- return (DLRBT_Node *)abk;
-}
-
-/* Node updater callback used for building ActBeztColumns from BezTriples */
-static void nupdate_abk_bezt(void *node, void *data)
-{
- ActBeztColumn *abk = (ActBeztColumn *)node;
- BezTriple *bezt = (BezTriple *)data;
-
- /* just add the BezTriple to the buffer if there's space, or allocate a new one */
- if (abk->numBezts >= MAX_ABK_BUFSIZE) {
- // TODO: need to allocate new array to cater...
- //bezts_extra = MEM_callocN(...);
- if (G.debug & G_DEBUG)
- printf("FIXME: nupdate_abk_bezt() missing case for too many overlapping BezTriples\n");
- }
- else {
- /* just store an extra one */
- abk->bezts[abk->numBezts++] = bezt;
- }
-}
-
-/* --------------- */
-
-/* Return the BezTriple in the given ActBeztColumn that matches the requested value */
-static BezTriple *abk_get_bezt_with_value(ActBeztColumn *abk, float value)
-{
- BezTriple *bezt;
- int i;
-
- /* sanity checks */
- if (abk == NULL)
- return NULL;
-
- /* look over each BezTriple in this container */
- for (i = 0; i < abk->numBezts; i++) {
- /* only do exact match for now... */
- if (/*i >= MAX_ABK_BUFSIZE*/ 0) {
- // TODO: this case needs special handling
- }
- else {
- /* just use the default buffer */
- bezt = abk->bezts[i];
-
- if (bezt->vec[1][1] == value)
- return bezt;
- }
- }
-
- return NULL;
-}
-
/* ActKeyBlocks (Long Keyframes) ------------------------------------------ */
/* Comparator callback used for ActKeyBlock and cframe float-value pointer */
@@ -369,11 +253,12 @@ static BezTriple *abk_get_bezt_with_value(ActBeztColumn *abk, float value)
short compare_ab_cfraPtr(void *node, void *data)
{
ActKeyBlock *ab = (ActKeyBlock *)node;
- float *cframe = data;
+ const float *cframe = data;
+ float val = *cframe;
- if (*cframe < ab->start)
+ if (val < ab->start)
return -1;
- else if (*cframe > ab->start)
+ else if (val > ab->start)
return 1;
else
return 0;
@@ -396,17 +281,25 @@ static ActKeyBlock *bezts_to_new_actkeyblock(BezTriple *prev, BezTriple *beztn)
return ab;
}
-static void add_bezt_to_keyblocks_list(DLRBT_Tree *blocks, DLRBT_Tree *beztTree, BezTriple *beztn)
+static void add_bezt_to_keyblocks_list(DLRBT_Tree *blocks, BezTriple *first_bezt, BezTriple *beztn)
{
ActKeyBlock *new_ab = NULL;
- ActBeztColumn *abk;
- BezTriple *prev;
+ BezTriple *prev = NULL;
/* get the BezTriple immediately before the given one which has the same value */
- /* the keyframes immediately before the ones containing the specified keyframe */
- abk = (ActBeztColumn *)BLI_dlrbTree_search_prev(beztTree, compare_abk_bezt, beztn);
- /* if applicable, the BezTriple with the same value */
- prev = (abk) ? abk_get_bezt_with_value(abk, beztn->vec[1][1]) : NULL;
+ if (beztn != first_bezt) {
+ /* 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
+ * current FCurve.
+ *
+ * -- Aligorith (20140415)
+ */
+ prev = beztn - 1;
+ }
+
/* check if block needed - same value(s)?
* -> firstly, handles must have same central value as each other
@@ -414,6 +307,7 @@ static void add_bezt_to_keyblocks_list(DLRBT_Tree *blocks, DLRBT_Tree *beztTree,
*/
if (prev == NULL) return;
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;
@@ -428,6 +322,7 @@ static void add_bezt_to_keyblocks_list(DLRBT_Tree *blocks, DLRBT_Tree *beztTree,
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
* an A ___ B |---| B situation
*/
@@ -436,17 +331,19 @@ static void add_bezt_to_keyblocks_list(DLRBT_Tree *blocks, DLRBT_Tree *beztTree,
// 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 */
- if (ab->start == prev->vec[1][0]) {
+ /* 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 (BEZSELECTED(beztn)) ab->sel = SELECT;
- ab->modified += 1;
+ ab->modified++;
/* done... no need to insert */
return;
}
else {
- ActKeyBlock **abnp = NULL;
+ 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])
@@ -666,7 +563,7 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa
glEnable(GL_BLEND);
/* get View2D scaling factor */
- UI_view2d_getscale(v2d, &xscale, NULL);
+ UI_view2d_scale_get(v2d, &xscale, NULL);
/* locked channels are less strongly shown, as feedback for locked channels in DopeSheet */
/* TODO: allow this opacity factor to be themed? */
@@ -674,18 +571,23 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa
/* draw keyblocks */
if (blocks) {
+ float sel_color[4], unsel_color[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;
+
+ /* NOTE: the tradeoff for changing colors between each draw is dwarfed by the cost of checking validity */
for (ab = blocks->first; ab; ab = ab->next) {
if (actkeyblock_is_valid(ab, keys)) {
- float color[4];
-
/* draw block */
if (ab->sel)
- UI_GetThemeColor4fv(TH_STRIP_SELECT, color);
+ glColor4fv(sel_color);
else
- UI_GetThemeColor4fv(TH_STRIP, color);
-
- color[3] *= alpha;
- glColor4fv(color);
+ glColor4fv(unsel_color);
glRectf(ab->start, ypos - iconsize, ab->end, ypos + iconsize);
}
@@ -875,7 +777,6 @@ void summary_to_keylist(bAnimContext *ac, DLRBT_Tree *keys, DLRBT_Tree *blocks)
/* loop through each F-Curve, grabbing the keyframes */
for (ale = anim_data.first; ale; ale = ale->next) {
-
/* Why not use all #eAnim_KeyType here?
* All of the other key types are actually "summaries" themselves, and will just end up duplicating stuff
* that comes up through standard filtering of just F-Curves.
@@ -896,7 +797,7 @@ void summary_to_keylist(bAnimContext *ac, DLRBT_Tree *keys, DLRBT_Tree *blocks)
break;
}
}
-
+
BLI_freelistN(&anim_data);
}
}
@@ -972,7 +873,6 @@ void ob_to_keylist(bDopeSheet *ads, Object *ob, DLRBT_Tree *keys, DLRBT_Tree *bl
void fcurve_to_keylist(AnimData *adt, FCurve *fcu, DLRBT_Tree *keys, DLRBT_Tree *blocks)
{
- DLRBT_Tree *beztTree = NULL;
BezTriple *bezt;
unsigned int v;
@@ -981,25 +881,10 @@ void fcurve_to_keylist(AnimData *adt, FCurve *fcu, DLRBT_Tree *keys, DLRBT_Tree
if (adt)
ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 0);
- /* if getting long keyframes too, grab the BezTriples in a BST for
- * accelerated searching...
- */
- if (blocks) {
- /* init new tree */
- beztTree = BLI_dlrbTree_new();
-
- /* populate tree with the BezTriples */
- for (v = 0, bezt = fcu->bezt; v < fcu->totvert; v++, bezt++)
- BLI_dlrbTree_add(beztTree, compare_abk_bezt, nalloc_abk_bezt, nupdate_abk_bezt, bezt);
-
- /* make sure that it is suitable for linked-list searching too */
- BLI_dlrbTree_linkedlist_sync(beztTree);
- }
-
/* 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, beztTree, bezt);
+ if (blocks) add_bezt_to_keyblocks_list(blocks, fcu->bezt, bezt);
}
/* update the number of curves that elements have appeared in */
@@ -1007,12 +892,6 @@ void fcurve_to_keylist(AnimData *adt, FCurve *fcu, DLRBT_Tree *keys, DLRBT_Tree
set_touched_actkeycolumn(keys->root);
if (blocks)
set_touched_actkeyblock(blocks->root);
-
- /* free temp data for building long keyframes */
- if (blocks && beztTree) {
- BLI_dlrbTree_free(beztTree);
- MEM_freeN(beztTree);
- }
/* unapply NLA-mapping if applicable */
if (adt)
diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c
index e5929d0ad8e..7e7453487b8 100644
--- a/source/blender/editors/animation/keyframes_edit.c
+++ b/source/blender/editors/animation/keyframes_edit.c
@@ -35,30 +35,16 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
-#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BLI_lasso.h"
#include "DNA_anim_types.h"
-#include "DNA_armature_types.h"
-#include "DNA_camera_types.h"
-#include "DNA_key_types.h"
-#include "DNA_lamp_types.h"
-#include "DNA_lattice_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_material_types.h"
#include "DNA_object_types.h"
-#include "DNA_meta_types.h"
#include "DNA_node_types.h"
-#include "DNA_particle_types.h"
#include "DNA_scene_types.h"
#include "DNA_space_types.h"
-#include "DNA_world_types.h"
#include "BKE_fcurve.h"
-#include "BKE_key.h"
-#include "BKE_material.h"
-
#include "ED_anim_api.h"
#include "ED_keyframes_edit.h"
@@ -428,6 +414,7 @@ void ANIM_editkeyframes_refresh(bAnimContext *ac)
*/
#define KEYFRAME_OK_CHECKS(check) \
{ \
+ CHECK_TYPE(ok, short); \
if (check(1)) \
ok |= KEYFRAME_OK_KEY; \
\
@@ -1102,6 +1089,13 @@ static short set_easingtype_easeinout(KeyframeEditData *UNUSED(ked), BezTriple *
return 0;
}
+static short set_easingtype_easeauto(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
+{
+ if (bezt->f2 & SELECT)
+ bezt->easing = BEZT_IPO_EASE_AUTO;
+ return 0;
+}
+
/* Set the easing type of the selected BezTriples in each F-Curve to the specified one */
KeyframeEditFunc ANIM_editkeyframes_easing(short mode)
{
@@ -1113,8 +1107,10 @@ KeyframeEditFunc ANIM_editkeyframes_easing(short mode)
return set_easingtype_easeout;
case BEZT_IPO_EASE_IN_OUT: /* both */
- default:
return set_easingtype_easeinout;
+
+ default: /* auto */
+ return set_easingtype_easeauto;
}
}
@@ -1291,7 +1287,7 @@ KeyframeEditFunc ANIM_editkeyframes_buildselmap(short mode)
/* flush selection map values to the given beztriple */
short bezt_selmap_flush(KeyframeEditData *ked, BezTriple *bezt)
{
- char *map = ked->data;
+ const char *map = ked->data;
short on = map[ked->curIndex];
/* select or deselect based on whether the map allows it or not */
diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c
index f2161c4f094..c610595c4ba 100644
--- a/source/blender/editors/animation/keyframes_general.c
+++ b/source/blender/editors/animation/keyframes_general.c
@@ -36,7 +36,6 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
-#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "DNA_anim_types.h"
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 72402d498ba..78c87d58766 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -40,7 +40,6 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
-#include "BLI_dynstr.h"
#include "BLI_utildefines.h"
#include "BLF_translation.h"
@@ -59,7 +58,6 @@
#include "BKE_armature.h"
#include "BKE_depsgraph.h"
#include "BKE_fcurve.h"
-#include "BKE_main.h"
#include "BKE_idcode.h"
#include "BKE_nla.h"
#include "BKE_global.h"
@@ -72,6 +70,7 @@
#include "ED_keyframing.h"
#include "ED_keyframes_edit.h"
#include "ED_screen.h"
+#include "ED_object.h"
#include "UI_interface.h"
#include "UI_resources.h"
@@ -395,11 +394,18 @@ int insert_vert_fcurve(FCurve *fcu, float x, float y, short flag)
beztr.vec[2][0] = x + 1.0f;
beztr.vec[2][1] = y;
beztr.f1 = beztr.f2 = beztr.f3 = SELECT;
- beztr.h1 = beztr.h2 = U.keyhandles_new; /* use default handle type here */
- //BEZKEYTYPE(&beztr)= scene->keytype; /* default keyframe type */
- /* use default interpolation mode, with exceptions for int/discrete values */
- beztr.ipo = U.ipo_new;
+ if (flag & INSERTKEY_NO_USERPREF) {
+ beztr.h1 = beztr.h2 = HD_AUTO_ANIM;
+ beztr.ipo = BEZT_IPO_BEZ;
+ }
+ else {
+ beztr.h1 = beztr.h2 = U.keyhandles_new; /* use default handle type here */
+ //BEZKEYTYPE(&beztr)= scene->keytype; /* default keyframe type */
+
+ /* use default interpolation mode, with exceptions for int/discrete values */
+ beztr.ipo = U.ipo_new;
+ }
if (fcu->flag & FCURVE_DISCRETE_VALUES)
beztr.ipo = BEZT_IPO_CONST;
@@ -1265,6 +1271,8 @@ static int modify_key_op_poll(bContext *C)
static int insert_key_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
+ Object *obedit = CTX_data_edit_object(C);
+ bool ob_edit_mode = false;
KeyingSet *ks = NULL;
int type = RNA_enum_get(op->ptr, "type");
float cfra = (float)CFRA; // XXX for now, don't bother about all the yucky offset crap
@@ -1287,12 +1295,25 @@ static int insert_key_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "No active keying set");
return OPERATOR_CANCELLED;
}
+
+ /* exit the edit mode to make sure that those object data properties that have been
+ * updated since the last switching to the edit mode will be keyframed correctly
+ */
+ if (obedit && ANIM_keyingset_find_id(ks, (ID *)obedit->data)) {
+ ED_object_toggle_modes(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_toggle_modes(C, OB_MODE_EDIT);
+ }
+
/* report failure or do updates? */
if (success == MODIFYKEY_INVALID_CONTEXT) {
BKE_report(op->reports, RPT_ERROR, "No suitable context info for active keying set");
@@ -1304,7 +1325,7 @@ static int insert_key_exec(bContext *C, wmOperator *op)
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_EDITED, NULL);
+ 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");
@@ -1456,7 +1477,7 @@ static int delete_key_exec(bContext *C, wmOperator *op)
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_EDITED, NULL);
+ 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");
@@ -1709,7 +1730,7 @@ static int insert_key_button_exec(bContext *C, wmOperator *op)
uiContextAnimUpdate(C);
/* send notifiers that keyframes have been changed */
- WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
}
return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
@@ -1780,7 +1801,7 @@ static int delete_key_button_exec(bContext *C, wmOperator *op)
uiContextAnimUpdate(C);
/* send notifiers that keyframes have been changed */
- WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL);
}
return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
@@ -1850,7 +1871,7 @@ static int clear_key_button_exec(bContext *C, wmOperator *op)
uiContextAnimUpdate(C);
/* send notifiers that keyframes have been changed */
- WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL);
}
return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index 3e7009337a8..ad2db0d9c66 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -39,8 +39,6 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
-#include "BLI_math.h"
-#include "BLI_dynstr.h"
#include "BLI_utildefines.h"
#include "DNA_anim_types.h"
@@ -641,6 +639,16 @@ void ANIM_keyingset_infos_exit(void)
BKE_keyingsets_free(&builtin_keyingsets);
}
+/* Check if the ID appears in the paths specified by the KeyingSet */
+bool ANIM_keyingset_find_id(KeyingSet *ks, ID *id)
+{
+ /* sanity checks */
+ if (ELEM(NULL, ks, id))
+ return false;
+
+ return BLI_findptr(&ks->paths, id, offsetof(KS_Path, id)) != NULL;
+}
+
/* ******************************************* */
/* KEYING SETS API (for UI) */
@@ -916,7 +924,7 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe
ReportList *reports = CTX_wm_reports(C);
KS_Path *ksp;
int kflag = 0, success = 0;
- char *groupname = NULL;
+ const char *groupname = NULL;
/* sanity checks */
if (ks == NULL)
@@ -1009,7 +1017,7 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe
}
/* send notifiers for updates (this doesn't require context to work!) */
- WM_main_add_notifier(NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
+ WM_main_add_notifier(NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
}
/* return the number of channels successfully affected */
diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c
index 52a8137f27f..16975eed75e 100644
--- a/source/blender/editors/armature/armature_add.c
+++ b/source/blender/editors/armature/armature_add.c
@@ -312,7 +312,7 @@ void updateDuplicateSubtargetObjects(EditBone *dupBone, ListBase *editbones, Obj
/* does this constraint have a subtarget in
* this armature?
*/
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(curcon);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(curcon);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c
index e5e4ee9bf08..c5aa81c3a37 100644
--- a/source/blender/editors/armature/armature_edit.c
+++ b/source/blender/editors/armature/armature_edit.c
@@ -203,36 +203,42 @@ void ED_armature_origin_set(Scene *scene, Object *ob, float cursor[3], int cente
float ED_rollBoneToVector(EditBone *bone, const float align_axis[3], const bool axis_only)
{
float mat[3][3], nor[3];
+ float vec[3], align_axis_proj[3], roll = 0.0f;
+
+ BLI_ASSERT_UNIT_V3(align_axis);
sub_v3_v3v3(nor, bone->tail, bone->head);
+
+ /* if tail == head! */
+ if (is_zero_v3(nor)) {
+ return roll;
+ }
+
vec_roll_to_mat3(nor, 0.0f, mat);
-
+
/* check the bone isn't aligned with the axis */
- if (!is_zero_v3(align_axis) && angle_v3v3(align_axis, mat[2]) > FLT_EPSILON) {
- float vec[3], align_axis_proj[3], roll;
-
- /* project the new_up_axis along the normal */
- project_v3_v3v3(vec, align_axis, nor);
- sub_v3_v3v3(align_axis_proj, align_axis, vec);
-
- if (axis_only) {
- if (angle_v3v3(align_axis_proj, mat[2]) > (float)(M_PI / 2.0)) {
- negate_v3(align_axis_proj);
- }
- }
-
- roll = angle_v3v3(align_axis_proj, mat[2]);
-
- cross_v3_v3v3(vec, mat[2], align_axis_proj);
-
- if (dot_v3v3(vec, nor) < 0) {
- roll = -roll;
- }
-
+ if (dot_v3v3(align_axis, mat[2]) >= (1.0f - FLT_EPSILON)) {
return roll;
}
- return 0.0f;
+ /* project the new_up_axis along the normal */
+ project_v3_v3v3(vec, align_axis, nor);
+ sub_v3_v3v3(align_axis_proj, align_axis, vec);
+
+ if (axis_only) {
+ if (angle_v3v3(align_axis_proj, mat[2]) > (float)(M_PI_2)) {
+ negate_v3(align_axis_proj);
+ }
+ }
+
+ roll = angle_v3v3(align_axis_proj, mat[2]);
+
+ cross_v3_v3v3(vec, mat[2], align_axis_proj);
+
+ if (dot_v3v3(vec, nor) < 0.0f) {
+ return -roll;
+ }
+ return roll;
}
@@ -253,9 +259,9 @@ static EnumPropertyItem prop_calc_roll_types[] = {
{CALC_ROLL_TAN_X, "X", 0, "Local X Tangent", ""},
{CALC_ROLL_TAN_Z, "Z", 0, "Local Z Tangent", ""},
- {CALC_ROLL_X, "X", 0, "Global X Axis", ""},
- {CALC_ROLL_Y, "Y", 0, "Global Y Axis", ""},
- {CALC_ROLL_Z, "Z", 0, "Global Z Axis", ""},
+ {CALC_ROLL_X, "GLOBAL_X", 0, "Global X Axis", ""},
+ {CALC_ROLL_Y, "GLOBAL_Y", 0, "Global Y Axis", ""},
+ {CALC_ROLL_Z, "GLOBAL_Z", 0, "Global Z Axis", ""},
{CALC_ROLL_ACTIVE, "ACTIVE", 0, "Active Bone", ""},
{CALC_ROLL_VIEW, "VIEW", 0, "View Axis", ""},
@@ -1221,7 +1227,7 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op))
}
else {
for (con = pchan->constraints.first; con; con = con->next) {
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h
index f3db9042879..1d054ffc2e9 100644
--- a/source/blender/editors/armature/armature_intern.h
+++ b/source/blender/editors/armature/armature_intern.h
@@ -133,7 +133,6 @@ void POSE_OT_rotation_mode_set(struct wmOperatorType *ot);
void POSE_OT_quaternions_flip(struct wmOperatorType *ot);
-void POSE_OT_armature_layers(struct wmOperatorType *ot);
void POSE_OT_bone_layers(struct wmOperatorType *ot);
/* ******************************************************* */
diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c
index c214dc35fbf..9afc45955bd 100644
--- a/source/blender/editors/armature/armature_naming.c
+++ b/source/blender/editors/armature/armature_naming.c
@@ -104,7 +104,7 @@ static void constraint_bone_name_fix(Object *ob, ListBase *conlist, const char *
bConstraintTarget *ct;
for (curcon = conlist->first; curcon; curcon = curcon->next) {
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(curcon);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(curcon);
ListBase targets = {NULL, NULL};
/* constraint targets */
diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c
index f3c23c1f202..b7e38546ca2 100644
--- a/source/blender/editors/armature/armature_ops.c
+++ b/source/blender/editors/armature/armature_ops.c
@@ -139,7 +139,6 @@ void ED_operatortypes_armature(void)
WM_operatortype_append(POSE_OT_quaternions_flip);
- WM_operatortype_append(POSE_OT_armature_layers);
WM_operatortype_append(POSE_OT_bone_layers);
WM_operatortype_append(POSE_OT_propagate);
@@ -284,7 +283,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
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);
@@ -385,7 +384,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
/* armature/bone layers */
WM_keymap_add_item(keymap, "ARMATURE_OT_layers_show_all", ACCENTGRAVEKEY, KM_PRESS, KM_CTRL, 0);
- WM_keymap_add_item(keymap, "POSE_OT_armature_layers", MKEY, KM_PRESS, KM_SHIFT, 0);
+ 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);
/* special transforms: */
diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c
index 21f769bb3ed..e4ba8728e55 100644
--- a/source/blender/editors/armature/armature_relations.c
+++ b/source/blender/editors/armature/armature_relations.c
@@ -40,7 +40,6 @@
#include "BLF_translation.h"
#include "BKE_action.h"
-#include "BKE_armature.h"
#include "BKE_constraint.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
@@ -73,7 +72,7 @@ static void joined_armature_fix_links_constraints(
bConstraint *con;
for (con = lb->first; con; con = con->next) {
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
@@ -300,7 +299,7 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
if (ob->type == OB_ARMATURE) {
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
for (con = pchan->constraints.first; con; con = con->next) {
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
@@ -338,7 +337,7 @@ 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) {
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c
index e420e56fdb0..9c3c93e4850 100644
--- a/source/blender/editors/armature/armature_select.c
+++ b/source/blender/editors/armature/armature_select.c
@@ -80,13 +80,15 @@ void *get_bone_from_selectbuffer(Scene *scene, Base *base, unsigned int *buffer,
EditBone *ebone;
void *firstunSel = NULL, *firstSel = NULL, *data;
unsigned int hitresult;
- short i, takeNext = 0, sel;
+ short i;
+ bool takeNext = false;
for (i = 0; i < hits; i++) {
hitresult = buffer[3 + (i * 4)];
- if (!(hitresult & BONESEL_NOSEL)) { // -1
- if (hitresult & BONESEL_ANY) { // to avoid including objects in selection
+ if (!(hitresult & BONESEL_NOSEL)) {
+ if (hitresult & BONESEL_ANY) { /* to avoid including objects in selection */
+ bool sel;
hitresult &= ~(BONESEL_ANY);
/* Determine what the current bone is */
@@ -305,7 +307,7 @@ static EditBone *get_nearest_editbonepoint(ViewContext *vc, const int mval[2],
if (hits > 0) {
if (hits == 1) {
- if (!(buffer[3] & BONESEL_NOSEL))
+ if (!(buffer[3] & BONESEL_NOSEL))
besthitresult = buffer[3];
}
else {
diff --git a/source/blender/editors/armature/armature_skinning.c b/source/blender/editors/armature/armature_skinning.c
index 560af2dbd0b..e898e600e9b 100644
--- a/source/blender/editors/armature/armature_skinning.c
+++ b/source/blender/editors/armature/armature_skinning.c
@@ -191,7 +191,7 @@ static void add_vgroups__mapFunc(void *userData, int index, const float co[3],
static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], int numbones, Bone **bonelist,
bDeformGroup **dgrouplist, bDeformGroup **dgroupflip,
- float (*root)[3], float (*tip)[3], int *selected, float scale)
+ float (*root)[3], float (*tip)[3], const int *selected, float scale)
{
/* Create vertex group weights from envelopes */
diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c
index 52e3285d240..97f69d86aee 100644
--- a/source/blender/editors/armature/armature_utils.c
+++ b/source/blender/editors/armature/armature_utils.c
@@ -216,6 +216,31 @@ void ED_armature_ebone_to_mat4(EditBone *ebone, float mat[4][4])
copy_v3_v3(mat[3], ebone->head);
}
+void ED_armature_ebone_from_mat3(EditBone *ebone, float mat[3][3])
+{
+ float vec[3], roll;
+ const float len = len_v3v3(ebone->head, ebone->tail);
+
+ mat3_to_vec_roll(mat, vec, &roll);
+
+ madd_v3_v3v3fl(ebone->tail, ebone->head, vec, len);
+ ebone->roll = roll;
+}
+
+void ED_armature_ebone_from_mat4(EditBone *ebone, float mat[4][4])
+{
+ float mat3[3][3];
+
+ copy_m3_m4(mat3, mat);
+ /* We want normalized matrix here, to be consistent with ebone_to_mat. */
+ BLI_ASSERT_UNIT_M3(mat3);
+
+ sub_v3_v3(ebone->tail, ebone->head);
+ copy_v3_v3(ebone->head, mat[3]);
+ add_v3_v3(ebone->tail, mat[3]);
+ ED_armature_ebone_from_mat3(ebone, mat3);
+}
+
/**
* Return a pointer to the bone of the given name
*/
@@ -482,7 +507,7 @@ static void fix_bonelist_roll(ListBase *bonelist, ListBase *editbonelist)
print_m4("difmat", difmat);
printf("Roll = %f\n", RAD2DEGF(-atan2(difmat[2][0], difmat[2][2])));
#endif
- curBone->roll = (float)-atan2(difmat[2][0], difmat[2][2]);
+ curBone->roll = -atan2f(difmat[2][0], difmat[2][2]);
/* and set restposition again */
BKE_armature_where_is_bone(curBone, curBone->parent);
diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c
index 8f71f722525..647b640ee61 100644
--- a/source/blender/editors/armature/editarmature_retarget.c
+++ b/source/blender/editors/armature/editarmature_retarget.c
@@ -40,7 +40,6 @@
#include "BKE_constraint.h"
#include "BKE_armature.h"
#include "BKE_context.h"
-#include "BKE_scene.h"
#include "ED_armature.h"
#include "ED_util.h"
@@ -708,7 +707,7 @@ static void RIG_reconnectControlBones(RigGraph *rg)
/* DO SOME MAGIC HERE */
for (pchan = rg->ob->pose->chanbase.first; pchan; pchan = pchan->next) {
for (con = pchan->constraints.first; con; con = con->next) {
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
@@ -833,7 +832,7 @@ static void RIG_reconnectControlBones(RigGraph *rg)
/* DO SOME MAGIC HERE */
for (pchan = rg->ob->pose->chanbase.first; pchan; pchan = pchan->next) {
for (con = pchan->constraints.first; con; con = con->next) {
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
@@ -1684,7 +1683,7 @@ static RetargetMode detectArcRetargetMode(RigArc *iarc)
if (nb_edges > 2) {
for (edge = iarc->edges.first; edge; edge = edge->next) {
- if (fabs(edge->angle - avg_angle) > M_PI / 6) {
+ if (fabsf(edge->angle - avg_angle) > (float)(M_PI / 6)) {
large_angle = 1;
}
}
@@ -1795,7 +1794,7 @@ static float costLength(float original_length, float current_length, float lengt
return MAX_COST;
}
else {
- float length_ratio = fabs((current_length - original_length) / original_length);
+ float length_ratio = fabsf((current_length - original_length) / original_length);
return length_weight * length_ratio * length_ratio;
}
}
diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c
index a1ba76c3c08..475ffd23617 100644
--- a/source/blender/editors/armature/editarmature_sketch.c
+++ b/source/blender/editors/armature/editarmature_sketch.c
@@ -932,7 +932,6 @@ static void sk_projectDrawPoint(bContext *C, float vec[3], SK_Stroke *stk, SK_Dr
zfac = ED_view3d_calc_zfac(ar->regiondata, fp, NULL);
- /* method taken from editview.c - mouse_cursor() */
if (ED_view3d_project_short_global(ar, fp, cval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
VECSUB2D(mval_f, cval, dd->mval);
ED_view3d_win_to_delta(ar, mval_f, dvec, zfac);
diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c
index c2a54c6d9f8..56e7bde0081 100644
--- a/source/blender/editors/armature/meshlaplacian.c
+++ b/source/blender/editors/armature/meshlaplacian.c
@@ -1209,7 +1209,7 @@ static void harmonic_ray_callback(void *userdata, int index, const BVHTreeRay *r
}
}
-static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, float *co1, float *co2)
+static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, const float co1[3], const float co2[3])
{
MDefBoundIsect *isect;
BVHTreeRayHit hit;
@@ -1218,14 +1218,23 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, float
void *data[3] = {mdb->cagedm->getTessFaceArray(mdb->cagedm), mdb, &isect_mdef};
MFace *mface1 = data[0], *mface;
float vert[4][3], len, end[3];
- static float epsilon[3] = {0, 0, 0}; //1e-4, 1e-4, 1e-4};
+ // static float epsilon[3] = {1e-4, 1e-4, 1e-4};
+
+ /* happens binding when a cage has no faces */
+ if (UNLIKELY(mdb->bvhtree == NULL))
+ return NULL;
/* setup isec */
memset(&isect_mdef, 0, sizeof(isect_mdef));
isect_mdef.lambda = 1e10f;
+#if 0
add_v3_v3v3(isect_mdef.start, co1, epsilon);
add_v3_v3v3(end, co2, epsilon);
+#else
+ copy_v3_v3(isect_mdef.start, co1);
+ copy_v3_v3(end, co2);
+#endif
sub_v3_v3v3(isect_mdef.vec, end, isect_mdef.start);
hit.index = -1;
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c
index b354facb9b3..de8b2e36d5b 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -36,12 +36,10 @@
#include "DNA_anim_types.h"
#include "DNA_armature_types.h"
-#include "DNA_constraint_types.h"
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
#include "BKE_anim.h"
-#include "BKE_action.h"
#include "BKE_armature.h"
#include "BKE_context.h"
#include "BKE_deform.h"
@@ -124,7 +122,7 @@ void ED_armature_exit_posemode(bContext *C, Base *base)
/* if a selected or active bone is protected, throw error (oonly if warn == 1) and return 1 */
/* only_selected == 1: the active bone is allowed to be protected */
#if 0 /* UNUSED 2.5 */
-static short pose_has_protected_selected(Object *ob, short warn)
+static bool pose_has_protected_selected(Object *ob, short warn)
{
/* check protection */
if (ob->proxy) {
@@ -424,7 +422,7 @@ static void pose_copy_menu(Scene *scene)
/* copy constraints to tmpbase and apply 'local' tags before
* appending to list of constraints for this channel
*/
- BKE_copy_constraints(&tmp_constraints, &pchanact->constraints, true);
+ BKE_constraints_copy(&tmp_constraints, &pchanact->constraints, true);
if ((ob->proxy) && (pchan->bone->layer & arm->layer_protected)) {
bConstraint *con;
@@ -536,7 +534,7 @@ static void pose_copy_menu(Scene *scene)
/* copy constraints to tmpbase and apply 'local' tags before
* appending to list of constraints for this channel
*/
- BKE_copy_constraints(&tmp_constraints, &const_copy, true);
+ BKE_constraints_copy(&tmp_constraints, &const_copy, true);
if ((ob->proxy) && (pchan->bone->layer & arm->layer_protected)) {
/* add proxy-local tags */
for (con = tmp_constraints.first; con; con = con->next)
@@ -707,17 +705,37 @@ void POSE_OT_rotation_mode_set(wmOperatorType *ot)
/* ********************************************** */
-/* Show all armature layers */
-static int pose_armature_layers_showall_poll(bContext *C)
+static int armature_layers_poll(bContext *C)
{
- /* this single operator can be used in posemode OR editmode for armatures */
+ /* Armature layers operators can be used in posemode OR editmode for armatures */
return ED_operator_posemode(C) || ED_operator_editarmature(C);
}
+static bArmature *armature_layers_get_data(Object **ob)
+{
+ bArmature *arm = NULL;
+
+ /* Sanity checking and handling of posemode. */
+ if (*ob) {
+ Object *tob = BKE_object_pose_armature_get(*ob);
+ if (tob) {
+ *ob = tob;
+ arm = (*ob)->data;
+ }
+ else if ((*ob)->type == OB_ARMATURE) {
+ arm = (*ob)->data;
+ }
+ }
+
+ return arm;
+}
+
+/* Show all armature layers */
+
static int pose_armature_layers_showall_exec(bContext *C, wmOperator *op)
{
- Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
- bArmature *arm = (ob) ? ob->data : NULL;
+ Object *ob = CTX_data_active_object(C);
+ bArmature *arm = armature_layers_get_data(&ob);
PointerRNA ptr;
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... */
@@ -754,7 +772,7 @@ void ARMATURE_OT_layers_show_all(wmOperatorType *ot)
/* callbacks */
ot->exec = pose_armature_layers_showall_exec;
- ot->poll = pose_armature_layers_showall_poll;
+ ot->poll = armature_layers_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -766,10 +784,10 @@ void ARMATURE_OT_layers_show_all(wmOperatorType *ot)
/* ------------------- */
/* Present a popup to get the layers that should be used */
-static int pose_armature_layers_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+static int armature_layers_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
- bArmature *arm = (ob) ? ob->data : NULL;
+ Object *ob = CTX_data_active_object(C);
+ 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... */
@@ -787,13 +805,14 @@ static int pose_armature_layers_invoke(bContext *C, wmOperator *op, const wmEven
}
/* Set the visible layers for the active armature (edit and pose modes) */
-static int pose_armature_layers_exec(bContext *C, wmOperator *op)
+static int armature_layers_exec(bContext *C, wmOperator *op)
{
- Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
+ Object *ob = CTX_data_active_object(C);
+ 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... */
- if (ELEM(NULL, ob, ob->data)) {
+ if (arm == NULL) {
return OPERATOR_CANCELLED;
}
@@ -801,7 +820,7 @@ static int pose_armature_layers_exec(bContext *C, wmOperator *op)
RNA_boolean_get_array(op->ptr, "layers", layers);
/* get pointer for armature, and write data there... */
- RNA_id_pointer_create((ID *)ob->data, &ptr);
+ RNA_id_pointer_create((ID *)arm, &ptr);
RNA_boolean_set_array(&ptr, "layers", layers);
/* note, notifier might evolve */
@@ -810,26 +829,6 @@ static int pose_armature_layers_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-
-void POSE_OT_armature_layers(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Change Armature Layers";
- ot->idname = "POSE_OT_armature_layers";
- ot->description = "Change the visible armature layers";
-
- /* callbacks */
- ot->invoke = pose_armature_layers_invoke;
- ot->exec = pose_armature_layers_exec;
- ot->poll = ED_operator_posemode;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* properties */
- RNA_def_boolean_layer_member(ot->srna, "layers", 32, NULL, "Layer", "Armature layers to make visible");
-}
-
void ARMATURE_OT_armature_layers(wmOperatorType *ot)
{
/* identifiers */
@@ -838,9 +837,9 @@ void ARMATURE_OT_armature_layers(wmOperatorType *ot)
ot->description = "Change the visible armature layers";
/* callbacks */
- ot->invoke = pose_armature_layers_invoke;
- ot->exec = pose_armature_layers_exec;
- ot->poll = ED_operator_editarmature;
+ ot->invoke = armature_layers_invoke;
+ ot->exec = armature_layers_exec;
+ ot->poll = armature_layers_poll;
/* 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 f77a3da06fb..3f4f720ccdb 100644
--- a/source/blender/editors/armature/pose_lib.c
+++ b/source/blender/editors/armature/pose_lib.c
@@ -610,6 +610,7 @@ void POSELIB_OT_pose_remove(wmOperatorType *ot)
/* 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);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
ot->prop = prop;
}
@@ -699,6 +700,7 @@ void POSELIB_OT_pose_rename(wmOperatorType *ot)
ot->prop = RNA_def_string(ot->srna, "name", "RenamedPose", 64, "New Pose Name", "New name for pose");
prop = RNA_def_enum(ot->srna, "pose", DummyRNA_NULL_items, 0, "Pose", "The pose to rename");
RNA_def_enum_funcs(prop, poselib_stored_pose_itemf);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
}
/* ************************************************************* */
@@ -878,7 +880,7 @@ static void poselib_apply_pose(tPoseLib_PreviewData *pld)
pchan = BKE_pose_channel_find_name(pose, agrp->name);
if (pchan) {
- short ok = 0;
+ bool ok = 0;
/* check if this bone should get any animation applied */
if (pld->selcount == 0) {
diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c
index a852f47ba4b..d783c1dcfde 100644
--- a/source/blender/editors/armature/pose_select.c
+++ b/source/blender/editors/armature/pose_select.c
@@ -43,7 +43,6 @@
#include "BKE_armature.h"
#include "BKE_constraint.h"
#include "BKE_context.h"
-#include "BKE_deform.h"
#include "BKE_depsgraph.h"
#include "BKE_object.h"
@@ -464,7 +463,7 @@ static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op
{
if (pchan->bone->flag & BONE_SELECTED) {
for (con = pchan->constraints.first; con; con = con->next) {
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c
index 56cc5c5b1ee..375cbb0fe2b 100644
--- a/source/blender/editors/armature/pose_slide.c
+++ b/source/blender/editors/armature/pose_slide.c
@@ -300,7 +300,7 @@ static void pose_slide_apply_props(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
*/
for (ld = pfl->fcurves.first; ld; ld = ld->next) {
FCurve *fcu = (FCurve *)ld->data;
- char *bPtr, *pPtr;
+ const char *bPtr, *pPtr;
if (fcu->rna_path == NULL)
continue;
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 9c0909b67f2..2fdc9ff846b 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -897,7 +897,7 @@ static void calc_shapeKeys(Object *obedit)
}
else {
int index;
- float *curofp;
+ const float *curofp;
if (oldkey) {
if (nu->bezt) {
@@ -1111,7 +1111,7 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves)
next = fcu->next;
if (!strncmp(fcu->rna_path, "splines", 7)) {
- char *ch = strchr(fcu->rna_path, '.');
+ const char *ch = strchr(fcu->rna_path, '.');
if (ch && (!strncmp(ch, ".bezier_points", 14) || !strncmp(ch, ".points", 7)))
fcurve_remove(adt, orig_curves, fcu);
@@ -2971,7 +2971,7 @@ static void select_adjacent_cp(ListBase *editnurb, short next,
BezTriple *bezt;
BPoint *bp;
int a;
- short lastsel = false;
+ bool lastsel = false;
if (next == 0) return;
@@ -3141,7 +3141,7 @@ void CURVE_OT_de_select_last(wmOperatorType *ot)
/******************* de select all operator ***************/
-static short nurb_has_selected_cps(ListBase *editnurb)
+static bool nurb_has_selected_cps(ListBase *editnurb)
{
Nurb *nu;
BezTriple *bezt;
@@ -4216,7 +4216,7 @@ static void make_selection_list_nurb(ListBase *editnurb)
}
}
-static void merge_2_nurb(wmOperator *op, ListBase *editnurb, Nurb *nu1, Nurb *nu2)
+static void merge_2_nurb(wmOperator *op, Curve *cu, ListBase *editnurb, Nurb *nu1, Nurb *nu2)
{
BPoint *bp, *bp1, *bp2, *temp;
float len1, len2;
@@ -4331,10 +4331,12 @@ static void merge_2_nurb(wmOperator *op, ListBase *editnurb, Nurb *nu1, Nurb *nu
for (u = 0; u < nu1->pntsu; u++, bp++) {
if (u < origu) {
+ keyIndex_updateBP(cu->editnurb, bp1, bp, 1);
*bp = *bp1; bp1++;
select_bpoint(bp, SELECT, SELECT, HIDDEN);
}
else {
+ keyIndex_updateBP(cu->editnurb, bp2, bp, 1);
*bp = *bp2; bp2++;
}
}
@@ -4356,9 +4358,10 @@ static void merge_2_nurb(wmOperator *op, ListBase *editnurb, Nurb *nu1, Nurb *nu
static int merge_nurb(bContext *C, wmOperator *op)
{
Object *obedit = CTX_data_edit_object(C);
+ Curve *cu = obedit->data;
ListBase *editnurb = object_editcurve_get(obedit);
NurbSort *nus1, *nus2;
- int ok = 1;
+ bool ok = true;
make_selection_list_nurb(editnurb);
@@ -4405,7 +4408,7 @@ static int merge_nurb(bContext *C, wmOperator *op)
}
while (nus2) {
- merge_2_nurb(op, editnurb, nus1->nu, nus2->nu);
+ merge_2_nurb(op, cu, editnurb, nus1->nu, nus2->nu);
nus2 = nus2->next;
}
@@ -4427,7 +4430,7 @@ static int make_segment_exec(bContext *C, wmOperator *op)
ListBase *nubase = object_editcurve_get(obedit);
Nurb *nu, *nu1 = NULL, *nu2 = NULL;
BPoint *bp;
- int ok = 0;
+ bool ok = false;
/* int a; */ /* UNUSED */
/* first decide if this is a surface merge! */
@@ -4552,6 +4555,7 @@ static int make_segment_exec(bContext *C, wmOperator *op)
nu1->bezt = bezt;
nu1->pntsu += nu2->pntsu;
BLI_remlink(nubase, nu2);
+ keyIndex_delNurb(cu->editnurb, nu2);
BKE_nurb_free(nu2); nu2 = NULL;
BKE_nurb_handles_calc(nu1);
}
@@ -4576,6 +4580,7 @@ static int make_segment_exec(bContext *C, wmOperator *op)
BKE_nurb_knot_calc_u(nu1);
}
+ keyIndex_delNurb(cu->editnurb, nu2);
BKE_nurb_free(nu2); nu2 = NULL;
}
@@ -4913,7 +4918,7 @@ static int addvert_Nurb(bContext *C, short mode, float location[3])
BezTriple *bezt, *newbezt = NULL;
BPoint *bp, *newbp = NULL;
float imat[4][4], temp[3];
- int ok = 0;
+ bool ok = false;
BezTriple *bezt_recalc[3] = {NULL};
invert_m4_m4(imat, obedit->obmat);
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c
index 5c067e80619..5c448effcd5 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -34,12 +34,6 @@
#include <wchar.h>
#include <errno.h>
-#ifndef WIN32
-# include <unistd.h>
-#else
-# include <io.h>
-#endif
-
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
@@ -57,7 +51,6 @@
#include "BKE_curve.h"
#include "BKE_depsgraph.h"
#include "BKE_font.h"
-#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_object.h"
#include "BKE_report.h"
@@ -716,7 +709,7 @@ static EnumPropertyItem style_items[] = {
{0, NULL, 0, NULL, NULL}
};
-static int set_style(bContext *C, const int style, const int clear)
+static int set_style(bContext *C, const int style, const bool clear)
{
Object *obedit = CTX_data_edit_object(C);
Curve *cu = obedit->data;
@@ -742,7 +735,7 @@ static int set_style(bContext *C, const int style, const int clear)
static int set_style_exec(bContext *C, wmOperator *op)
{
const int style = RNA_enum_get(op->ptr, "style");
- const int clear = RNA_boolean_get(op->ptr, "clear");
+ const bool clear = RNA_boolean_get(op->ptr, "clear");
return set_style(C, style, clear);
}
@@ -1790,7 +1783,7 @@ static int font_open_exec(bContext *C, wmOperator *op)
static int open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
VFont *vfont = NULL;
- char *path;
+ const char *path;
PointerRNA idptr;
PropertyPointerRNA *pprop;
@@ -1879,7 +1872,7 @@ static void undoFont_to_editFont(void *strv, void *ecu, void *UNUSED(obdata))
{
Curve *cu = (Curve *)ecu;
EditFont *ef = cu->editfont;
- char *str = strv;
+ const char *str = strv;
ef->pos = *((short *)str);
ef->len = *((short *)(str + 2));
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index a4597b6bf6c..38dd9048790 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -36,7 +36,6 @@
#include "BLI_sys_types.h"
-#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
@@ -44,10 +43,9 @@
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
-#include "DNA_userdef_types.h"
#include "DNA_view3d_types.h"
+#include "DNA_userdef_types.h"
-#include "BKE_blender.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_gpencil.h"
@@ -58,7 +56,6 @@
#include "BIF_glutil.h"
#include "ED_gpencil.h"
-#include "ED_sequencer.h"
#include "ED_view3d.h"
#include "gpencil_intern.h"
@@ -475,7 +472,7 @@ static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s,
/* draw a set of strokes */
static void gp_draw_strokes(bGPDframe *gpf, int offsx, int offsy, int winx, int winy, int dflag,
- short debug, short lthick, float color[4])
+ short debug, short lthick, const float color[4])
{
bGPDstroke *gps;
diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c
index 8fcbee6f758..f5bf1422488 100644
--- a/source/blender/editors/gpencil/editaction_gpencil.c
+++ b/source/blender/editors/gpencil/editaction_gpencil.c
@@ -37,7 +37,6 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
-#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "DNA_gpencil_types.h"
@@ -46,7 +45,6 @@
#include "BKE_fcurve.h"
#include "BKE_gpencil.h"
-#include "ED_anim_api.h"
#include "ED_gpencil.h"
#include "ED_keyframes_edit.h"
#include "ED_markers.h"
diff --git a/source/blender/editors/gpencil/gpencil_buttons.c b/source/blender/editors/gpencil/gpencil_buttons.c
index 481323992d0..0fe4d7e7157 100644
--- a/source/blender/editors/gpencil/gpencil_buttons.c
+++ b/source/blender/editors/gpencil/gpencil_buttons.c
@@ -33,7 +33,6 @@
#include <stdlib.h>
#include <stddef.h>
-#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLF_translation.h"
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 092951be3da..d25de906e31 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -52,7 +52,6 @@
#include "DNA_view3d_types.h"
#include "DNA_gpencil_types.h"
-#include "BKE_animsys.h"
#include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_depsgraph.h"
@@ -456,10 +455,8 @@ static void gp_strokepoint_convertcoords(bContext *C, bGPDstroke *gps, bGPDspoin
/* get screen coordinate */
if (gps->flag & GP_STROKE_2DSPACE) {
- int mvali[2];
View2D *v2d = &ar->v2d;
- UI_view2d_view_to_region(v2d, pt->x, pt->y, mvali, mvali + 1);
- VECCOPY2D(mvalf, mvali);
+ UI_view2d_view_to_region_fl(v2d, pt->x, pt->y, &mvalf[0], &mvalf[1]);
}
else {
if (subrect) {
@@ -472,9 +469,6 @@ static void gp_strokepoint_convertcoords(bContext *C, bGPDstroke *gps, bGPDspoin
}
}
- /* convert screen coordinate to 3d coordinates
- * - method taken from editview.c - mouse_cursor()
- */
ED_view3d_win_to_3d(ar, fp, mvalf, p3d);
}
}
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 65f205c2f2f..2f941142d9e 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -275,9 +275,9 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3]
*/
}
else {
- int mval_prj[2];
+ float mval_prj[2];
float rvec[3], dvec[3];
- float mval_f[2];
+ float mval_f[2] = {UNPACK2(mval)};
float zfac;
/* Current method just converts each point in screen-coordinates to
@@ -291,11 +291,9 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3]
gp_get_3d_reference(p, rvec);
zfac = ED_view3d_calc_zfac(p->ar->regiondata, rvec, NULL);
-
- /* method taken from editview.c - mouse_cursor() */
- /* TODO, use ED_view3d_project_float_global */
- if (ED_view3d_project_int_global(p->ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
- VECSUB2D(mval_f, mval_prj, mval);
+
+ 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);
sub_v3_v3v3(out, rvec, dvec);
}
@@ -909,7 +907,7 @@ static void gp_point_to_xy(ARegion *ar, View2D *v2d, rctf *subrect, bGPDstroke *
}
}
else if (gps->flag & GP_STROKE_2DSPACE) {
- UI_view2d_view_to_region(v2d, pt->x, pt->y, r_x, r_y);
+ UI_view2d_view_to_region_clip(v2d, pt->x, pt->y, r_x, r_y);
}
else {
if (subrect == NULL) { /* normal 3D view */
diff --git a/source/blender/editors/include/BIF_gl.h b/source/blender/editors/include/BIF_gl.h
index a3d3d8f05a2..477a7c0ce17 100644
--- a/source/blender/editors/include/BIF_gl.h
+++ b/source/blender/editors/include/BIF_gl.h
@@ -38,9 +38,12 @@
#ifdef __APPLE__
/* hacking pointsize and linewidth */
-#define glPointSize(f) glPointSize(U.pixelsize*(f))
-#define glLineWidth(f) glLineWidth(U.pixelsize*(f))
-
+# define glPointSize(f) glPointSize(U.pixelsize * (f))
+# define glLineWidth(f) glLineWidth(U.pixelsize * (f))
+#else
+ /* avoid include mismatch by referencing 'U' from both */
+# define glPointSize(f) glPointSize(((void)U.pixelsize, (f)))
+# define glLineWidth(f) glLineWidth(((void)U.pixelsize, (f)))
#endif
/*
diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h
index dc3fe66cbea..10f3f1bef4c 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -48,6 +48,7 @@ struct Object;
struct bDopeSheet;
+struct bAction;
struct bActionGroup;
struct FCurve;
struct FModifier;
@@ -162,7 +163,7 @@ typedef enum eAnim_ChannelType {
ANIMTYPE_GPDATABLOCK,
ANIMTYPE_GPLAYER,
-
+
ANIMTYPE_MASKDATABLOCK,
ANIMTYPE_MASKLAYER,
@@ -361,6 +362,13 @@ bool ANIM_animdata_context_getdata(bAnimContext *ac);
/* ------------------------ Drawing TypeInfo -------------------------- */
+/* role or level of animchannel in the hierarchy */
+typedef enum eAnimChannel_Role {
+ ACHANNEL_ROLE_EXPANDER = -1, /* datablock expander - a "composite" channel type */
+ ACHANNEL_ROLE_SPECIAL = 0, /* special purposes - not generally for hierarchy processing */
+ ACHANNEL_ROLE_CHANNEL = 1 /* data channel - a channel representing one of the actual building blocks of channels */
+} eAnimChannel_Role;
+
/* flag-setting behavior */
typedef enum eAnimChannels_SetFlag {
ACHANNEL_SETFLAG_CLEAR = 0, /* turn off */
@@ -376,17 +384,20 @@ typedef enum eAnimChannel_Settings {
ACHANNEL_SETTING_MUTE = 2,
ACHANNEL_SETTING_EXPAND = 3,
ACHANNEL_SETTING_VISIBLE = 4, /* only for Graph Editor */
- ACHANNEL_SETTING_SOLO = 5 /* only for NLA Tracks */
+ ACHANNEL_SETTING_SOLO = 5, /* only for NLA Tracks */
+ ACHANNEL_SETTING_PINNED = 6 /* only for NLA Actions */
} eAnimChannel_Settings;
/* Drawing, mouse handling, and flag setting behavior... */
typedef struct bAnimChannelType {
- /* type data */
+ /* -- Type data -- */
/* name of the channel type, for debugging */
const char *channel_type_name;
+ /* "level" or role in hierarchy - for finding the active channel */
+ eAnimChannel_Role channel_role;
- /* drawing */
+ /* -- 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]);
/* draw backdrop strip for channel */
@@ -403,16 +414,16 @@ typedef struct bAnimChannelType {
/* get icon (for channel lists) */
int (*icon)(bAnimListElem *ale);
- /* settings */
+ /* -- Settings -- */
/* check if the given setting is valid in the current context */
- bool (*has_setting)(bAnimContext *ac, bAnimListElem *ale, int setting);
+ bool (*has_setting)(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting);
/* get the flag used for this setting */
- int (*setting_flag)(bAnimContext *ac, int setting, bool *neg);
+ int (*setting_flag)(bAnimContext *ac, eAnimChannel_Settings setting, bool *neg);
/* get the pointer to int/short where data is stored,
* with type being sizeof(ptr_data) which should be fine for runtime use...
* - assume that setting has been checked to be valid for current context
*/
- void *(*setting_ptr)(bAnimListElem *ale, int setting, short *type);
+ void *(*setting_ptr)(bAnimListElem *ale, eAnimChannel_Settings setting, short *type);
} bAnimChannelType;
/* ------------------------ Drawing API -------------------------- */
@@ -454,7 +465,7 @@ void ANIM_channel_setting_set(bAnimContext *ac, bAnimListElem *ale, int setting,
* - setting: type of setting to set
* - on: whether the visibility setting has been enabled or disabled
*/
-void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAnimListElem *ale_setting, int setting, short on);
+void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAnimListElem *ale_setting, int setting, short mode);
/* Deselect all animation channels */
@@ -511,12 +522,12 @@ void free_fmodifiers_copybuf(void);
* assuming that the buffer has been cleared already with free_fmodifiers_copybuf()
* - active: only copy the active modifier
*/
-short ANIM_fmodifiers_copy_to_buf(ListBase *modifiers, short active);
+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
*/
-short ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, short replace);
+bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace);
/* ************************************************* */
/* ASSORTED TOOLS */
@@ -530,6 +541,14 @@ int getname_anim_fcurve(char *name, struct ID *id, struct FCurve *fcu);
/* Automatically determine a color for the nth F-Curve */
void getcolor_fcurve_rainbow(int cur, int tot, float out[3]);
+/* ----------------- NLA Drawing ----------------------- */
+/* NOTE: Technically, this is not in the animation module (it's in space_nla)
+ * but these are sometimes needed by various animation apis.
+ */
+
+/* Get color to use for NLA Action channel's background */
+void nla_action_get_color(struct AnimData *adt, struct bAction *act, float color[4]);
+
/* ----------------- NLA-Mapping ----------------------- */
/* anim_draw.c */
@@ -537,7 +556,7 @@ void getcolor_fcurve_rainbow(int cur, int tot, float out[3]);
struct AnimData *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale);
/* Apply/Unapply NLA mapping to all keyframes in the nominated F-Curve */
-void ANIM_nla_mapping_apply_fcurve(struct AnimData *adt, struct FCurve *fcu, short restore, short only_keys);
+void ANIM_nla_mapping_apply_fcurve(struct AnimData *adt, struct FCurve *fcu, bool restore, bool only_keys);
/* ..... */
diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h
index 4cf2257f6a1..7579f6cba65 100644
--- a/source/blender/editors/include/ED_armature.h
+++ b/source/blender/editors/include/ED_armature.h
@@ -90,7 +90,7 @@ typedef struct EditBone {
#define BONESEL_BONE (1 << 30)
#define BONESEL_ANY (BONESEL_TIP | BONESEL_ROOT | BONESEL_BONE)
-#define BONESEL_NOSEL (1 << 31) /* Indicates a negative number */
+#define BONESEL_NOSEL (1u << 31u)
/* useful macros */
#define EBONE_VISIBLE(arm, ebone) ( \
@@ -143,6 +143,9 @@ EditBone *ED_armature_bone_find_shared_parent(EditBone *ebone_child[], const uns
void ED_armature_ebone_to_mat3(EditBone *ebone, float mat[3][3]);
void ED_armature_ebone_to_mat4(EditBone *ebone, float mat[4][4]);
+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 transform_armature_mirror_update(struct Object *obedit);
void ED_armature_origin_set(struct Scene *scene, struct Object *ob, float cursor[3], int centermode, int around);
diff --git a/source/blender/editors/include/ED_buttons.h b/source/blender/editors/include/ED_buttons.h
index 5cc399fdcee..64c16605dec 100644
--- a/source/blender/editors/include/ED_buttons.h
+++ b/source/blender/editors/include/ED_buttons.h
@@ -34,6 +34,7 @@ bool ED_texture_context_check_world(const struct bContext *C);
bool ED_texture_context_check_material(const struct bContext *C);
bool ED_texture_context_check_lamp(const struct bContext *C);
bool ED_texture_context_check_particles(const struct bContext *C);
+bool ED_texture_context_check_linestyle(const struct bContext *C);
bool ED_texture_context_check_others(const struct bContext *C);
#endif /* __ED_BUTTONS_H__ */
diff --git a/source/blender/editors/include/ED_clip.h b/source/blender/editors/include/ED_clip.h
index 91f8b39f7b9..5f8ebd87d19 100644
--- a/source/blender/editors/include/ED_clip.h
+++ b/source/blender/editors/include/ED_clip.h
@@ -63,7 +63,7 @@ int ED_space_clip_get_clip_frame_number(struct SpaceClip *sc);
struct ImBuf *ED_space_clip_get_buffer(struct SpaceClip *sc);
struct ImBuf *ED_space_clip_get_stable_buffer(struct SpaceClip *sc, float loc[2], float *scale, float *angle);
-bool ED_space_clip_color_sample(struct SpaceClip *sc, struct ARegion *ar, int mval[2], float r_col[3]);
+bool ED_space_clip_color_sample(struct Scene *scene, struct SpaceClip *sc, struct ARegion *ar, int mval[2], float r_col[3]);
void ED_clip_update_frame(const struct Main *mainp, int cfra);
bool ED_clip_view_selection(const struct bContext *C, struct ARegion *ar, bool fit);
diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h
index adb147d4ff0..b15a83809f5 100644
--- a/source/blender/editors/include/ED_image.h
+++ b/source/blender/editors/include/ED_image.h
@@ -47,7 +47,7 @@ void ED_space_image_set(struct SpaceImage *sima, struct Scene *scene, s
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);
-bool ED_space_image_color_sample(struct SpaceImage *sima, struct ARegion *ar, int mval[2], float r_col[3]);
+bool ED_space_image_color_sample(struct Scene *scene, struct SpaceImage *sima, struct ARegion *ar, int mval[2], float r_col[3]);
struct ImBuf *ED_space_image_acquire_buffer(struct SpaceImage *sima, void **lock_r);
void ED_space_image_release_buffer(struct SpaceImage *sima, struct ImBuf *ibuf, void *lock);
bool ED_space_image_has_buffer(struct SpaceImage *sima);
diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h
index 7543e170c9d..5c7b3c531be 100644
--- a/source/blender/editors/include/ED_keyframing.h
+++ b/source/blender/editors/include/ED_keyframing.h
@@ -202,6 +202,9 @@ struct KeyingSet *ANIM_builtin_keyingset_get_named(struct KeyingSet *prevKS, con
/* Find KeyingSet type info given a name */
KeyingSetInfo *ANIM_keyingset_info_find_name(const char name[]);
+/* Find a given ID in the KeyingSet */
+bool ANIM_keyingset_find_id(struct KeyingSet *ks, ID *id);
+
/* for RNA type registrations... */
void ANIM_keyingset_info_register(KeyingSetInfo *ksi);
void ANIM_keyingset_info_unregister(struct Main *bmain, KeyingSetInfo *ksi);
diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h
index b26dddd6f42..824c82a0069 100644
--- a/source/blender/editors/include/ED_node.h
+++ b/source/blender/editors/include/ED_node.h
@@ -108,7 +108,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 Scene *scene, 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_sculpt.h b/source/blender/editors/include/ED_sculpt.h
index 6105db14d6a..8fcb228803b 100644
--- a/source/blender/editors/include/ED_sculpt.h
+++ b/source/blender/editors/include/ED_sculpt.h
@@ -45,16 +45,9 @@ void ED_operatortypes_sculpt(void);
void sculpt_get_redraw_planes(float planes[4][4], struct ARegion *ar,
struct RegionView3D *rv3d, struct Object *ob);
void ED_sculpt_get_average_stroke(struct Object *ob, float stroke[3]);
-int ED_sculpt_minmax(struct bContext *C, float min[3], float max[3]);
-int ED_sculpt_mask_layers_ensure(struct Object *ob,
- struct MultiresModifierData *mmd);
+bool ED_sculpt_minmax(struct bContext *C, float min[3], float max[3]);
int do_sculpt_mask_box_select(struct ViewContext *vc, struct rcti *rect, bool select, bool extend);
-enum {
- ED_SCULPT_MASK_LAYER_CALC_VERT = (1 << 0),
- ED_SCULPT_MASK_LAYER_CALC_LOOP = (1 << 1)
-};
-
/* paint_ops.c */
void ED_operatortypes_paint(void);
void ED_keymap_paint(struct wmKeyConfig *keyconf);
diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h
index 35f12a47f82..41ff9b88da9 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -103,7 +103,7 @@ enum TfmMode {
* returns 1 if successful, 0 otherwise (usually means there's no selection)
* (if 0 is returns, *vec is unmodified)
* */
-int calculateTransformCenter(struct bContext *C, int centerMode, float cent3d[3], float cent2d[2]);
+bool calculateTransformCenter(struct bContext *C, int centerMode, float cent3d[3], float cent2d[2]);
struct TransInfo;
struct ScrArea;
diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h
index f268595ff52..6d9f1c4eda0 100644
--- a/source/blender/editors/include/ED_util.h
+++ b/source/blender/editors/include/ED_util.h
@@ -79,14 +79,6 @@ void undo_editmode_push(struct bContext *C, const char *name,
void undo_editmode_clear(void);
-/* crazyspace.c */
-float (*crazyspace_get_mapped_editverts(struct Scene *scene, struct Object *obedit))[3];
-void crazyspace_set_quats_editmesh(struct BMEditMesh *em, float (*origcos)[3], float (*mappedcos)[3], float (*quats)[4],
- const bool use_select);
-void crazyspace_set_quats_mesh(struct Mesh *me, float (*origcos)[3], float (*mappedcos)[3], float (*quats)[4]);
-int sculpt_get_first_deform_matrices(struct Scene *scene, struct Object *ob, float (**deformmats)[3][3], float (**deformcos)[3]);
-void crazyspace_build_sculpt(struct Scene *scene, struct Object *ob, float (**deformmats)[3][3], float (**deformcos)[3]);
-
/* cut-paste buffer free */
void ED_clipboard_posebuf_free(void);
diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h
index 4e15f3ee881..c776026a811 100644
--- a/source/blender/editors/include/UI_icons.h
+++ b/source/blender/editors/include/UI_icons.h
@@ -616,9 +616,7 @@ DEF_ICON(NEXT_KEYFRAME)
DEF_ICON(PLAY_AUDIO)
DEF_ICON(PLAY_REVERSE)
DEF_ICON(PREVIEW_RANGE)
-#ifndef DEF_ICON_BLANK_SKIP
- DEF_ICON(BLANK180)
-#endif
+DEF_ICON(ACTION_TWEAK)
DEF_ICON(PMARKER_ACT)
DEF_ICON(PMARKER_SEL)
DEF_ICON(PMARKER)
@@ -640,25 +638,25 @@ DEF_ICON(SOLO_OFF)
DEF_ICON(SOLO_ON)
DEF_ICON(FRAME_PREV)
DEF_ICON(FRAME_NEXT)
+DEF_ICON(NLA_PUSHDOWN)
+DEF_ICON(IPO_CONSTANT)
+DEF_ICON(IPO_LINEAR)
+DEF_ICON(IPO_BEZIER)
+DEF_ICON(IPO_SINE)
+DEF_ICON(IPO_QUAD)
+DEF_ICON(IPO_CUBIC)
+DEF_ICON(IPO_QUART)
+DEF_ICON(IPO_QUINT)
+DEF_ICON(IPO_EXPO)
+DEF_ICON(IPO_CIRC)
+DEF_ICON(IPO_BOUNCE)
+DEF_ICON(IPO_ELASTIC)
+DEF_ICON(IPO_BACK)
+DEF_ICON(IPO_EASE_IN)
+DEF_ICON(IPO_EASE_OUT)
+DEF_ICON(IPO_EASE_IN_OUT)
#ifndef DEF_ICON_BLANK_SKIP
/* available */
- DEF_ICON(BLANK186)
- DEF_ICON(BLANK187)
- DEF_ICON(BLANK188)
- DEF_ICON(BLANK189)
- DEF_ICON(BLANK190)
- DEF_ICON(BLANK191)
- DEF_ICON(BLANK192)
- DEF_ICON(BLANK193)
- DEF_ICON(BLANK194)
- DEF_ICON(BLANK195)
- DEF_ICON(BLANK196)
- DEF_ICON(BLANK197)
- DEF_ICON(BLANK198)
- DEF_ICON(BLANK199)
- DEF_ICON(BLANK200)
- DEF_ICON(BLANK201)
- DEF_ICON(BLANK202)
DEF_ICON(BLANK203)
DEF_ICON(BLANK204)
DEF_ICON(BLANK205)
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 7eb39fd4b3c..8de9650ddef 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -173,6 +173,8 @@ enum {
UI_BUT_COLOR_CUBIC = (1 << 23), /* cubic saturation for the color wheel */
UI_BUT_LIST_ITEM = (1 << 24), /* This but is "inside" a list item (currently used to change theme colors). */
UI_BUT_DRAG_MULTI = (1 << 25), /* edit this button as well as the active button (not just dragging) */
+ UI_BUT_SCA_LINK_GREY = (1 << 26), /* used to flag if sca links shoud be grey out */
+ UI_BUT_HAS_SEP_CHAR = (1 << 27), /* but->str contains UI_SEP_CHAR, used for key shortcuts */
};
#define UI_PANEL_WIDTH 340
@@ -432,7 +434,7 @@ void uiButSetDragName(uiBut *but, const char *name);
void uiButSetDragValue(uiBut *but);
void uiButSetDragImage(uiBut *but, const char *path, int icon, struct ImBuf *ima, float scale);
-int UI_but_active_drop_name(struct bContext *C);
+bool UI_but_active_drop_name(struct bContext *C);
void uiButSetFlag(uiBut *but, int flag);
void uiButClearFlag(uiBut *but, int flag);
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index 1208446e14d..cb7cf3ee404 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -34,6 +34,8 @@
#ifndef __UI_VIEW2D_H__
#define __UI_VIEW2D_H__
+#include "BLI_compiler_attrs.h"
+
/* ------------------------------------------ */
/* Settings and Defines: */
@@ -190,28 +192,39 @@ void UI_view2d_listview_visible_cells(struct View2D *v2d, float columnwidth, flo
int *row_min, int *row_max);
/* coordinate conversion */
-void UI_view2d_region_to_view(struct View2D *v2d, float x, float y, float *viewx, float *viewy);
-void UI_view2d_view_to_region(struct View2D *v2d, float x, float y, int *regionx, int *regiony);
-void UI_view2d_to_region_no_clip(struct View2D *v2d, float x, float y, int *regionx, int *region_y);
-void UI_view2d_to_region_float(struct View2D *v2d, float x, float y, float *regionx, float *regiony);
+float UI_view2d_region_to_view_x(struct View2D *v2d, float x);
+float UI_view2d_region_to_view_y(struct View2D *v2d, float y);
+void UI_view2d_region_to_view(struct View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL();
+void UI_view2d_region_to_view_rctf(struct View2D *v2d, const struct rctf *rect_src, struct rctf *rect_dst) ATTR_NONNULL();
+
+float UI_view2d_view_to_region_x(struct View2D *v2d, float x);
+float UI_view2d_view_to_region_y(struct View2D *v2d, float y);
+bool UI_view2d_view_to_region_clip(struct View2D *v2d, float x, float y, int *r_region_x, int *r_region_y) ATTR_NONNULL();
+
+void UI_view2d_view_to_region(struct View2D *v2d, float x, float y, int *r_region_x, int *r_region_y) ATTR_NONNULL();
+void UI_view2d_view_to_region_fl(struct View2D *v2d, float x, float y, float *r_region_x, float *r_region_y) ATTR_NONNULL();
+void UI_view2d_view_to_region_rcti(struct View2D *v2d, const struct rctf *rect_src, struct rcti *rect_dst) ATTR_NONNULL();
+bool UI_view2d_view_to_region_rcti_clip(struct View2D *v2d, const struct rctf *rect_src, struct rcti *rect_dst) ATTR_NONNULL();
/* utilities */
struct View2D *UI_view2d_fromcontext(const struct bContext *C);
struct View2D *UI_view2d_fromcontext_rwin(const struct bContext *C);
-void UI_view2d_getscale(struct View2D *v2d, float *x, float *y);
-void UI_view2d_getscale_inverse(struct View2D *v2d, float *x, float *y);
+void UI_view2d_scale_get(struct View2D *v2d, float *x, float *y);
+void UI_view2d_scale_get_inverse(struct View2D *v2d, float *x, float *y);
-void UI_view2d_getcenter(struct View2D *v2d, float *x, float *y);
-void UI_view2d_setcenter(struct View2D *v2d, float x, float y);
+void UI_view2d_center_get(struct View2D *v2d, float *x, float *y);
+void UI_view2d_center_set(struct View2D *v2d, float x, float y);
void UI_view2d_offset(struct View2D *v2d, float xfac, float yfac);
short UI_view2d_mouse_in_scrollers(const struct bContext *C, struct View2D *v2d, int x, int y);
/* cached text drawing in v2d, to allow pixel-aligned draw as post process */
-void UI_view2d_text_cache_add(struct View2D *v2d, float x, float y, const char *str, const char col[4]);
-void UI_view2d_text_cache_rectf(struct View2D *v2d, const struct rctf *rect, const char *str, const char col[4]);
+void UI_view2d_text_cache_add(struct View2D *v2d, float x, float y,
+ const char *str, size_t str_len, const char col[4]);
+void UI_view2d_text_cache_add_rectf(struct View2D *v2d, const struct rctf *rect_view,
+ const char *str, size_t str_len, const char col[4]);
void UI_view2d_text_cache_draw(struct ARegion *ar);
/* operators */
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 8a4233a97b0..19d4e32152f 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -45,7 +45,6 @@
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
-#include "BLI_path_util.h"
#include "BLI_rect.h"
#include "BLI_utildefines.h"
@@ -98,6 +97,19 @@ bool ui_block_is_menu(const uiBlock *block)
((block->flag & UI_BLOCK_KEEP_OPEN) == 0));
}
+static bool ui_is_but_unit_radians_ex(UnitSettings *unit, const int unit_type)
+{
+ return (unit->system_rotation == USER_UNIT_ROT_RADIANS && unit_type == PROP_UNIT_ROTATION);
+}
+
+static bool ui_is_but_unit_radians(const uiBut *but)
+{
+ UnitSettings *unit = but->block->unit;
+ const int unit_type = uiButGetUnitType(but);
+
+ return ui_is_but_unit_radians_ex(unit, unit_type);
+}
+
/* ************* window matrix ************** */
void ui_block_to_window_fl(const ARegion *ar, uiBlock *block, float *x, float *y)
@@ -207,43 +219,41 @@ void ui_block_translate(uiBlock *block, int x, int y)
static void ui_text_bounds_block(uiBlock *block, float offset)
{
uiStyle *style = UI_GetStyle();
- uiBut *bt;
- int i = 0, j, x1addval = offset, nextcol;
- int lastcol = 0, col = 0;
-
+ uiBut *bt, *init_col_bt, *col_bt;
+ int i = 0, j, x1addval = offset;
+
uiStyleFontSet(&style->widget);
-
- for (bt = block->buttons.first; bt; bt = bt->next) {
+
+ for (init_col_bt = bt = block->buttons.first; bt; bt = bt->next) {
if (!ELEM(bt->type, SEPR, SEPRLINE)) {
j = BLF_width(style->widget.uifont_id, bt->drawstr, sizeof(bt->drawstr));
- if (j > i) i = j;
+ if (j > i)
+ i = j;
}
- if (bt->next && bt->rect.xmin < bt->next->rect.xmin)
- lastcol++;
- }
+ if (bt->next && bt->rect.xmin < bt->next->rect.xmin) {
+ /* End of this column, and it’s not the last one. */
+ for (col_bt = init_col_bt; col_bt->prev != bt; col_bt = col_bt->next) {
+ col_bt->rect.xmin = x1addval;
+ col_bt->rect.xmax = x1addval + i + block->bounds;
- /* cope with multi collumns */
- bt = block->buttons.first;
- while (bt) {
- nextcol = (bt->next && bt->rect.xmin < bt->next->rect.xmin);
-
- bt->rect.xmin = x1addval;
- bt->rect.xmax = bt->rect.xmin + i + block->bounds;
-
- if (col == lastcol) {
- bt->rect.xmax = max_ff(bt->rect.xmax, offset + block->minbounds);
- }
+ ui_check_but(col_bt); /* clips text again */
+ }
- ui_check_but(bt); /* clips text again */
-
- if (nextcol) {
+ /* And we prepare next column. */
x1addval += i + block->bounds;
- col++;
+ i = 0;
+ init_col_bt = col_bt;
}
-
- bt = bt->next;
+ }
+
+ /* Last column. */
+ for (col_bt = init_col_bt; col_bt; col_bt = col_bt->next) {
+ col_bt->rect.xmin = x1addval;
+ col_bt->rect.xmax = max_ff(x1addval + i + block->bounds, offset + block->minbounds);
+
+ ui_check_but(col_bt); /* clips text again */
}
}
@@ -431,10 +441,15 @@ void uiExplicitBoundsBlock(uiBlock *block, int minx, int miny, int maxx, int max
static int ui_but_float_precision(uiBut *but, double value)
{
- int prec;
+ int prec = (int)but->a2;
- /* first check if prec is 0 and fallback to a simple default */
- if ((prec = (int)but->a2) == -1) {
+ /* first check for various special cases:
+ * * If button is radians, we want additional precision (see T39861).
+ * * If prec is not set, we fallback to a simple default */
+ if (ui_is_but_unit_radians(but) && prec < 5) {
+ prec = 5;
+ }
+ else if (prec == -1) {
prec = (but->hardmax < 10.001f) ? 3 : 2;
}
@@ -445,7 +460,7 @@ static int ui_but_float_precision(uiBut *but, double value)
/* link line drawing is not part of buttons or theme.. so we stick with it here */
-static void ui_draw_linkline(uiLinkLine *line, int highlightActiveLines)
+static void ui_draw_linkline(uiLinkLine *line, int highlightActiveLines, int dashInactiveLines)
{
rcti rect;
@@ -456,11 +471,13 @@ static void ui_draw_linkline(uiLinkLine *line, int highlightActiveLines)
rect.xmax = BLI_rctf_cent_x(&line->to->rect);
rect.ymax = BLI_rctf_cent_y(&line->to->rect);
- if (line->flag & UI_SELECT)
+ if (dashInactiveLines)
+ UI_ThemeColor(TH_GRID);
+ else if (line->flag & UI_SELECT)
glColor3ub(100, 100, 100);
else if (highlightActiveLines && ((line->from->flag & UI_ACTIVE) || (line->to->flag & UI_ACTIVE)))
UI_ThemeColor(TH_TEXT_HI);
- else
+ else
glColor3ub(0, 0, 0);
ui_draw_link_bezier(&rect);
@@ -471,7 +488,8 @@ static void ui_draw_links(uiBlock *block)
uiBut *but;
uiLinkLine *line;
- /* Draw the inactive lines (lines with neither button being hovered over).
+ /* Draw the grey out lines. Do this first so they appear at the
+ * bottom of inactive or active lines.
* As we go, remember if we see any active or selected lines. */
bool found_selectline = false;
bool found_activeline = false;
@@ -479,8 +497,10 @@ static void ui_draw_links(uiBlock *block)
for (but = block->buttons.first; but; but = but->next) {
if (but->type == LINK && but->link) {
for (line = but->link->lines.first; line; line = line->next) {
- if (!(line->from->flag & UI_ACTIVE) && !(line->to->flag & UI_ACTIVE))
- ui_draw_linkline(line, 0);
+ if (!(line->from->flag & UI_ACTIVE) && !(line->to->flag & UI_ACTIVE)) {
+ if (line->deactive)
+ ui_draw_linkline(line, 0, true);
+ }
else
found_activeline = true;
@@ -490,14 +510,26 @@ static void ui_draw_links(uiBlock *block)
}
}
+ /* Draw the inactive lines (lines with neither button being hovered over) */
+ for (but = block->buttons.first; but; but = but->next) {
+ if (but->type == LINK && but->link) {
+ for (line = but->link->lines.first; line; line = line->next) {
+ if (!(line->from->flag & UI_ACTIVE) && !(line->to->flag & UI_ACTIVE)) {
+ if (!line->deactive)
+ ui_draw_linkline(line, 0, false);
+ }
+ }
+ }
+ }
+
/* Draw any active lines (lines with either button being hovered over).
- * Do this last so they appear on top of inactive lines. */
+ * Do this last so they appear on top of inactive and grey out lines. */
if (found_activeline) {
for (but = block->buttons.first; but; but = but->next) {
if (but->type == LINK && but->link) {
for (line = but->link->lines.first; line; line = line->next) {
if ((line->from->flag & UI_ACTIVE) || (line->to->flag & UI_ACTIVE))
- ui_draw_linkline(line, !found_selectline);
+ ui_draw_linkline(line, !found_selectline, false);
}
}
}
@@ -854,11 +886,12 @@ static void ui_menu_block_set_keyaccels(uiBlock *block)
void ui_but_add_shortcut(uiBut *but, const char *shortcut_str, const bool do_strip)
{
- if (do_strip) {
- char *cpoin = strchr(but->str, UI_SEP_CHAR);
+ if (do_strip && (but->flag & UI_BUT_HAS_SEP_CHAR)) {
+ char *cpoin = strrchr(but->str, UI_SEP_CHAR);
if (cpoin) {
*cpoin = '\0';
}
+ but->flag &= ~UI_BUT_HAS_SEP_CHAR;
}
/* without this, just allow stripping of the shortcut */
@@ -877,6 +910,7 @@ void ui_but_add_shortcut(uiBut *but, const char *shortcut_str, const bool do_str
butstr_orig, shortcut_str);
MEM_freeN(butstr_orig);
but->str = but->strdata;
+ but->flag |= UI_BUT_HAS_SEP_CHAR;
ui_check_but(but);
}
}
@@ -1264,7 +1298,7 @@ void uiDrawBlock(const bContext *C, uiBlock *block)
*/
int ui_is_but_push_ex(uiBut *but, double *value)
{
- int is_push = false;
+ int is_push = 0;
if (but->bit) {
const bool state = ELEM3(but->type, TOGN, ICONTOGN, OPTIONN) ? false : true;
@@ -1350,7 +1384,7 @@ static uiBut *ui_find_inlink(uiBlock *block, void *poin)
return NULL;
}
-static void ui_add_link_line(ListBase *listb, uiBut *but, uiBut *bt)
+static void ui_add_link_line(ListBase *listb, uiBut *but, uiBut *bt, short deactive)
{
uiLinkLine *line;
@@ -1358,6 +1392,7 @@ static void ui_add_link_line(ListBase *listb, uiBut *but, uiBut *bt)
BLI_addtail(listb, line);
line->from = but;
line->to = bt;
+ line->deactive = deactive;
}
uiBut *uiFindInlink(uiBlock *block, void *poin)
@@ -1384,14 +1419,25 @@ void uiComposeLinks(uiBlock *block)
for (a = 0; a < *(link->totlink); a++) {
bt = ui_find_inlink(block, (*ppoin)[a]);
if (bt) {
- ui_add_link_line(&link->lines, but, bt);
+ if ((but->flag & UI_BUT_SCA_LINK_GREY) || (bt->flag & UI_BUT_SCA_LINK_GREY)) {
+ ui_add_link_line(&link->lines, but, bt, true);
+ }
+ else {
+ ui_add_link_line(&link->lines, but, bt, false);
+ }
+
}
}
}
else if (link->poin) {
bt = ui_find_inlink(block, *(link->poin) );
if (bt) {
- ui_add_link_line(&link->lines, but, bt);
+ if ((but->flag & UI_BUT_SCA_LINK_GREY) || (bt->flag & UI_BUT_SCA_LINK_GREY)) {
+ ui_add_link_line(&link->lines, but, bt, true);
+ }
+ else {
+ ui_add_link_line(&link->lines, but, bt, false);
+ }
}
}
}
@@ -1489,14 +1535,14 @@ void ui_get_but_vectorf(uiBut *but, float vec[3])
}
}
else if (but->pointype == UI_BUT_POIN_CHAR) {
- char *cp = (char *)but->poin;
+ const char *cp = (char *)but->poin;
vec[0] = ((float)cp[0]) / 255.0f;
vec[1] = ((float)cp[1]) / 255.0f;
vec[2] = ((float)cp[2]) / 255.0f;
}
else if (but->pointype == UI_BUT_POIN_FLOAT) {
- float *fp = (float *)but->poin;
+ const float *fp = (float *)but->poin;
copy_v3_v3(vec, fp);
}
else {
@@ -1584,7 +1630,7 @@ bool ui_is_but_unit(const uiBut *but)
return false;
#if 1 /* removed so angle buttons get correct snapping */
- if (unit->system_rotation == USER_UNIT_ROT_RADIANS && unit_type == PROP_UNIT_ROTATION)
+ if (ui_is_but_unit_radians_ex(unit, unit_type))
return false;
#endif
@@ -1862,7 +1908,7 @@ void ui_convert_to_unit_alt_name(uiBut *but, char *str, size_t maxlen)
static void ui_get_but_string_unit(uiBut *but, char *str, int len_max, double value, bool pad, int float_precision)
{
UnitSettings *unit = but->block->unit;
- int do_split = (unit->flag & USER_UNIT_OPT_SPLIT) != 0;
+ const bool do_split = (unit->flag & USER_UNIT_OPT_SPLIT) != 0;
int unit_type = uiButGetUnitType(but);
int precision;
@@ -1873,7 +1919,7 @@ static void ui_get_but_string_unit(uiBut *but, char *str, int len_max, double va
/* Sanity checks */
precision = (int)but->a2;
if (precision > UI_PRECISION_FLOAT_MAX) precision = UI_PRECISION_FLOAT_MAX;
- else if (precision == -1) precision = 2;
+ else if (precision == -1) precision = 2;
}
else {
precision = float_precision;
@@ -2651,7 +2697,7 @@ void ui_check_but(uiBut *but)
/* if we are doing text editing, this will override the drawstr */
if (but->editstr)
- BLI_strncpy(but->drawstr, but->editstr, UI_MAX_DRAW_STR);
+ but->drawstr[0] = '\0';
/* text clipping moved to widget drawing code itself */
}
@@ -3089,7 +3135,7 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu
column_end = totitems;
for (b = a + 1; b < totitems; b++) {
- item = &item_array[ b];
+ item = &item_array[b];
/* new column on N rows or on separation label */
if (((b - a) % rows == 0) || (!item->identifier[0] && item->name)) {
diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c
index d44802803da..f0f08358013 100644
--- a/source/blender/editors/interface/interface_anim.c
+++ b/source/blender/editors/interface/interface_anim.c
@@ -117,10 +117,19 @@ bool ui_but_anim_expression_set(uiBut *but, const char *str)
if (fcu && driven) {
driver = fcu->driver;
- if (driver && driver->type == DRIVER_TYPE_PYTHON) {
+ if (driver && (driver->type == DRIVER_TYPE_PYTHON)) {
BLI_strncpy_utf8(driver->expression, str, sizeof(driver->expression));
+
+ /* tag driver as needing to be recompiled */
driver->flag |= DRIVER_FLAG_RECOMPILE;
+
+ /* clear invalid flags which may prevent this from working */
+ driver->flag &= ~DRIVER_FLAG_INVALID;
+ fcu->flag &= ~FCURVE_DISABLED;
+
+ /* this notifier should update the Graph Editor and trigger depsgraph refresh? */
WM_event_add_notifier(but->block->evil_C, NC_ANIMATION | ND_KEYFRAME, NULL);
+
return true;
}
}
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 2d13159261b..d0f238bc5ba 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -32,7 +32,6 @@
#include <string.h>
#include "DNA_color_types.h"
-#include "DNA_object_types.h"
#include "DNA_screen_types.h"
#include "DNA_movieclip_types.h"
@@ -456,7 +455,7 @@ static void draw_scope_end(const rctf *rect, GLint *scissor)
}
static void histogram_draw_one(float r, float g, float b, float alpha,
- float x, float y, float w, float h, float *data, int res, const bool is_line)
+ float x, float y, float w, float h, const float *data, int res, const bool is_line)
{
int i;
@@ -749,12 +748,12 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
static float polar_to_x(float center, float diam, float ampli, float angle)
{
- return center + diam *ampli * cosf(angle);
+ return center + diam * ampli * cosf(angle);
}
static float polar_to_y(float center, float diam, float ampli, float angle)
{
- return center + diam *ampli * sinf(angle);
+ return center + diam * ampli * sinf(angle);
}
static void vectorscope_draw_target(float centerx, float centery, float diam, const float colf[3])
@@ -1132,7 +1131,6 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
/* layer: box outline */
glColor4f(0.0, 0.0, 0.0, 1.0);
fdrawbox(x1, y1, x1 + sizex, rect->ymax);
- glEnd();
/* layer: box outline */
glEnable(GL_BLEND);
@@ -1484,7 +1482,8 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti *recti)
{
rctf rect;
- int ok = 0, width, height;
+ bool ok = false;
+ int width, height;
GLint scissor[4];
MovieClipScopes *scopes = (MovieClipScopes *)but->poin;
@@ -1523,9 +1522,9 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
IMB_freeImBuf(scopes->track_preview);
tmpibuf = BKE_tracking_sample_pattern(scopes->frame_width, scopes->frame_height,
- scopes->track_search, scopes->track,
- &scopes->undist_marker, true, scopes->use_track_mask,
- width, height, scopes->track_pos);
+ scopes->track_search, scopes->track,
+ &scopes->undist_marker, true, scopes->use_track_mask,
+ width, height, scopes->track_pos);
if (tmpibuf) {
if (tmpibuf->rect_float)
@@ -1612,14 +1611,14 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol
static const float size = 5.0f;
/* 16 values of sin function */
- static float si[16] = {
+ const float si[16] = {
0.00000000f, 0.39435585f, 0.72479278f, 0.93775213f,
0.99871650f, 0.89780453f, 0.65137248f, 0.29936312f,
-0.10116832f, -0.48530196f, -0.79077573f, -0.96807711f,
-0.98846832f, -0.84864425f, -0.57126821f, -0.20129852f
};
/* 16 values of cos function */
- static float co[16] = {
+ const float co[16] = {
1.00000000f, 0.91895781f, 0.68896691f, 0.34730525f,
-0.05064916f, -0.44039415f, -0.75875812f, -0.95413925f,
-0.99486932f, -0.87434661f, -0.61210598f, -0.25065253f,
diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c
index 023a0cd6fcb..5b7915e20c5 100644
--- a/source/blender/editors/interface/interface_eyedropper.c
+++ b/source/blender/editors/interface/interface_eyedropper.c
@@ -149,7 +149,7 @@ static void eyedropper_color_sample_fl(bContext *C, Eyedropper *UNUSED(eye), int
int mval[2] = {mx - ar->winrct.xmin,
my - ar->winrct.ymin};
- if (ED_space_image_color_sample(sima, ar, mval, r_col)) {
+ if (ED_space_image_color_sample(CTX_data_scene(C), sima, ar, mval, r_col)) {
return;
}
}
@@ -161,7 +161,7 @@ static void eyedropper_color_sample_fl(bContext *C, Eyedropper *UNUSED(eye), int
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(CTX_data_scene(C), snode, ar, mval, r_col)) {
return;
}
}
@@ -173,7 +173,7 @@ static void eyedropper_color_sample_fl(bContext *C, Eyedropper *UNUSED(eye), int
int mval[2] = {mx - ar->winrct.xmin,
my - ar->winrct.ymin};
- if (ED_space_clip_color_sample(sc, ar, mval, r_col)) {
+ if (ED_space_clip_color_sample(CTX_data_scene(C), sc, ar, mval, r_col)) {
return;
}
}
@@ -476,8 +476,9 @@ static void datadropper_id_sample_pt(bContext *C, DataDropper *ddr, int mx, int
if (sa->spacetype == SPACE_VIEW3D) {
ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
if (ar && BLI_rcti_isect_pt(&ar->winrct, mx, my)) {
- int mval[2] = {mx - ar->winrct.xmin,
- my - ar->winrct.ymin};
+ const int mval[2] = {
+ mx - ar->winrct.xmin,
+ my - ar->winrct.ymin};
Base *base;
CTX_wm_area_set(C, sa);
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index c69472b74b0..2da04ed56f3 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -1675,7 +1675,9 @@ static void ui_but_drop(bContext *C, const wmEvent *event, uiBut *but, uiHandleB
/* c = copy, v = paste */
static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, char mode)
{
- char buf[UI_MAX_DRAW_STR + 1] = {0};
+ int buf_paste_len = 0;
+ const char *buf_paste = "";
+ bool buf_paste_alloc = false;
if (mode == 'v' && but->lock == true) {
return;
@@ -1690,14 +1692,18 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
if (mode == 'v') {
/* extract first line from clipboard in case of multi-line copies */
- int pbuf_len;
- char *pbuf = WM_clipboard_text_get_firstline(false, &pbuf_len);
- if (pbuf) {
- BLI_strncpy(buf, pbuf, sizeof(buf));
- MEM_freeN(pbuf);
+ const char *buf_paste_test;
+
+ buf_paste_test = WM_clipboard_text_get_firstline(false, &buf_paste_len);
+ if (buf_paste_test) {
+ buf_paste = buf_paste_test;
+ buf_paste_alloc = true;
}
}
-
+
+ /* No return from here down */
+
+
/* numeric value */
if (ELEM(but->type, NUM, NUMSLI)) {
@@ -1707,18 +1713,19 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
else if (mode == 'c') {
/* Get many decimal places, then strip trailing zeros.
* note: too high values start to give strange results (6 or so is ok) */
- ui_get_but_string_ex(but, buf, sizeof(buf), 6);
- BLI_str_rstrip_float_zero(buf, '\0');
+ char buf_copy[UI_MAX_DRAW_STR];
+ ui_get_but_string_ex(but, buf_copy, sizeof(buf_copy), 6);
+ BLI_str_rstrip_float_zero(buf_copy, '\0');
- WM_clipboard_text_set(buf, 0);
+ WM_clipboard_text_set(buf_copy, 0);
}
else {
double val;
- if (ui_set_but_string_eval_num(C, but, buf, &val)) {
+ if (ui_set_but_string_eval_num(C, but, buf_paste, &val)) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
data->value = val;
- ui_set_but_string(C, but, buf);
+ ui_set_but_string(C, but, buf_paste);
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
}
@@ -1732,12 +1739,13 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
/* pass */
}
else if (mode == 'c') {
+ char buf_copy[UI_MAX_DRAW_STR];
ui_get_but_vectorf(but, xyz);
- BLI_snprintf(buf, sizeof(buf), "[%f, %f, %f]", xyz[0], xyz[1], xyz[2]);
- WM_clipboard_text_set(buf, 0);
+ BLI_snprintf(buf_copy, sizeof(buf_copy), "[%f, %f, %f]", xyz[0], xyz[1], xyz[2]);
+ WM_clipboard_text_set(buf_copy, 0);
}
else {
- if (sscanf(buf, "[%f, %f, %f]", &xyz[0], &xyz[1], &xyz[2]) == 3) {
+ if (sscanf(buf_paste, "[%f, %f, %f]", &xyz[0], &xyz[1], &xyz[2]) == 3) {
if (normalize_v3(xyz) == 0.0f) {
/* better set Z up then have a zero vector */
xyz[2] = 1.0;
@@ -1758,6 +1766,8 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
/* pass */
}
else if (mode == 'c') {
+ char buf_copy[UI_MAX_DRAW_STR];
+
if (but->rnaprop && RNA_property_array_length(&but->rnapoin, but->rnaprop) == 4)
rgba[3] = RNA_property_float_get_index(&but->rnapoin, but->rnaprop, 3);
else
@@ -1768,12 +1778,12 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
srgb_to_linearrgb_v3_v3(rgba, rgba);
- BLI_snprintf(buf, sizeof(buf), "[%f, %f, %f, %f]", rgba[0], rgba[1], rgba[2], rgba[3]);
- WM_clipboard_text_set(buf, 0);
+ BLI_snprintf(buf_copy, sizeof(buf_copy), "[%f, %f, %f, %f]", rgba[0], rgba[1], rgba[2], rgba[3]);
+ WM_clipboard_text_set(buf_copy, 0);
}
else {
- if (sscanf(buf, "[%f, %f, %f, %f]", &rgba[0], &rgba[1], &rgba[2], &rgba[3]) == 4) {
+ if (sscanf(buf_paste, "[%f, %f, %f, %f]", &rgba[0], &rgba[1], &rgba[2], &rgba[3]) == 4) {
/* assume linear colors in buffer */
if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
linearrgb_to_srgb_v3_v3(rgba, rgba);
@@ -1797,7 +1807,6 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
}
else if (mode == 'c') {
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
- BLI_strncpy(buf, active_data->str, UI_MAX_DRAW_STR);
WM_clipboard_text_set(active_data->str, 0);
active_data->cancel = true;
button_activate_state(C, but, BUTTON_STATE_EXIT);
@@ -1805,8 +1814,10 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
else {
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
- if (ui_is_but_utf8(but)) BLI_strncpy_utf8(active_data->str, buf, active_data->maxlen);
- else BLI_strncpy(active_data->str, buf, active_data->maxlen);
+ if (ui_is_but_utf8(but))
+ BLI_strncpy_utf8(active_data->str, buf_paste, active_data->maxlen);
+ else
+ BLI_strncpy(active_data->str, buf_paste, active_data->maxlen);
if (ELEM(but->type, SEARCH_MENU, SEARCH_MENU_UNLINK)) {
/* else uiSearchboxData.active member is not updated [#26856] */
@@ -1819,43 +1830,39 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
/* colorband (not supported by system clipboard) */
else if (but->type == BUT_COLORBAND) {
if (mode == 'c') {
- if (but->poin == NULL)
- return;
-
- memcpy(&but_copypaste_coba, but->poin, sizeof(ColorBand));
+ if (but->poin != NULL) {
+ memcpy(&but_copypaste_coba, but->poin, sizeof(ColorBand));
+ }
}
else {
- if (but_copypaste_coba.tot == 0)
- return;
-
- if (!but->poin)
- but->poin = MEM_callocN(sizeof(ColorBand), "colorband");
+ if (but_copypaste_coba.tot != 0) {
+ if (!but->poin)
+ but->poin = MEM_callocN(sizeof(ColorBand), "colorband");
- button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
- memcpy(data->coba, &but_copypaste_coba, sizeof(ColorBand));
- button_activate_state(C, but, BUTTON_STATE_EXIT);
+ button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
+ memcpy(data->coba, &but_copypaste_coba, sizeof(ColorBand));
+ button_activate_state(C, but, BUTTON_STATE_EXIT);
+ }
}
}
else if (but->type == BUT_CURVE) {
if (mode == 'c') {
- if (but->poin == NULL)
- return;
-
- but_copypaste_curve_alive = true;
- curvemapping_free_data(&but_copypaste_curve);
- curvemapping_copy_data(&but_copypaste_curve, (CurveMapping *) but->poin);
+ if (but->poin != NULL) {
+ but_copypaste_curve_alive = true;
+ curvemapping_free_data(&but_copypaste_curve);
+ curvemapping_copy_data(&but_copypaste_curve, (CurveMapping *) but->poin);
+ }
}
else {
- if (!but_copypaste_curve_alive)
- return;
+ if (but_copypaste_curve_alive) {
+ if (!but->poin)
+ but->poin = MEM_callocN(sizeof(CurveMapping), "curvemapping");
- if (!but->poin)
- but->poin = MEM_callocN(sizeof(CurveMapping), "curvemapping");
-
- button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
- curvemapping_free_data((CurveMapping *) but->poin);
- curvemapping_copy_data((CurveMapping *) but->poin, &but_copypaste_curve);
- button_activate_state(C, but, BUTTON_STATE_EXIT);
+ button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
+ curvemapping_free_data((CurveMapping *) but->poin);
+ curvemapping_copy_data((CurveMapping *) but->poin, &but_copypaste_curve);
+ button_activate_state(C, but, BUTTON_STATE_EXIT);
+ }
}
}
/* operator button (any type) */
@@ -1881,6 +1888,10 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
WM_clipboard_text_set(str, 0);
}
}
+
+ if (buf_paste_alloc) {
+ MEM_freeN((void *)buf_paste);
+ }
}
/* ************************ password text ******************************
@@ -1993,7 +2004,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con
origstr = MEM_mallocN(sizeof(char) * data->maxlen, "ui_textedit origstr");
- BLI_strncpy(origstr, but->drawstr, data->maxlen);
+ BLI_strncpy(origstr, but->editstr, data->maxlen);
if (ELEM3(but->type, TEX, SEARCH_MENU, SEARCH_MENU_UNLINK)) {
if (but->flag & UI_HAS_ICON) {
@@ -4275,6 +4286,14 @@ static void ui_rgb_to_color_picker_HSVCUBE_compat_v(uiBut *but, const float rgb[
rgb_to_hsv_compat_v(rgb, hsv);
}
+static void ui_rgb_to_color_picker_HSVCUBE_v(uiBut *but, const float rgb[3], float hsv[3])
+{
+ if (but->a1 == UI_GRAD_L_ALT)
+ rgb_to_hsl_v(rgb, hsv);
+ else
+ rgb_to_hsv_v(rgb, hsv);
+}
+
static void ui_color_picker_to_rgb_HSVCUBE_v(uiBut *but, const float hsv[3], float rgb[3])
{
if (but->a1 == UI_GRAD_L_ALT)
@@ -4509,7 +4528,7 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
}
/* XXX hardcoded keymap check.... */
else if (event->type == BACKSPACEKEY && event->val == KM_PRESS) {
- if (but->a1 == UI_GRAD_V_ALT) {
+ if (ELEM(but->a1, UI_GRAD_V_ALT, UI_GRAD_L_ALT)) {
int len;
/* reset only value */
@@ -4521,47 +4540,20 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
float *hsv = ui_block_hsv_get(but->block);
RNA_property_float_get_default_array(&but->rnapoin, but->rnaprop, def);
- rgb_to_hsv_v(def, def_hsv);
-
+ ui_rgb_to_color_picker_HSVCUBE_v(but, def, def_hsv);
+
ui_get_but_vectorf(but, rgb);
- rgb_to_hsv_compat_v(rgb, hsv);
+ ui_rgb_to_color_picker_HSVCUBE_compat_v(but, rgb, hsv);
def_hsv[0] = hsv[0];
def_hsv[1] = hsv[1];
- hsv_to_rgb_v(def_hsv, rgb);
+ ui_color_picker_to_rgb_HSVCUBE_v(but, def_hsv, rgb);
ui_set_but_vectorf(but, rgb);
- RNA_property_update(C, &but->rnapoin, but->rnaprop);
- }
- return WM_UI_HANDLER_BREAK;
- }
- else if (but->a1 == UI_GRAD_L_ALT) {
- int len;
-
- /* reset only value */
-
- len = RNA_property_array_length(&but->rnapoin, but->rnaprop);
- if (ELEM(len, 3, 4)) {
- float rgb[3], def_hsl[3];
- float def[4];
- float *hsl = ui_block_hsv_get(but->block);
-
- RNA_property_float_get_default_array(&but->rnapoin, but->rnaprop, def);
- rgb_to_hsl_v(def, def_hsl);
-
- ui_get_but_vectorf(but, rgb);
- rgb_to_hsl_compat_v(rgb, hsl);
-
- def_hsl[0] = hsl[0];
- def_hsl[1] = hsl[1];
-
- hsl_to_rgb_v(def_hsl, rgb);
- ui_set_but_vectorf(but, rgb);
-
RNA_property_update(C, &but->rnapoin, but->rnaprop);
+ return WM_UI_HANDLER_BREAK;
}
- return WM_UI_HANDLER_BREAK;
}
}
}
@@ -4599,7 +4591,7 @@ static bool ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data,
bool changed = true;
float mx_fl, my_fl;
float rgb[3];
- float hsv[3];
+ float *hsv = ui_block_hsv_get(but->block);
bool use_display_colorspace = ui_color_picker_use_display_colorspace(but);
ui_mouse_scale_warp(data, mx, my, &mx_fl, &my_fl, shift);
@@ -4626,8 +4618,6 @@ static bool ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data,
if (use_display_colorspace)
ui_block_to_display_space_v3(but->block, rgb);
- copy_v3_v3(hsv, ui_block_hsv_get(but->block));
-
ui_rgb_to_color_picker_compat_v(rgb, hsv);
/* exception, when using color wheel in 'locked' value state:
@@ -4694,11 +4684,14 @@ static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data,
const enum eSnapType snap, const bool shift)
{
float *hsv = ui_block_hsv_get(but->block);
+ bool use_display_colorspace = ui_color_picker_use_display_colorspace(but);
float rgb[3];
float phi, r /*, sqr */ /* UNUSED */, v[2];
float sensitivity = (shift ? 0.06f : 0.3f) * ndof->dt;
ui_get_but_vectorf(but, rgb);
+ if (use_display_colorspace)
+ ui_block_to_display_space_v3(but->block, rgb);
ui_rgb_to_color_picker_compat_v(rgb, hsv);
/* Convert current color on hue/sat disc to circular coordinates phi, r */
@@ -4749,6 +4742,9 @@ static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data,
normalize_v3(data->vec);
mul_v3_fl(data->vec, but->a2);
}
+
+ if (use_display_colorspace)
+ ui_block_to_scene_linear_v3(but->block, data->vec);
ui_set_but_vectorf(but, data->vec);
}
@@ -4801,10 +4797,10 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle
def = MEM_callocN(sizeof(float) * len, "reset_defaults - float");
RNA_property_float_get_default_array(&but->rnapoin, but->rnaprop, def);
- rgb_to_hsv_v(def, def_hsv);
+ ui_color_picker_to_rgb_v(def, def_hsv);
ui_get_but_vectorf(but, rgb);
- rgb_to_hsv_compat_v(rgb, hsv);
+ ui_rgb_to_color_picker_compat_v(rgb, hsv);
def_hsv[0] = hsv[0];
def_hsv[2] = hsv[2];
@@ -5601,6 +5597,14 @@ void ui_panel_menu(bContext *C, ARegion *ar, Panel *pa)
char tmpstr[80];
BLI_snprintf(tmpstr, sizeof(tmpstr), "%s" UI_SEP_CHAR_S "%s", IFACE_("Pin"), IFACE_("Shift+Left Mouse"));
uiItemR(layout, &ptr, "use_pin", 0, tmpstr, ICON_NONE);
+
+ /* evil, force shortcut flag */
+ {
+ uiBlock *block = uiLayoutGetBlock(layout);
+ uiBut *but = block->buttons.last;
+ but->flag |= UI_BUT_HAS_SEP_CHAR;
+ }
+
}
uiPupMenuEnd(C, pup);
}
@@ -6263,7 +6267,7 @@ void uiFreeActiveButtons(const bContext *C, bScreen *screen)
/* returns true if highlighted button allows drop of names */
/* called in region context */
-int UI_but_active_drop_name(bContext *C)
+bool UI_but_active_drop_name(bContext *C)
{
ARegion *ar = CTX_wm_region(C);
uiBut *but = ui_but_find_activated(ar);
@@ -6355,7 +6359,7 @@ static bool ui_is_but_interactive(const uiBut *but, const bool labeledit)
return false;
if (but->flag & UI_SCROLLED)
return false;
- if ((but->type == TEX) && (but->dt & UI_EMBOSSN) && !labeledit)
+ if ((but->type == TEX) && (but->dt == UI_EMBOSSN) && !labeledit)
return false;
if ((but->type == LISTROW) && labeledit)
return false;
@@ -7239,7 +7243,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
}
else {
/* XXX issue is because WM_event_add_mousemove(C) is a bad hack and not reliable,
- *if that gets coded better this bypass can go away too.
+ * if that gets coded better this bypass can go away too.
*
* This is needed to make sure if a button was active,
* it stays active while the mouse is over it.
@@ -7308,7 +7312,7 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *ar)
if (dyn_data->items_filter_neworder || dyn_data->items_filter_flags) {
/* If we have a display order different from collection order, we have some work! */
int *org_order = MEM_mallocN(dyn_data->items_shown * sizeof(int), __func__);
- int *new_order = dyn_data->items_filter_neworder;
+ const int *new_order = dyn_data->items_filter_neworder;
int i, org_idx = -1, len = dyn_data->items_len;
int current_idx = -1;
int filter_exclude = ui_list->filter_flag & UILST_FLT_EXCLUDE;
@@ -7726,7 +7730,7 @@ static int ui_handle_menu_event(
/* check if mouse is inside block */
inside = BLI_rctf_isect_pt(&block->rect, mx, my);
- inside_title = inside && ((my + (UI_UNIT_Y * 1.5f)) > block->rect.xmax);
+ inside_title = inside && ((my + (UI_UNIT_Y * 1.5f)) > block->rect.ymax);
/* if there's an active modal button, don't check events or outside, except for search menu */
but = ui_but_find_activated(ar);
@@ -7743,11 +7747,7 @@ static int ui_handle_menu_event(
sub_v2_v2v2_int(mdiff, &event->x, menu->grab_xy_prev);
copy_v2_v2_int(menu->grab_xy_prev, &event->x);
- BLI_rcti_translate(&ar->winrct, UNPACK2(mdiff));
-
- ED_region_update_rect(C, ar);
-
- ED_region_tag_redraw(ar);
+ ui_popup_translate(C, ar, mdiff);
}
return retval;
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index d7056d898cb..546b2b85af5 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -27,24 +27,14 @@
* \ingroup edinterface
*/
-
#include <math.h>
#include <stdlib.h>
#include <string.h>
-#ifndef WIN32
-# include <unistd.h>
-#else
-# include <io.h>
-# include <direct.h>
-# include "BLI_winstuff.h"
-#endif
-
#include "MEM_guardedalloc.h"
#include "GPU_extensions.h"
-#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "BLI_fileops_types.h"
@@ -479,13 +469,13 @@ static void init_brush_icons(void)
#define INIT_BRUSH_ICON(icon_id, name) \
{ \
- unsigned char *rect = (unsigned char *)datatoc_ ##name## _png; \
- int size = datatoc_ ##name## _png_size; \
- DrawInfo *di; \
+ unsigned char *rect = (unsigned char *)datatoc_ ##name## _png; \
+ int size = datatoc_ ##name## _png_size; \
+ DrawInfo *di; \
\
- di = def_internal_icon(NULL, icon_id, 0, 0, w, ICON_TYPE_BUFFER); \
- di->data.buffer.image->datatoc_rect = rect; \
- di->data.buffer.image->datatoc_size = size; \
+ di = def_internal_icon(NULL, icon_id, 0, 0, w, ICON_TYPE_BUFFER); \
+ di->data.buffer.image->datatoc_rect = rect; \
+ di->data.buffer.image->datatoc_size = size; \
}
/* end INIT_BRUSH_ICON */
@@ -614,13 +604,13 @@ static void init_internal_icons(void)
#endif
if (b16buf == NULL)
b16buf = IMB_ibImageFromMemory((unsigned char *)datatoc_blender_icons16_png,
- datatoc_blender_icons16_png_size, IB_rect, NULL, "<blender icons>");
+ datatoc_blender_icons16_png_size, IB_rect, NULL, "<blender icons>");
if (b16buf)
IMB_premultiply_alpha(b16buf);
if (b32buf == NULL)
b32buf = IMB_ibImageFromMemory((unsigned char *)datatoc_blender_icons32_png,
- datatoc_blender_icons32_png_size, IB_rect, NULL, "<blender icons>");
+ datatoc_blender_icons32_png_size, IB_rect, NULL, "<blender icons>");
if (b32buf)
IMB_premultiply_alpha(b32buf);
@@ -719,7 +709,7 @@ static void init_iconfile_list(struct ListBase *list)
for (i = 0; i < totfile; i++) {
if ((dir[i].type & S_IFREG)) {
- char *filename = dir[i].relname;
+ const char *filename = dir[i].relname;
if (BLI_testextensie(filename, ".png")) {
/* loading all icons on file start is overkill & slows startup
@@ -1137,7 +1127,7 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al
#endif
if (!iimg->rect) return; /* something has gone wrong! */
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
icon_draw_rect(x, y, w, h, aspect, iimg->w, iimg->h, iimg->rect, alpha, rgb, is_preview);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index bb321353955..3fe6452e56b 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -147,7 +147,7 @@ enum {
typedef struct uiLinkLine { /* only for draw/edit */
struct uiLinkLine *next, *prev;
struct uiBut *from, *to;
- short flag, pad;
+ short flag, deactive;
} uiLinkLine;
typedef struct {
@@ -473,12 +473,15 @@ struct ARegion *ui_tooltip_create(struct bContext *C, struct ARegion *butregion,
void ui_tooltip_free(struct bContext *C, struct ARegion *ar);
uiBut *ui_popup_menu_memory_get(struct uiBlock *block);
-void ui_popup_menu_memory_set(struct uiBlock *block, struct uiBut *but);
+void ui_popup_menu_memory_set(uiBlock *block, struct uiBut *but);
+
+void ui_popup_translate(struct bContext *C, struct ARegion *ar, const int mdiff[2]);
float *ui_block_hsv_get(struct uiBlock *block);
void ui_popup_block_scrolltest(struct uiBlock *block);
void ui_rgb_to_color_picker_compat_v(const float rgb[3], float r_cp[3]);
+void ui_rgb_to_color_picker_v(const float rgb[3], float r_cp[3]);
void ui_color_picker_to_rgb_v(const float r_cp[3], float rgb[3]);
void ui_color_picker_to_rgb(float r_cp0, float r_cp1, float r_cp2, float *r, float *g, float *b);
@@ -548,7 +551,7 @@ void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect);
uiWidgetColors *ui_tooltip_get_theme(void);
void ui_draw_tooltip_background(uiStyle *UNUSED(style), uiBlock *block, rcti *rect);
void ui_draw_search_back(struct uiStyle *style, uiBlock *block, rcti *rect);
-int ui_link_bezier_points(const rcti *rect, float coord_array[][2], int resol);
+bool ui_link_bezier_points(const rcti *rect, float coord_array[][2], int resol);
void ui_draw_link_bezier(const rcti *rect);
extern void ui_draw_but(const struct bContext *C, ARegion *ar, struct uiStyle *style, uiBut *but, rcti *rect);
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 1686abab9c7..0bc679dede0 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -410,8 +410,8 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in
uiBlockBeginAlign(block);
for (a = 0; a < colbuts; a++) {
- int layer_num = a + b * colbuts;
- int layer_flag = 1 << layer_num;
+ const int layer_num = a + b * colbuts;
+ const unsigned int layer_flag = (1u << layer_num);
if (layer_used & layer_flag) {
if (layer_active & layer_flag)
@@ -428,8 +428,8 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in
uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(layer_num));
}
for (a = 0; a < colbuts; a++) {
- int layer_num = a + len / 2 + b * colbuts;
- int layer_flag = 1 << layer_num;
+ const int layer_num = a + len / 2 + b * colbuts;
+ const unsigned int layer_flag = (1u << layer_num);
if (layer_used & layer_flag) {
if (layer_active & layer_flag)
@@ -1624,8 +1624,8 @@ static void ui_item_menutype_func(bContext *C, uiLayout *layout, void *arg_mt)
CTX_store_set(C, NULL);
}
-static void ui_item_menu(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg, void *argN,
- const char *tip, bool force_menu)
+static uiBut *ui_item_menu(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg, void *argN,
+ const char *tip, bool force_menu)
{
uiBlock *block = layout->root->block;
uiBut *but;
@@ -1675,6 +1675,8 @@ static void ui_item_menu(uiLayout *layout, const char *name, int icon, uiMenuCre
{
uiButSetMenuFromPulldown(but);
}
+
+ return but;
}
void uiItemM(uiLayout *layout, bContext *UNUSED(C), const char *menuname, const char *name, int icon)
@@ -1821,8 +1823,7 @@ void uiItemMenuEnumO(uiLayout *layout, bContext *C, const char *opname, const ch
{
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
MenuItemLevel *lvl;
- char namestr_buf[UI_MAX_NAME_STR], keybuf[128];
- char *namestr = namestr_buf;
+ uiBut *but;
UI_OPERATOR_ERROR_RET(ot, opname, return );
@@ -1832,10 +1833,9 @@ void uiItemMenuEnumO(uiLayout *layout, bContext *C, const char *opname, const ch
return;
}
- if (name)
- namestr += BLI_strncpy_rlen(namestr, name, sizeof(namestr_buf));
- else
- namestr += BLI_strncpy_rlen(namestr, RNA_struct_ui_name(ot->srna), sizeof(namestr_buf));
+ if (name == NULL) {
+ name = RNA_struct_ui_name(ot->srna);
+ }
if (layout->root->type == UI_LAYOUT_MENU && !icon)
icon = ICON_BLANK1;
@@ -1845,17 +1845,20 @@ void uiItemMenuEnumO(uiLayout *layout, bContext *C, const char *opname, const ch
BLI_strncpy(lvl->propname, propname, sizeof(lvl->propname));
lvl->opcontext = layout->root->opcontext;
+ but = ui_item_menu(layout, name, icon, menu_item_enum_opname_menu, NULL, lvl,
+ RNA_struct_ui_description(ot->srna), true);
+
/* add hotkey here, lower UI code can't detect it */
- if (layout->root->block->flag & UI_BLOCK_LOOP) {
- if (ot->prop && ot->invoke &&
- WM_key_event_operator_string(C, ot->idname, layout->root->opcontext, NULL, false, keybuf, sizeof(keybuf)))
+ if ((layout->root->block->flag & UI_BLOCK_LOOP) &&
+ (ot->prop && ot->invoke))
+ {
+ char keybuf[128];
+ if (WM_key_event_operator_string(C, ot->idname, layout->root->opcontext, NULL, false,
+ keybuf, sizeof(keybuf)))
{
- namestr += BLI_snprintf(namestr, sizeof(namestr_buf) - (namestr - namestr_buf), "|%s", keybuf);
+ ui_but_add_shortcut(but, keybuf, false);
}
}
-
- ui_item_menu(layout, namestr_buf, icon, menu_item_enum_opname_menu, NULL, lvl, RNA_struct_ui_description(ot->srna),
- true);
}
static void menu_item_enum_rna_menu(bContext *UNUSED(C), uiLayout *layout, void *arg)
@@ -3021,7 +3024,7 @@ void uiLayoutContextCopy(uiLayout *layout, bContextStore *context)
static void ui_intro_button(DynStr *ds, uiButtonItem *bitem)
{
uiBut *but = bitem->but;
- BLI_dynstr_appendf(ds, "'type':%d, ", but->type); /* see ~ UI_interface.h:200 */
+ 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 */
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index 4bbccec7f9d..316a4d34881 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -283,14 +283,24 @@ static bool copy_to_selected_list(bContext *C, PointerRNA *ptr, ListBase *lb, bo
return true;
}
-static int copy_to_selected_button_poll(bContext *C)
+/**
+ * called from both exec & poll
+ *
+ * \note: normally we wouldn't call a loop from within a poll function,
+ * However this is a special case, and for regular poll calls, getting
+ * the context from the button will fail early.
+ */
+static bool copy_to_selected_button(bContext *C, bool all, bool poll)
{
PointerRNA ptr, lptr, idptr;
PropertyRNA *prop, *lprop;
- int index, success = 0;
+ bool success = false;
+ int index;
+ /* try to reset the nominated setting to its default value */
uiContextActiveProperty(C, &ptr, &prop, &index);
+ /* if there is a valid property that is editable... */
if (ptr.data && prop) {
char *path = NULL;
bool use_path;
@@ -314,8 +324,18 @@ static int copy_to_selected_button_poll(bContext *C)
}
if (lprop == prop) {
- if (RNA_property_editable(&lptr, prop))
- success = 1;
+ if (RNA_property_editable(&lptr, lprop)) {
+ if (poll) {
+ success = true;
+ break;
+ }
+ else {
+ if (RNA_property_copy(&lptr, &ptr, prop, (all) ? -1 : index)) {
+ RNA_property_update(C, &lptr, prop);
+ success = true;
+ }
+ }
+ }
}
}
}
@@ -330,58 +350,19 @@ static int copy_to_selected_button_poll(bContext *C)
return success;
}
-static int copy_to_selected_button_exec(bContext *C, wmOperator *op)
+static int copy_to_selected_button_poll(bContext *C)
{
- PointerRNA ptr, lptr, idptr;
- PropertyRNA *prop, *lprop;
- bool success = false;
- int index;
- const bool all = RNA_boolean_get(op->ptr, "all");
-
- /* try to reset the nominated setting to its default value */
- uiContextActiveProperty(C, &ptr, &prop, &index);
-
- /* if there is a valid property that is editable... */
- if (ptr.data && prop) {
- char *path = NULL;
- bool use_path;
- CollectionPointerLink *link;
- ListBase lb;
-
- if (!copy_to_selected_list(C, &ptr, &lb, &use_path))
- return OPERATOR_CANCELLED;
+ return copy_to_selected_button(C, false, true);
+}
- if (!use_path || (path = RNA_path_from_ID_to_property(&ptr, prop))) {
- for (link = lb.first; link; link = link->next) {
- if (link->ptr.data != ptr.data) {
- if (use_path) {
- lprop = NULL;
- RNA_id_pointer_create(link->ptr.id.data, &idptr);
- RNA_path_resolve_property(&idptr, path, &lptr, &lprop);
- }
- else {
- lptr = link->ptr;
- lprop = prop;
- }
+static int copy_to_selected_button_exec(bContext *C, wmOperator *op)
+{
+ bool success;
- if (lprop == prop) {
- if (RNA_property_editable(&lptr, lprop)) {
- if (RNA_property_copy(&lptr, &ptr, prop, (all) ? -1 : index)) {
- RNA_property_update(C, &lptr, prop);
- success = true;
- }
- }
- }
- }
- }
+ const bool all = RNA_boolean_get(op->ptr, "all");
- if (path)
- MEM_freeN(path);
- }
+ success = copy_to_selected_button(C, all, false);
- BLI_freelistN(&lb);
- }
-
return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
@@ -678,7 +659,7 @@ static void edittranslation_find_po_file(const char *root, const char *uilng, ch
/* Now try without the second iso code part (_ES in es_ES). */
{
- char *tc = NULL;
+ const char *tc = NULL;
size_t szt = 0;
tstr[0] = '\0';
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index e9a4119ac7e..2ccb3740777 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -41,7 +41,6 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
-#include "BLI_math_color_blend.h"
#include "BLI_utildefines.h"
#include "BLF_translation.h"
@@ -210,8 +209,8 @@ Panel *uiPanelFindByType(ARegion *ar, PanelType *pt)
const char *tabname = pt->idname;
for (pa = ar->panels.first; pa; pa = pa->next) {
- if (STREQLEN(pa->panelname, idname, UI_MAX_NAME_STR)) {
- if (STREQLEN(pa->tabname, tabname, UI_MAX_NAME_STR)) {
+ if (STREQLEN(pa->panelname, idname, sizeof(pa->panelname))) {
+ if (STREQLEN(pa->tabname, tabname, sizeof(pa->panelname))) {
return pa;
}
}
@@ -227,9 +226,9 @@ Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, Pan
{
Panel *patab, *palast, *panext;
const char *drawname = CTX_IFACE_(pt->translation_context, pt->label);
- char *idname = pt->idname;
- char *tabname = pt->idname;
- char *hookname = NULL;
+ const char *idname = pt->idname;
+ const char *tabname = pt->idname;
+ const char *hookname = NULL;
const bool newpanel = (pa == NULL);
int align = panel_aligned(sa, ar);
@@ -240,8 +239,8 @@ Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, Pan
/* new panel */
pa = MEM_callocN(sizeof(Panel), "new panel");
pa->type = pt;
- BLI_strncpy(pa->panelname, idname, UI_MAX_NAME_STR);
- BLI_strncpy(pa->tabname, tabname, UI_MAX_NAME_STR);
+ BLI_strncpy(pa->panelname, idname, sizeof(pa->panelname));
+ BLI_strncpy(pa->tabname, tabname, sizeof(pa->tabname));
if (pt->flag & PNL_DEFAULT_CLOSED) {
if (align == BUT_VERTICAL)
@@ -262,8 +261,8 @@ Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, Pan
if (hookname) {
for (patab = ar->panels.first; patab; patab = patab->next) {
if ((patab->runtime_flag & PNL_ACTIVE) && patab->paneltab == NULL) {
- if (strncmp(hookname, patab->panelname, UI_MAX_NAME_STR) == 0) {
- if (strncmp(tabname, patab->tabname, UI_MAX_NAME_STR) == 0) {
+ if (STREQLEN(hookname, patab->panelname, sizeof(patab->panelname))) {
+ if (STREQLEN(tabname, patab->tabname, sizeof(patab->tabname))) {
pa->paneltab = patab;
ui_panel_copy_offset(pa, patab);
break;
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 37cfbbb2cff..97d4869bb2d 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -41,12 +41,10 @@
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
-#include "BLI_dynstr.h"
#include "BLI_ghash.h"
#include "BKE_context.h"
#include "BKE_screen.h"
-#include "BKE_idcode.h"
#include "BKE_report.h"
#include "BKE_global.h"
@@ -769,7 +767,7 @@ bool ui_searchbox_apply(uiBut *but, ARegion *ar)
if (data->active != -1) {
const char *name = data->items.names[data->active];
- const char *name_sep = data->use_sep ? strchr(name, UI_SEP_CHAR) : NULL;
+ const char *name_sep = data->use_sep ? strrchr(name, UI_SEP_CHAR) : NULL;
BLI_strncpy(but->editstr, name, name_sep ? (name_sep - name) : data->items.maxstrlen);
@@ -875,7 +873,7 @@ void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but, const bool reset)
for (a = 0; a < data->items.totitem; a++) {
const char *name = data->items.names[a];
- const char *name_sep = data->use_sep ? strchr(name, UI_SEP_CHAR) : NULL;
+ const char *name_sep = data->use_sep ? strrchr(name, UI_SEP_CHAR) : NULL;
if (STREQLEN(but->editstr, name, name_sep ? (name_sep - name) : data->items.maxstrlen)) {
data->active = a;
break;
@@ -1092,8 +1090,7 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
BLI_rcti_rctf_copy(&rect_i, &rect_fl);
if (butregion->v2d.cur.xmin != butregion->v2d.cur.xmax) {
- UI_view2d_to_region_no_clip(&butregion->v2d, rect_fl.xmin, rect_fl.ymin, &rect_i.xmin, &rect_i.ymin);
- UI_view2d_to_region_no_clip(&butregion->v2d, rect_fl.xmax, rect_fl.ymax, &rect_i.xmax, &rect_i.ymax);
+ UI_view2d_view_to_region_rcti(&butregion->v2d, &rect_fl, &rect_i);
}
BLI_rcti_translate(&rect_i, butregion->winrct.xmin, butregion->winrct.ymin);
@@ -1118,7 +1115,7 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
int newy1 = but->rect.ymax + ofsy;
if (butregion->v2d.cur.xmin != butregion->v2d.cur.xmax)
- UI_view2d_to_region_no_clip(&butregion->v2d, 0, newy1, NULL, &newy1);
+ newy1 = UI_view2d_view_to_region_y(&butregion->v2d, newy1);
newy1 += butregion->winrct.ymin;
@@ -1223,10 +1220,7 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
short dir1 = 0, dir2 = 0;
/* transform to window coordinates, using the source button region/block */
- butrct = but->rect;
-
- ui_block_to_window_fl(butregion, but->block, &butrct.xmin, &butrct.ymin);
- ui_block_to_window_fl(butregion, but->block, &butrct.xmax, &butrct.ymax);
+ ui_block_to_window_rctf(butregion, but->block, &butrct, &but->rect);
/* widget_roundbox_set has this correction too, keep in sync */
if (but->type != PULLDOWN) {
@@ -1253,8 +1247,7 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
}
/* aspect = (float)(BLI_rcti_size_x(&block->rect) + 4);*/ /*UNUSED*/
- ui_block_to_window_fl(butregion, but->block, &block->rect.xmin, &block->rect.ymin);
- ui_block_to_window_fl(butregion, but->block, &block->rect.xmax, &block->rect.ymax);
+ ui_block_to_window_rctf(butregion, but->block, &block->rect, &block->rect);
//block->rect.xmin -= 2.0; block->rect.ymin -= 2.0;
//block->rect.xmax += 2.0; block->rect.ymax += 2.0;
@@ -1376,8 +1369,7 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
/* apply offset, buttons in window coords */
for (bt = block->buttons.first; bt; bt = bt->next) {
- ui_block_to_window_fl(butregion, but->block, &bt->rect.xmin, &bt->rect.ymin);
- ui_block_to_window_fl(butregion, but->block, &bt->rect.xmax, &bt->rect.ymax);
+ ui_block_to_window_rctf(butregion, but->block, &bt->rect, &bt->rect);
BLI_rctf_translate(&bt->rect, xof, yof);
@@ -1644,7 +1636,7 @@ static void ui_warp_pointer(int x, int y)
void ui_set_but_hsv(uiBut *but)
{
float col[3];
- float *hsv = ui_block_hsv_get(but->block);
+ const float *hsv = ui_block_hsv_get(but->block);
ui_color_picker_to_rgb_v(hsv, col);
@@ -1652,16 +1644,25 @@ void ui_set_but_hsv(uiBut *but)
}
/* also used by small picker, be careful with name checks below... */
-static void ui_update_block_buts_rgb(uiBlock *block, const float rgb[3])
+static void ui_update_block_buts_rgb(uiBlock *block, const float rgb[3], bool is_display_space)
{
uiBut *bt;
float *hsv = ui_block_hsv_get(block);
struct ColorManagedDisplay *display = NULL;
-
/* this is to keep the H and S value when V is equal to zero
* and we are working in HSV mode, of course!
*/
- ui_rgb_to_color_picker_compat_v(rgb, hsv);
+ if (is_display_space) {
+ ui_rgb_to_color_picker_compat_v(rgb, hsv);
+ }
+ else {
+ /* we need to convert to display space to use hsv, because hsv is stored in display space */
+ float rgb_display[3];
+
+ copy_v3_v3(rgb_display, rgb);
+ ui_block_to_display_space_v3(block, rgb_display);
+ ui_rgb_to_color_picker_compat_v(rgb_display, hsv);
+ }
if (block->color_profile)
display = ui_block_display_get(block);
@@ -1675,6 +1676,7 @@ static void ui_update_block_buts_rgb(uiBlock *block, const float rgb[3])
}
else if (strcmp(bt->str, "Hex: ") == 0) {
float rgb_gamma[3];
+ unsigned char rgb_gamma_uchar[3];
double intpart;
char col[16];
@@ -1691,8 +1693,8 @@ static void ui_update_block_buts_rgb(uiBlock *block, const float rgb[3])
if (rgb_gamma[1] > 1.0f) rgb_gamma[1] = modf(rgb_gamma[1], &intpart);
if (rgb_gamma[2] > 1.0f) rgb_gamma[2] = modf(rgb_gamma[2], &intpart);
- BLI_snprintf(col, sizeof(col), "%02X%02X%02X",
- FTOCHAR(rgb_gamma[0]), FTOCHAR(rgb_gamma[1]), FTOCHAR(rgb_gamma[2]));
+ rgb_float_to_uchar(rgb_gamma_uchar, rgb_gamma);
+ BLI_snprintf(col, sizeof(col), "%02X%02X%02X", UNPACK3OP((unsigned int), rgb_gamma_uchar));
strcpy(bt->poin, col);
}
@@ -1734,7 +1736,7 @@ static void do_picker_rna_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(arg))
if (prop) {
RNA_property_float_get_array(&ptr, prop, rgb);
- ui_update_block_buts_rgb(but->block, rgb);
+ ui_update_block_buts_rgb(but->block, rgb, (RNA_property_subtype(prop) == PROP_COLOR_GAMMA));
}
if (popup)
@@ -1746,11 +1748,17 @@ static void do_color_wheel_rna_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(a
uiBut *but = (uiBut *)bt1;
uiPopupBlockHandle *popup = but->block->handle;
float rgb[3];
- float *hsv = ui_block_hsv_get(but->block);
-
+ const float *hsv = ui_block_hsv_get(but->block);
+ bool use_display_colorspace = ui_color_picker_use_display_colorspace(but);
+
ui_color_picker_to_rgb_v(hsv, rgb);
- ui_update_block_buts_rgb(but->block, rgb);
+ /* hsv is saved in display space so convert back */
+ if (use_display_colorspace) {
+ ui_block_to_scene_linear_v3(but->block, rgb);
+ }
+
+ ui_update_block_buts_rgb(but->block, rgb, !use_display_colorspace);
if (popup)
popup->menuretval = UI_RETURN_UPDATE;
@@ -1771,7 +1779,7 @@ static void do_hex_rna_cb(bContext *UNUSED(C), void *bt1, void *hexcl)
ui_block_to_scene_linear_v3(but->block, rgb);
}
- ui_update_block_buts_rgb(but->block, rgb);
+ ui_update_block_buts_rgb(but->block, rgb, false);
if (popup)
popup->menuretval = UI_RETURN_UPDATE;
@@ -1868,6 +1876,7 @@ static void uiBlockPicker(uiBlock *block, float rgba[4], PointerRNA *ptr, Proper
static char tip[50];
static char hexcol[128];
float rgb_gamma[3];
+ unsigned char rgb_gamma_uchar[3];
float softmin, softmax, hardmin, hardmax, step, precision;
float *hsv = ui_block_hsv_get(block);
int yco;
@@ -1972,14 +1981,15 @@ static void uiBlockPicker(uiBlock *block, float rgba[4], PointerRNA *ptr, Proper
rgba[3] = 1.0f;
}
- BLI_snprintf(hexcol, sizeof(hexcol), "%02X%02X%02X", FTOCHAR(rgb_gamma[0]), FTOCHAR(rgb_gamma[1]), FTOCHAR(rgb_gamma[2]));
+ rgb_float_to_uchar(rgb_gamma_uchar, rgb_gamma);
+ BLI_snprintf(hexcol, sizeof(hexcol), "%02X%02X%02X", UNPACK3OP((unsigned int), rgb_gamma_uchar));
yco = -3.0f * UI_UNIT_Y;
bt = uiDefBut(block, TEX, 0, IFACE_("Hex: "), 0, yco, butwidth, UI_UNIT_Y, hexcol, 0, 8, 0, 0, TIP_("Hex triplet for color (#RRGGBB)"));
uiButSetFunc(bt, do_hex_rna_cb, bt, hexcol);
uiDefBut(block, LABEL, 0, IFACE_("(Gamma Corrected)"), 0, yco - UI_UNIT_Y, butwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
- rgb_to_hsv_v(rgba, hsv);
+ ui_rgb_to_color_picker_v(rgb_gamma, hsv);
picker_new_hide_reveal(block, colormode);
}
@@ -2002,16 +2012,24 @@ static int ui_picker_small_wheel_cb(const bContext *UNUSED(C), uiBlock *block, c
uiPopupBlockHandle *popup = block->handle;
float rgb[3];
float *hsv = ui_block_hsv_get(block);
+ bool use_display_colorspace = ui_color_picker_use_display_colorspace(but);
ui_get_but_vectorf(but, rgb);
-
- rgb_to_hsv_compat_v(rgb, hsv);
+
+ if (use_display_colorspace)
+ ui_block_to_display_space_v3(block, rgb);
+
+ ui_rgb_to_color_picker_compat_v(rgb, hsv);
+
hsv[2] = CLAMPIS(hsv[2] + add, 0.0f, 1.0f);
- hsv_to_rgb_v(hsv, rgb);
+ ui_color_picker_to_rgb_v(hsv, rgb);
+
+ if (use_display_colorspace)
+ ui_block_to_scene_linear_v3(block, rgb);
ui_set_but_vectorf(but, rgb);
- ui_update_block_buts_rgb(block, rgb);
+ ui_update_block_buts_rgb(block, rgb, !use_display_colorspace);
if (popup)
popup->menuretval = UI_RETURN_UPDATE;
@@ -2063,11 +2081,14 @@ static unsigned int ui_popup_string_hash(const char *str)
{
/* sometimes button contains hotkey, sometimes not, strip for proper compare */
int hash;
- char *delimit = strchr(str, UI_SEP_CHAR);
+ const char *delimit = strrchr(str, UI_SEP_CHAR);
- if (delimit) *delimit = '\0';
- hash = BLI_ghashutil_strhash(str);
- if (delimit) *delimit = UI_SEP_CHAR;
+ if (delimit) {
+ hash = BLI_ghashutil_strhash_n(str, delimit - str);
+ }
+ else {
+ hash = BLI_ghashutil_strhash(str);
+ }
return hash;
}
@@ -2117,6 +2138,29 @@ void ui_popup_menu_memory_set(uiBlock *block, uiBut *but)
ui_popup_menu_memory__internal(block, but);
}
+/**
+ * Translate any popup regions (so we can drag them).
+ */
+void ui_popup_translate(bContext *C, ARegion *ar, const int mdiff[2])
+{
+ uiBlock *block;
+
+ BLI_rcti_translate(&ar->winrct, UNPACK2(mdiff));
+
+ ED_region_update_rect(C, ar);
+
+ ED_region_tag_redraw(ar);
+
+ /* update blocks */
+ for (block = ar->uiblocks.first; block; block = block->next) {
+ uiSafetyRct *saferct;
+ for (saferct = block->saferct.first; saferct; saferct = saferct->next) {
+ BLI_rctf_translate(&saferct->parent, UNPACK2(mdiff));
+ BLI_rctf_translate(&saferct->safety, UNPACK2(mdiff));
+ }
+ }
+}
+
/******************** Popup Menu with callback or string **********************/
struct uiPopupMenu {
@@ -2533,6 +2577,18 @@ void ui_rgb_to_color_picker_compat_v(const float rgb[3], float r_cp[3])
}
}
+void ui_rgb_to_color_picker_v(const float rgb[3], float r_cp[3])
+{
+ switch (U.color_picker_type) {
+ case USER_CP_CIRCLE_HSL:
+ rgb_to_hsl_v(rgb, r_cp);
+ break;
+ default:
+ rgb_to_hsv_v(rgb, r_cp);
+ break;
+ }
+}
+
void ui_color_picker_to_rgb_v(const float r_cp[3], float rgb[3])
{
switch (U.color_picker_type) {
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index f9595edf616..fa31c20eb74 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -38,7 +38,6 @@
#include "DNA_screen_types.h"
#include "DNA_userdef_types.h"
-#include "BLI_math.h"
#include "BLI_listbase.h"
#include "BLI_rect.h"
#include "BLI_string.h"
@@ -56,6 +55,9 @@
#include "interface_intern.h"
+#ifdef WIN32
+# include "BLI_math_base.h" /* M_PI */
+#endif
/* style + theme + layout-engine = UI */
@@ -430,7 +432,7 @@ void uiStyleInit(void)
if (blf_mono_font_render == -1)
blf_mono_font_render = BLF_load_mem_unique("monospace", monofont_ttf, monofont_size);
- BLF_size(blf_mono_font_render, 12 * U.pixelsize, 72 );
+ BLF_size(blf_mono_font_render, 12 * U.pixelsize, 72);
}
void uiStyleFontSet(uiFontStyle *fs)
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 6284c1a0442..e4c26d86044 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -48,25 +48,20 @@
#include "BLF_api.h"
#include "BLF_translation.h"
-#include "BKE_animsys.h"
#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
-#include "BKE_displist.h"
-#include "BKE_dynamicpaint.h"
#include "BKE_global.h"
#include "BKE_idcode.h"
#include "BKE_library.h"
+#include "BKE_linestyle.h"
#include "BKE_main.h"
-#include "BKE_material.h"
#include "BKE_modifier.h"
-#include "BKE_node.h"
#include "BKE_object.h"
#include "BKE_packedFile.h"
#include "BKE_particle.h"
#include "BKE_report.h"
#include "BKE_sca.h"
-#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_texture.h"
@@ -312,6 +307,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
Scene *scene = CTX_data_scene(C);
ED_object_single_user(bmain, scene, (struct Object *)id);
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
+ DAG_relations_tag_update(bmain);
}
else {
if (id) {
@@ -451,7 +447,7 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str
/* text button with name */
if (id) {
char name[UI_MAX_NAME_STR];
- const short user_alert = (id->us <= 0);
+ const bool user_alert = (id->us <= 0);
//text_idbutton(id, name);
name[0] = '\0';
@@ -1112,7 +1108,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
// int rb_col; // UNUSED
/* get constraint typeinfo */
- cti = BKE_constraint_get_typeinfo(con);
+ cti = BKE_constraint_typeinfo_get(con);
if (cti == NULL) {
/* exception for 'Null' constraint - it doesn't have constraint typeinfo! */
BLI_strncpy(typestr, (con->type == CONSTRAINT_TYPE_NULL) ? IFACE_("Null") : IFACE_("Unknown"), sizeof(typestr));
@@ -1121,7 +1117,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
BLI_strncpy(typestr, IFACE_(cti->name), sizeof(typestr));
/* determine whether constraint is proxy protected or not */
- if (BKE_proxylocked_constraints_owner(ob, pchan))
+ if (BKE_constraints_proxylocked_owner(ob, pchan))
proxy_protected = (con->flag & CONSTRAINT_PROXY_LOCAL) == 0;
else
proxy_protected = 0;
@@ -1184,7 +1180,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
*
* Up/Down buttons should only be shown (or not grayed - todo) if they serve some purpose.
*/
- if (BKE_proxylocked_constraints_owner(ob, pchan)) {
+ if (BKE_constraints_proxylocked_owner(ob, pchan)) {
if (con->prev) {
prev_proxylock = (con->prev->flag & CONSTRAINT_PROXY_LOCAL) ? 0 : 1;
}
@@ -1308,8 +1304,8 @@ void uiTemplatePreview(uiLayout *layout, bContext *C, ID *id, int show_buttons,
char _preview_id[UI_MAX_NAME_STR];
- if (id && !ELEM4(GS(id->name), ID_MA, ID_TE, ID_WO, ID_LA)) {
- RNA_warning("Expected ID of type material, texture, lamp or world");
+ if (id && !ELEM5(GS(id->name), ID_MA, ID_TE, ID_WO, ID_LA, ID_LS)) {
+ RNA_warning("Expected ID of type material, texture, lamp, world or line style");
return;
}
@@ -1324,6 +1320,8 @@ void uiTemplatePreview(uiLayout *layout, bContext *C, ID *id, int show_buttons,
pr_texture = &((World *)parent)->pr_texture;
else if (parent && (GS(parent->name) == ID_LA))
pr_texture = &((Lamp *)parent)->pr_texture;
+ else if (parent && (GS(parent->name) == ID_LS))
+ pr_texture = &((FreestyleLineStyle *)parent)->pr_texture;
if (pr_texture) {
if (*pr_texture == TEX_PR_OTHER)
@@ -1404,6 +1402,10 @@ void uiTemplatePreview(uiLayout *layout, bContext *C, ID *id, int show_buttons,
uiDefButS(block, ROW, B_MATPRV, IFACE_("World"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
pr_texture, 10, TEX_PR_OTHER, 0, 0, "");
}
+ else if (GS(parent->name) == ID_LS) {
+ uiDefButS(block, ROW, B_MATPRV, IFACE_("Line Style"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
+ pr_texture, 10, TEX_PR_OTHER, 0, 0, "");
+ }
uiDefButS(block, ROW, B_MATPRV, IFACE_("Both"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
pr_texture, 10, TEX_PR_BOTH, 0, 0, "");
@@ -1495,7 +1497,7 @@ static void colorband_update_cb(bContext *UNUSED(C), void *bt_v, void *coba_v)
}
static void colorband_buttons_layout(uiLayout *layout, uiBlock *block, ColorBand *coba, const rctf *butr,
- RNAUpdateCb *cb, int expand)
+ RNAUpdateCb *cb, int expand)
{
uiLayout *row, *split, *subsplit;
uiBut *bt;
@@ -2430,7 +2432,7 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, const char *propname,
}
void uiTemplateGameStates(uiLayout *layout, PointerRNA *ptr, const char *propname,
- PointerRNA *used_ptr, const char *used_propname, int active_state)
+ PointerRNA *used_ptr, const char *used_propname, int active_state)
{
uiLayout *uRow, *uCol;
PropertyRNA *prop, *used_prop = NULL;
@@ -3288,7 +3290,9 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
handle_event = B_STOPCOMPO;
break;
}
- else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_OBJECT_BAKE_TEXTURE)) {
+ else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_OBJECT_BAKE_TEXTURE) ||
+ WM_jobs_test(wm, scene, WM_JOB_TYPE_OBJECT_BAKE))
+ {
/* Skip bake jobs in compositor to avoid compo header displaying
* progress bar which is not being updated (bake jobs only need
* to update NC_IMAGE context.
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index bcb46b4b60b..2c958c5028a 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -43,7 +43,6 @@
#include "BLF_translation.h"
-#include "BKE_context.h"
#include "BKE_report.h"
#include "MEM_guardedalloc.h"
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index ff749289636..b25aac785a7 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -37,7 +37,6 @@
#include "DNA_userdef_types.h"
#include "BLI_math.h"
-#include "BLI_listbase.h"
#include "BLI_rect.h"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
@@ -851,7 +850,9 @@ static void widget_draw_icon(const uiBut *but, BIFIconID icon, float alpha, cons
float aspect, height;
if (but->flag & UI_ICON_PREVIEW) {
+ glEnable(GL_BLEND);
widget_draw_preview(icon, alpha, rect);
+ glDisable(GL_BLEND);
return;
}
@@ -919,18 +920,18 @@ static void widget_draw_icon(const uiBut *but, BIFIconID icon, float alpha, cons
glDisable(GL_BLEND);
}
-static void ui_text_clip_give_prev_off(uiBut *but)
+static void ui_text_clip_give_prev_off(uiBut *but, const char *str)
{
- char *prev_utf8 = BLI_str_find_prev_char_utf8(but->drawstr, but->drawstr + but->ofs);
- int bytes = but->drawstr + but->ofs - prev_utf8;
+ const char *prev_utf8 = BLI_str_find_prev_char_utf8(str, str + but->ofs);
+ int bytes = str + but->ofs - prev_utf8;
but->ofs -= bytes;
}
-static void ui_text_clip_give_next_off(uiBut *but)
+static void ui_text_clip_give_next_off(uiBut *but, const char *str)
{
- char *next_utf8 = BLI_str_find_next_char_utf8(but->drawstr + but->ofs, NULL);
- int bytes = next_utf8 - (but->drawstr + but->ofs);
+ const char *next_utf8 = BLI_str_find_next_char_utf8(str + but->ofs, NULL);
+ int bytes = next_utf8 - (str + but->ofs);
but->ofs += bytes;
}
@@ -1090,36 +1091,39 @@ static void ui_text_clip_cursor(uiFontStyle *fstyle, uiBut *but, const rcti *rec
if (but->ofs > but->pos)
but->ofs = but->pos;
- if (BLF_width(fstyle->uifont_id, but->drawstr, sizeof(but->drawstr)) <= okwidth)
+ if (BLF_width(fstyle->uifont_id, but->editstr, INT_MAX) <= okwidth)
but->ofs = 0;
- but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs, sizeof(but->drawstr) - but->ofs);
+ but->strwidth = BLF_width(fstyle->uifont_id, but->editstr + but->ofs, INT_MAX);
- while (but->strwidth > okwidth) {
- float width;
+ if (but->strwidth > okwidth) {
+ int len = strlen(but->editstr);
- /* string position of cursor */
- width = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs, but->pos - but->ofs);
+ while (but->strwidth > okwidth) {
+ float width;
- /* if cursor is at 20 pixels of right side button we clip left */
- if (width > okwidth - 20) {
- ui_text_clip_give_next_off(but);
- }
- else {
- int len, bytes;
- /* shift string to the left */
- if (width < 20 && but->ofs > 0)
- ui_text_clip_give_prev_off(but);
- len = strlen(but->drawstr);
- bytes = BLI_str_utf8_size(BLI_str_find_prev_char_utf8(but->drawstr, but->drawstr + len));
- if (bytes < 0)
- bytes = 1;
- but->drawstr[len - bytes] = 0;
- }
+ /* string position of cursor */
+ width = BLF_width(fstyle->uifont_id, but->editstr + but->ofs, (but->pos - but->ofs));
- but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs, sizeof(but->drawstr) - but->ofs);
+ /* if cursor is at 20 pixels of right side button we clip left */
+ if (width > okwidth - 20) {
+ ui_text_clip_give_next_off(but, but->editstr);
+ }
+ else {
+ int bytes;
+ /* shift string to the left */
+ if (width < 20 && but->ofs > 0)
+ ui_text_clip_give_prev_off(but, but->editstr);
+ bytes = BLI_str_utf8_size(BLI_str_find_prev_char_utf8(but->editstr, but->editstr + len));
+ if (bytes == -1)
+ bytes = 1;
+ len -= bytes;
+ }
- if (but->strwidth < 10) break;
+ but->strwidth = BLF_width(fstyle->uifont_id, but->editstr + but->ofs, len - but->ofs);
+
+ if (but->strwidth < 10) break;
+ }
}
if (fstyle->kerning == 1) {
@@ -1138,7 +1142,7 @@ static void ui_text_clip_right_label(uiFontStyle *fstyle, uiBut *but, const rcti
const int okwidth = max_ii(BLI_rcti_size_x(rect) - border, 0);
char *cpoin = NULL;
int drawstr_len = strlen(but->drawstr);
- char *cpend = but->drawstr + drawstr_len;
+ const char *cpend = but->drawstr + drawstr_len;
/* need to set this first */
uiStyleFontSet(fstyle);
@@ -1164,7 +1168,7 @@ static void ui_text_clip_right_label(uiFontStyle *fstyle, uiBut *but, const rcti
/* chop off the leading text, starting from the right */
while (but->strwidth > okwidth && cp2 > but->drawstr) {
- char *prev_utf8 = BLI_str_find_prev_char_utf8(but->drawstr, cp2);
+ const char *prev_utf8 = BLI_str_find_prev_char_utf8(but->drawstr, cp2);
int bytes = cp2 - prev_utf8;
/* shift the text after and including cp2 back by 1 char, +1 to include null terminator */
@@ -1181,7 +1185,7 @@ static void ui_text_clip_right_label(uiFontStyle *fstyle, uiBut *but, const rcti
/* after the leading text is gone, chop off the : and following space, with ofs */
while ((but->strwidth > okwidth) && (but->ofs < 2)) {
- ui_text_clip_give_next_off(but);
+ ui_text_clip_give_next_off(but, but->drawstr);
but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs, sizeof(but->drawstr) - but->ofs);
if (but->strwidth < 10) break;
}
@@ -1232,6 +1236,14 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
fstyle->align = UI_STYLE_TEXT_LEFT;
}
}
+ else {
+ if (but->editstr) {
+ /* max length isn't used in this case,
+ * we rely on string being NULL terminated. */
+ drawstr_left_len = INT_MAX;
+ drawstr = but->editstr;
+ }
+ }
/* text button selection and cursor */
@@ -1282,9 +1294,11 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
#endif
/* cut string in 2 parts - only for menu entries */
- if ((but->block->flag & UI_BLOCK_LOOP)) {
- if (ELEM3(but->type, NUM, TEX, NUMSLI) == 0) {
- drawstr_right = strchr(drawstr, UI_SEP_CHAR);
+ if ((but->block->flag & UI_BLOCK_LOOP) &&
+ (but->editstr == NULL))
+ {
+ if (but->flag & UI_BUT_HAS_SEP_CHAR) {
+ drawstr_right = strrchr(drawstr, UI_SEP_CHAR);
if (drawstr_right) {
drawstr_left_len = (drawstr_right - drawstr);
drawstr_right++;
@@ -1325,7 +1339,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
if (but->menu_key != '\0') {
char fixedbuf[128];
- char *str;
+ const char *str;
BLI_strncpy(fixedbuf, drawstr + but->ofs, min_ii(sizeof(fixedbuf), drawstr_left_len));
@@ -2308,7 +2322,7 @@ void ui_hsvcube_pos_from_vals(uiBut *but, const rcti *rect, float *hsv, float *x
case UI_GRAD_V_ALT:
x = 0.5f;
/* exception only for value strip - use the range set in but->min/max */
- y = (hsv[2] - but->softmin ) / (but->softmax - but->softmin);
+ y = (hsv[2] - but->softmin) / (but->softmax - but->softmin);
break;
}
@@ -2322,7 +2336,7 @@ static void ui_draw_but_HSVCUBE(uiBut *but, const rcti *rect)
{
float rgb[3];
float x = 0.0f, y = 0.0f;
- float *hsv = ui_block_hsv_get(but->block);
+ const float *hsv = ui_block_hsv_get(but->block);
float hsv_n[3];
bool use_display_colorspace = ui_color_picker_use_display_colorspace(but);
@@ -2462,7 +2476,7 @@ static void widget_numbut_embossn(uiBut *UNUSED(but), uiWidgetColors *wcol, rcti
widget_numbut_draw(wcol, rect, state, roundboxalign, true);
}
-int ui_link_bezier_points(const rcti *rect, float coord_array[][2], int resol)
+bool ui_link_bezier_points(const rcti *rect, float coord_array[][2], int resol)
{
float dist, vec[4][2];
@@ -2479,9 +2493,9 @@ int ui_link_bezier_points(const rcti *rect, float coord_array[][2], int resol)
vec[2][0] = vec[3][0] - dist;
vec[2][1] = vec[3][1];
- BKE_curve_forward_diff_bezier(vec[0][0], vec[1][0], vec[2][0], vec[3][0], coord_array[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);
-
+ BKE_curve_forward_diff_bezier(vec[0][0], vec[1][0], vec[2][0], vec[3][0], &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;
}
@@ -2489,7 +2503,7 @@ int ui_link_bezier_points(const rcti *rect, float coord_array[][2], int resol)
void ui_draw_link_bezier(const rcti *rect)
{
float coord_array[LINK_RESOL + 1][2];
-
+
if (ui_link_bezier_points(rect, coord_array, LINK_RESOL)) {
/* we can reuse the dist variable here to increment the GL curve eval amount*/
// const float dist = 1.0f / (float)LINK_RESOL; // UNUSED
@@ -3753,6 +3767,7 @@ void ui_draw_preview_item(uiFontStyle *fstyle, rcti *rect, const char *name, int
wt->state(wt, state);
wt->draw(&wt->wcol, rect, 0, 0);
+ glEnable(GL_BLEND);
widget_draw_preview(iconid, 1.0f, rect);
BLF_width_and_height(fstyle->uifont_id, name, BLF_DRAW_STR_DUMMY_MAX, &font_dims[0], &font_dims[1]);
@@ -3775,7 +3790,6 @@ void ui_draw_preview_item(uiFontStyle *fstyle, rcti *rect, const char *name, int
bg_rect.xmax = rect->xmax - PREVIEW_PAD;
glColor4ubv((unsigned char *)wt->wcol_theme->inner_sel);
- glEnable(GL_BLEND);
glRecti(bg_rect.xmin, bg_rect.ymin, bg_rect.xmax, bg_rect.ymax);
glDisable(GL_BLEND);
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 8e53f9d2332..16550327a5e 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -950,7 +950,7 @@ void ui_theme_init_default(void)
rgba_char_args_set(btheme->tact.keytype_jitter, 148, 229, 117, 255);
rgba_char_args_set(btheme->tact.keytype_jitter_select, 97, 192, 66, 255);
- rgba_char_args_set(btheme->tact.keyborder, 0, 0, 0, 255);
+ rgba_char_args_set(btheme->tact.keyborder, 0, 0, 0, 255);
rgba_char_args_set(btheme->tact.keyborder_select, 0, 0, 0, 255);
/* space nla */
@@ -969,7 +969,7 @@ void ui_theme_init_default(void)
rgba_char_args_set(btheme->tnla.nla_sound, 43, 61, 61, 255);
rgba_char_args_set(btheme->tnla.nla_sound_sel, 31, 122, 122, 255);
- rgba_char_args_set(btheme->tnla.keyborder, 0, 0, 0, 255);
+ rgba_char_args_set(btheme->tnla.keyborder, 0, 0, 0, 255);
rgba_char_args_set(btheme->tnla.keyborder_select, 0, 0, 0, 255);
/* space file */
@@ -1091,7 +1091,7 @@ void ui_theme_init_default(void)
/* space node, re-uses syntax and console color storage */
btheme->tnode = btheme->tv3d;
- rgba_char_args_set(btheme->tnode.edge_select, 255, 255, 255, 255); /* wire selected */
+ rgba_char_args_set(btheme->tnode.edge_select, 255, 255, 255, 255); /* wire selected */
rgba_char_args_set(btheme->tnode.syntaxl, 155, 155, 155, 160); /* TH_NODE, backdrop */
rgba_char_args_set(btheme->tnode.syntaxn, 100, 100, 100, 255); /* in */
rgba_char_args_set(btheme->tnode.nodeclass_output, 100, 100, 100, 255); /* output */
@@ -1735,7 +1735,7 @@ void init_userdef_do_versions(void)
/* adjust themes */
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
- char *col;
+ const char *col;
/* IPO Editor: Handles/Vertices */
col = btheme->tipo.vertex;
@@ -2381,12 +2381,12 @@ void init_userdef_do_versions(void)
rgba_char_args_set(btheme->tact.keytype_jitter_select, 97, 192, 66, 255);
/* key border */
- rgba_char_args_set(btheme->tact.keyborder, 0, 0, 0, 255);
+ rgba_char_args_set(btheme->tact.keyborder, 0, 0, 0, 255);
rgba_char_args_set(btheme->tact.keyborder_select, 0, 0, 0, 255);
/* NLA ............................ */
/* key border */
- rgba_char_args_set(btheme->tnla.keyborder, 0, 0, 0, 255);
+ rgba_char_args_set(btheme->tnla.keyborder, 0, 0, 0, 255);
rgba_char_args_set(btheme->tnla.keyborder_select, 0, 0, 0, 255);
/* Graph Editor ................... */
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index f20a196627e..982e8f1a9fe 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -38,9 +38,11 @@
#include "DNA_scene_types.h"
#include "DNA_userdef_types.h"
-#include "BLI_blenlib.h"
-#include "BLI_math.h"
#include "BLI_utildefines.h"
+#include "BLI_link_utils.h"
+#include "BLI_rect.h"
+#include "BLI_math.h"
+#include "BLI_memarena.h"
#include "BLI_timecode.h"
#include "BKE_context.h"
@@ -54,7 +56,6 @@
#include "BLF_api.h"
-#include "ED_anim_api.h"
#include "ED_screen.h"
#include "UI_interface.h"
@@ -66,6 +67,35 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, int resize, int mask_
/* *********************************************************************** */
+BLI_INLINE int clamp_float_to_int(const float f)
+{
+ const float min = INT_MIN;
+ const float max = INT_MAX;
+
+ if (UNLIKELY(f < min)) {
+ return min;
+ }
+ else if (UNLIKELY(f > max)) {
+ return max;
+ }
+ else {
+ return (int)f;
+ }
+}
+
+/**
+ * use instead of #BLI_rcti_rctf_copy so we have consistent behavior
+ * with users of #clamp_float_to_int.
+ */
+BLI_INLINE void clamp_rctf_to_rcti(rcti *dst, const rctf *src)
+{
+ dst->xmin = clamp_float_to_int(src->xmin);
+ dst->xmax = clamp_float_to_int(src->xmax);
+ dst->ymin = clamp_float_to_int(src->ymin);
+ dst->ymax = clamp_float_to_int(src->ymax);
+}
+
+
/* XXX still unresolved: scrolls hide/unhide vs region mask handling */
/* XXX there's V2D_SCROLL_HORIZONTAL_HIDE and V2D_SCROLL_HORIZONTAL_FULLR ... */
@@ -1948,7 +1978,7 @@ void UI_view2d_listview_visible_cells(View2D *v2d, float columnwidth, float rowh
/* min */
UI_view2d_listview_view_to_cell(v2d, columnwidth, rowheight, startx, starty,
v2d->cur.xmin, v2d->cur.ymin, column_min, row_min);
-
+
/* max*/
UI_view2d_listview_view_to_cell(v2d, columnwidth, rowheight, startx, starty,
v2d->cur.xmax, v2d->cur.ymax, column_max, row_max);
@@ -1958,28 +1988,44 @@ void UI_view2d_listview_visible_cells(View2D *v2d, float columnwidth, float rowh
/* *********************************************************************** */
/* Coordinate Conversions */
+float UI_view2d_region_to_view_x(struct View2D *v2d, float x)
+{
+ return (v2d->cur.xmin + (BLI_rctf_size_x(&v2d->cur) * (x - v2d->mask.xmin) / BLI_rcti_size_x(&v2d->mask)));
+}
+float UI_view2d_region_to_view_y(struct View2D *v2d, float y)
+{
+ return (v2d->cur.ymin + (BLI_rctf_size_y(&v2d->cur) * (y - v2d->mask.ymin) / BLI_rcti_size_y(&v2d->mask)));
+}
+
/* Convert from screen/region space to 2d-View space
*
* - x,y = coordinates to convert
* - viewx,viewy = resultant coordinates
*/
-void UI_view2d_region_to_view(View2D *v2d, float x, float y, float *r_viewx, float *r_viewy)
+void UI_view2d_region_to_view(View2D *v2d, float x, float y, float *r_view_x, float *r_view_y)
{
- float div, ofs;
+ *r_view_x = UI_view2d_region_to_view_x(v2d, x);
+ *r_view_y = UI_view2d_region_to_view_y(v2d, y);
+}
- if (r_viewx) {
- div = (float)BLI_rcti_size_x(&v2d->mask);
- ofs = (float)v2d->mask.xmin;
-
- *r_viewx = v2d->cur.xmin + BLI_rctf_size_x(&v2d->cur) * ((float)x - ofs) / div;
- }
+void UI_view2d_region_to_view_rctf(View2D *v2d, const rctf *rect_src, rctf *rect_dst)
+{
+ const float cur_size[2] = {BLI_rctf_size_x(&v2d->cur), BLI_rctf_size_y(&v2d->cur)};
+ const float mask_size[2] = {BLI_rcti_size_x(&v2d->mask), BLI_rcti_size_y(&v2d->mask)};
- if (r_viewy) {
- div = (float)BLI_rcti_size_y(&v2d->mask);
- ofs = (float)v2d->mask.ymin;
-
- *r_viewy = v2d->cur.ymin + BLI_rctf_size_y(&v2d->cur) * ((float)y - ofs) / div;
- }
+ rect_dst->xmin = (v2d->cur.xmin + (cur_size[0] * (rect_src->xmin - v2d->mask.xmin) / mask_size[0]));
+ rect_dst->xmax = (v2d->cur.xmin + (cur_size[0] * (rect_src->xmax - v2d->mask.xmin) / mask_size[0]));
+ rect_dst->ymin = (v2d->cur.ymin + (cur_size[1] * (rect_src->ymin - v2d->mask.ymin) / mask_size[1]));
+ rect_dst->ymax = (v2d->cur.ymin + (cur_size[1] * (rect_src->ymax - v2d->mask.ymin) / mask_size[1]));
+}
+
+float UI_view2d_view_to_region_x(View2D *v2d, float x)
+{
+ return (v2d->mask.xmin + (((x - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur)) * BLI_rcti_size_x(&v2d->mask)));
+}
+float UI_view2d_view_to_region_y(View2D *v2d, float y)
+{
+ return (v2d->mask.ymin + (((y - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur)) * BLI_rcti_size_y(&v2d->mask)));
}
/* Convert from 2d-View space to screen/region space
@@ -1988,24 +2034,24 @@ void UI_view2d_region_to_view(View2D *v2d, float x, float y, float *r_viewx, flo
* - x,y = coordinates to convert
* - regionx,regiony = resultant coordinates
*/
-void UI_view2d_view_to_region(View2D *v2d, float x, float y, int *regionx, int *regiony)
+bool UI_view2d_view_to_region_clip(View2D *v2d, float x, float y, int *r_region_x, int *r_region_y)
{
- /* set initial value in case coordinate lies outside of bounds */
- if (regionx)
- *regionx = V2D_IS_CLIPPED;
- if (regiony)
- *regiony = V2D_IS_CLIPPED;
-
/* express given coordinates as proportional values */
x = (x - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur);
y = (y - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur);
/* check if values are within bounds */
if ((x >= 0.0f) && (x <= 1.0f) && (y >= 0.0f) && (y <= 1.0f)) {
- if (regionx)
- *regionx = (int)(v2d->mask.xmin + x * BLI_rcti_size_x(&v2d->mask));
- if (regiony)
- *regiony = (int)(v2d->mask.ymin + y * BLI_rcti_size_y(&v2d->mask));
+ *r_region_x = (int)(v2d->mask.xmin + (x * BLI_rcti_size_x(&v2d->mask)));
+ *r_region_y = (int)(v2d->mask.ymin + (y * BLI_rcti_size_y(&v2d->mask)));
+
+ return true;
+ }
+ else {
+ /* set initial value in case coordinate lies outside of bounds */
+ *r_region_x = *r_region_y = V2D_IS_CLIPPED;
+
+ return false;
}
}
@@ -2015,38 +2061,86 @@ void UI_view2d_view_to_region(View2D *v2d, float x, float y, int *regionx, int *
* - x,y = coordinates to convert
* - regionx,regiony = resultant coordinates
*/
-void UI_view2d_to_region_no_clip(View2D *v2d, float x, float y, int *regionx, int *regiony)
+void UI_view2d_view_to_region(View2D *v2d, float x, float y, int *r_region_x, int *r_region_y)
{
/* step 1: express given coordinates as proportional values */
x = (x - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur);
y = (y - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur);
-
+
/* step 2: convert proportional distances to screen coordinates */
- x = v2d->mask.xmin + x * BLI_rcti_size_x(&v2d->mask);
- y = v2d->mask.ymin + y * BLI_rcti_size_y(&v2d->mask);
-
+ x = v2d->mask.xmin + (x * BLI_rcti_size_x(&v2d->mask));
+ y = v2d->mask.ymin + (y * BLI_rcti_size_y(&v2d->mask));
+
/* although we don't clamp to lie within region bounds, we must avoid exceeding size of ints */
- if (regionx) {
- if (x < INT_MIN) *regionx = INT_MIN;
- else if (x > INT_MAX) *regionx = INT_MAX;
- else *regionx = (int)x;
- }
- if (regiony) {
- if (y < INT_MIN) *regiony = INT_MIN;
- else if (y > INT_MAX) *regiony = INT_MAX;
- else *regiony = (int)y;
- }
+ *r_region_x = clamp_float_to_int(x);
+ *r_region_y = clamp_float_to_int(y);
}
-void UI_view2d_to_region_float(View2D *v2d, float x, float y, float *regionx, float *regiony)
+void UI_view2d_view_to_region_fl(View2D *v2d, float x, float y, float *r_region_x, float *r_region_y)
{
/* express given coordinates as proportional values */
- x = -v2d->cur.xmin / BLI_rctf_size_x(&v2d->cur);
- y = -v2d->cur.ymin / BLI_rctf_size_y(&v2d->cur);
+ x = (x - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur);
+ y = (y - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur);
/* convert proportional distances to screen coordinates */
- *regionx = v2d->mask.xmin + x * BLI_rcti_size_x(&v2d->mask);
- *regiony = v2d->mask.ymin + y * BLI_rcti_size_y(&v2d->mask);
+ *r_region_x = v2d->mask.xmin + (x * BLI_rcti_size_x(&v2d->mask));
+ *r_region_y = v2d->mask.ymin + (y * BLI_rcti_size_y(&v2d->mask));
+}
+
+void UI_view2d_view_to_region_rcti(View2D *v2d, const rctf *rect_src, rcti *rect_dst)
+{
+ const float cur_size[2] = {BLI_rctf_size_x(&v2d->cur), BLI_rctf_size_y(&v2d->cur)};
+ const float mask_size[2] = {BLI_rcti_size_x(&v2d->mask), BLI_rcti_size_y(&v2d->mask)};
+ rctf rect_tmp;
+
+ /* step 1: express given coordinates as proportional values */
+ rect_tmp.xmin = (rect_src->xmin - v2d->cur.xmin) / cur_size[0];
+ rect_tmp.xmax = (rect_src->xmax - v2d->cur.xmin) / cur_size[0];
+ rect_tmp.ymin = (rect_src->ymin - v2d->cur.ymin) / cur_size[1];
+ rect_tmp.ymax = (rect_src->ymax - v2d->cur.ymin) / cur_size[1];
+
+
+ /* step 2: convert proportional distances to screen coordinates */
+ rect_tmp.xmin = v2d->mask.xmin + (rect_tmp.xmin * mask_size[0]);
+ rect_tmp.xmax = v2d->mask.xmin + (rect_tmp.xmax * mask_size[0]);
+ rect_tmp.ymin = v2d->mask.ymin + (rect_tmp.ymin * mask_size[1]);
+ rect_tmp.ymax = v2d->mask.ymin + (rect_tmp.ymax * mask_size[1]);
+
+ clamp_rctf_to_rcti(rect_dst, &rect_tmp);
+}
+
+bool UI_view2d_view_to_region_rcti_clip(View2D *v2d, const rctf *rect_src, rcti *rect_dst)
+{
+ const float cur_size[2] = {BLI_rctf_size_x(&v2d->cur), BLI_rctf_size_y(&v2d->cur)};
+ const float mask_size[2] = {BLI_rcti_size_x(&v2d->mask), BLI_rcti_size_y(&v2d->mask)};
+ rctf rect_tmp;
+
+ BLI_assert(rect_src->xmin <= rect_src->xmax && rect_src->ymin <= rect_src->ymax);
+
+ /* step 1: express given coordinates as proportional values */
+ rect_tmp.xmin = (rect_src->xmin - v2d->cur.xmin) / cur_size[0];
+ rect_tmp.xmax = (rect_src->xmax - v2d->cur.xmin) / cur_size[0];
+ rect_tmp.ymin = (rect_src->ymin - v2d->cur.ymin) / cur_size[1];
+ rect_tmp.ymax = (rect_src->ymax - v2d->cur.ymin) / cur_size[1];
+
+ if (((rect_tmp.xmax < 0.0f) || (rect_tmp.xmin > 1.0f) ||
+ (rect_tmp.ymax < 0.0f) || (rect_tmp.ymin > 1.0f)) == 0)
+ {
+ /* step 2: convert proportional distances to screen coordinates */
+ rect_tmp.xmin = v2d->mask.xmin + (rect_tmp.xmin * mask_size[0]);
+ rect_tmp.xmax = v2d->mask.ymin + (rect_tmp.xmax * mask_size[0]);
+ rect_tmp.ymin = v2d->mask.ymin + (rect_tmp.ymin * mask_size[1]);
+ rect_tmp.ymax = v2d->mask.ymin + (rect_tmp.ymax * mask_size[1]);
+
+ clamp_rctf_to_rcti(rect_dst, &rect_tmp);
+
+ return true;
+ }
+ else {
+ rect_dst->xmin = rect_dst->xmax = rect_dst->ymin = rect_dst->ymax = V2D_IS_CLIPPED;
+
+ return false;
+ }
}
/* *********************************************************************** */
@@ -2085,13 +2179,13 @@ View2D *UI_view2d_fromcontext_rwin(const bContext *C)
*
* - x,y = scale on each axis
*/
-void UI_view2d_getscale(View2D *v2d, float *x, float *y)
+void UI_view2d_scale_get(View2D *v2d, float *x, float *y)
{
if (x) *x = BLI_rcti_size_x(&v2d->mask) / BLI_rctf_size_x(&v2d->cur);
if (y) *y = BLI_rcti_size_y(&v2d->mask) / BLI_rctf_size_y(&v2d->cur);
}
-/* Same as UI_view2d_getscale() - 1.0f / x, y */
-void UI_view2d_getscale_inverse(View2D *v2d, float *x, float *y)
+/* Same as UI_view2d_scale_get() - 1.0f / x, y */
+void UI_view2d_scale_get_inverse(View2D *v2d, float *x, float *y)
{
if (x) *x = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
if (y) *y = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask);
@@ -2100,13 +2194,13 @@ void UI_view2d_getscale_inverse(View2D *v2d, float *x, float *y)
/* Simple functions for consistent center offset access.
* Used by node editor to shift view center for each individual node tree.
*/
-void UI_view2d_getcenter(struct View2D *v2d, float *x, float *y)
+void UI_view2d_center_get(struct View2D *v2d, float *x, float *y)
{
/* get center */
if (x) *x = BLI_rctf_cent_x(&v2d->cur);
if (y) *y = BLI_rctf_cent_y(&v2d->cur);
}
-void UI_view2d_setcenter(struct View2D *v2d, float x, float y)
+void UI_view2d_center_set(struct View2D *v2d, float x, float y)
{
BLI_rctf_recenter(&v2d->cur, x, y);
@@ -2175,56 +2269,79 @@ short UI_view2d_mouse_in_scrollers(const bContext *C, View2D *v2d, int x, int y)
/* ******************* view2d text drawing cache ******************** */
-/* assumes caches are used correctly, so for time being no local storage in v2d */
-static ListBase strings = {NULL, NULL};
-
typedef struct View2DString {
- struct View2DString *next, *prev;
+ struct View2DString *next;
union {
unsigned char ub[4];
int pack;
} col;
- int mval[2];
rcti rect;
+ int mval[2];
} View2DString;
+/* assumes caches are used correctly, so for time being no local storage in v2d */
+static MemArena *g_v2d_strings_arena = NULL;
+static View2DString *g_v2d_strings = NULL;
-void UI_view2d_text_cache_add(View2D *v2d, float x, float y, const char *str, const char col[4])
+void UI_view2d_text_cache_add(View2D *v2d, float x, float y,
+ const char *str, size_t str_len, const char col[4])
{
int mval[2];
- UI_view2d_view_to_region(v2d, x, y, mval, mval + 1);
-
- if (mval[0] != V2D_IS_CLIPPED && mval[1] != V2D_IS_CLIPPED) {
- int len = strlen(str) + 1;
- /* use calloc, rect has to be zeroe'd */
- View2DString *v2s = MEM_callocN(sizeof(View2DString) + len, "View2DString");
- char *v2s_str = (char *)(v2s + 1);
- memcpy(v2s_str, str, len);
+ BLI_assert(str_len == strlen(str));
+
+ if (UI_view2d_view_to_region_clip(v2d, x, y, &mval[0], &mval[1])) {
+ int alloc_len = str_len + 1;
+ View2DString *v2s;
+
+ if (g_v2d_strings_arena == NULL) {
+ g_v2d_strings_arena = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 14), __func__);
+ }
+
+ v2s = BLI_memarena_alloc(g_v2d_strings_arena, sizeof(View2DString) + alloc_len);
+
+ BLI_LINKS_PREPEND(g_v2d_strings, v2s);
- BLI_addtail(&strings, v2s);
v2s->col.pack = *((int *)col);
+
+ memset(&v2s->rect, 0, sizeof(v2s->rect));
+
v2s->mval[0] = mval[0];
v2s->mval[1] = mval[1];
+
+ memcpy(v2s + 1, str, alloc_len);
}
}
/* no clip (yet) */
-void UI_view2d_text_cache_rectf(View2D *v2d, const rctf *rect, const char *str, const char col[4])
+void UI_view2d_text_cache_add_rectf(View2D *v2d, const rctf *rect_view,
+ const char *str, size_t str_len, const char col[4])
{
- int len = strlen(str) + 1;
- View2DString *v2s = MEM_callocN(sizeof(View2DString) + len, "View2DString");
- char *v2s_str = (char *)(v2s + 1);
- memcpy(v2s_str, str, len);
+ rcti rect;
+
+ BLI_assert(str_len == strlen(str));
+
+ if (UI_view2d_view_to_region_rcti_clip(v2d, rect_view, &rect)) {
+ int alloc_len = str_len + 1;
+ View2DString *v2s;
- UI_view2d_to_region_no_clip(v2d, rect->xmin, rect->ymin, &v2s->rect.xmin, &v2s->rect.ymin);
- UI_view2d_to_region_no_clip(v2d, rect->xmax, rect->ymax, &v2s->rect.xmax, &v2s->rect.ymax);
+ if (g_v2d_strings_arena == NULL) {
+ g_v2d_strings_arena = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 14), __func__);
+ }
+
+ v2s = BLI_memarena_alloc(g_v2d_strings_arena, sizeof(View2DString) + alloc_len);
+
+ BLI_LINKS_PREPEND(g_v2d_strings, v2s);
+
+ v2s->col.pack = *((int *)col);
+
+ v2s->rect = rect;
- v2s->col.pack = *((int *)col);
- v2s->mval[0] = v2s->rect.xmin;
- v2s->mval[1] = v2s->rect.ymin;
+ v2s->mval[0] = v2s->rect.xmin;
+ v2s->mval[1] = v2s->rect.ymin;
- BLI_addtail(&strings, v2s);
+ memcpy(v2s + 1, str, alloc_len);
+ }
}
@@ -2234,7 +2351,7 @@ void UI_view2d_text_cache_draw(ARegion *ar)
int col_pack_prev = 0;
/* investigate using BLF_ascender() */
- const float default_height = strings.first ? BLF_height_default("28", 3) : 0.0f;
+ const float default_height = g_v2d_strings ? BLF_height_default("28", 3) : 0.0f;
// glMatrixMode(GL_PROJECTION);
// glPushMatrix();
@@ -2242,7 +2359,7 @@ void UI_view2d_text_cache_draw(ARegion *ar)
// glPushMatrix();
ED_region_pixelspace(ar);
- for (v2s = strings.first; v2s; v2s = v2s->next) {
+ for (v2s = g_v2d_strings; v2s; v2s = v2s->next) {
const char *str = (const char *)(v2s + 1);
int xofs = 0, yofs;
@@ -2263,14 +2380,17 @@ void UI_view2d_text_cache_draw(ARegion *ar)
BLF_disable_default(BLF_CLIPPING);
}
}
-
+ g_v2d_strings = NULL;
+
+ if (g_v2d_strings_arena) {
+ BLI_memarena_free(g_v2d_strings_arena);
+ g_v2d_strings_arena = NULL;
+ }
+
// glMatrixMode(GL_PROJECTION);
// glPopMatrix();
// glMatrixMode(GL_MODELVIEW);
// glPopMatrix();
-
- if (strings.first)
- BLI_freelistN(&strings);
}
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index 2271b91806b..e30c6ca61ba 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -757,7 +757,7 @@ static int view_zoomin_invoke(bContext *C, wmOperator *op, const wmEvent *event)
ARegion *ar = CTX_wm_region(C);
/* store initial mouse position (in view space) */
- UI_view2d_region_to_view(&ar->v2d,
+ UI_view2d_region_to_view(&ar->v2d,
event->mval[0], event->mval[1],
&vzd->mx_2d, &vzd->my_2d);
}
@@ -1033,7 +1033,7 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, const wmEvent *even
if (U.viewzoom == USER_ZOOM_CONT) {
/* needs a timer to continue redrawing */
- vzd->timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.01f);
+ vzd->timer = WM_event_add_timer(CTX_wm_manager(C), window, TIMER, 0.01f);
vzd->timer_lastdraw = PIL_check_seconds_timer();
}
@@ -1182,8 +1182,8 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op)
const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
/* convert coordinates of rect to 'tot' rect coordinates */
- UI_view2d_region_to_view(v2d, RNA_int_get(op->ptr, "xmin"), RNA_int_get(op->ptr, "ymin"), &rect.xmin, &rect.ymin);
- UI_view2d_region_to_view(v2d, RNA_int_get(op->ptr, "xmax"), RNA_int_get(op->ptr, "ymax"), &rect.xmax, &rect.ymax);
+ WM_operator_properties_border_to_rctf(op, &rect);
+ UI_view2d_region_to_view_rctf(v2d, &rect, &rect);
/* check if zooming in/out view */
gesture_mode = RNA_int_get(op->ptr, "gesture_mode");
@@ -1348,14 +1348,14 @@ struct SmoothView2DStore {
*/
static float smooth_view_rect_to_fac(const rctf *rect_a, const rctf *rect_b)
{
- float size_a[2] = {BLI_rctf_size_x(rect_a),
- BLI_rctf_size_y(rect_a)};
- float size_b[2] = {BLI_rctf_size_x(rect_b),
- BLI_rctf_size_y(rect_b)};
- float cent_a[2] = {BLI_rctf_cent_x(rect_a),
- BLI_rctf_cent_y(rect_a)};
- float cent_b[2] = {BLI_rctf_cent_x(rect_b),
- BLI_rctf_cent_y(rect_b)};
+ const float size_a[2] = {BLI_rctf_size_x(rect_a),
+ BLI_rctf_size_y(rect_a)};
+ const float size_b[2] = {BLI_rctf_size_x(rect_b),
+ BLI_rctf_size_y(rect_b)};
+ const float cent_a[2] = {BLI_rctf_cent_x(rect_a),
+ BLI_rctf_cent_y(rect_a)};
+ const float cent_b[2] = {BLI_rctf_cent_x(rect_b),
+ BLI_rctf_cent_y(rect_b)};
float fac_max = 0.0f;
float tfac;
diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c
index d2c1d844326..b816103de13 100644
--- a/source/blender/editors/mask/mask_add.c
+++ b/source/blender/editors/mask/mask_add.c
@@ -40,7 +40,6 @@
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_mask_types.h"
-#include "DNA_object_types.h" /* SELECT */
#include "WM_api.h"
#include "WM_types.h"
diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index e84bdf12067..92d55cc1abb 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -531,7 +531,7 @@ static void draw_spline_curve(const bContext *C, MaskLayer *masklay, MaskSpline
if (!is_fill) {
- float *fp = &diff_points[0][0];
+ const float *fp = &diff_points[0][0];
float *fp_feather = &feather_points[0][0];
float tvec[2];
int i;
@@ -622,7 +622,7 @@ void ED_mask_draw(const bContext *C,
ED_mask_get_size(sa, &width, &height);
ED_mask_get_aspect(sa, ar, &aspx, &aspy);
- UI_view2d_getscale(&ar->v2d, &xscale, &yscale);
+ UI_view2d_scale_get(&ar->v2d, &xscale, &yscale);
draw_masklays(C, mask, draw_flag, draw_type, width, height, xscale * aspx, yscale * aspy);
}
@@ -643,15 +643,21 @@ static void mask_rasterize_func(TaskPool *pool, void *taskdata, int UNUSED(threa
ThreadedMaskRasterizeState *state = (ThreadedMaskRasterizeState *) BLI_task_pool_userdata(pool);
ThreadedMaskRasterizeData *data = (ThreadedMaskRasterizeData *) taskdata;
int scanline;
+ const float x_inv = 1.0f / (float)state->width;
+ const float y_inv = 1.0f / (float)state->height;
+ const float x_px_ofs = x_inv * 0.5f;
+ const float y_px_ofs = y_inv * 0.5f;
for (scanline = 0; scanline < data->num_scanlines; scanline++) {
+ float xy[2];
int x, y = data->start_scanline + scanline;
+
+ xy[1] = ((float)y * y_inv) + y_px_ofs;
+
for (x = 0; x < state->width; x++) {
int index = y * state->width + x;
- float xy[2];
- xy[0] = (float) x / state->width;
- xy[1] = (float) y / state->height;
+ xy[0] = ((float)x * x_inv) + x_px_ofs;
state->buffer[index] = BKE_maskrasterize_handle_sample(state->handle, xy);
}
@@ -732,7 +738,7 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar,
float xofs, yofs;
/* find window pixel coordinates of origin */
- UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y);
+ UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x, &y);
/* w = BLI_rctf_size_x(&v2d->tot); */
diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c
index d94a1906a84..1acdff8b824 100644
--- a/source/blender/editors/mask/mask_edit.c
+++ b/source/blender/editors/mask/mask_edit.c
@@ -326,7 +326,7 @@ void ED_mask_pixelspace_factor(ScrArea *sa, ARegion *ar, float *scalex, float *s
SpaceClip *sc = sa->spacedata.first;
float aspx, aspy;
- UI_view2d_getscale(&ar->v2d, scalex, scaley);
+ UI_view2d_scale_get(&ar->v2d, scalex, scaley);
ED_space_clip_get_aspect(sc, &aspx, &aspy);
*scalex *= aspx;
@@ -343,7 +343,7 @@ void ED_mask_pixelspace_factor(ScrArea *sa, ARegion *ar, float *scalex, float *s
SpaceImage *sima = sa->spacedata.first;
float aspx, aspy;
- UI_view2d_getscale(&ar->v2d, scalex, scaley);
+ UI_view2d_scale_get(&ar->v2d, scalex, scaley);
ED_space_image_get_aspect(sima, &aspx, &aspy);
*scalex *= aspx;
diff --git a/source/blender/editors/mask/mask_editaction.c b/source/blender/editors/mask/mask_editaction.c
index 547f08653cb..bcf9ee5c88d 100644
--- a/source/blender/editors/mask/mask_editaction.c
+++ b/source/blender/editors/mask/mask_editaction.c
@@ -36,11 +36,9 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
-#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "DNA_mask_types.h"
-#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BKE_fcurve.h"
diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c
index 00629ab9537..b7e026ca8e3 100644
--- a/source/blender/editors/mask/mask_ops.c
+++ b/source/blender/editors/mask/mask_ops.c
@@ -1854,7 +1854,7 @@ static int mask_hide_view_set_exec(bContext *C, wmOperator *op)
{
Mask *mask = CTX_data_edit_mask(C);
MaskLayer *masklay;
- const int unselected = RNA_boolean_get(op->ptr, "unselected");
+ const bool unselected = RNA_boolean_get(op->ptr, "unselected");
bool changed = false;
for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
diff --git a/source/blender/editors/mask/mask_relationships.c b/source/blender/editors/mask/mask_relationships.c
index 9cc1702addb..e02561d839c 100644
--- a/source/blender/editors/mask/mask_relationships.c
+++ b/source/blender/editors/mask/mask_relationships.c
@@ -46,7 +46,6 @@
#include "ED_screen.h"
#include "ED_clip.h" /* frame remapping functions */
-#include "ED_mask.h" /* own include */
#include "mask_intern.h" /* own include */
@@ -112,7 +111,7 @@ static int mask_parent_set_exec(bContext *C, wmOperator *UNUSED(op))
int framenr, parent_type;
float parmask_pos[2], orig_corners[4][2];
- char *sub_parent_name;
+ const char *sub_parent_name;
if (ELEM(NULL, sc, clip)) {
return OPERATOR_CANCELLED;
@@ -195,7 +194,7 @@ void MASK_OT_parent_set(wmOperatorType *ot)
//ot->invoke = mask_parent_set_invoke;
ot->exec = mask_parent_set_exec;
- ot->poll = ED_maskedit_mask_poll;
+ ot->poll = ED_space_clip_maskedit_mask_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c
index 56eb8cf626b..af6f127327c 100644
--- a/source/blender/editors/mask/mask_select.c
+++ b/source/blender/editors/mask/mask_select.c
@@ -40,13 +40,11 @@
#include "BKE_mask.h"
#include "DNA_mask_types.h"
-#include "DNA_object_types.h" /* SELECT */
#include "WM_api.h"
#include "WM_types.h"
#include "ED_screen.h"
-#include "ED_clip.h"
#include "ED_mask.h" /* own include */
#include "RNA_access.h"
@@ -699,7 +697,7 @@ static int mask_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmE
MaskSpline *spline;
MaskSplinePoint *point = NULL;
float co[2];
- int do_select = !RNA_boolean_get(op->ptr, "deselect");
+ bool do_select = !RNA_boolean_get(op->ptr, "deselect");
const float threshold = 19;
bool changed = false;
diff --git a/source/blender/editors/mask/mask_shapekey.c b/source/blender/editors/mask/mask_shapekey.c
index 26b97580b91..99ffc9cd7d2 100644
--- a/source/blender/editors/mask/mask_shapekey.c
+++ b/source/blender/editors/mask/mask_shapekey.c
@@ -38,7 +38,6 @@
#include "BKE_context.h"
#include "BKE_depsgraph.h"
#include "BKE_mask.h"
-#include "BKE_report.h"
#include "DNA_object_types.h"
#include "DNA_mask_types.h"
diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c
index 9e1785e27d1..5150a703951 100644
--- a/source/blender/editors/mesh/editface.c
+++ b/source/blender/editors/mesh/editface.c
@@ -29,7 +29,6 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
-#include "BLI_edgehash.h"
#include "BLI_bitmap.h"
#include "BLF_translation.h"
@@ -66,7 +65,7 @@ void paintface_flush_flags(Object *ob)
DerivedMesh *dm = ob->derivedFinal;
MPoly *polys, *mp_orig;
MFace *faces;
- int *index_array = NULL;
+ const int *index_array = NULL;
int totface, totpoly;
int i;
@@ -499,7 +498,7 @@ void paintvert_flush_flags(Object *ob)
Mesh *me = BKE_mesh_from_object(ob);
DerivedMesh *dm = ob->derivedFinal;
MVert *dm_mvert, *dm_mv;
- int *index_array = NULL;
+ const int *index_array = NULL;
int totvert;
int i;
diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c
index a442d549a14..b288a02a3d1 100644
--- a/source/blender/editors/mesh/editmesh_add.c
+++ b/source/blender/editors/mesh/editmesh_add.c
@@ -32,7 +32,6 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
-#include "BLI_math.h"
#include "BLF_translation.h"
diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c
index fe49d9ad000..6a54f1979cf 100644
--- a/source/blender/editors/mesh/editmesh_bisect.c
+++ b/source/blender/editors/mesh/editmesh_bisect.c
@@ -32,7 +32,6 @@
#include "DNA_object_types.h"
#include "BLI_math.h"
-#include "BLI_string.h"
#include "BLF_translation.h"
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index cffd38b2a30..366a8253849 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -1156,25 +1156,30 @@ static void calc_ortho_extent(KnifeTool_OpData *kcd)
* s in screen projection of p. */
static bool point_is_visible(KnifeTool_OpData *kcd, const float p[3], const float s[2], bglMats *mats)
{
- float p1[3], no[3], view[3];
BMFace *f_hit;
/* If not cutting through, make sure no face is in front of p */
if (!kcd->cut_through) {
+ float dist;
+ float view[3], p_ofs[3];
+
/* TODO: I think there's a simpler way to get the required raycast ray */
ED_view3d_unproject(mats, view, s[0], s[1], 0.0f);
+
mul_m4_v3(kcd->ob->imat, view);
- /* make p1 a little towards view, so ray doesn't hit p's face. */
- copy_v3_v3(p1, p);
- sub_v3_v3(view, p1);
- normalize_v3(view);
- copy_v3_v3(no, view);
- mul_v3_fl(no, 3.0f * KNIFE_FLT_EPSBIG);
- add_v3_v3(p1, no);
+ /* make p_ofs a little towards view, so ray doesn't hit p's face. */
+ sub_v3_v3(view, p);
+ dist = normalize_v3(view);
+ madd_v3_v3v3fl(p_ofs, p, view, KNIFE_FLT_EPSBIG * 3.0f);
+
+ /* avoid projecting behind the viewpoint */
+ if (kcd->is_ortho) {
+ dist = FLT_MAX;
+ }
/* see if there's a face hit between p1 and the view */
- f_hit = BKE_bmbvh_ray_cast(kcd->bmbvh, p1, no, KNIFE_FLT_EPS, NULL, NULL, NULL);
+ f_hit = BKE_bmbvh_ray_cast(kcd->bmbvh, p_ofs, view, KNIFE_FLT_EPS, &dist, NULL, NULL);
if (f_hit)
return false;
}
@@ -1395,6 +1400,12 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
isect_kind = isect_line_line_v3(kfe->v1->cageco, kfe->v2->cageco, r1, r2, p, p2);
if (isect_kind >= 1 && point_is_visible(kcd, p, sint, &mats)) {
memset(&hit, 0, sizeof(hit));
+ if (kcd->snap_midpoints) {
+ /* choose intermediate point snap too */
+ mid_v3_v3v3(p, kfe->v1->cageco, kfe->v2->cageco);
+ mid_v2_v2v2(sint, se1, se2);
+ lambda = 0.5f;
+ }
hit.kfe = kfe;
copy_v3_v3(hit.hit, p);
copy_v3_v3(hit.cagehit, p);
@@ -2618,9 +2629,9 @@ static void knifetool_init(bContext *C, KnifeTool_OpData *kcd,
ED_region_tag_redraw(kcd->ar);
- kcd->refs = BLI_mempool_create(sizeof(Ref), 1, 2048, 0);
- kcd->kverts = BLI_mempool_create(sizeof(KnifeVert), 1, 512, BLI_MEMPOOL_ALLOW_ITER);
- kcd->kedges = BLI_mempool_create(sizeof(KnifeEdge), 1, 512, BLI_MEMPOOL_ALLOW_ITER);
+ kcd->refs = BLI_mempool_create(sizeof(Ref), 0, 2048, 0);
+ kcd->kverts = BLI_mempool_create(sizeof(KnifeVert), 0, 512, BLI_MEMPOOL_ALLOW_ITER);
+ kcd->kedges = BLI_mempool_create(sizeof(KnifeEdge), 0, 512, BLI_MEMPOOL_ALLOW_ITER);
kcd->origedgemap = BLI_ghash_ptr_new("knife origedgemap");
kcd->origvertmap = BLI_ghash_ptr_new("knife origvertmap");
@@ -2928,7 +2939,7 @@ static void edvm_mesh_knife_face_point(BMFace *f, float r_cent[3])
unsigned int (*index)[3] = BLI_array_alloca(index, tottri);
int j;
- float const *best_co[3] = {NULL};
+ const float *best_co[3] = {NULL};
float best_area = -1.0f;
bool ok = false;
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c
index 9a02a9761b0..4ef6c13ec3e 100644
--- a/source/blender/editors/mesh/editmesh_loopcut.c
+++ b/source/blender/editors/mesh/editmesh_loopcut.c
@@ -415,7 +415,7 @@ static int ringsel_init(bContext *C, wmOperator *op, bool do_cut)
lcd->num.unit_type[1] = B_UNIT_NONE;
/* XXX, temp, workaround for [# ] */
- EDBM_mesh_ensure_valid_dm_hack(CTX_data_scene(C), lcd->em);
+ EDBM_mesh_ensure_valid_dm_hack(scene, lcd->em);
em_setup_viewcontext(C, &lcd->vc);
@@ -493,7 +493,7 @@ static int loopcut_init(bContext *C, wmOperator *op, const wmEvent *event)
{
Scene *scene = CTX_data_scene(C);
ToolSettings *settings = scene->toolsettings;
- int mesh_select_mode[3] = {
+ const int mesh_select_mode[3] = {
(settings->selectmode & SCE_SELECT_VERTEX) != 0,
(settings->selectmode & SCE_SELECT_EDGE) != 0,
(settings->selectmode & SCE_SELECT_FACE) != 0,
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index 467b08c266c..15bfeea8918 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -41,7 +41,6 @@
#include "BLI_smallhash.h"
#include "BKE_context.h"
-#include "BKE_displist.h"
#include "BKE_report.h"
#include "BKE_paint.h"
#include "BKE_editmesh.h"
@@ -59,8 +58,6 @@
#include "ED_screen.h"
#include "ED_view3d.h"
-#include "BIF_gl.h"
-
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
@@ -168,7 +165,7 @@ void EDBM_select_mirrored(BMEditMesh *em, bool extend,
void EDBM_automerge(Scene *scene, Object *obedit, bool update, const char hflag)
{
- int ok;
+ bool ok;
BMEditMesh *em = BKE_editmesh_from_object(obedit);
ok = BMO_op_callf(em->bm, BMO_FLAG_DEFAULTS,
@@ -2092,7 +2089,7 @@ static int edbm_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmE
BMVert *eve;
BMEdge *e, *eed;
BMFace *efa;
- int sel = !RNA_boolean_get(op->ptr, "deselect");
+ const bool sel = !RNA_boolean_get(op->ptr, "deselect");
int limit;
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 68f80087e31..159eac4a275 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -823,27 +823,24 @@ static int edbm_mark_sharp_exec(bContext *C, wmOperator *op)
BMEdge *eed;
BMIter iter;
const bool clear = RNA_boolean_get(op->ptr, "clear");
+ const bool use_verts = RNA_boolean_get(op->ptr, "use_verts");
/* auto-enable sharp edge drawing */
if (clear == 0) {
me->drawflag |= ME_DRAWSHARP;
}
- if (!clear) {
- BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) {
- if (!BM_elem_flag_test(eed, BM_ELEM_SELECT) || BM_elem_flag_test(eed, BM_ELEM_HIDDEN))
+ BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) {
+ if (use_verts) {
+ if (!(BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) || BM_elem_flag_test(eed->v2, BM_ELEM_SELECT))) {
continue;
-
- BM_elem_flag_disable(eed, BM_ELEM_SMOOTH);
+ }
}
- }
- else {
- BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) {
- if (!BM_elem_flag_test(eed, BM_ELEM_SELECT) || BM_elem_flag_test(eed, BM_ELEM_HIDDEN))
- continue;
-
- BM_elem_flag_enable(eed, BM_ELEM_SMOOTH);
+ else if (!BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
+ continue;
}
+
+ BM_elem_flag_set(eed, BM_ELEM_SMOOTH, clear);
}
EDBM_update_generic(em, true, false);
@@ -867,11 +864,13 @@ void MESH_OT_mark_sharp(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- prop = RNA_def_boolean(ot->srna, "clear", 0, "Clear", "");
+ prop = RNA_def_boolean(ot->srna, "clear", false, "Clear", "");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+ prop = RNA_def_boolean(ot->srna, "use_verts", false, "Vertices",
+ "Consider vertices instead of edges to select which edges to (un)tag as sharp");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
-
static int edbm_vert_connect_exec(bContext *C, wmOperator *op)
{
Object *obedit = CTX_data_edit_object(C);
@@ -1285,7 +1284,7 @@ static int edbm_do_smooth_vertex_exec(bContext *C, wmOperator *op)
Mesh *me = obedit->data;
BMEditMesh *em = BKE_editmesh_from_object(obedit);
ModifierData *md;
- int mirrx = false, mirry = false, mirrz = false;
+ bool mirrx = false, mirry = false, mirrz = false;
int i, repeat;
float clip_dist = 0.0f;
bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0;
@@ -1370,7 +1369,7 @@ static int edbm_do_smooth_laplacian_vertex_exec(bContext *C, wmOperator *op)
BMEditMesh *em = BKE_editmesh_from_object(obedit);
Mesh *me = obedit->data;
bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0;
- int usex = true, usey = true, usez = true, preserve_volume = true;
+ bool usex = true, usey = true, usez = true, preserve_volume = true;
int i, repeat;
float lambda_factor;
float lambda_border;
@@ -2072,7 +2071,7 @@ static int edbm_blend_from_shape_exec(bContext *C, wmOperator *op)
if (use_add) {
/* in add mode, we add relative shape key offset */
if (kb) {
- float *rco = CustomData_bmesh_get_n(&em->bm->vdata, eve->head.data, CD_SHAPEKEY, kb->relative);
+ const float *rco = CustomData_bmesh_get_n(&em->bm->vdata, eve->head.data, CD_SHAPEKEY, kb->relative);
sub_v3_v3v3(co, co, rco);
}
@@ -2158,6 +2157,7 @@ void MESH_OT_blend_from_shape(wmOperatorType *ot)
/* properties */
prop = RNA_def_enum(ot->srna, "shape", DummyRNA_NULL_items, 0, "Shape", "Shape key to use for blending");
RNA_def_enum_funcs(prop, shape_itemf);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
RNA_def_float(ot->srna, "blend", 1.0f, -FLT_MAX, FLT_MAX, "Blend", "Blending factor", -2.0f, 2.0f);
RNA_def_boolean(ot->srna, "add", 1, "Add", "Add rather than blend between shapes");
}
@@ -2653,7 +2653,7 @@ static void mesh_separate_material_assign_mat_nr(Object *ob, const short mat_nr)
ID *obdata = ob->data;
Material ***matarar;
- short *totcolp;
+ const short *totcolp;
totcolp = give_totcolp_id(obdata);
matarar = give_matarar_id(obdata);
@@ -4264,7 +4264,7 @@ static void sort_bmelem_flag(Scene *scene, Object *ob,
pb = pblock[j];
sb = sblock[j];
if (pb && sb && !map[j]) {
- char *p_blk;
+ const char *p_blk;
BMElemSort *s_blk;
int tot = totelem[j];
int aff = affected[j];
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c
index b84a0cc6600..758cbd59794 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -50,7 +50,6 @@
#include "BKE_editmesh_bvh.h"
#include "BKE_object.h" /* XXX. only for EDBM_mesh_ensure_valid_dm_hack() which will be removed */
-#include "BKE_scene.h" /* XXX, only for eval_ctx used in EDBM_mesh_ensure_valid_dm_hack */
#include "WM_api.h"
#include "WM_types.h"
@@ -1135,7 +1134,7 @@ void EDBM_verts_mirror_cache_begin(BMEditMesh *em, const int axis,
BMVert *EDBM_verts_mirror_get(BMEditMesh *em, BMVert *v)
{
- int *mirr = CustomData_bmesh_get_layer_n(&em->bm->vdata, v->head.data, em->mirror_cdlayer);
+ const int *mirr = CustomData_bmesh_get_layer_n(&em->bm->vdata, v->head.data, em->mirror_cdlayer);
BLI_assert(em->mirror_cdlayer != -1); /* invalid use */
@@ -1261,9 +1260,11 @@ void EDBM_mesh_reveal(BMEditMesh *em)
BM_EDGES_OF_MESH,
BM_FACES_OF_MESH};
- int sels[3] = {(em->selectmode & SCE_SELECT_VERTEX),
- (em->selectmode & SCE_SELECT_EDGE),
- (em->selectmode & SCE_SELECT_FACE), };
+ const bool sels[3] = {
+ (em->selectmode & SCE_SELECT_VERTEX) != 0,
+ (em->selectmode & SCE_SELECT_EDGE) != 0,
+ (em->selectmode & SCE_SELECT_FACE) != 0,
+ };
int i;
/* Use tag flag to remember what was hidden before all is revealed.
diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c
index 0740370cd1f..7c38ef21791 100644
--- a/source/blender/editors/mesh/mesh_ops.c
+++ b/source/blender/editors/mesh/mesh_ops.c
@@ -31,7 +31,6 @@
#include "DNA_scene_types.h"
#include "DNA_modifier_types.h"
-#include "BLI_math.h"
#include "RNA_access.h"
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index c1d1c10124e..d252ae20270 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -596,7 +596,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
DerivedMesh *dm = NULL;
Key *key = me->key;
KeyBlock *kb;
- int ok = 0, nonequal_verts = 0;
+ bool ok = false, nonequal_verts = false;
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases)
{
@@ -606,7 +606,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
selme = (Mesh *)base->object->data;
if (selme->totvert == me->totvert)
- ok++;
+ ok = true;
else
nonequal_verts = 1;
}
diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c
index a833c530711..1441a1ef4c0 100644
--- a/source/blender/editors/metaball/mball_edit.c
+++ b/source/blender/editors/metaball/mball_edit.c
@@ -56,7 +56,6 @@
#include "ED_mball.h"
#include "ED_screen.h"
#include "ED_view3d.h"
-#include "ED_transform.h"
#include "ED_util.h"
#include "WM_api.h"
@@ -502,7 +501,7 @@ static int hide_metaelems_exec(bContext *C, wmOperator *op)
Object *obedit = CTX_data_edit_object(C);
MetaBall *mb = (MetaBall *)obedit->data;
MetaElem *ml;
- const int invert = RNA_boolean_get(op->ptr, "unselected") ? SELECT : 0;
+ const bool invert = RNA_boolean_get(op->ptr, "unselected") ? SELECT : 0;
ml = mb->editelems->first;
diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt
index 8277c7f7b86..1bb35b65918 100644
--- a/source/blender/editors/object/CMakeLists.txt
+++ b/source/blender/editors/object/CMakeLists.txt
@@ -42,6 +42,7 @@ set(INC_SYS
set(SRC
object_add.c
object_bake.c
+ object_bake_api.c
object_constraint.c
object_edit.c
object_group.c
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index e3041d97019..99dd8b75609 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -45,7 +45,6 @@
#include "DNA_object_force.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
-#include "DNA_speaker_types.h"
#include "DNA_vfont_types.h"
#include "DNA_actuator_types.h"
@@ -61,7 +60,6 @@
#include "BKE_animsys.h"
#include "BKE_armature.h"
#include "BKE_camera.h"
-#include "BKE_constraint.h"
#include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_depsgraph.h"
@@ -79,7 +77,6 @@
#include "BKE_material.h"
#include "BKE_mball.h"
#include "BKE_mesh.h"
-#include "BKE_modifier.h"
#include "BKE_nla.h"
#include "BKE_object.h"
#include "BKE_particle.h"
@@ -798,6 +795,8 @@ void OBJECT_OT_empty_add(wmOperatorType *ot)
static int empty_drop_named_image_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
+ Scene *scene = CTX_data_scene(C);
+
Base *base = NULL;
Image *ima = NULL;
Object *ob = NULL;
@@ -826,7 +825,7 @@ static int empty_drop_named_image_invoke(bContext *C, wmOperator *op, const wmEv
/* if empty under cursor, then set object */
if (base && base->object->type == OB_EMPTY) {
ob = base->object;
- WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, CTX_data_scene(C));
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
}
else {
/* add new empty */
@@ -843,8 +842,11 @@ static int empty_drop_named_image_invoke(bContext *C, wmOperator *op, const wmEv
ED_view3d_cursor3d_position(C, ob->loc, event->mval);
}
- ob->empty_drawtype = OB_EMPTY_IMAGE;
+ BKE_object_empty_draw_type_set(ob, OB_EMPTY_IMAGE);
+
+ id_us_min(ob->data);
ob->data = ima;
+ id_us_plus(ob->data);
return OPERATOR_FINISHED;
}
@@ -987,6 +989,8 @@ static int group_instance_add_exec(bContext *C, wmOperator *op)
/* only used as menu */
void OBJECT_OT_group_instance_add(wmOperatorType *ot)
{
+ PropertyRNA *prop;
+
/* identifiers */
ot->name = "Add Group Instance";
ot->description = "Add a dupligroup instance";
@@ -1002,8 +1006,10 @@ void OBJECT_OT_group_instance_add(wmOperatorType *ot)
/* properties */
RNA_def_string(ot->srna, "name", "Group", MAX_ID_NAME - 2, "Name", "Group name to add");
- ot->prop = RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", "");
- RNA_def_enum_funcs(ot->prop, RNA_group_itemf);
+ prop = RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", "");
+ RNA_def_enum_funcs(prop, RNA_group_itemf);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
+ ot->prop = prop;
ED_object_add_generic_props(ot, false);
}
@@ -1028,7 +1034,7 @@ static int object_speaker_add_exec(bContext *C, wmOperator *op)
/* create new data for NLA hierarchy */
AnimData *adt = BKE_id_add_animdata(&ob->id);
NlaTrack *nlt = add_nlatrack(adt, NULL);
- NlaStrip *strip = add_nla_soundstrip(CTX_data_scene(C), ob->data);
+ NlaStrip *strip = add_nla_soundstrip(scene, ob->data);
strip->start = CFRA;
strip->end += strip->start;
@@ -1259,8 +1265,8 @@ static void copy_object_set_idnew(bContext *C, int dupflag)
/********************* Make Duplicates Real ************************/
static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
- const short use_base_parent,
- const short use_hierarchy)
+ const bool use_base_parent,
+ const bool use_hierarchy)
{
Main *bmain = CTX_data_main(C);
ListBase *lb;
@@ -1410,8 +1416,8 @@ static int object_duplicates_make_real_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
- const short use_base_parent = RNA_boolean_get(op->ptr, "use_base_parent");
- const short use_hierarchy = RNA_boolean_get(op->ptr, "use_hierarchy");
+ const bool use_base_parent = RNA_boolean_get(op->ptr, "use_base_parent");
+ const bool use_hierarchy = RNA_boolean_get(op->ptr, "use_hierarchy");
BKE_main_id_clear_newpoins(bmain);
diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c
index 5a8d1d081f8..94574e81b81 100644
--- a/source/blender/editors/object/object_bake.c
+++ b/source/blender/editors/object/object_bake.c
@@ -49,7 +49,6 @@
#include "BLI_math_geom.h"
#include "BKE_blender.h"
-#include "BKE_ccg.h"
#include "BKE_screen.h"
#include "BKE_context.h"
#include "BKE_global.h"
@@ -60,7 +59,6 @@
#include "BKE_cdderivedmesh.h"
#include "BKE_modifier.h"
#include "BKE_DerivedMesh.h"
-#include "BKE_subsurf.h"
#include "BKE_depsgraph.h"
#include "BKE_mesh.h"
#include "BKE_scene.h"
@@ -81,6 +79,7 @@
#include "WM_types.h"
#include "ED_object.h"
+#include "ED_screen.h"
#include "object_intern.h"
@@ -895,4 +894,5 @@ void OBJECT_OT_bake_image(wmOperatorType *ot)
ot->exec = bake_image_exec;
ot->invoke = objects_bake_render_invoke;
ot->modal = objects_bake_render_modal;
+ ot->poll = ED_operator_object_active;
}
diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c
new file mode 100644
index 00000000000..46555f89da9
--- /dev/null
+++ b/source/blender/editors/object/object_bake_api.c
@@ -0,0 +1,1109 @@
+/*
+ * ***** 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) 2004 by Blender Foundation
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s):
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/object/object_bake_api.c
+ * \ingroup edobj
+ */
+
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_object_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_material_types.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+#include "RNA_enum_types.h"
+
+#include "BLI_listbase.h"
+#include "BLI_string.h"
+#include "BLI_fileops.h"
+#include "BLI_math_geom.h"
+#include "BLI_path_util.h"
+
+#include "BKE_context.h"
+#include "BKE_global.h"
+#include "BKE_image.h"
+#include "BKE_library.h"
+#include "BKE_main.h"
+#include "BKE_report.h"
+#include "BKE_modifier.h"
+#include "BKE_mesh.h"
+
+#include "RE_engine.h"
+#include "RE_pipeline.h"
+
+#include "IMB_imbuf_types.h"
+#include "IMB_imbuf.h"
+#include "IMB_colormanagement.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "ED_object.h"
+#include "ED_screen.h"
+#include "ED_uvedit.h"
+
+#include "GPU_draw.h"
+
+#include "object_intern.h"
+
+/* catch esc */
+static int bake_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
+{
+ /* no running blender, remove handler and pass through */
+ if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C), WM_JOB_TYPE_OBJECT_BAKE))
+ return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
+
+ /* running render */
+ switch (event->type) {
+ case ESCKEY:
+ {
+ G.is_break = true;
+ return OPERATOR_RUNNING_MODAL;
+ }
+ }
+ return OPERATOR_PASS_THROUGH;
+}
+
+/* for exec() when there is no render job
+ * note: this wont check for the escape key being pressed, but doing so isnt threadsafe */
+static int bake_break(void *UNUSED(rjv))
+{
+ if (G.is_break)
+ return 1;
+ return 0;
+}
+
+static bool write_internal_bake_pixels(
+ Image *image, BakePixel pixel_array[], float *buffer,
+ const int width, const int height, const int margin,
+ const bool is_clear, const bool is_noncolor)
+{
+ ImBuf *ibuf;
+ void *lock;
+ bool is_float;
+ char *mask_buffer = NULL;
+ const int num_pixels = width * height;
+
+ ibuf = BKE_image_acquire_ibuf(image, NULL, &lock);
+
+ if (!ibuf)
+ return false;
+
+ if (margin > 0 || !is_clear) {
+ mask_buffer = MEM_callocN(sizeof(char) * num_pixels, "Bake Mask");
+ RE_bake_mask_fill(pixel_array, num_pixels, mask_buffer);
+ }
+
+ is_float = (ibuf->flags & IB_rectfloat);
+
+ /* colormanagement conversions */
+ if (!is_noncolor) {
+ const char *from_colorspace;
+ const char *to_colorspace;
+
+ from_colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR);
+
+ if (is_float)
+ to_colorspace = IMB_colormanagement_get_float_colorspace(ibuf);
+ else
+ to_colorspace = IMB_colormanagement_get_rect_colorspace(ibuf);
+
+ if (from_colorspace != to_colorspace)
+ IMB_colormanagement_transform(buffer, ibuf->x, ibuf->y, ibuf->channels, from_colorspace, to_colorspace, false);
+ }
+
+ /* populates the ImBuf */
+ if (is_clear) {
+ if (is_float) {
+ IMB_buffer_float_from_float(
+ ibuf->rect_float, buffer, ibuf->channels,
+ IB_PROFILE_LINEAR_RGB, IB_PROFILE_LINEAR_RGB, false,
+ ibuf->x, ibuf->y, ibuf->x, ibuf->y);
+ }
+ else {
+ IMB_buffer_byte_from_float(
+ (unsigned char *) ibuf->rect, buffer, ibuf->channels, ibuf->dither,
+ IB_PROFILE_SRGB, IB_PROFILE_SRGB,
+ false, ibuf->x, ibuf->y, ibuf->x, ibuf->x);
+ }
+ }
+ else {
+ if (is_float) {
+ IMB_buffer_float_from_float_mask(
+ ibuf->rect_float, buffer, ibuf->channels,
+ ibuf->x, ibuf->y, ibuf->x, ibuf->y, mask_buffer);
+ }
+ else {
+ IMB_buffer_byte_from_float_mask(
+ (unsigned char *) ibuf->rect, buffer, ibuf->channels, ibuf->dither,
+ false, ibuf->x, ibuf->y, ibuf->x, ibuf->x, mask_buffer);
+ }
+ }
+
+ /* margins */
+ if (margin > 0)
+ RE_bake_margin(ibuf, mask_buffer, margin);
+
+ ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID | IB_BITMAPDIRTY;
+
+ if (ibuf->rect_float)
+ ibuf->userflags |= IB_RECT_INVALID;
+
+ /* force mipmap recalc */
+ if (ibuf->mipmap[0]) {
+ ibuf->userflags |= IB_MIPMAP_INVALID;
+ imb_freemipmapImBuf(ibuf);
+ }
+
+ BKE_image_release_ibuf(image, ibuf, NULL);
+
+ if (mask_buffer)
+ MEM_freeN(mask_buffer);
+
+ return true;
+}
+
+/* force OpenGL reload */
+static void reset_images_gpu(BakeImages *bake_images)
+{
+ int i;
+ for (i = 0; i < bake_images->size; i++) {
+ Image *ima = bake_images->data[i].image;
+ if (ima->ok == IMA_OK_LOADED) {
+ GPU_free_image(ima);
+ }
+ }
+}
+
+static bool write_external_bake_pixels(
+ const char *filepath, BakePixel pixel_array[], float *buffer,
+ const int width, const int height, const int margin,
+ ImageFormatData *im_format, const bool is_noncolor)
+{
+ ImBuf *ibuf = NULL;
+ bool ok = false;
+ bool is_float;
+
+ is_float = im_format->depth > 8;
+
+ /* create a new ImBuf */
+ ibuf = IMB_allocImBuf(width, height, im_format->planes, (is_float ? IB_rectfloat : IB_rect));
+
+ if (!ibuf)
+ return false;
+
+ /* populates the ImBuf */
+ if (is_float) {
+ IMB_buffer_float_from_float(
+ ibuf->rect_float, buffer, ibuf->channels,
+ IB_PROFILE_LINEAR_RGB, IB_PROFILE_LINEAR_RGB, false,
+ ibuf->x, ibuf->y, ibuf->x, ibuf->y);
+ }
+ else {
+ if (!is_noncolor) {
+ const char *from_colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR);
+ const char *to_colorspace = IMB_colormanagement_get_rect_colorspace(ibuf);
+ IMB_colormanagement_transform(buffer, ibuf->x, ibuf->y, ibuf->channels, from_colorspace, to_colorspace, false);
+ }
+
+ IMB_buffer_byte_from_float(
+ (unsigned char *) ibuf->rect, buffer, ibuf->channels, ibuf->dither,
+ IB_PROFILE_SRGB, IB_PROFILE_SRGB,
+ false, ibuf->x, ibuf->y, ibuf->x, ibuf->x);
+ }
+
+ /* margins */
+ if (margin > 0) {
+ char *mask_buffer = NULL;
+ const int num_pixels = width * height;
+
+ mask_buffer = MEM_callocN(sizeof(char) * num_pixels, "Bake Mask");
+ RE_bake_mask_fill(pixel_array, num_pixels, mask_buffer);
+ RE_bake_margin(ibuf, mask_buffer, margin);
+
+ if (mask_buffer)
+ MEM_freeN(mask_buffer);
+ }
+
+ if ((ok = BKE_imbuf_write(ibuf, filepath, im_format))) {
+#ifndef WIN32
+ chmod(filepath, S_IRUSR | S_IWUSR);
+#endif
+ //printf("%s saving bake map: '%s'\n", __func__, filepath);
+ }
+
+ /* garbage collection */
+ IMB_freeImBuf(ibuf);
+
+ return ok;
+}
+
+static bool is_noncolor_pass(ScenePassType pass_type)
+{
+ return ELEM7(pass_type,
+ SCE_PASS_Z,
+ SCE_PASS_NORMAL,
+ SCE_PASS_VECTOR,
+ SCE_PASS_INDEXOB,
+ SCE_PASS_UV,
+ SCE_PASS_RAYHITS,
+ SCE_PASS_INDEXMA);
+}
+
+static bool build_image_lookup(Main *bmain, Object *ob, BakeImages *bake_images, ReportList *reports)
+{
+ const int tot_mat = ob->totcol;
+ int i, j;
+ int tot_images = 0;
+
+ /* error handling and tag (in case multiple materials share the same image) */
+ BKE_main_id_tag_idcode(bmain, ID_IM, false);
+
+ for (i = 0; i < tot_mat; i++) {
+ Image *image;
+ ED_object_get_active_image(ob, i + 1, &image, NULL, NULL);
+
+ if (!image) {
+ if (ob->mat[i]) {
+ BKE_reportf(reports, RPT_ERROR,
+ "No active image found in material %d (%s)", i, ob->mat[i]->id.name + 2);
+ }
+ else if (((Mesh *) ob->data)->mat[i]) {
+ BKE_reportf(reports, RPT_ERROR,
+ "No active image found in material %d (%s)", i, ((Mesh *) ob->data)->mat[i]->id.name + 2);
+ }
+ else {
+ BKE_reportf(reports, RPT_ERROR,
+ "No active image found in material %d", i);
+ }
+ return false;
+ }
+
+ if ((image->id.flag & LIB_DOIT)) {
+ for (j = 0; j < i; j++) {
+ if (bake_images->data[j].image == image) {
+ bake_images->lookup[i] = j;
+ break;
+ }
+ }
+ }
+ else {
+ bake_images->lookup[i] = tot_images;
+ bake_images->data[tot_images].image = image;
+ image->id.flag |= LIB_DOIT;
+ tot_images++;
+ }
+ }
+
+ bake_images->size = tot_images;
+ return true;
+}
+
+/*
+ * returns the total number of pixels
+ */
+static int initialize_internal_images(BakeImages *bake_images, ReportList *reports)
+{
+ int i;
+ int tot_size = 0;
+
+ for (i = 0; i < bake_images->size; i++) {
+ ImBuf *ibuf;
+ void *lock;
+
+ BakeImage *bk_image = &bake_images->data[i];
+ ibuf = BKE_image_acquire_ibuf(bk_image->image, NULL, &lock);
+
+ if (ibuf) {
+ bk_image->width = ibuf->x;
+ bk_image->height = ibuf->y;
+ bk_image->offset = tot_size;
+
+ tot_size += ibuf->x * ibuf->y;
+ }
+ else {
+ BKE_image_release_ibuf(bk_image->image, ibuf, lock);
+ BKE_reportf(reports, RPT_ERROR, "Not initialized image %s", bk_image->image->id.name + 2);
+ return 0;
+ }
+ BKE_image_release_ibuf(bk_image->image, ibuf, lock);
+ }
+ return tot_size;
+}
+
+typedef struct BakeAPIRender {
+ Object *ob;
+ Main *main;
+ Scene *scene;
+ ReportList *reports;
+ ListBase selected_objects;
+
+ ScenePassType pass_type;
+ int margin;
+
+ int save_mode;
+
+ bool is_clear;
+ bool is_split_materials;
+ bool is_automatic_name;
+ bool use_selected_to_active;
+
+ float cage_extrusion;
+ int normal_space;
+ BakeNormalSwizzle normal_swizzle[3];
+
+ char custom_cage[MAX_NAME];
+ char filepath[FILE_MAX];
+
+ int width;
+ int height;
+ const char *identifier;
+
+ int result;
+ bool ready;
+} BakeAPIRender;
+
+static int bake(
+ Main *bmain, Scene *scene, Object *ob_low, ListBase *selected_objects, ReportList *reports,
+ const ScenePassType pass_type, const int margin,
+ const BakeSaveMode save_mode, const bool is_clear, const bool is_split_materials,
+ const bool is_automatic_name, const bool use_selected_to_active,
+ const float cage_extrusion, const int normal_space, const BakeNormalSwizzle normal_swizzle[],
+ const char *custom_cage, const char *filepath, const int width, const int height,
+ const char *identifier)
+{
+ int op_result = OPERATOR_CANCELLED;
+ bool ok = false;
+
+ Object *ob_cage = NULL;
+
+ BakeHighPolyData *highpoly;
+ int tot_highpoly;
+
+ char restrict_flag_low = ob_low->restrictflag;
+ char restrict_flag_cage;
+
+ Mesh *me_low = NULL;
+ Render *re;
+
+ float *result = NULL;
+
+ BakePixel *pixel_array_low = NULL;
+
+ const bool is_save_internal = (save_mode == R_BAKE_SAVE_INTERNAL);
+ const bool is_noncolor = is_noncolor_pass(pass_type);
+ const int depth = RE_pass_depth(pass_type);
+
+ bool is_highpoly = false;
+ bool is_tangent;
+
+ BakeImages bake_images = {NULL};
+
+ int num_pixels;
+ int tot_materials;
+ int i;
+
+ re = RE_NewRender(scene->id.name);
+ RE_SetReports(re, NULL);
+
+ is_tangent = pass_type == SCE_PASS_NORMAL && normal_space == R_BAKE_SPACE_TANGENT;
+ tot_materials = ob_low->totcol;
+
+ if (tot_materials == 0) {
+ if (is_save_internal) {
+ BKE_report(reports, RPT_ERROR,
+ "No active image found. Add a material or bake to an external file");
+
+ goto cleanup;
+ }
+ else if (is_split_materials) {
+ BKE_report(reports, RPT_ERROR,
+ "No active image found. Add a material or bake without the Split Materials option");
+
+ goto cleanup;
+ }
+ else {
+ /* baking externally without splitting materials */
+ tot_materials = 1;
+ }
+ }
+
+ /* we overallocate in case there is more materials than images */
+ bake_images.data = MEM_callocN(sizeof(BakeImage) * tot_materials, "bake images dimensions (width, height, offset)");
+ bake_images.lookup = MEM_callocN(sizeof(int) * tot_materials, "bake images lookup (from material to BakeImage)");
+
+ if (!build_image_lookup(bmain, ob_low, &bake_images, reports))
+ goto cleanup;
+
+ if (is_save_internal) {
+ num_pixels = initialize_internal_images(&bake_images, reports);
+
+ if (num_pixels == 0) {
+ goto cleanup;
+ }
+
+ if (is_clear) {
+ RE_bake_ibuf_clear(&bake_images, is_tangent);
+ }
+ }
+ else {
+ /* when saving extenally always use the size specified in the UI */
+
+ num_pixels = width * height * bake_images.size;
+
+ for (i = 0; i < bake_images.size; i++) {
+ bake_images.data[i].width = width;
+ bake_images.data[i].height = height;
+ bake_images.data[i].offset = (is_split_materials ? num_pixels : 0);
+ bake_images.data[i].image = NULL;
+ }
+
+ if (!is_split_materials) {
+ /* saving a single image */
+ for (i = 0; i < tot_materials; i++)
+ bake_images.lookup[i] = 0;
+ }
+ }
+
+ if (use_selected_to_active) {
+ CollectionPointerLink *link;
+ tot_highpoly = 0;
+
+ for (link = selected_objects->first; link; link = link->next) {
+ Object *ob_iter = link->ptr.data;
+
+ if (ob_iter == ob_low)
+ continue;
+
+ tot_highpoly ++;
+ }
+
+ if (tot_highpoly == 0) {
+ BKE_report(reports, RPT_ERROR, "No valid selected objects");
+ op_result = OPERATOR_CANCELLED;
+
+ goto cleanup;
+ }
+ else {
+ is_highpoly = true;
+ }
+ }
+
+ if (custom_cage[0] != '\0') {
+ ob_cage = BLI_findstring(&bmain->object, custom_cage, offsetof(ID, name) + 2);
+
+ /* TODO check if cage object has the same topology (num of triangles and a valid UV) */
+ if (ob_cage == NULL || ob_cage->type != OB_MESH) {
+ BKE_report(reports, RPT_ERROR, "No valid cage object");
+ op_result = OPERATOR_CANCELLED;
+
+ goto cleanup;
+ }
+ else {
+ restrict_flag_cage = ob_cage->restrictflag;
+ }
+ }
+
+ RE_bake_engine_set_engine_parameters(re, bmain, scene);
+
+ /* blender_test_break uses this global */
+ G.is_break = false;
+
+ RE_test_break_cb(re, NULL, bake_break);
+
+ pixel_array_low = MEM_callocN(sizeof(BakePixel) * num_pixels, "bake pixels low poly");
+ result = MEM_callocN(sizeof(float) * depth * num_pixels, "bake return pixels");
+
+ if (is_highpoly) {
+ CollectionPointerLink *link;
+ ModifierData *md, *nmd;
+ ListBase modifiers_tmp, modifiers_original;
+ float mat_low[4][4];
+ int i = 0;
+ highpoly = MEM_callocN(sizeof(BakeHighPolyData) * tot_highpoly, "bake high poly objects");
+
+ /* prepare cage mesh */
+ if (ob_cage) {
+ me_low = BKE_mesh_new_from_object(bmain, scene, ob_cage, 1, 2, 1, 0);
+ copy_m4_m4(mat_low, ob_cage->obmat);
+ }
+ else {
+ modifiers_original = ob_low->modifiers;
+ BLI_listbase_clear(&modifiers_tmp);
+
+ for (md = ob_low->modifiers.first; md; md = md->next) {
+ /* Edge Split cannot be applied in the cage,
+ * the cage is supposed to have interpolated normals
+ * between the faces unless the geometry is physically
+ * split. So we create a copy of the low poly mesh without
+ * the eventual edge split.*/
+
+ if (md->type == eModifierType_EdgeSplit)
+ continue;
+
+ nmd = modifier_new(md->type);
+ BLI_strncpy(nmd->name, md->name, sizeof(nmd->name));
+ modifier_copyData(md, nmd);
+ BLI_addtail(&modifiers_tmp, nmd);
+ }
+
+ /* temporarily replace the modifiers */
+ ob_low->modifiers = modifiers_tmp;
+
+ /* get the cage mesh as it arrives in the renderer */
+ me_low = BKE_mesh_new_from_object(bmain, scene, ob_low, 1, 2, 1, 0);
+ copy_m4_m4(mat_low, ob_low->obmat);
+ }
+
+ /* populate highpoly array */
+ for (link = selected_objects->first; link; link = link->next) {
+ TriangulateModifierData *tmd;
+ Object *ob_iter = link->ptr.data;
+
+ if (ob_iter == ob_low)
+ continue;
+
+ /* initialize highpoly_data */
+ highpoly[i].ob = ob_iter;
+ highpoly[i].me = NULL;
+ highpoly[i].tri_mod = NULL;
+ highpoly[i].restrict_flag = ob_iter->restrictflag;
+ highpoly[i].pixel_array = MEM_callocN(sizeof(BakePixel) * num_pixels, "bake pixels high poly");
+
+
+ /* triangulating so BVH returns the primitive_id that will be used for rendering */
+ highpoly[i].tri_mod = ED_object_modifier_add(
+ reports, bmain, scene, highpoly[i].ob,
+ "TmpTriangulate", eModifierType_Triangulate);
+ tmd = (TriangulateModifierData *)highpoly[i].tri_mod;
+ tmd->quad_method = MOD_TRIANGULATE_QUAD_FIXED;
+ tmd->ngon_method = MOD_TRIANGULATE_NGON_EARCLIP;
+
+ highpoly[i].me = BKE_mesh_new_from_object(bmain, scene, highpoly[i].ob, 1, 2, 1, 0);
+ highpoly[i].ob->restrictflag &= ~OB_RESTRICT_RENDER;
+
+ /* lowpoly to highpoly transformation matrix */
+ invert_m4_m4(highpoly[i].mat_lowtohigh, highpoly[i].ob->obmat);
+ mul_m4_m4m4(highpoly[i].mat_lowtohigh, highpoly[i].mat_lowtohigh, mat_low);
+
+ i++;
+ }
+
+ BLI_assert(i == tot_highpoly);
+
+ /* populate the pixel array with the face data */
+ RE_bake_pixels_populate(me_low, pixel_array_low, num_pixels, &bake_images);
+
+ ob_low->restrictflag |= OB_RESTRICT_RENDER;
+
+ /* populate the pixel arrays with the corresponding face data for each high poly object */
+ RE_bake_pixels_populate_from_objects(
+ me_low, pixel_array_low, highpoly, tot_highpoly,
+ num_pixels, cage_extrusion);
+
+ /* the baking itself */
+ for (i = 0; i < tot_highpoly; i++) {
+ if (RE_bake_has_engine(re)) {
+ ok = RE_bake_engine(re, highpoly[i].ob, highpoly[i].pixel_array, num_pixels,
+ depth, pass_type, result);
+ }
+ else {
+ ok = RE_bake_internal(re, highpoly[i].ob, highpoly[i].pixel_array, num_pixels,
+ depth, pass_type, result);
+ }
+
+ if (!ok)
+ break;
+ }
+
+ /* reverting data back */
+ if (ob_cage) {
+ ob_cage->restrictflag |= OB_RESTRICT_RENDER;
+ }
+ else {
+ ob_low->modifiers = modifiers_original;
+
+ while ((md = BLI_pophead(&modifiers_tmp))) {
+ modifier_free(md);
+ }
+ }
+ }
+ else {
+ /* get the mesh as it arrives in the renderer */
+ me_low = BKE_mesh_new_from_object(bmain, scene, ob_low, 1, 2, 1, 0);
+
+ /* populate the pixel array with the face data */
+ RE_bake_pixels_populate(me_low, pixel_array_low, num_pixels, &bake_images);
+
+ /* make sure low poly renders */
+ ob_low->restrictflag &= ~OB_RESTRICT_RENDER;
+
+ if (RE_bake_has_engine(re))
+ ok = RE_bake_engine(re, ob_low, pixel_array_low, num_pixels, depth, pass_type, result);
+ else
+ ok = RE_bake_internal(re, ob_low, pixel_array_low, num_pixels, depth, pass_type, result);
+ }
+
+ /* normal space conversion
+ * the normals are expected to be in world space, +X +Y +Z */
+ if (pass_type == SCE_PASS_NORMAL) {
+ switch (normal_space) {
+ case R_BAKE_SPACE_WORLD:
+ {
+ /* Cycles internal format */
+ if ((normal_swizzle[0] == R_BAKE_POSX) &&
+ (normal_swizzle[1] == R_BAKE_POSY) &&
+ (normal_swizzle[2] == R_BAKE_POSZ))
+ {
+ break;
+ }
+ else {
+ RE_bake_normal_world_to_world(pixel_array_low, num_pixels, depth, result, normal_swizzle);
+ }
+ break;
+ }
+ case R_BAKE_SPACE_OBJECT:
+ {
+ RE_bake_normal_world_to_object(pixel_array_low, num_pixels, depth, result, ob_low, normal_swizzle);
+ break;
+ }
+ case R_BAKE_SPACE_TANGENT:
+ {
+ if (is_highpoly) {
+ RE_bake_normal_world_to_tangent(pixel_array_low, num_pixels, depth, result, me_low, normal_swizzle);
+ }
+ else {
+ /* from multiresolution */
+ Mesh *me_nores = NULL;
+ ModifierData *md = NULL;
+ int mode;
+
+ md = modifiers_findByType(ob_low, eModifierType_Multires);
+
+ if (md) {
+ mode = md->mode;
+ md->mode &= ~eModifierMode_Render;
+ }
+
+ me_nores = BKE_mesh_new_from_object(bmain, scene, ob_low, 1, 2, 1, 0);
+ RE_bake_pixels_populate(me_nores, pixel_array_low, num_pixels, &bake_images);
+
+ RE_bake_normal_world_to_tangent(pixel_array_low, num_pixels, depth, result, me_nores, normal_swizzle);
+ BKE_libblock_free(bmain, me_nores);
+
+ if (md)
+ md->mode = mode;
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+ if (!ok) {
+ BKE_report(reports, RPT_ERROR, "Problem baking object map");
+ op_result = OPERATOR_CANCELLED;
+ }
+ else {
+ /* save the results */
+ for (i = 0; i < bake_images.size; i++) {
+ BakeImage *bk_image = &bake_images.data[i];
+
+ if (is_save_internal) {
+ ok = write_internal_bake_pixels(
+ bk_image->image,
+ pixel_array_low + bk_image->offset,
+ result + bk_image->offset * depth,
+ bk_image->width, bk_image->height,
+ margin, is_clear, is_noncolor);
+
+ if (!ok) {
+ BKE_report(reports, RPT_ERROR,
+ "Problem saving the bake map internally, "
+ "make sure there is a Texture Image node in the current object material");
+ op_result = OPERATOR_CANCELLED;
+ }
+ else {
+ BKE_report(reports, RPT_INFO,
+ "Baking map saved to internal image, save it externally or pack it");
+ op_result = OPERATOR_FINISHED;
+ }
+ }
+ /* save externally */
+ else {
+ BakeData *bake = &scene->r.bake;
+ char name[FILE_MAX];
+
+ BKE_makepicstring_from_type(name, filepath, bmain->name, 0, bake->im_format.imtype, true, false);
+
+ if (is_automatic_name) {
+ BLI_path_suffix(name, FILE_MAX, ob_low->id.name + 2, "_");
+ BLI_path_suffix(name, FILE_MAX, identifier, "_");
+ }
+
+ if (is_split_materials) {
+ if (bk_image->image) {
+ BLI_path_suffix(name, FILE_MAX, bk_image->image->id.name + 2, "_");
+ }
+ else {
+ if (ob_low->mat[i]) {
+ BLI_path_suffix(name, FILE_MAX, ob_low->mat[i]->id.name + 2, "_");
+ }
+ else if (me_low->mat[i]) {
+ BLI_path_suffix(name, FILE_MAX, me_low->mat[i]->id.name + 2, "_");
+ }
+ else {
+ /* if everything else fails, use the material index */
+ char tmp[4];
+ sprintf(tmp, "%d", i % 1000);
+ BLI_path_suffix(name, FILE_MAX, tmp, "_");
+ }
+ }
+ }
+
+ /* save it externally */
+ ok = write_external_bake_pixels(
+ name,
+ pixel_array_low + bk_image->offset,
+ result + bk_image->offset * depth,
+ bk_image->width, bk_image->height,
+ margin, &bake->im_format, is_noncolor);
+
+ if (!ok) {
+ BKE_reportf(reports, RPT_ERROR, "Problem saving baked map in \"%s\".", name);
+ op_result = OPERATOR_CANCELLED;
+ }
+ else {
+ BKE_reportf(reports, RPT_INFO, "Baking map written to \"%s\".", name);
+ op_result = OPERATOR_FINISHED;
+ }
+
+ if (!is_split_materials) {
+ break;
+ }
+ }
+ }
+ }
+
+ if (is_save_internal)
+ reset_images_gpu(&bake_images);
+
+cleanup:
+
+ if (is_highpoly) {
+ int i;
+ for (i = 0; i < tot_highpoly; i++) {
+ highpoly[i].ob->restrictflag = highpoly[i].restrict_flag;
+
+ if (highpoly[i].pixel_array)
+ MEM_freeN(highpoly[i].pixel_array);
+
+ if (highpoly[i].tri_mod)
+ ED_object_modifier_remove(reports, bmain, highpoly[i].ob, highpoly[i].tri_mod);
+
+ if (highpoly[i].me)
+ BKE_libblock_free(bmain, highpoly[i].me);
+ }
+ MEM_freeN(highpoly);
+ }
+
+ ob_low->restrictflag = restrict_flag_low;
+
+ if (ob_cage)
+ ob_cage->restrictflag = restrict_flag_cage;
+
+ if (pixel_array_low)
+ MEM_freeN(pixel_array_low);
+
+ if (bake_images.data)
+ MEM_freeN(bake_images.data);
+
+ if (bake_images.lookup)
+ MEM_freeN(bake_images.lookup);
+
+ if (result)
+ MEM_freeN(result);
+
+ if (me_low)
+ BKE_libblock_free(bmain, me_low);
+
+ return op_result;
+}
+
+static void bake_init_api_data(wmOperator *op, bContext *C, BakeAPIRender *bkr)
+{
+ bool is_save_internal;
+
+ bkr->ob = CTX_data_active_object(C);
+ bkr->main = CTX_data_main(C);
+ bkr->scene = CTX_data_scene(C);
+
+ bkr->pass_type = RNA_enum_get(op->ptr, "type");
+ bkr->margin = RNA_int_get(op->ptr, "margin");
+
+ bkr->save_mode = RNA_enum_get(op->ptr, "save_mode");
+ is_save_internal = (bkr->save_mode == R_BAKE_SAVE_INTERNAL);
+
+ bkr->is_clear = RNA_boolean_get(op->ptr, "use_clear");
+ bkr->is_split_materials = (!is_save_internal) && RNA_boolean_get(op->ptr, "use_split_materials");
+ bkr->is_automatic_name = RNA_boolean_get(op->ptr, "use_automatic_name");
+ bkr->use_selected_to_active = RNA_boolean_get(op->ptr, "use_selected_to_active");
+ bkr->cage_extrusion = RNA_float_get(op->ptr, "cage_extrusion");
+
+ bkr->normal_space = RNA_enum_get(op->ptr, "normal_space");
+ bkr->normal_swizzle[0] = RNA_enum_get(op->ptr, "normal_r");
+ bkr->normal_swizzle[1] = RNA_enum_get(op->ptr, "normal_g");
+ bkr->normal_swizzle[2] = RNA_enum_get(op->ptr, "normal_b");
+
+ bkr->width = RNA_int_get(op->ptr, "width");
+ bkr->height = RNA_int_get(op->ptr, "height");
+ bkr->identifier = "";
+
+ RNA_string_get(op->ptr, "cage", bkr->custom_cage);
+
+ if ((!is_save_internal) && bkr->is_automatic_name) {
+ PropertyRNA *prop = RNA_struct_find_property(op->ptr, "type");
+ RNA_property_enum_identifier(C, op->ptr, prop, bkr->pass_type, &bkr->identifier);
+ }
+
+ if (bkr->use_selected_to_active)
+ CTX_data_selected_objects(C, &bkr->selected_objects);
+
+ bkr->reports = op->reports;
+
+ /* XXX hack to force saving to always be internal. Whether (and how) to support
+ * external saving will be addressed later */
+ bkr->save_mode = R_BAKE_SAVE_INTERNAL;
+}
+
+static int bake_exec(bContext *C, wmOperator *op)
+{
+ int result;
+ BakeAPIRender bkr = {NULL};
+
+ bake_init_api_data(op, C, &bkr);
+
+ result = bake(
+ bkr.main, bkr.scene, bkr.ob, &bkr.selected_objects, bkr.reports,
+ bkr.pass_type, bkr.margin, bkr.save_mode,
+ bkr.is_clear, bkr.is_split_materials, bkr.is_automatic_name, bkr.use_selected_to_active,
+ bkr.cage_extrusion, bkr.normal_space, bkr.normal_swizzle,
+ bkr.custom_cage, bkr.filepath, bkr.width, bkr.height, bkr.identifier);
+
+ BLI_freelistN(&bkr.selected_objects);
+ return result;
+}
+
+static void bake_startjob(void *bkv, short *UNUSED(stop), short *UNUSED(do_update), float *UNUSED(progress))
+{
+ BakeAPIRender *bkr = (BakeAPIRender *)bkv;
+
+ bkr->result = bake(
+ bkr->main, bkr->scene, bkr->ob, &bkr->selected_objects, bkr->reports,
+ bkr->pass_type, bkr->margin, bkr->save_mode,
+ bkr->is_clear, bkr->is_split_materials, bkr->is_automatic_name, bkr->use_selected_to_active,
+ bkr->cage_extrusion, bkr->normal_space, bkr->normal_swizzle,
+ bkr->custom_cage, bkr->filepath, bkr->width, bkr->height, bkr->identifier
+ );
+}
+
+static void bake_freejob(void *bkv)
+{
+ BakeAPIRender *bkr = (BakeAPIRender *)bkv;
+
+ BLI_freelistN(&bkr->selected_objects);
+ MEM_freeN(bkr);
+
+ G.is_rendering = false;
+}
+
+static void bake_set_props(wmOperator *op, Scene *scene)
+{
+ PropertyRNA *prop;
+ BakeData *bake = &scene->r.bake;
+
+ prop = RNA_struct_find_property(op->ptr, "filepath");
+ if (!RNA_property_is_set(op->ptr, prop)) {
+ RNA_property_string_set(op->ptr, prop, bake->filepath);
+ }
+
+ prop = RNA_struct_find_property(op->ptr, "width");
+ if (!RNA_property_is_set(op->ptr, prop)) {
+ RNA_property_int_set(op->ptr, prop, bake->width);
+ }
+
+ prop = RNA_struct_find_property(op->ptr, "height");
+ if (!RNA_property_is_set(op->ptr, prop)) {
+ RNA_property_int_set(op->ptr, prop, bake->width);
+ }
+
+ prop = RNA_struct_find_property(op->ptr, "margin");
+ if (!RNA_property_is_set(op->ptr, prop)) {
+ RNA_property_int_set(op->ptr, prop, bake->margin);
+ }
+
+ prop = RNA_struct_find_property(op->ptr, "use_selected_to_active");
+ if (!RNA_property_is_set(op->ptr, prop)) {
+ RNA_property_boolean_set(op->ptr, prop, (bake->flag & R_BAKE_TO_ACTIVE));
+ }
+
+ prop = RNA_struct_find_property(op->ptr, "cage_extrusion");
+ if (!RNA_property_is_set(op->ptr, prop)) {
+ RNA_property_float_set(op->ptr, prop, bake->cage_extrusion);
+ }
+
+ prop = RNA_struct_find_property(op->ptr, "cage");
+ if (!RNA_property_is_set(op->ptr, prop)) {
+ RNA_property_string_set(op->ptr, prop, bake->cage);
+ }
+
+ prop = RNA_struct_find_property(op->ptr, "normal_space");
+ if (!RNA_property_is_set(op->ptr, prop)) {
+ RNA_property_enum_set(op->ptr, prop, bake->normal_space);
+ }
+
+ prop = RNA_struct_find_property(op->ptr, "normal_r");
+ if (!RNA_property_is_set(op->ptr, prop)) {
+ RNA_property_enum_set(op->ptr, prop, bake->normal_swizzle[0]);
+ }
+
+ prop = RNA_struct_find_property(op->ptr, "normal_g");
+ if (!RNA_property_is_set(op->ptr, prop)) {
+ RNA_property_enum_set(op->ptr, prop, bake->normal_swizzle[1]);
+ }
+
+ prop = RNA_struct_find_property(op->ptr, "normal_b");
+ if (!RNA_property_is_set(op->ptr, prop)) {
+ RNA_property_enum_set(op->ptr, prop, bake->normal_swizzle[2]);
+ }
+
+ prop = RNA_struct_find_property(op->ptr, "save_mode");
+ if (!RNA_property_is_set(op->ptr, prop)) {
+ RNA_property_enum_set(op->ptr, prop, bake->save_mode);
+ }
+
+ prop = RNA_struct_find_property(op->ptr, "use_clear");
+ if (!RNA_property_is_set(op->ptr, prop)) {
+ RNA_property_boolean_set(op->ptr, prop, (bake->flag & R_BAKE_CLEAR));
+ }
+
+ prop = RNA_struct_find_property(op->ptr, "use_split_materials");
+ if (!RNA_property_is_set(op->ptr, prop)) {
+ RNA_property_boolean_set(op->ptr, prop, (bake->flag & R_BAKE_SPLIT_MAT));
+ }
+
+ prop = RNA_struct_find_property(op->ptr, "use_automatic_name");
+ if (!RNA_property_is_set(op->ptr, prop)) {
+ RNA_property_boolean_set(op->ptr, prop, (bake->flag & R_BAKE_AUTO_NAME));
+ }
+}
+
+static int bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+{
+ wmJob *wm_job;
+ BakeAPIRender *bkr;
+ Scene *scene = CTX_data_scene(C);
+
+ bake_set_props(op, scene);
+
+ /* only one render job at a time */
+ if (WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_OBJECT_BAKE))
+ return OPERATOR_CANCELLED;
+
+ bkr = MEM_callocN(sizeof(BakeAPIRender), "render bake");
+
+ /* init bake render */
+ bake_init_api_data(op, C, bkr);
+
+ /* setup job */
+ wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Texture Bake",
+ WM_JOB_EXCL_RENDER | WM_JOB_PRIORITY | WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_BAKE);
+ WM_jobs_customdata_set(wm_job, bkr, bake_freejob);
+ WM_jobs_timer(wm_job, 0.5, NC_IMAGE, 0); /* TODO - only draw bake image, can we enforce this */
+ WM_jobs_callbacks(wm_job, bake_startjob, NULL, NULL, NULL);
+
+ G.is_break = false;
+ G.is_rendering = true;
+
+ WM_jobs_start(CTX_wm_manager(C), wm_job);
+
+ WM_cursor_wait(0);
+
+ /* add modal handler for ESC */
+ WM_event_add_modal_handler(C, op);
+
+ WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, scene);
+ return OPERATOR_RUNNING_MODAL;
+}
+
+void OBJECT_OT_bake(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Bake";
+ ot->description = "Bake image textures of selected objects";
+ ot->idname = "OBJECT_OT_bake";
+
+ /* api callbacks */
+ ot->exec = bake_exec;
+ ot->modal = bake_modal;
+ ot->invoke = bake_invoke;
+ ot->poll = ED_operator_object_active_editable_mesh;
+
+ RNA_def_enum(ot->srna, "type", render_pass_type_items, SCE_PASS_COMBINED, "Type",
+ "Type of pass to bake, some of them may not be supported by the current render engine");
+ RNA_def_string_file_path(ot->srna, "filepath", NULL, FILE_MAX, "File Path",
+ "Image filepath to use when saving externally");
+ RNA_def_int(ot->srna, "width", 512, 1, INT_MAX, "Width",
+ "Horizontal dimension of the baking map (external only)", 64, 4096);
+ RNA_def_int(ot->srna, "height", 512, 1, INT_MAX, "Height",
+ "Vertical dimension of the baking map (external only)", 64, 4096);
+ RNA_def_int(ot->srna, "margin", 16, 0, INT_MAX, "Margin",
+ "Extends the baked result as a post process filter", 0, 64);
+ RNA_def_boolean(ot->srna, "use_selected_to_active", false, "Selected to Active",
+ "Bake shading on the surface of selected objects to the active object");
+ RNA_def_float(ot->srna, "cage_extrusion", 0.0, 0.0, 1.0, "Cage Extrusion",
+ "Distance to use for the inward ray cast when using selected to active", 0.0, 1.0);
+ RNA_def_string(ot->srna, "cage", NULL, MAX_NAME, "Cage",
+ "Object to use as cage");
+ RNA_def_enum(ot->srna, "normal_space", normal_space_items, R_BAKE_SPACE_TANGENT, "Normal Space",
+ "Choose normal space for baking");
+ RNA_def_enum(ot->srna, "normal_r", normal_swizzle_items, R_BAKE_POSX, "R", "Axis to bake in red channel");
+ RNA_def_enum(ot->srna, "normal_g", normal_swizzle_items, R_BAKE_POSY, "G", "Axis to bake in green channel");
+ RNA_def_enum(ot->srna, "normal_b", normal_swizzle_items, R_BAKE_POSZ, "B", "Axis to bake in blue channel");
+ RNA_def_enum(ot->srna, "save_mode", bake_save_mode_items, R_BAKE_SAVE_INTERNAL, "Save Mode",
+ "Choose how to save the baking map");
+ RNA_def_boolean(ot->srna, "use_clear", false, "Clear",
+ "Clear Images before baking (only for internal saving)");
+ RNA_def_boolean(ot->srna, "use_split_materials", false, "Split Materials",
+ "Split baked maps per material, using material name in output file (external only)");
+ RNA_def_boolean(ot->srna, "use_automatic_name", false, "Automatic Name",
+ "Automatically name the output file with the pass type");
+}
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index 9b79b2e93da..85e4bbce8dc 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -74,7 +74,6 @@
#include "RNA_enum_types.h"
#include "ED_object.h"
-#include "ED_armature.h"
#include "ED_keyframing.h"
#include "ED_screen.h"
@@ -143,7 +142,7 @@ ListBase *get_constraint_lb(Object *ob, bConstraint *con, bPoseChannel **r_pchan
/* single constraint */
bConstraint *get_active_constraint(Object *ob)
{
- return BKE_constraints_get_active(get_active_constraints(ob));
+ return BKE_constraints_active_get(get_active_constraints(ob));
}
/* -------------- Constraint Management (Add New, Remove, Rename) -------------------- */
@@ -227,7 +226,7 @@ static void update_pyconstraint_cb(void *arg1, void *arg2)
/* helper function for add_constriant - sets the last target for the active constraint */
static void set_constraint_nth_target(bConstraint *con, Object *target, const char subtarget[], int index)
{
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
int num_targets, i;
@@ -299,7 +298,7 @@ static void test_constraints(Object *owner, bPoseChannel *pchan)
/* Check all constraints - is constraint valid? */
if (conlist) {
for (curcon = conlist->first; curcon; curcon = curcon->next) {
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(curcon);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(curcon);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
@@ -542,8 +541,20 @@ static int edit_constraint_poll_generic(bContext *C, StructRNA *rna_type)
PointerRNA ptr = CTX_data_pointer_get_type(C, "constraint", rna_type);
Object *ob = (ptr.id.data) ? ptr.id.data : ED_object_active_context(C);
- if (!ptr.data || !ob || ob->id.lib) return 0;
- if (ptr.id.data && ((ID *)ptr.id.data)->lib) return 0;
+ if (!ptr.data) {
+ CTX_wm_operator_poll_msg_set(C, "Context missing 'constraint'");
+ return 0;
+ }
+
+ if (!ob) {
+ CTX_wm_operator_poll_msg_set(C, "Context missing active object");
+ return 0;
+ }
+
+ if (ob->id.lib || (ptr.id.data && ((ID *)ptr.id.data)->lib)) {
+ CTX_wm_operator_poll_msg_set(C, "Cannot edit library data");
+ return 0;
+ }
return 1;
}
@@ -614,7 +625,7 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int
list = get_active_constraints(ob);
}
- con = BKE_constraints_findByName(list, constraint_name);
+ 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>");
@@ -1135,7 +1146,7 @@ void ED_object_constraint_set_active(Object *ob, bConstraint *con)
if ((lb && con) && (con->flag & CONSTRAINT_ACTIVE))
return;
- BKE_constraints_set_active(lb, con);
+ BKE_constraints_active_set(lb, con);
}
void ED_object_constraint_update(Object *ob)
@@ -1174,9 +1185,9 @@ static int constraint_delete_exec(bContext *C, wmOperator *UNUSED(op))
const bool is_ik = ELEM(con->type, CONSTRAINT_TYPE_KINEMATIC, CONSTRAINT_TYPE_SPLINEIK);
/* free the constraint */
- if (BKE_remove_constraint(lb, con)) {
+ if (BKE_constraint_remove(lb, con)) {
/* there's no active constraint now, so make sure this is the case */
- BKE_constraints_set_active(lb, NULL);
+ BKE_constraints_active_set(lb, NULL);
ED_object_constraint_update(ob); /* needed to set the flags on posebones correctly */
@@ -1319,7 +1330,7 @@ static int pose_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op))
/* free constraints for all selected bones */
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
{
- BKE_free_constraints(&pchan->constraints);
+ BKE_constraints_free(&pchan->constraints);
pchan->constflag &= ~(PCHAN_HAS_IK | PCHAN_HAS_SPLINEIK | PCHAN_HAS_CONST);
}
CTX_DATA_END;
@@ -1356,7 +1367,7 @@ static int object_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op))
/* do freeing */
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
{
- BKE_free_constraints(&ob->constraints);
+ BKE_constraints_free(&ob->constraints);
DAG_id_tag_update(&ob->id, OB_RECALC_OB);
}
CTX_DATA_END;
@@ -1400,7 +1411,7 @@ static int pose_constraint_copy_exec(bContext *C, wmOperator *op)
{
/* if we're not handling the object we're copying from, copy all constraints over */
if (pchan != chan) {
- BKE_copy_constraints(&chan->constraints, &pchan->constraints, true);
+ BKE_constraints_copy(&chan->constraints, &pchan->constraints, true);
/* update flags (need to add here, not just copy) */
chan->constflag |= pchan->constflag;
}
@@ -1440,7 +1451,7 @@ static int object_constraint_copy_exec(bContext *C, wmOperator *UNUSED(op))
{
/* if we're not handling the object we're copying from, copy all constraints over */
if (obact != ob) {
- BKE_copy_constraints(&ob->constraints, &obact->constraints, true);
+ BKE_constraints_copy(&ob->constraints, &obact->constraints, true);
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
}
@@ -1650,9 +1661,9 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase
/* create a new constraint of the type requried, and add it to the active/given constraints list */
if (pchan)
- con = BKE_add_pose_constraint(ob, pchan, NULL, type);
+ con = BKE_constraint_add_for_pose(ob, pchan, NULL, type);
else
- con = BKE_add_ob_constraint(ob, NULL, type);
+ 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
@@ -1948,7 +1959,7 @@ static int pose_ik_clear_exec(bContext *C, wmOperator *UNUSED(op))
for (con = pchan->constraints.first; con; con = next) {
next = con->next;
if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
- BKE_remove_constraint(&pchan->constraints, con);
+ BKE_constraint_remove(&pchan->constraints, con);
}
}
pchan->constflag &= ~(PCHAN_HAS_IK | PCHAN_HAS_TARGET);
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 7ae54a1a803..002bec4ef0b 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -45,7 +45,6 @@
#include "DNA_armature_types.h"
#include "DNA_curve_types.h"
#include "DNA_group_types.h"
-#include "DNA_lattice_types.h"
#include "DNA_material_types.h"
#include "DNA_meta_types.h"
#include "DNA_property_types.h"
@@ -64,7 +63,6 @@
#include "BKE_curve.h"
#include "BKE_effect.h"
#include "BKE_depsgraph.h"
-#include "BKE_font.h"
#include "BKE_image.h"
#include "BKE_library.h"
#include "BKE_main.h"
@@ -72,7 +70,6 @@
#include "BKE_mball.h"
#include "BKE_mesh.h"
#include "BKE_object.h"
-#include "BKE_paint.h"
#include "BKE_pointcache.h"
#include "BKE_property.h"
#include "BKE_sca.h"
@@ -178,7 +175,7 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
bool changed = false;
- const int unselected = RNA_boolean_get(op->ptr, "unselected");
+ const bool unselected = RNA_boolean_get(op->ptr, "unselected");
CTX_DATA_BEGIN(C, Base *, base, visible_bases)
{
@@ -209,7 +206,7 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op)
DAG_id_type_tag(bmain, ID_OB);
DAG_relations_tag_update(bmain);
- WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C));
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
}
@@ -273,7 +270,7 @@ void OBJECT_OT_hide_render_clear(wmOperatorType *ot)
static int object_hide_render_set_exec(bContext *C, wmOperator *op)
{
- const int unselected = RNA_boolean_get(op->ptr, "unselected");
+ const bool unselected = RNA_boolean_get(op->ptr, "unselected");
CTX_DATA_BEGIN(C, Base *, base, visible_bases)
{
@@ -432,7 +429,7 @@ void ED_object_editmode_enter(bContext *C, int flag)
Object *ob;
ScrArea *sa = CTX_wm_area(C);
View3D *v3d = NULL;
- int ok = 0;
+ bool ok = false;
if (scene->id.lib) return;
@@ -990,7 +987,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
}
else if (event == 22) {
/* Copy the constraint channels over */
- BKE_copy_constraints(&base->object->constraints, &ob->constraints, true);
+ BKE_constraints_copy(&base->object->constraints, &ob->constraints, true);
do_depgraph_update = true;
}
@@ -1130,8 +1127,7 @@ static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op))
if (ob->pd == NULL)
ob->pd = object_add_collision_fields(PFIELD_FORCE);
-
- if (ob->pd->forcefield == 0)
+ else if (ob->pd->forcefield == 0)
ob->pd->forcefield = PFIELD_FORCE;
else
ob->pd->forcefield = 0;
@@ -1867,7 +1863,7 @@ void OBJECT_OT_game_property_copy(wmOperatorType *ot)
RNA_def_enum(ot->srna, "operation", game_properties_copy_operations, 3, "Operation", "");
prop = RNA_def_enum(ot->srna, "property", DummyRNA_NULL_items, 0, "Property", "Properties to copy");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_ENUM_NO_TRANSLATE);
RNA_def_enum_funcs(prop, gameprops_itemf);
ot->prop = prop;
}
diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c
index 72d7ffaf2ea..69bd64542f4 100644
--- a/source/blender/editors/object/object_group.c
+++ b/source/blender/editors/object/object_group.c
@@ -238,6 +238,7 @@ void GROUP_OT_objects_add_active(wmOperatorType *ot)
/* properties */
prop = RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", "The group to add other selected objects to");
RNA_def_enum_funcs(prop, group_object_active_itemf);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
ot->prop = prop;
}
@@ -249,7 +250,7 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op)
int single_group_index = RNA_enum_get(op->ptr, "group");
Group *single_group = group_object_active_find_index(ob, single_group_index);
Group *group;
- int ok = 0;
+ bool ok = false;
if (ob == NULL)
return OPERATOR_CANCELLED;
@@ -301,6 +302,7 @@ void GROUP_OT_objects_remove_active(wmOperatorType *ot)
/* properties */
prop = RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", "The group to remove other selected objects from");
RNA_def_enum_funcs(prop, group_object_active_itemf);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
ot->prop = prop;
}
@@ -393,6 +395,7 @@ void GROUP_OT_objects_remove(wmOperatorType *ot)
/* properties */
prop = RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", "The group to remove this object from");
RNA_def_enum_funcs(prop, group_object_active_itemf);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
ot->prop = prop;
}
@@ -476,7 +479,7 @@ static int group_link_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Object *ob = ED_object_context(C);
- Group *group = BLI_findlink(&CTX_data_main(C)->group, RNA_enum_get(op->ptr, "group"));
+ Group *group = BLI_findlink(&bmain->group, RNA_enum_get(op->ptr, "group"));
if (ELEM(NULL, ob, group))
return OPERATOR_CANCELLED;
@@ -527,6 +530,7 @@ void OBJECT_OT_group_link(wmOperatorType *ot)
/* properties */
prop = RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", "");
RNA_def_enum_funcs(prop, RNA_group_local_itemf);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
ot->prop = prop;
}
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index e67381a1d43..6407d2eb8b8 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -50,7 +50,6 @@
#include "BKE_context.h"
#include "BKE_depsgraph.h"
#include "BKE_main.h"
-#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_report.h"
@@ -65,7 +64,6 @@
#include "ED_curve.h"
#include "ED_mesh.h"
#include "ED_screen.h"
-#include "ED_object.h"
#include "WM_types.h"
#include "WM_api.h"
@@ -542,7 +540,7 @@ static int object_add_hook_selob_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
Object *obsel = NULL;
- const int use_bone = RNA_boolean_get(op->ptr, "use_bone");
+ 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)
@@ -694,6 +692,7 @@ void OBJECT_OT_hook_remove(wmOperatorType *ot)
/* 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);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
ot->prop = prop;
}
@@ -737,6 +736,7 @@ void OBJECT_OT_hook_reset(wmOperatorType *ot)
/* 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);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
}
static int object_hook_recenter_exec(bContext *C, wmOperator *op)
@@ -786,6 +786,7 @@ void OBJECT_OT_hook_recenter(wmOperatorType *ot)
/* 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);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
}
static int object_hook_assign_exec(bContext *C, wmOperator *op)
@@ -845,6 +846,7 @@ void OBJECT_OT_hook_assign(wmOperatorType *ot)
/* 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);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
}
static int object_hook_select_exec(bContext *C, wmOperator *op)
@@ -887,5 +889,6 @@ void OBJECT_OT_hook_select(wmOperatorType *ot)
/* 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);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
}
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index 5864f1e618e..fd6b9a1bad0 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -254,6 +254,7 @@ void OBJECT_OT_group_remove(struct wmOperatorType *ot);
/* object_bake.c */
void OBJECT_OT_bake_image(wmOperatorType *ot);
+void OBJECT_OT_bake(wmOperatorType *ot);
/* object_lod.c */
void OBJECT_OT_lod_add(struct wmOperatorType *ot);
diff --git a/source/blender/editors/object/object_lod.c b/source/blender/editors/object/object_lod.c
index fdce59b10ff..a7cc4131a96 100644
--- a/source/blender/editors/object/object_lod.c
+++ b/source/blender/editors/object/object_lod.c
@@ -33,7 +33,6 @@
#include "DNA_object_types.h"
#include "BKE_context.h"
-#include "BKE_main.h"
#include "BKE_object.h"
#include "ED_screen.h"
@@ -51,7 +50,13 @@
static int object_lod_add_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = ED_object_context(C);
+
+#ifdef WITH_GAMEENGINE
BKE_object_lod_add(ob);
+#else
+ (void)ob;
+#endif
+
return OPERATOR_FINISHED;
}
@@ -75,8 +80,13 @@ static int object_lod_remove_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_context(C);
int index = RNA_int_get(op->ptr, "index");
+#ifdef WITH_GAMEENGINE
if (!BKE_object_lod_remove(ob, index))
return OPERATOR_CANCELLED;
+#else
+ (void)ob;
+ (void)index;
+#endif
WM_event_add_notifier(C, NC_OBJECT | ND_LOD, CTX_wm_view3d(C));
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 234273de9b9..3e33268704c 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -69,6 +69,7 @@
#include "BKE_report.h"
#include "BKE_object.h"
#include "BKE_ocean.h"
+#include "BKE_paint.h"
#include "BKE_particle.h"
#include "BKE_softbody.h"
#include "BKE_editmesh.h"
@@ -80,7 +81,6 @@
#include "ED_armature.h"
#include "ED_object.h"
#include "ED_screen.h"
-#include "ED_sculpt.h"
#include "ED_mesh.h"
#include "WM_api.h"
@@ -161,7 +161,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc
if (ob->mode & OB_MODE_SCULPT) {
/* ensure that grid paint mask layer is created */
- ED_sculpt_mask_layers_ensure(ob, (MultiresModifierData *)new_md);
+ BKE_sculpt_mask_layers_ensure(ob, (MultiresModifierData *)new_md);
}
}
else if (type == eModifierType_Skin) {
@@ -1187,7 +1187,7 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op)
if (ob->mode & OB_MODE_SCULPT) {
/* ensure that grid paint mask layer is created */
- ED_sculpt_mask_layers_ensure(ob, mmd);
+ BKE_sculpt_mask_layers_ensure(ob, mmd);
}
return OPERATOR_FINISHED;
@@ -1454,7 +1454,7 @@ static int skin_edit_poll(bContext *C)
edit_modifier_poll_generic(C, &RNA_SkinModifier, (1 << OB_MESH)));
}
-static void skin_root_clear(BMesh *bm, BMVert *bm_vert, GHash *visited)
+static void skin_root_clear(BMesh *bm, BMVert *bm_vert, GSet *visited)
{
BMEdge *bm_edge;
BMIter bm_iter;
@@ -1462,14 +1462,14 @@ static void skin_root_clear(BMesh *bm, BMVert *bm_vert, GHash *visited)
BM_ITER_ELEM (bm_edge, &bm_iter, bm_vert, BM_EDGES_OF_VERT) {
BMVert *v2 = BM_edge_other_vert(bm_edge, bm_vert);
- if (!BLI_ghash_lookup(visited, v2)) {
+ if (!BLI_gset_haskey(visited, v2)) {
MVertSkin *vs = CustomData_bmesh_get(&bm->vdata,
v2->head.data,
CD_MVERT_SKIN);
/* clear vertex root flag and add to visited set */
vs->flag &= ~MVERT_SKIN_ROOT;
- BLI_ghash_insert(visited, v2, v2);
+ BLI_gset_insert(visited, v2);
skin_root_clear(bm, v2, visited);
}
@@ -1483,14 +1483,14 @@ static int skin_root_mark_exec(bContext *C, wmOperator *UNUSED(op))
BMesh *bm = em->bm;
BMVert *bm_vert;
BMIter bm_iter;
- GHash *visited;
+ GSet *visited;
- visited = BLI_ghash_ptr_new("skin_root_mark_exec visited");
+ visited = BLI_gset_ptr_new(__func__);
BKE_mesh_ensure_skin_customdata(ob->data);
BM_ITER_MESH (bm_vert, &bm_iter, bm, BM_VERTS_OF_MESH) {
- if (!BLI_ghash_lookup(visited, bm_vert) &&
+ if (!BLI_gset_haskey(visited, bm_vert) &&
BM_elem_flag_test(bm_vert, BM_ELEM_SELECT))
{
MVertSkin *vs = CustomData_bmesh_get(&bm->vdata,
@@ -1499,14 +1499,14 @@ static int skin_root_mark_exec(bContext *C, wmOperator *UNUSED(op))
/* mark vertex as root and add to visited set */
vs->flag |= MVERT_SKIN_ROOT;
- BLI_ghash_insert(visited, bm_vert, bm_vert);
+ BLI_gset_insert(visited, bm_vert);
/* clear root flag from all connected vertices (recursively) */
skin_root_clear(bm, bm_vert, visited);
}
}
- BLI_ghash_free(visited, NULL, NULL);
+ BLI_gset_free(visited, NULL);
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index 5f93f4b5deb..a8f07747d3a 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -35,8 +35,6 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
-#include "BLI_math.h"
-#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "BKE_context.h"
@@ -241,6 +239,7 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_hook_recenter);
WM_operatortype_append(OBJECT_OT_bake_image);
+ WM_operatortype_append(OBJECT_OT_bake);
WM_operatortype_append(OBJECT_OT_drop_named_material);
WM_operatortype_append(OBJECT_OT_laplaciandeform_bind);
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 7e138639cea..6ff21f75733 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -44,9 +44,7 @@
#include "DNA_material_types.h"
#include "DNA_meta_types.h"
#include "DNA_particle_types.h"
-#include "DNA_rigidbody_types.h"
#include "DNA_scene_types.h"
-#include "DNA_speaker_types.h"
#include "DNA_world_types.h"
#include "DNA_object_types.h"
#include "DNA_vfont_types.h"
@@ -424,6 +422,7 @@ void OBJECT_OT_proxy_make(wmOperatorType *ot)
/* properties */
prop = RNA_def_enum(ot->srna, "object", DummyRNA_DEFAULT_items, 0, "Proxy Object", "Name of lib-linked/grouped object to make a proxy for"); /* XXX, relies on hard coded ID at the moment */
RNA_def_enum_funcs(prop, proxy_group_object_itemf);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
ot->prop = prop;
}
@@ -738,12 +737,12 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object
bFollowPathConstraint *data;
float cmat[4][4], vec[3];
- con = BKE_add_ob_constraint(ob, "AutoPath", CONSTRAINT_TYPE_FOLLOWPATH);
+ con = BKE_constraint_add_for_object(ob, "AutoPath", CONSTRAINT_TYPE_FOLLOWPATH);
data = con->data;
data->tar = par;
- BKE_get_constraint_target_matrix(scene, con, 0, CONSTRAINT_OBTYPE_OBJECT, NULL, cmat, scene->r.cfra);
+ BKE_constraint_target_matrix_get(scene, con, 0, CONSTRAINT_OBTYPE_OBJECT, NULL, cmat, scene->r.cfra);
sub_v3_v3v3(vec, ob->obmat[3], cmat[3]);
copy_v3_v3(ob->loc, vec);
@@ -819,7 +818,7 @@ static int parent_set_exec(bContext *C, wmOperator *op)
int tree_tot;
struct KDTree *tree = NULL;
int vert_par[3] = {0, 0, 0};
- int *vert_par_p = is_vert_par ? vert_par : NULL;
+ const int *vert_par_p = is_vert_par ? vert_par : NULL;
if (is_vert_par) {
@@ -1130,7 +1129,7 @@ static int object_track_clear_exec(bContext *C, wmOperator *op)
for (con = ob->constraints.last; con; con = pcon) {
pcon = con->prev;
if (ELEM3(con->type, CONSTRAINT_TYPE_TRACKTO, CONSTRAINT_TYPE_LOCKTRACK, CONSTRAINT_TYPE_DAMPTRACK))
- BKE_remove_constraint(&ob->constraints, con);
+ BKE_constraint_remove(&ob->constraints, con);
}
if (type == 1)
@@ -1186,7 +1185,7 @@ static int track_set_exec(bContext *C, wmOperator *op)
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
{
if (ob != obact) {
- con = BKE_add_ob_constraint(ob, "AutoTrack", CONSTRAINT_TYPE_DAMPTRACK);
+ con = BKE_constraint_add_for_object(ob, "AutoTrack", CONSTRAINT_TYPE_DAMPTRACK);
data = con->data;
data->tar = obact;
@@ -1207,7 +1206,7 @@ static int track_set_exec(bContext *C, wmOperator *op)
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
{
if (ob != obact) {
- con = BKE_add_ob_constraint(ob, "AutoTrack", CONSTRAINT_TYPE_TRACKTO);
+ con = BKE_constraint_add_for_object(ob, "AutoTrack", CONSTRAINT_TYPE_TRACKTO);
data = con->data;
data->tar = obact;
@@ -1229,7 +1228,7 @@ static int track_set_exec(bContext *C, wmOperator *op)
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
{
if (ob != obact) {
- con = BKE_add_ob_constraint(ob, "AutoTrack", CONSTRAINT_TYPE_LOCKTRACK);
+ con = BKE_constraint_add_for_object(ob, "AutoTrack", CONSTRAINT_TYPE_LOCKTRACK);
data = con->data;
data->tar = obact;
@@ -1662,6 +1661,7 @@ void OBJECT_OT_make_links_scene(wmOperatorType *ot)
/* properties */
prop = RNA_def_enum(ot->srna, "scene", DummyRNA_NULL_items, 0, "Scene", "");
RNA_def_enum_funcs(prop, RNA_scene_local_itemf);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
ot->prop = prop;
}
@@ -1719,6 +1719,17 @@ static void single_object_users(Main *bmain, Scene *scene, View3D *v3d, int flag
/* base gets copy of object */
obn = BKE_object_copy(ob);
base->object = obn;
+
+ if (copy_groups) {
+ if (ob->flag & OB_FROMGROUP) {
+ obn->flag |= OB_FROMGROUP;
+ }
+ }
+ else {
+ /* copy already clears */
+ }
+ base->flag = obn->flag;
+
ob->id.us--;
}
}
@@ -2106,7 +2117,7 @@ static void tag_localizable_objects(bContext *C, int mode)
/* If data is also gonna to become local, mark data we're interested in
* as gonna-to-be-local.
*/
- if (mode == MAKE_LOCAL_SELECT_OBDATA) {
+ if (mode == MAKE_LOCAL_SELECT_OBDATA && object->data) {
ID *data_id = (ID *) object->data;
data_id->flag |= LIB_DOIT;
}
@@ -2275,24 +2286,32 @@ static int make_single_user_exec(bContext *C, wmOperator *op)
View3D *v3d = CTX_wm_view3d(C); /* ok if this is NULL */
int flag = RNA_enum_get(op->ptr, "type"); /* 0==ALL, SELECTED==selected objecs */
bool copy_groups = false;
+ bool update_deps = false;
BKE_main_id_clear_newpoins(bmain);
- if (RNA_boolean_get(op->ptr, "object"))
+ if (RNA_boolean_get(op->ptr, "object")) {
single_object_users(bmain, scene, v3d, flag, copy_groups);
- if (RNA_boolean_get(op->ptr, "obdata"))
+ /* needed since object relationships may have changed */
+ update_deps = true;
+ }
+
+ if (RNA_boolean_get(op->ptr, "obdata")) {
single_obdata_users(bmain, scene, flag);
+ }
- if (RNA_boolean_get(op->ptr, "material"))
+ if (RNA_boolean_get(op->ptr, "material")) {
single_mat_users(scene, flag, RNA_boolean_get(op->ptr, "texture"));
+ }
#if 0 /* can't do this separate from materials */
if (RNA_boolean_get(op->ptr, "texture"))
single_mat_users(scene, flag, true);
#endif
- if (RNA_boolean_get(op->ptr, "animation"))
+ if (RNA_boolean_get(op->ptr, "animation")) {
single_object_action_users(scene, flag);
+ }
/* TODO(sergey): This should not be needed, however some tool still could rely
* on the fact, that id->newid is kept NULL by default.
@@ -2302,6 +2321,11 @@ static int make_single_user_exec(bContext *C, wmOperator *op)
BKE_main_id_clear_newpoins(bmain);
WM_event_add_notifier(C, NC_WINDOW, NULL);
+
+ if (update_deps) {
+ DAG_relations_tag_update(bmain);
+ }
+
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index 41ca4bf50e7..b1a78407491 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -33,8 +33,6 @@
#include <stdlib.h>
#include <string.h>
-#include "MEM_guardedalloc.h"
-
#include "DNA_anim_types.h"
#include "DNA_group_types.h"
#include "DNA_material_types.h"
@@ -47,7 +45,6 @@
#include "BLI_math.h"
#include "BLI_listbase.h"
#include "BLI_rand.h"
-#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BLF_translation.h"
@@ -486,7 +483,7 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
if (changed) {
- WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C));
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
return OPERATOR_FINISHED;
}
@@ -862,7 +859,7 @@ static int object_select_grouped_exec(bContext *C, wmOperator *op)
else if (nr == 14) changed |= select_similar_pass_index(C, ob);
if (changed) {
- WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C));
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
return OPERATOR_FINISHED;
}
@@ -1099,7 +1096,7 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
/* undo? */
- WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C));
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index b0d3d363c45..6e59f9f4aea 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -375,7 +375,7 @@ static void ignore_parent_tx(Main *bmain, Scene *scene, Object *ob)
}
}
-static int apply_objects_internal(bContext *C, ReportList *reports, int apply_loc, int apply_rot, int apply_scale)
+static int apply_objects_internal(bContext *C, ReportList *reports, bool apply_loc, bool apply_rot, bool apply_scale)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
@@ -566,8 +566,14 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo
* and is something that many users would be willing to
* sacrifice for having an easy way to do this.
*/
- float max_scale = MAX3(ob->size[0], ob->size[1], ob->size[2]);
- ob->empty_drawsize *= max_scale;
+
+ if ((apply_loc == false) &&
+ (apply_rot == false) &&
+ (apply_scale == true))
+ {
+ float max_scale = max_fff(fabsf(ob->size[0]), fabsf(ob->size[1]), fabsf(ob->size[2]));
+ ob->empty_drawsize *= max_scale;
+ }
}
else {
continue;
@@ -647,9 +653,9 @@ void OBJECT_OT_visual_transform_apply(wmOperatorType *ot)
static int object_transform_apply_exec(bContext *C, wmOperator *op)
{
- const int loc = RNA_boolean_get(op->ptr, "location");
- const int rot = RNA_boolean_get(op->ptr, "rotation");
- const int sca = RNA_boolean_get(op->ptr, "scale");
+ const bool loc = RNA_boolean_get(op->ptr, "location");
+ const bool rot = RNA_boolean_get(op->ptr, "rotation");
+ const bool sca = RNA_boolean_get(op->ptr, "scale");
if (loc || rot || sca) {
return apply_objects_internal(C, op->reports, loc, rot, sca);
@@ -881,7 +887,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
Curve *cu = ob->data;
- if (cu->bb == NULL && (centermode != ORIGIN_TO_CURSOR)) {
+ if (ob->bb == NULL && (centermode != ORIGIN_TO_CURSOR)) {
/* do nothing*/
}
else {
@@ -889,8 +895,9 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
/* done */
}
else {
- cent[0] = 0.5f * (cu->bb->vec[4][0] + cu->bb->vec[0][0]);
- cent[1] = 0.5f * (cu->bb->vec[0][1] + cu->bb->vec[2][1]) - 0.5f; /* extra 0.5 is the height o above line */
+ /* extra 0.5 is the height o above line */
+ cent[0] = 0.5f * (ob->bb->vec[4][0] + ob->bb->vec[0][0]);
+ cent[1] = 0.5f * (ob->bb->vec[0][1] + ob->bb->vec[2][1]);
}
cent[2] = 0.0f;
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index 40cf7684201..ccc3e2e8278 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -60,8 +60,6 @@
#include "BKE_customdata.h"
#include "BKE_deform.h"
#include "BKE_depsgraph.h"
-#include "BKE_global.h"
-#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
#include "BKE_editmesh.h"
#include "BKE_report.h"
@@ -864,6 +862,7 @@ static void vgroup_operator_subset_select_props(wmOperatorType *ot, bool use_act
else {
RNA_def_enum_funcs(prop, rna_vertex_group_select_itemf);
}
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
ot->prop = prop;
}
@@ -4229,6 +4228,7 @@ void OBJECT_OT_vertex_group_set_active(wmOperatorType *ot)
/* properties */
prop = RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", "Vertex group to set as active");
RNA_def_enum_funcs(prop, vgroup_itemf);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
ot->prop = prop;
}
diff --git a/source/blender/editors/physics/particle_boids.c b/source/blender/editors/physics/particle_boids.c
index 8a5f623c533..ef1e661c580 100644
--- a/source/blender/editors/physics/particle_boids.c
+++ b/source/blender/editors/physics/particle_boids.c
@@ -33,7 +33,6 @@
#include "MEM_guardedalloc.h"
#include "DNA_particle_types.h"
-#include "DNA_scene_types.h"
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index f835d08032b..3c6bdf86a50 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -48,7 +48,6 @@
#include "BLI_lasso.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
-#include "BLI_dynstr.h"
#include "BLI_kdtree.h"
#include "BLI_rand.h"
#include "BLI_utildefines.h"
@@ -62,7 +61,6 @@
#include "BKE_modifier.h"
#include "BKE_particle.h"
#include "BKE_report.h"
-#include "BKE_scene.h"
#include "BKE_pointcache.h"
@@ -3356,8 +3354,8 @@ static int brush_add(PEData *data, short number)
short size2= size*size;
DerivedMesh *dm=0;
RNG *rng;
- int *index_mf_to_mpoly;
- int *index_mp_to_orig;
+ const int *index_mf_to_mpoly;
+ const int *index_mp_to_orig;
bool release_dm = false;
invert_m4_m4(imat, ob->obmat);
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index cf228fcffb5..3972ed1c49e 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -37,41 +37,27 @@
#include "MEM_guardedalloc.h"
/* types */
-#include "DNA_anim_types.h"
#include "DNA_action_types.h"
#include "DNA_object_types.h"
#include "DNA_object_fluidsim.h"
#include "BLI_blenlib.h"
-#include "BLI_threads.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
-#include "BKE_animsys.h"
-#include "BKE_armature.h"
-#include "BKE_blender.h"
#include "BKE_context.h"
#include "BKE_customdata.h"
-#include "BKE_DerivedMesh.h"
-#include "BKE_displist.h"
-#include "BKE_effect.h"
#include "BKE_fluidsim.h"
#include "BKE_global.h"
-#include "BKE_ipo.h"
-#include "BKE_key.h"
#include "BKE_main.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_report.h"
#include "BKE_scene.h"
-#include "BKE_softbody.h"
-#include "BKE_unit.h"
-
#include "LBM_fluidsim.h"
#include "ED_screen.h"
-#include "ED_fluidsim.h"
#include "WM_types.h"
#include "WM_api.h"
@@ -84,7 +70,6 @@
#include "WM_api.h"
#include "DNA_scene_types.h"
-#include "DNA_ipo_types.h"
#include "DNA_mesh_types.h"
#include "PIL_time.h"
@@ -1101,22 +1086,6 @@ static void UNUSED_FUNCTION(fluidsimFreeBake)(Object *UNUSED(ob))
#else /* WITH_MOD_FLUID */
-/* compile dummy functions for disabled fluid sim */
-
-FluidsimSettings *fluidsimSettingsNew(Object *UNUSED(srcob))
-{
- return NULL;
-}
-
-void fluidsimSettingsFree(FluidsimSettings *UNUSED(fss))
-{
-}
-
-FluidsimSettings *fluidsimSettingsCopy(FluidsimSettings *UNUSED(fss))
-{
- return NULL;
-}
-
/* only compile dummy functions */
static int fluidsimBake(bContext *UNUSED(C), ReportList *UNUSED(reports), Object *UNUSED(ob), short UNUSED(do_job))
{
diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c
index 422b2525725..71e5e23b5f1 100644
--- a/source/blender/editors/physics/physics_pointcache.c
+++ b/source/blender/editors/physics/physics_pointcache.c
@@ -29,11 +29,8 @@
* \ingroup edphys
*/
-
#include <stdlib.h>
-#include "MEM_guardedalloc.h"
-
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
@@ -42,12 +39,8 @@
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_main.h"
-#include "BKE_modifier.h"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
-#include "BKE_report.h"
-#include "BKE_scene.h"
-
#include "ED_particle.h"
diff --git a/source/blender/editors/physics/rigidbody_constraint.c b/source/blender/editors/physics/rigidbody_constraint.c
index 00b9940121c..dd0816e509d 100644
--- a/source/blender/editors/physics/rigidbody_constraint.c
+++ b/source/blender/editors/physics/rigidbody_constraint.c
@@ -33,21 +33,16 @@
#include <stdlib.h>
#include <string.h>
-#include "MEM_guardedalloc.h"
-
-#include "DNA_group_types.h"
#include "DNA_object_types.h"
#include "DNA_rigidbody_types.h"
#include "DNA_scene_types.h"
-#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
#include "BKE_global.h"
#include "BKE_group.h"
-#include "BKE_object.h"
#include "BKE_report.h"
#include "BKE_rigidbody.h"
diff --git a/source/blender/editors/physics/rigidbody_object.c b/source/blender/editors/physics/rigidbody_object.c
index e4426fdbbf2..7ba37bbb76b 100644
--- a/source/blender/editors/physics/rigidbody_object.c
+++ b/source/blender/editors/physics/rigidbody_object.c
@@ -642,6 +642,7 @@ void RIGIDBODY_OT_mass_calculate(wmOperatorType *ot)
"Material Preset",
"Type of material that objects are made of (determines material density)");
RNA_def_enum_funcs(prop, rigidbody_materials_itemf);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
RNA_def_float(ot->srna, "density", 1.0, FLT_MIN, FLT_MAX,
"Density",
diff --git a/source/blender/editors/physics/rigidbody_world.c b/source/blender/editors/physics/rigidbody_world.c
index b7430cb8a95..1c893992cf2 100644
--- a/source/blender/editors/physics/rigidbody_world.c
+++ b/source/blender/editors/physics/rigidbody_world.c
@@ -37,7 +37,6 @@
#include "DNA_rigidbody_types.h"
#include "DNA_scene_types.h"
-#include "BLI_blenlib.h"
#include "BLI_math.h"
#ifdef WITH_BULLET
@@ -45,13 +44,8 @@
#endif
#include "BKE_context.h"
-#include "BKE_depsgraph.h"
-#include "BKE_group.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
#include "BKE_report.h"
#include "BKE_rigidbody.h"
-#include "BKE_utildefines.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -60,7 +54,6 @@
#include "WM_api.h"
#include "WM_types.h"
-#include "ED_physics.h"
#include "ED_screen.h"
#include "physics_intern.h"
@@ -159,7 +152,7 @@ static int rigidbody_world_export_exec(bContext *C, wmOperator *op)
char path[FILE_MAX];
/* sanity checks */
- if ELEM(NULL, scene, rbw) {
+ if (ELEM(NULL, scene, rbw)) {
BKE_report(op->reports, RPT_ERROR, "No Rigid Body World to export");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c
index 064f6ca3d1e..9fa312884da 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -35,7 +35,6 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
-#include "BLI_threads.h"
#include "BLI_utildefines.h"
#include "PIL_time.h"
@@ -51,15 +50,12 @@
#include "BKE_context.h"
#include "BKE_colortools.h"
#include "BKE_depsgraph.h"
-#include "BKE_freestyle.h"
#include "BKE_global.h"
#include "BKE_image.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_node.h"
-#include "BKE_multires.h"
#include "BKE_object.h"
-#include "BKE_paint.h"
#include "BKE_report.h"
#include "BKE_sequencer.h"
#include "BKE_screen.h"
@@ -99,6 +95,7 @@ static int render_break(void *rjv);
typedef struct RenderJob {
Main *main;
Scene *scene;
+ Scene *current_scene;
Render *re;
SceneRenderLayer *srl;
struct Object *camera_override;
@@ -124,7 +121,7 @@ typedef struct RenderJob {
static void image_buffer_rect_update(RenderJob *rj, RenderResult *rr, ImBuf *ibuf, ImageUser *iuser, volatile rcti *renrect)
{
Scene *scene = rj->scene;
- float *rectf = NULL;
+ const float *rectf = NULL;
int ymin, ymax, xmin, xmax;
int rymin, rxmin;
int linear_stride, linear_offset_x, linear_offset_y;
@@ -478,7 +475,8 @@ static void render_image_update_pass_and_layer(RenderJob *rj, RenderResult *rr,
for (sa = win->screen->areabase.first; sa; sa = sa->next) {
if (sa->spacetype == SPACE_IMAGE) {
SpaceImage *sima = sa->spacedata.first;
- if (sima->image == rj->image) {
+ // sa->spacedata might be empty when toggling fullscreen mode.
+ if (sima != NULL && sima->image == rj->image) {
if (first_sa == NULL) {
first_sa = sa;
}
@@ -565,6 +563,13 @@ static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrec
BKE_image_release_ibuf(ima, ibuf, lock);
}
+static void current_scene_update(void *rjv, Scene *scene)
+{
+ RenderJob *rj = rjv;
+ rj->current_scene = scene;
+ rj->iuser.scene = scene;
+}
+
static void render_startjob(void *rjv, short *stop, short *do_update, float *progress)
{
RenderJob *rj = rjv;
@@ -869,6 +874,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
rj = MEM_callocN(sizeof(RenderJob), "render job");
rj->main = mainp;
rj->scene = scene;
+ rj->current_scene = rj->scene;
rj->srl = srl;
rj->camera_override = camera_override;
rj->lay_override = 0;
@@ -941,6 +947,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
RE_test_break_cb(re, rj, render_breakjob);
RE_draw_lock_cb(re, rj, render_drawlock);
RE_display_update_cb(re, rj, image_rect_update);
+ 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);
@@ -1484,7 +1491,7 @@ Scene *ED_render_job_get_scene(const bContext *C)
RenderJob *rj = (RenderJob *)WM_jobs_customdata_from_type(wm, WM_JOB_TYPE_RENDER);
if (rj)
- return rj->scene;
+ return rj->current_scene;
return NULL;
}
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index 242ba1f1d67..c1f8dd89f71 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -37,13 +37,11 @@
#include "BLI_math.h"
#include "BLI_blenlib.h"
-#include "BLI_dlrbTree.h"
#include "BLI_utildefines.h"
#include "BLI_jitter.h"
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
-#include "DNA_world_types.h"
#include "BKE_context.h"
#include "BKE_global.h"
@@ -59,7 +57,6 @@
#include "ED_screen.h"
#include "ED_view3d.h"
-#include "ED_image.h"
#include "RE_pipeline.h"
#include "IMB_imbuf_types.h"
@@ -69,9 +66,6 @@
#include "RNA_access.h"
#include "RNA_define.h"
-#include "BIF_gl.h"
-#include "BIF_glutil.h"
-
#include "GPU_extensions.h"
#include "wm_window.h"
@@ -512,8 +506,8 @@ static bool screen_opengl_render_anim_step(bContext *C, wmOperator *op)
ImBuf *ibuf, *ibuf_save = NULL;
void *lock;
char name[FILE_MAX];
- int ok = 0;
- const short view_context = (oglrender->v3d != NULL);
+ bool ok = false;
+ const bool view_context = (oglrender->v3d != NULL);
Object *camera = NULL;
bool is_movie;
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index fdb9b5c04ed..4c34c4edba9 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -45,7 +45,6 @@
#include "BLI_math.h"
#include "BLI_blenlib.h"
-#include "BLI_threads.h"
#include "BLI_utildefines.h"
#include "BLO_readfile.h"
@@ -57,7 +56,6 @@
#include "DNA_object_types.h"
#include "DNA_lamp_types.h"
#include "DNA_space_types.h"
-#include "DNA_view3d_types.h"
#include "DNA_scene_types.h"
#include "DNA_brush_types.h"
#include "DNA_screen_types.h"
@@ -65,7 +63,6 @@
#include "BKE_brush.h"
#include "BKE_context.h"
#include "BKE_colortools.h"
-#include "BKE_depsgraph.h"
#include "BKE_global.h"
#include "BKE_idprop.h"
#include "BKE_image.h"
@@ -75,7 +72,6 @@
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_node.h"
-#include "BKE_object.h"
#include "BKE_scene.h"
#include "BKE_texture.h"
#include "BKE_world.h"
@@ -98,7 +94,6 @@
#include "ED_datafiles.h"
#include "ED_render.h"
-#include "ED_view3d.h"
#include "UI_interface.h"
@@ -350,7 +345,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
if (base->object->id.name[2] == 'c') {
Material *shadmat = give_current_material(base->object, base->object->actcol);
if (shadmat) {
- if (mat->mode & MA_SHADBUF) shadmat->septex = 0;
+ if (mat->mode2 & MA_CASTSHADOW) shadmat->septex = 0;
else shadmat->septex |= 1;
}
}
@@ -524,7 +519,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
/* new UI convention: draw is in pixel space already. */
/* uses ROUNDBOX button in block to get the rect */
-static int ed_preview_draw_rect(ScrArea *sa, int split, int first, rcti *rect, rcti *newrect)
+static bool ed_preview_draw_rect(ScrArea *sa, int split, int first, rcti *rect, rcti *newrect)
{
Render *re;
RenderResult rres;
@@ -532,7 +527,7 @@ static int ed_preview_draw_rect(ScrArea *sa, int split, int first, rcti *rect, r
int offx = 0;
int newx = BLI_rcti_size_x(rect);
int newy = BLI_rcti_size_y(rect);
- int ok = 0;
+ bool ok = false;
if (!split || first) sprintf(name, "Preview %p", (void *)sa);
else sprintf(name, "SecondPreview %p", (void *)sa);
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index 3906b3d0c10..97f6b346666 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -31,7 +31,6 @@
#include "MEM_guardedalloc.h"
-#include "DNA_mesh_types.h"
#include "DNA_curve_types.h"
#include "DNA_lamp_types.h"
#include "DNA_material_types.h"
@@ -43,7 +42,6 @@
#include "DNA_world_types.h"
#include "BLI_blenlib.h"
-#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BLF_translation.h"
@@ -55,13 +53,11 @@
#include "BKE_font.h"
#include "BKE_freestyle.h"
#include "BKE_global.h"
-#include "BKE_icons.h"
#include "BKE_image.h"
#include "BKE_library.h"
#include "BKE_linestyle.h"
#include "BKE_main.h"
#include "BKE_material.h"
-#include "BKE_node.h"
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_texture.h"
@@ -716,7 +712,7 @@ static int freestyle_lineset_add_exec(bContext *C, wmOperator *UNUSED(op))
Scene *scene = CTX_data_scene(C);
SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay);
- BKE_freestyle_lineset_add(&srl->freestyleConfig);
+ BKE_freestyle_lineset_add(&srl->freestyleConfig, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
@@ -1579,6 +1575,9 @@ static void copy_mtex_copybuf(ID *id)
case ID_PA:
mtex = &(((ParticleSettings *)id)->mtex[(int)((ParticleSettings *)id)->texact]);
break;
+ case ID_LS:
+ mtex = &(((FreestyleLineStyle *)id)->mtex[(int)((FreestyleLineStyle *)id)->texact]);
+ break;
}
if (mtex && *mtex) {
@@ -1612,6 +1611,9 @@ static void paste_mtex_copybuf(ID *id)
case ID_PA:
mtex = &(((ParticleSettings *)id)->mtex[(int)((ParticleSettings *)id)->texact]);
break;
+ case ID_LS:
+ mtex = &(((FreestyleLineStyle *)id)->mtex[(int)((FreestyleLineStyle *)id)->texact]);
+ break;
default:
BLI_assert("invalid id type");
return;
@@ -1678,7 +1680,8 @@ static int paste_mtex_exec(bContext *C, wmOperator *UNUSED(op))
Lamp *la = CTX_data_pointer_get_type(C, "lamp", &RNA_Lamp).data;
World *wo = CTX_data_pointer_get_type(C, "world", &RNA_World).data;
ParticleSystem *psys = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem).data;
-
+ FreestyleLineStyle *linestyle = CTX_data_pointer_get_type(C, "line_style", &RNA_FreestyleLineStyle).data;
+
if (ma)
id = &ma->id;
else if (la)
@@ -1687,6 +1690,8 @@ static int paste_mtex_exec(bContext *C, wmOperator *UNUSED(op))
id = &wo->id;
else if (psys)
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 81eb11d7138..94d8d78de1a 100644
--- a/source/blender/editors/render/render_update.c
+++ b/source/blender/editors/render/render_update.c
@@ -29,8 +29,6 @@
#include <stdlib.h>
#include <string.h>
-#include "MEM_guardedalloc.h"
-
#include "DNA_lamp_types.h"
#include "DNA_material_types.h"
#include "DNA_meshdata_types.h"
@@ -47,17 +45,12 @@
#include "BLI_utildefines.h"
#include "BKE_context.h"
-#include "BKE_depsgraph.h"
#include "BKE_DerivedMesh.h"
#include "BKE_icons.h"
-#include "BKE_image.h"
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_node.h"
#include "BKE_paint.h"
-#include "BKE_scene.h"
-#include "BKE_texture.h"
-#include "BKE_world.h"
#include "GPU_material.h"
#include "GPU_buffers.h"
@@ -366,7 +359,7 @@ static void texture_changed(Main *bmain, Tex *tex)
Scene *scene;
Object *ob;
bNode *node;
- int texture_draw = false;
+ bool texture_draw = false;
/* icons */
BKE_icon_changed(BKE_icon_getid(&tex->id));
diff --git a/source/blender/editors/render/render_view.c b/source/blender/editors/render/render_view.c
index 80ce74f3c5b..0beb5737ec7 100644
--- a/source/blender/editors/render/render_view.c
+++ b/source/blender/editors/render/render_view.c
@@ -29,21 +29,14 @@
#include <string.h>
#include <stddef.h>
-#include "MEM_guardedalloc.h"
-
-#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "DNA_scene_types.h"
#include "DNA_userdef_types.h"
-#include "BKE_blender.h"
#include "BKE_context.h"
#include "BKE_image.h"
#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_node.h"
-#include "BKE_report.h"
#include "BKE_screen.h"
#include "WM_api.h"
@@ -167,11 +160,12 @@ ScrArea *render_view_open(bContext *C, int mx, int my)
sa = CTX_wm_area(C);
}
else if (scene->r.displaymode == R_OUTPUT_SCREEN) {
- if (CTX_wm_area(C) && CTX_wm_area(C)->spacetype == SPACE_IMAGE)
- area_was_image = 1;
+ sa = CTX_wm_area(C);
+ if (sa && sa->spacetype == SPACE_IMAGE)
+ area_was_image = true;
/* this function returns with changed context */
- sa = ED_screen_full_newspace(C, CTX_wm_area(C), SPACE_IMAGE);
+ sa = ED_screen_full_newspace(C, sa, SPACE_IMAGE);
}
if (!sa) {
@@ -239,8 +233,8 @@ static int render_view_cancel_exec(bContext *C, wmOperator *UNUSED(op))
SpaceImage *sima = sa->spacedata.first;
/* test if we have a temp screen in front */
- if (CTX_wm_window(C)->screen->temp) {
- wm_window_lower(CTX_wm_window(C));
+ if (win->screen->temp) {
+ wm_window_lower(win);
return OPERATOR_FINISHED;
}
/* determine if render already shows */
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 71c55ddc4d5..151764dab6a 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -39,7 +39,6 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
-#include "BLI_alloca.h"
#include "BLI_linklist_stack.h"
#include "BLF_translation.h"
@@ -58,8 +57,6 @@
#include "ED_screen.h"
#include "ED_screen_types.h"
#include "ED_space_api.h"
-#include "ED_types.h"
-#include "ED_fileselect.h"
#include "BIF_gl.h"
#include "BIF_glutil.h"
@@ -1374,55 +1371,54 @@ void ED_region_toggle_hidden(bContext *C, ARegion *ar)
region_toggle_hidden(C, ar, 1);
}
-/* sa2 to sa1, we swap spaces for fullscreen to keep all allocated data */
-/* area vertices were set */
-void area_copy_data(ScrArea *sa1, ScrArea *sa2, const bool swap_space)
+/**
+ * we swap spaces for fullscreen to keep all allocated data area vertices were set
+ */
+void ED_area_data_copy(ScrArea *sa_dst, ScrArea *sa_src, const bool do_free)
{
SpaceType *st;
ARegion *ar;
- int spacetype = sa1->spacetype;
-
- sa1->headertype = sa2->headertype;
- sa1->spacetype = sa2->spacetype;
- sa1->type = sa2->type;
- sa1->butspacetype = sa2->butspacetype;
+ const char spacetype = sa_dst->spacetype;
- if (swap_space == 1) {
- SWAP(ListBase, sa1->spacedata, sa2->spacedata);
- /* exception: ensure preview is reset */
-// if (sa1->spacetype == SPACE_VIEW3D)
-// XXX BIF_view3d_previewrender_free(sa1->spacedata.first);
- }
- else if (swap_space == 2) {
- BKE_spacedata_copylist(&sa1->spacedata, &sa2->spacedata);
- }
- else {
- BKE_spacedata_freelist(&sa1->spacedata);
- BKE_spacedata_copylist(&sa1->spacedata, &sa2->spacedata);
+ sa_dst->headertype = sa_src->headertype;
+ sa_dst->spacetype = sa_src->spacetype;
+ sa_dst->type = sa_src->type;
+ sa_dst->butspacetype = sa_src->butspacetype;
+
+ /* area */
+ if (do_free) {
+ BKE_spacedata_freelist(&sa_dst->spacedata);
}
-
+ BKE_spacedata_copylist(&sa_dst->spacedata, &sa_src->spacedata);
+
/* Note; SPACE_EMPTY is possible on new screens */
-
+
/* regions */
- if (swap_space == 1) {
- SWAP(ListBase, sa1->regionbase, sa2->regionbase);
+ if (do_free) {
+ st = BKE_spacetype_from_id(spacetype);
+ for (ar = sa_dst->regionbase.first; ar; ar = ar->next)
+ BKE_area_region_free(st, ar);
+ BLI_freelistN(&sa_dst->regionbase);
}
- else {
- if (swap_space < 2) {
- st = BKE_spacetype_from_id(spacetype);
- for (ar = sa1->regionbase.first; ar; ar = ar->next)
- BKE_area_region_free(st, ar);
- BLI_freelistN(&sa1->regionbase);
- }
-
- st = BKE_spacetype_from_id(sa2->spacetype);
- for (ar = sa2->regionbase.first; ar; ar = ar->next) {
- ARegion *newar = BKE_area_region_copy(st, ar);
- BLI_addtail(&sa1->regionbase, newar);
- }
+ st = BKE_spacetype_from_id(sa_src->spacetype);
+ for (ar = sa_src->regionbase.first; ar; ar = ar->next) {
+ ARegion *newar = BKE_area_region_copy(st, ar);
+ BLI_addtail(&sa_dst->regionbase, newar);
}
}
+void ED_area_data_swap(ScrArea *sa_dst, ScrArea *sa_src)
+{
+ sa_dst->headertype = sa_src->headertype;
+ sa_dst->spacetype = sa_src->spacetype;
+ sa_dst->type = sa_src->type;
+ sa_dst->butspacetype = sa_src->butspacetype;
+
+
+ SWAP(ListBase, sa_dst->spacedata, sa_src->spacedata);
+ SWAP(ListBase, sa_dst->regionbase, sa_src->regionbase);
+}
+
/* *********** Space switching code *********** */
void ED_area_swapspace(bContext *C, ScrArea *sa1, ScrArea *sa2)
@@ -1432,9 +1428,9 @@ void ED_area_swapspace(bContext *C, ScrArea *sa1, ScrArea *sa2)
ED_area_exit(C, sa1);
ED_area_exit(C, sa2);
- area_copy_data(tmp, sa1, 2);
- area_copy_data(sa1, sa2, 0);
- area_copy_data(sa2, tmp, 0);
+ ED_area_data_copy(tmp, sa1, false);
+ ED_area_data_copy(sa1, sa2, true);
+ ED_area_data_copy(sa2, tmp, true);
ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa1);
ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa2);
@@ -1926,8 +1922,8 @@ void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy)
/* the image is located inside (0, 0), (1, 1) as set by view2d */
UI_ThemeColorShade(TH_BACK, 20);
- UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x1, &y1);
- UI_view2d_to_region_no_clip(&ar->v2d, 1.0f, 1.0f, &x2, &y2);
+ UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x1, &y1);
+ UI_view2d_view_to_region(&ar->v2d, 1.0f, 1.0f, &x2, &y2);
glRectf(x1, y1, x2, y2);
/* gridsize adapted to zoom level */
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index 6b5f5a1a9ae..f31d79ff76b 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -39,11 +39,7 @@
#include "BLI_rect.h"
#include "BLI_utildefines.h"
#include "BLI_math.h"
-#include "BLI_threads.h"
-#include "BKE_blender.h"
-#include "BKE_global.h"
-#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BIF_gl.h"
@@ -502,7 +498,7 @@ static int get_cached_work_texture(int *r_w, int *r_h)
void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect, float scaleX, float scaleY)
{
unsigned char *uc_rect = (unsigned char *) rect;
- float *f_rect = (float *)rect;
+ const float *f_rect = (float *)rect;
float xzoom = glaGetOneFloat(GL_ZOOM_X), yzoom = glaGetOneFloat(GL_ZOOM_Y);
int ltexid = glaGetOneInteger(GL_TEXTURE_2D);
int lrowlength = glaGetOneInteger(GL_UNPACK_ROW_LENGTH);
@@ -692,17 +688,17 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo
glPixelStorei(GL_UNPACK_ROW_LENGTH, row_w);
if (format == GL_LUMINANCE || format == GL_RED) {
if (type == GL_FLOAT) {
- float *f_rect = (float *)rect;
+ const float *f_rect = (float *)rect;
glDrawPixels(draw_w, draw_h, format, type, f_rect + (off_y * row_w + off_x));
}
else if (type == GL_INT || type == GL_UNSIGNED_INT) {
- int *i_rect = (int *)rect;
+ const int *i_rect = (int *)rect;
glDrawPixels(draw_w, draw_h, format, type, i_rect + (off_y * row_w + off_x));
}
}
else { /* RGBA */
if (type == GL_FLOAT) {
- float *f_rect = (float *)rect;
+ const float *f_rect = (float *)rect;
glDrawPixels(draw_w, draw_h, format, type, f_rect + (off_y * row_w + off_x) * 4);
}
else if (type == GL_UNSIGNED_BYTE) {
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index b1c57030130..7c8987ae778 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -49,7 +49,6 @@
#include "RNA_access.h"
-#include "ED_object.h"
#include "ED_armature.h"
#include "WM_api.h"
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index b10f521d25d..f76f76aacaa 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -55,11 +55,9 @@
#include "WM_api.h"
#include "WM_types.h"
-#include "ED_image.h"
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_screen_types.h"
-#include "ED_fileselect.h"
#include "ED_clip.h"
#include "ED_render.h"
@@ -412,7 +410,7 @@ ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge)
sa->v4 = sv2;
}
- area_copy_data(newa, sa, 0);
+ ED_area_data_copy(newa, sa, true);
}
else {
@@ -444,7 +442,7 @@ ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge)
sa->v2 = sv2;
}
- area_copy_data(newa, sa, 0);
+ ED_area_data_copy(newa, sa, true);
}
/* remove double vertices en edges */
@@ -525,7 +523,7 @@ static void screen_copy(bScreen *to, bScreen *from)
BLI_listbase_clear(&sa->actionzones);
BLI_listbase_clear(&sa->handlers);
- area_copy_data(sa, saf, 0);
+ ED_area_data_copy(sa, saf, true);
}
/* put at zero (needed?) */
@@ -1840,7 +1838,7 @@ ScrArea *ED_screen_full_toggle(bContext *C, wmWindow *win, ScrArea *sa)
return NULL;
}
- area_copy_data(old, sa, 1); /* 1 = swap spacelist */
+ ED_area_data_swap(old, sa);
if (sa->flag & AREA_TEMP_INFO) sa->flag &= ~AREA_TEMP_INFO;
old->full = NULL;
@@ -1887,7 +1885,7 @@ ScrArea *ED_screen_full_toggle(bContext *C, wmWindow *win, ScrArea *sa)
/* copy area */
newa = newa->prev;
- area_copy_data(newa, sa, 1); /* 1 = swap spacelist */
+ ED_area_data_swap(newa, sa);
sa->flag |= AREA_TEMP_INFO;
sa->full = oldscreen;
diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h
index b279ddab42f..9e0421b6e99 100644
--- a/source/blender/editors/screen/screen_intern.h
+++ b/source/blender/editors/screen/screen_intern.h
@@ -38,7 +38,8 @@ struct Scene;
#define AZONESPOT (0.6f * U.widget_unit)
/* area.c */
-void area_copy_data(ScrArea *sa1, ScrArea *sa2, const bool swap_space);
+void ED_area_data_copy(ScrArea *sa_dst, ScrArea *sa_src, const bool do_free);
+void ED_area_data_swap(ScrArea *sa1, ScrArea *sa2);
void region_toggle_hidden(bContext *C, ARegion *ar, const bool do_fade);
/* screen_edit.c */
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 915ed7679f4..8b6a1b22a5c 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -45,7 +45,6 @@
#include "DNA_curve_types.h"
#include "DNA_scene_types.h"
#include "DNA_meta_types.h"
-#include "DNA_mesh_types.h"
#include "DNA_mask_types.h"
#include "DNA_node_types.h"
#include "DNA_userdef_types.h"
@@ -54,8 +53,6 @@
#include "BKE_customdata.h"
#include "BKE_global.h"
#include "BKE_main.h"
-#include "BKE_mesh.h"
-#include "BKE_node.h"
#include "BKE_object.h"
#include "BKE_report.h"
#include "BKE_scene.h"
@@ -738,7 +735,7 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* gesture is large enough? */
if (is_gesture) {
/* second area, for join when (sa1 != sa2) */
- sad->sa2 = screen_areahascursor(CTX_wm_screen(C), event->x, event->y);
+ sad->sa2 = screen_areahascursor(sc, event->x, event->y);
/* apply sends event */
actionzone_apply(C, op, sad->az->type);
actionzone_exit(op);
@@ -939,7 +936,7 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
newwin->screen = newsc;
/* copy area to new screen */
- area_copy_data((ScrArea *)newsc->areabase.first, sa, 0);
+ ED_area_data_copy((ScrArea *)newsc->areabase.first, sa, true);
ED_area_tag_redraw((ScrArea *)newsc->areabase.first);
@@ -1999,7 +1996,7 @@ static int frame_offset_exec(bContext *C, wmOperator *op)
sound_seek_scene(bmain, scene);
- WM_event_add_notifier(C, NC_SCENE | ND_FRAME, CTX_data_scene(C));
+ WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
return OPERATOR_FINISHED;
}
@@ -2095,6 +2092,12 @@ 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);
@@ -2869,9 +2872,11 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
ARegion *ar = CTX_wm_region(C);
/* some rules... */
- if (ar->regiontype != RGN_TYPE_WINDOW)
+ if (ar->regiontype != RGN_TYPE_WINDOW) {
BKE_report(op->reports, RPT_ERROR, "Only window region can be 4-splitted");
+ }
else if (ar->alignment == RGN_ALIGN_QSPLIT) {
+ /* Exit quad-view */
ScrArea *sa = CTX_wm_area(C);
ARegion *arn;
@@ -2879,10 +2884,33 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
ar->alignment = 0;
if (sa->spacetype == SPACE_VIEW3D) {
+ ARegion *ar_iter;
RegionView3D *rv3d = ar->regiondata;
- rv3d->viewlock_quad = rv3d->viewlock | RV3D_VIEWLOCK_INIT;
+
+ /* if this is a locked view, use settings from 'User' view */
+ if (rv3d->viewlock) {
+ View3D *v3d_user;
+ ARegion *ar_user;
+
+ if (ED_view3d_context_user_region(C, &v3d_user, &ar_user)) {
+ if (ar != ar_user) {
+ SWAP(void *, ar->regiondata, ar_user->regiondata);
+ rv3d = ar->regiondata;
+ }
+ }
+ }
+
+ rv3d->viewlock_quad = RV3D_VIEWLOCK_INIT;
rv3d->viewlock = 0;
rv3d->rflag &= ~RV3D_CLIPPING;
+
+ /* accumulate locks, incase they're mixed */
+ for (ar_iter = sa->regionbase.first; ar_iter; ar_iter = ar_iter->next) {
+ if (ar_iter->regiontype == RGN_TYPE_WINDOW) {
+ RegionView3D *rv3d_iter = ar_iter->regiondata;
+ rv3d->viewlock_quad |= rv3d_iter->viewlock;
+ }
+ }
}
for (ar = sa->regionbase.first; ar; ar = arn) {
@@ -2897,9 +2925,11 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
ED_area_tag_redraw(sa);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
}
- else if (ar->next)
+ else if (ar->next) {
BKE_report(op->reports, RPT_ERROR, "Only last region can be 4-splitted");
+ }
else {
+ /* Enter quad-view */
ScrArea *sa = CTX_wm_area(C);
ARegion *newar;
int count;
@@ -2929,9 +2959,13 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
region_quadview_init_rv3d(sa, ar, viewlock, ED_view3d_lock_view_from_index(index_qsplit++), RV3D_ORTHO);
region_quadview_init_rv3d(sa, (ar = ar->next), viewlock, ED_view3d_lock_view_from_index(index_qsplit++), RV3D_ORTHO);
region_quadview_init_rv3d(sa, (ar = ar->next), viewlock, ED_view3d_lock_view_from_index(index_qsplit++), RV3D_ORTHO);
+ /* forcing camera is distracting */
+#if 0
if (v3d->camera) region_quadview_init_rv3d(sa, (ar = ar->next), 0, RV3D_VIEW_CAMERA, RV3D_CAMOB);
else region_quadview_init_rv3d(sa, (ar = ar->next), 0, RV3D_VIEW_USER, RV3D_PERSP);
-
+#else
+ (void)v3d;
+#endif
}
ED_area_tag_redraw(sa);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
@@ -3056,7 +3090,7 @@ static int header_toggle_menus_exec(bContext *C, wmOperator *UNUSED(op))
sa->flag = sa->flag ^ HEADER_NO_PULLDOWN;
- ED_area_tag_redraw(CTX_wm_area(C));
+ ED_area_tag_redraw(sa);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c
index c5ca5ab921f..be5fd48b41a 100644
--- a/source/blender/editors/screen/screendump.c
+++ b/source/blender/editors/screen/screendump.c
@@ -301,8 +301,8 @@ typedef struct ScreenshotJob {
wmWindowManager *wm;
unsigned int *dumprect;
int x, y, dumpsx, dumpsy;
- short *stop;
- short *do_update;
+ const short *stop;
+ const short *do_update;
ReportList reports;
} ScreenshotJob;
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 81177dd8199..b1e4696cd02 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -54,6 +54,8 @@
#include "BIF_gl.h"
#include "BIF_glutil.h"
+#include "IMB_imbuf_types.h"
+
#include "ED_view3d.h"
#include "paint_intern.h"
@@ -159,6 +161,8 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima
if (refresh) {
struct ImagePool *pool = NULL;
+ bool convert_to_linear = false;
+ struct ColorSpace *colorspace;
/* stencil is rotated later */
const float rotation = (mtex->brush_map_mode != MTEX_MAP_MODE_STENCIL) ?
-mtex->rot : 0;
@@ -218,6 +222,17 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima
thread_num = 0;
#endif
+ if (mtex->tex->type == TEX_IMAGE && mtex->tex->ima) {
+ ImBuf *tex_ibuf = BKE_image_pool_acquire_ibuf(mtex->tex->ima, &mtex->tex->iuser, pool);
+ /* For consistency, sampling always returns color in linear space */
+ if (tex_ibuf && tex_ibuf->rect_float == NULL) {
+ convert_to_linear = true;
+ colorspace = tex_ibuf->rect_colorspace;
+ }
+ BKE_image_pool_release_ibuf(mtex->tex->ima, tex_ibuf, pool);
+ }
+
+
for (i = 0; i < size; i++) {
// largely duplicated from tex_strength
@@ -256,7 +271,7 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima
if (col) {
float rgba[4];
- paint_get_tex_pixel_col(mtex, x, y, rgba, pool, thread_num);
+ paint_get_tex_pixel_col(mtex, x, y, rgba, pool, thread_num, convert_to_linear, colorspace);
buffer[index * 4] = rgba[0] * 255;
buffer[index * 4 + 1] = rgba[1] * 255;
@@ -583,7 +598,7 @@ static void paint_draw_tex_overlay(UnifiedPaintSettings *ups, Brush *brush,
/* scale based on tablet pressure */
if (primary && ups->stroke_active && BKE_brush_use_size_pressure(vc->scene, brush)) {
glTranslatef(0.5f, 0.5f, 0);
- glScalef(1.0f / ups->pressure_value, 1.0f / ups->pressure_value, 1);
+ glScalef(1.0f / ups->size_pressure_value, 1.0f / ups->size_pressure_value, 1);
glTranslatef(-0.5f, -0.5f, 0);
}
@@ -711,7 +726,7 @@ static void paint_draw_cursor_overlay(UnifiedPaintSettings *ups, Brush *brush,
glPushMatrix();
glLoadIdentity();
glTranslatef(center[0], center[1], 0);
- glScalef(ups->pressure_value, ups->pressure_value, 1);
+ glScalef(ups->size_pressure_value, ups->size_pressure_value, 1);
glTranslatef(-center[0], -center[1], 0);
}
@@ -801,7 +816,7 @@ static void paint_cursor_on_hit(UnifiedPaintSettings *ups, Brush *brush, ViewCon
/* scale 3D brush radius by pressure */
if (ups->stroke_active && BKE_brush_use_size_pressure(vc->scene, brush))
- unprojected_radius *= ups->pressure_value;
+ unprojected_radius *= ups->size_pressure_value;
/* set cached value in either Brush or UnifiedPaintSettings */
BKE_brush_unprojected_radius_set(vc->scene, brush, unprojected_radius);
@@ -896,7 +911,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
/* draw an inner brush */
if (ups->stroke_active && BKE_brush_use_size_pressure(scene, brush)) {
/* inner at full alpha */
- glutil_draw_lined_arc(0.0, M_PI * 2.0, final_radius * ups->pressure_value, 40);
+ glutil_draw_lined_arc(0.0, M_PI * 2.0, final_radius * ups->size_pressure_value, 40);
/* outer at half alpha */
glColor4f(outline_col[0], outline_col[1], outline_col[2], outline_alpha * 0.5f);
}
diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c
index 6542bb2ca9b..3d860145f59 100644
--- a/source/blender/editors/sculpt_paint/paint_hide.c
+++ b/source/blender/editors/sculpt_paint/paint_hide.c
@@ -35,7 +35,6 @@
#include "MEM_guardedalloc.h"
#include "BLI_bitmap.h"
-#include "BLI_listbase.h"
#include "BLI_math_vector.h"
#include "BLI_utildefines.h"
@@ -98,7 +97,7 @@ static void partialvis_update_mesh(Object *ob,
{
Mesh *me = ob->data;
MVert *mvert;
- float *paint_mask;
+ const float *paint_mask;
int *vert_indices;
int totvert, i;
bool any_changed = false, any_visible = false;
@@ -253,6 +252,20 @@ static void partialvis_update_bmesh_verts(BMesh *bm,
}
}
+static void partialvis_update_bmesh_faces(GSet *faces, PartialVisAction action)
+{
+ GSetIterator gs_iter;
+
+ GSET_ITER (gs_iter, faces) {
+ BMFace *f = BLI_gsetIterator_getKey(&gs_iter);
+
+ if ((action == PARTIALVIS_HIDE) && paint_is_bmesh_face_hidden(f))
+ BM_elem_flag_enable(f, BM_ELEM_HIDDEN);
+ else
+ BM_elem_flag_disable(f, BM_ELEM_HIDDEN);
+ }
+}
+
static void partialvis_update_bmesh(Object *ob,
PBVH *pbvh,
PBVHNode *node,
@@ -261,12 +274,13 @@ static void partialvis_update_bmesh(Object *ob,
float planes[4][4])
{
BMesh *bm;
- GSet *unique, *other;
+ GSet *unique, *other, *faces;
bool any_changed = false, any_visible = false;
bm = BKE_pbvh_get_bmesh(pbvh);
unique = BKE_pbvh_bmesh_node_unique_verts(node);
other = BKE_pbvh_bmesh_node_other_verts(node);
+ faces = BKE_pbvh_bmesh_node_faces(node);
sculpt_undo_push_node(ob, node, SCULPT_UNDO_HIDDEN);
@@ -286,6 +300,9 @@ static void partialvis_update_bmesh(Object *ob,
&any_changed,
&any_visible);
+ /* finally loop over node faces and tag the ones that are fully hidden */
+ partialvis_update_bmesh_faces(faces, action);
+
if (any_changed) {
BKE_pbvh_node_mark_rebuild_draw(node);
BKE_pbvh_node_fully_hidden_set(node, !any_visible);
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 4cf59a575b9..5e2bdcb3c93 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -42,9 +42,6 @@
#include "BLI_math.h"
#include "BLI_blenlib.h"
-#include "BLI_linklist.h"
-#include "BLI_memarena.h"
-#include "BLI_threads.h"
#include "BLI_utildefines.h"
#include "PIL_time.h"
@@ -57,37 +54,24 @@
#include "DNA_node_types.h"
#include "DNA_object_types.h"
-#include "BKE_camera.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
-#include "BKE_DerivedMesh.h"
-#include "BKE_idprop.h"
#include "BKE_brush.h"
#include "BKE_image.h"
-#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_mesh.h"
#include "BKE_node.h"
-#include "BKE_object.h"
#include "BKE_paint.h"
-#include "BKE_report.h"
-#include "BKE_scene.h"
-#include "BKE_colortools.h"
#include "BKE_editmesh.h"
-#include "BIF_gl.h"
-#include "BIF_glutil.h"
-
#include "UI_view2d.h"
#include "ED_image.h"
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_sculpt.h"
-#include "ED_uvedit.h"
#include "ED_view3d.h"
-#include "ED_mesh.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -718,71 +702,6 @@ int get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy)
/************************ cursor drawing *******************************/
-void brush_drawcursor_texpaint_uvsculpt(bContext *C, int x, int y, void *UNUSED(customdata))
-{
-#define PX_SIZE_FADE_MAX 12.0f
-#define PX_SIZE_FADE_MIN 4.0f
-
- Scene *scene = CTX_data_scene(C);
- //Brush *brush = image_paint_brush(C);
- Paint *paint = BKE_paint_get_active_from_context(C);
- Brush *brush = BKE_paint_brush(paint);
-
- if (paint && brush && paint->flags & PAINT_SHOW_BRUSH) {
- float zoomx, zoomy;
- const float size = (float)BKE_brush_size_get(scene, brush);
- short use_zoom;
- float pixel_size;
- float alpha = 0.5f;
-
- use_zoom = get_imapaint_zoom(C, &zoomx, &zoomy);
-
- if (use_zoom) {
- pixel_size = size * max_ff(zoomx, zoomy);
- }
- else {
- pixel_size = size;
- }
-
- /* fade out the brush (cheap trick to work around brush interfering with sampling [#])*/
- if (pixel_size < PX_SIZE_FADE_MIN) {
- return;
- }
- else if (pixel_size < PX_SIZE_FADE_MAX) {
- alpha *= (pixel_size - PX_SIZE_FADE_MIN) / (PX_SIZE_FADE_MAX - PX_SIZE_FADE_MIN);
- }
-
- glPushMatrix();
-
- glTranslatef((float)x, (float)y, 0.0f);
-
- /* No need to scale for uv sculpting, on the contrary it might be useful to keep un-scaled */
- if (use_zoom)
- glScalef(zoomx, zoomy, 1.0f);
-
- glColor4f(brush->add_col[0], brush->add_col[1], brush->add_col[2], alpha);
- glEnable(GL_LINE_SMOOTH);
- glEnable(GL_BLEND);
- {
- UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
- /* hrmf, duplicate paint_draw_cursor logic here */
- if (ups->stroke_active && BKE_brush_use_size_pressure(scene, brush)) {
- /* inner at full alpha */
- glutil_draw_lined_arc(0, (float)(M_PI * 2.0), size * ups->pressure_value, 40);
- /* outer at half alpha */
- glColor4f(brush->add_col[0], brush->add_col[1], brush->add_col[2], alpha * 0.5f);
- }
- }
- glutil_draw_lined_arc(0, (float)(M_PI * 2.0), size, 40);
- glDisable(GL_BLEND);
- glDisable(GL_LINE_SMOOTH);
-
- glPopMatrix();
- }
-#undef PX_SIZE_FADE_MAX
-#undef PX_SIZE_FADE_MIN
-}
-
static void toggle_paint_cursor(bContext *C, int enable)
{
wmWindowManager *wm = CTX_wm_manager(C);
@@ -808,7 +727,7 @@ void ED_space_image_paint_update(wmWindowManager *wm, ToolSettings *settings)
wmWindow *win;
ScrArea *sa;
ImagePaintSettings *imapaint = &settings->imapaint;
- int enabled = false;
+ bool enabled = false;
for (win = wm->windows.first; win; win = win->next)
for (sa = win->screen->areabase.first; sa; sa = sa->next)
@@ -976,7 +895,7 @@ static int sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *event
RNA_int_set_array(op->ptr, "location", event->mval);
paint_sample_color(C, ar, event->mval[0], event->mval[1]);
- WM_cursor_modal_set(CTX_wm_window(C), BC_EYEDROPPER_CURSOR);
+ WM_cursor_modal_set(win, BC_EYEDROPPER_CURSOR);
WM_event_add_modal_handler(C, op);
WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush);
diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c
index 19f2673d96a..667b487d4b1 100644
--- a/source/blender/editors/sculpt_paint/paint_image_2d.c
+++ b/source/blender/editors/sculpt_paint/paint_image_2d.c
@@ -39,11 +39,9 @@
#include "DNA_object_types.h"
#include "BLI_math.h"
-#include "BLI_rect.h"
#include "BKE_context.h"
#include "BKE_brush.h"
-#include "BKE_main.h"
#include "BKE_image.h"
#include "BKE_paint.h"
#include "BKE_report.h"
@@ -126,8 +124,8 @@ typedef struct ImagePaintState {
Image *image;
ImBuf *canvas;
ImBuf *clonecanvas;
- char *warnpackedfile;
- char *warnmultifile;
+ const char *warnpackedfile;
+ const char *warnmultifile;
bool do_masking;
@@ -233,6 +231,9 @@ static ImBuf *brush_painter_imbuf_new(BrushPainter *painter, int size)
Scene *scene = painter->scene;
Brush *brush = painter->brush;
+ const char *display_device = scene->display_settings.display_device;
+ struct ColorManagedDisplay *display = IMB_colormanagement_display_get_named(display_device);
+
rctf tex_mapping = painter->tex_mapping;
rctf mask_mapping = painter->mask_mapping;
struct ImagePool *pool = painter->pool;
@@ -258,8 +259,9 @@ static ImBuf *brush_painter_imbuf_new(BrushPainter *painter, int size)
if (brush->imagepaint_tool == PAINT_TOOL_DRAW) {
copy_v3_v3(brush_rgb, brush->rgb);
- if (use_color_correction)
- srgb_to_linearrgb_v3_v3(brush_rgb, brush_rgb);
+ if (use_color_correction) {
+ IMB_colormanagement_display_to_scene_linear_v3(brush_rgb, display);
+ }
}
else {
brush_rgb[0] = 1.0f;
@@ -278,7 +280,7 @@ static ImBuf *brush_painter_imbuf_new(BrushPainter *painter, int size)
BKE_brush_sample_tex_3D(scene, brush, texco, rgba, thread, pool);
/* TODO(sergey): Support texture paint color space. */
if (!use_float) {
- linearrgb_to_srgb_v3_v3(rgba, rgba);
+ IMB_colormanagement_scene_linear_to_display_v3(rgba, display);
}
mul_v3_v3(rgba, brush_rgb);
}
@@ -326,6 +328,9 @@ static void brush_painter_imbuf_update(BrushPainter *painter, ImBuf *oldtexibuf,
Scene *scene = painter->scene;
Brush *brush = painter->brush;
+ const char *display_device = scene->display_settings.display_device;
+ struct ColorManagedDisplay *display = IMB_colormanagement_display_get_named(display_device);
+
rctf tex_mapping = painter->tex_mapping;
rctf mask_mapping = painter->mask_mapping;
struct ImagePool *pool = painter->pool;
@@ -348,8 +353,9 @@ static void brush_painter_imbuf_update(BrushPainter *painter, ImBuf *oldtexibuf,
if (brush->imagepaint_tool == PAINT_TOOL_DRAW) {
copy_v3_v3(brush_rgb, brush->rgb);
- if (use_color_correction)
- srgb_to_linearrgb_v3_v3(brush_rgb, brush_rgb);
+ if (use_color_correction) {
+ IMB_colormanagement_display_to_scene_linear_v3(brush_rgb, display);
+ }
}
else {
brush_rgb[0] = 1.0f;
@@ -369,7 +375,7 @@ static void brush_painter_imbuf_update(BrushPainter *painter, ImBuf *oldtexibuf,
BKE_brush_sample_tex_3D(scene, brush, texco, rgba, thread, pool);
/* TODO(sergey): Support texture paint color space. */
if (!use_float) {
- linearrgb_to_srgb_v3_v3(rgba, rgba);
+ IMB_colormanagement_scene_linear_to_display_v3(rgba, display);
}
mul_v3_v3(rgba, brush_rgb);
}
@@ -391,7 +397,7 @@ static void brush_painter_imbuf_update(BrushPainter *painter, ImBuf *oldtexibuf,
/* read from old texture buffer */
if (use_texture_old) {
- float *otf = oldtexibuf->rect_float + ((y - origy + yt) * oldtexibuf->x + (x - origx + xt)) * 4;
+ const float *otf = oldtexibuf->rect_float + ((y - origy + yt) * oldtexibuf->x + (x - origx + xt)) * 4;
copy_v4_v4(rgba, otf);
}
@@ -485,8 +491,8 @@ static void brush_painter_imbuf_partial_update(BrushPainter *painter, const floa
w = h = 0;
}
- x1 = destx;
- y1 = desty;
+ x1 = min_ii(destx, ibuf->x);
+ y1 = min_ii(desty, ibuf->y);
x2 = min_ii(destx + w, ibuf->x);
y2 = min_ii(desty + h, ibuf->y);
@@ -521,8 +527,8 @@ static void brush_painter_2d_tex_mapping(ImagePaintState *s, int size, const flo
if (mapmode == MTEX_MAP_MODE_STENCIL) {
/* map from view coordinates of brush to region coordinates */
- UI_view2d_to_region_no_clip(s->v2d, ipos[0] * invw, ipos[1] * invh, &xmin, &ymin);
- UI_view2d_to_region_no_clip(s->v2d, (ipos[0] + size) * invw, (ipos[1] + size) * invh, &xmax, &ymax);
+ UI_view2d_view_to_region(s->v2d, ipos[0] * invw, ipos[1] * invh, &xmin, &ymin);
+ UI_view2d_view_to_region(s->v2d, (ipos[0] + size) * invw, (ipos[1] + size) * invh, &xmax, &ymax);
/* output mapping from brush ibuf x/y to region coordinates */
mapping->xmin = xmin;
@@ -663,7 +669,7 @@ static void paint_2d_ibuf_rgb_get(ImBuf *ibuf, int x, int y, const bool is_torus
}
if (ibuf->rect_float) {
- float *rrgbf = ibuf->rect_float + (ibuf->x * y + x) * 4;
+ const float *rrgbf = ibuf->rect_float + (ibuf->x * y + x) * 4;
copy_v4_v4(r_rgb, rrgbf);
}
else {
@@ -859,7 +865,7 @@ static int paint_2d_op(void *state, ImBuf *ibufb, unsigned short *maskb, const f
ImagePaintRegion region[4];
short torus = s->brush->flag & BRUSH_TORUS;
short blend = s->blend;
- float *offset = s->brush->clone.offset;
+ const float *offset = s->brush->clone.offset;
float liftpos[2];
float brush_alpha = BKE_brush_alpha_get(s->scene, s->brush);
unsigned short mask_max = (unsigned short)(brush_alpha * 65535.0f);
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index c6de5749274..492857bd0bb 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -60,35 +60,23 @@
#include "BKE_camera.h"
#include "BKE_context.h"
-#include "BKE_depsgraph.h"
#include "BKE_DerivedMesh.h"
#include "BKE_idprop.h"
#include "BKE_brush.h"
#include "BKE_image.h"
#include "BKE_library.h"
#include "BKE_main.h"
-#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
-#include "BKE_node.h"
-#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_report.h"
#include "BKE_scene.h"
-#include "BKE_colortools.h"
-
-#include "BKE_editmesh.h"
-
-#include "BIF_gl.h"
-#include "BIF_glutil.h"
#include "UI_view2d.h"
-#include "ED_image.h"
#include "ED_screen.h"
#include "ED_sculpt.h"
#include "ED_uvedit.h"
#include "ED_view3d.h"
-#include "ED_mesh.h"
#include "GPU_extensions.h"
@@ -375,27 +363,6 @@ static int project_bucket_offset_safe(const ProjPaintState *ps, const float proj
}
}
-/* still use 2D X,Y space but this works for verts transformed by a perspective matrix, using their 4th component as a weight */
-static void barycentric_weights_v2_persp(const float v1[4], const float v2[4], const float v3[4], const float co[2], float w[3])
-{
- float wtot_inv, wtot;
-
- w[0] = area_tri_signed_v2(v2, v3, co) / v1[3];
- w[1] = area_tri_signed_v2(v3, v1, co) / v2[3];
- w[2] = area_tri_signed_v2(v1, v2, co) / v3[3];
- wtot = w[0] + w[1] + w[2];
-
- if (wtot != 0.0f) {
- wtot_inv = 1.0f / wtot;
-
- w[0] = w[0] * wtot_inv;
- w[1] = w[1] * wtot_inv;
- w[2] = w[2] * wtot_inv;
- }
- else /* dummy values for zero area face */
- w[0] = w[1] = w[2] = 1.0f / 3.0f;
-}
-
static float VecZDepthOrtho(const float pt[2],
const float v1[3], const float v2[3], const float v3[3],
float w[3])
@@ -444,7 +411,7 @@ static int project_paint_PickFace(const ProjPaintState *ps, const float pt[2], f
{
LinkNode *node;
float w_tmp[3];
- float *v1, *v2, *v3, *v4;
+ const float *v1, *v2, *v3, *v4;
int bucket_index;
int face_index;
int best_side = -1;
@@ -581,7 +548,7 @@ static bool project_paint_PickColor(const ProjPaintState *ps, const float pt[2],
if (rgba) {
if (ibuf->rect_float) {
- float *rgba_tmp_fp = ibuf->rect_float + (xi + yi * ibuf->x * 4);
+ const float *rgba_tmp_fp = ibuf->rect_float + (xi + yi * ibuf->x * 4);
premul_float_to_straight_uchar(rgba, rgba_tmp_fp);
}
else {
@@ -983,19 +950,16 @@ static void uv_image_outset(float (*orig_uv)[2], float (*outset_uv)[2], const fl
normalize_v2(dir3);
}
- /* TODO - angle_normalized_v2v2(...) * (M_PI/180.0f)
- * This is incorrect. Its already given radians but without it wont work.
- * need to look into a fix - campbell */
if (is_quad) {
- a1 = shell_angle_to_dist(angle_normalized_v2v2(dir4, dir1) * ((float)M_PI / 180.0f));
- a2 = shell_angle_to_dist(angle_normalized_v2v2(dir1, dir2) * ((float)M_PI / 180.0f));
- a3 = shell_angle_to_dist(angle_normalized_v2v2(dir2, dir3) * ((float)M_PI / 180.0f));
- a4 = shell_angle_to_dist(angle_normalized_v2v2(dir3, dir4) * ((float)M_PI / 180.0f));
+ a1 = shell_v2v2_mid_normalized_to_dist(dir4, dir1);
+ a2 = shell_v2v2_mid_normalized_to_dist(dir1, dir2);
+ a3 = shell_v2v2_mid_normalized_to_dist(dir2, dir3);
+ a4 = shell_v2v2_mid_normalized_to_dist(dir3, dir4);
}
else {
- a1 = shell_angle_to_dist(angle_normalized_v2v2(dir3, dir1) * ((float)M_PI / 180.0f));
- a2 = shell_angle_to_dist(angle_normalized_v2v2(dir1, dir2) * ((float)M_PI / 180.0f));
- a3 = shell_angle_to_dist(angle_normalized_v2v2(dir2, dir3) * ((float)M_PI / 180.0f));
+ a1 = shell_v2v2_mid_normalized_to_dist(dir3, dir1);
+ a2 = shell_v2v2_mid_normalized_to_dist(dir1, dir2);
+ a3 = shell_v2v2_mid_normalized_to_dist(dir2, dir3);
}
if (is_quad) {
@@ -1077,9 +1041,9 @@ static void project_face_seams_init(const ProjPaintState *ps, const int face_ind
*
* This is used for finding a pixels location in screenspace for painting */
static void screen_px_from_ortho(
- float uv[2],
- float v1co[3], float v2co[3], float v3co[3], /* Screenspace coords */
- float uv1co[2], float uv2co[2], float uv3co[2],
+ const float uv[2],
+ const float v1co[3], const float v2co[3], const float v3co[3], /* Screenspace coords */
+ const float uv1co[2], const float uv2co[2], const float uv3co[2],
float pixelScreenCo[4],
float w[3])
{
@@ -1087,47 +1051,12 @@ static void screen_px_from_ortho(
interp_v3_v3v3v3(pixelScreenCo, v1co, v2co, v3co, w);
}
-/* same as screen_px_from_ortho except we need to take into account
- * the perspective W coord for each vert */
+/* same as screen_px_from_ortho except we
+ * do perspective correction on the pixel coordinate */
static void screen_px_from_persp(
- float uv[2],
- float v1co[4], float v2co[4], float v3co[4], /* screenspace coords */
- float uv1co[2], float uv2co[2], float uv3co[2],
- float pixelScreenCo[4],
- float w[3])
-{
-
- float wtot_inv, wtot;
- barycentric_weights_v2(uv1co, uv2co, uv3co, uv, w);
-
- /* re-weight from the 4th coord of each screen vert */
- w[0] *= v1co[3];
- w[1] *= v2co[3];
- w[2] *= v3co[3];
-
- wtot = w[0] + w[1] + w[2];
-
- if (wtot > 0.0f) {
- wtot_inv = 1.0f / wtot;
- w[0] *= wtot_inv;
- w[1] *= wtot_inv;
- w[2] *= wtot_inv;
- }
- else {
- w[0] = w[1] = w[2] = 1.0f / 3.0f; /* dummy values for zero area face */
- }
- /* done re-weighting */
-
- interp_v3_v3v3v3(pixelScreenCo, v1co, v2co, v3co, w);
-}
-
-
-/* same as screen_px_from_persp except we return ortho weights back to the caller.
- * These weights will be used to determine correct interpolation of uvs in cloned uv layer */
-static void screen_px_from_persp_ortho_weights(
- float uv[2],
- float v1co[4], float v2co[4], float v3co[4], /* screenspace coords */
- float uv1co[2], float uv2co[2], float uv3co[2],
+ const float uv[2],
+ const float v1co[4], const float v2co[4], const float v3co[4], /* screenspace coords */
+ const float uv1co[2], const float uv2co[2], const float uv3co[2],
float pixelScreenCo[4],
float w[3])
{
@@ -1162,7 +1091,7 @@ static void screen_px_from_persp_ortho_weights(
static void project_face_pixel(const MTFace *tf_other, ImBuf *ibuf_other, const float w[3],
int side, unsigned char rgba_ub[4], float rgba_f[4])
{
- float *uvCo1, *uvCo2, *uvCo3;
+ const float *uvCo1, *uvCo2, *uvCo3;
float uv_other[2], x, y;
uvCo1 = (float *)tf_other->uv[0];
@@ -1242,7 +1171,7 @@ static float project_paint_uvpixel_mask(
MFace *mf = &ps->dm_mface[face_index];
float no[3], angle;
if (mf->flag & ME_SMOOTH) {
- short *no1, *no2, *no3;
+ const short *no1, *no2, *no3;
no1 = ps->dm_mvert[mf->v1].no;
if (side == 1) {
no2 = ps->dm_mvert[mf->v3].no;
@@ -1286,7 +1215,7 @@ static float project_paint_uvpixel_mask(
else {
/* Annoying but for the perspective view we need to get the pixels location in 3D space :/ */
float viewDirPersp[3];
- float *co1, *co2, *co3;
+ const float *co1, *co2, *co3;
co1 = ps->dm_mvert[mf->v1].co;
if (side == 1) {
co2 = ps->dm_mvert[mf->v3].co;
@@ -1735,8 +1664,8 @@ static bool project_bucket_isect_circle(const float cent[2], const float radius_
static void rect_to_uvspace_ortho(
rctf *bucket_bounds,
- float *v1coSS, float *v2coSS, float *v3coSS,
- float *uv1co, float *uv2co, float *uv3co,
+ const float *v1coSS, const float *v2coSS, const float *v3coSS,
+ const float *uv1co, const float *uv2co, const float *uv3co,
float bucket_bounds_uv[4][2],
const int flip)
{
@@ -1768,8 +1697,8 @@ static void rect_to_uvspace_ortho(
/* same as above but use barycentric_weights_v2_persp */
static void rect_to_uvspace_persp(
rctf *bucket_bounds,
- float *v1coSS, float *v2coSS, float *v3coSS,
- float *uv1co, float *uv2co, float *uv3co,
+ const float *v1coSS, const float *v2coSS, const float *v3coSS,
+ const float *uv1co, const float *uv2co, const float *uv3co,
float bucket_bounds_uv[4][2],
const int flip
)
@@ -1845,7 +1774,7 @@ static void project_bucket_clip_face(
const bool is_ortho,
rctf *bucket_bounds,
float *v1coSS, float *v2coSS, float *v3coSS,
- float *uv1co, float *uv2co, float *uv3co,
+ const float *uv1co, const float *uv2co, const float *uv3co,
float bucket_bounds_uv[8][2],
int *tot)
{
@@ -2207,7 +2136,6 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
float uv_clip[8][2];
int uv_clip_tot;
const bool is_ortho = ps->is_ortho;
- const bool is_clone_other = ((ps->brush->imagepaint_tool == PAINT_TOOL_CLONE) && ps->dm_mtface_clone);
const bool do_backfacecull = ps->do_backfacecull;
const bool do_clip = ps->rv3d ? ps->rv3d->rflag & RV3D_CLIPPING : 0;
@@ -2315,7 +2243,6 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
has_x_isect = has_isect = 1;
if (is_ortho) screen_px_from_ortho(uv, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, pixelScreenCo, w);
- else if (is_clone_other) screen_px_from_persp_ortho_weights(uv, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, pixelScreenCo, w);
else screen_px_from_persp(uv, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, pixelScreenCo, w);
/* a pity we need to get the worldspace pixel location here */
@@ -2676,7 +2603,7 @@ static bool project_bucket_face_isect(ProjPaintState *ps, int bucket_x, int buck
/* TODO - replace this with a tricker method that uses sideofline for all screenCoords's edges against the closest bucket corner */
rctf bucket_bounds;
float p1[2], p2[2], p3[2], p4[2];
- float *v, *v1, *v2, *v3, *v4 = NULL;
+ const float *v, *v1, *v2, *v3, *v4 = NULL;
int fidx;
project_bucket_bounds(ps, bucket_x, bucket_y, &bucket_bounds);
@@ -2964,7 +2891,7 @@ static void project_paint_begin(ProjPaintState *ps)
IDProperty *idgroup = IDP_GetProperties(&ps->reproject_image->id, 0);
IDProperty *view_data = IDP_GetPropertyFromGroup(idgroup, PROJ_VIEW_DATA_ID);
- float *array = (float *)IDP_Array(view_data);
+ const float *array = (float *)IDP_Array(view_data);
/* use image array, written when creating image */
memcpy(winmat, array, sizeof(winmat)); array += sizeof(winmat) / sizeof(float);
@@ -3190,7 +3117,7 @@ static void project_paint_begin(ProjPaintState *ps)
}
if (is_face_sel && (tpage = project_paint_face_image(ps, ps->dm_mtface, face_index))) {
- float *v1coSS, *v2coSS, *v3coSS, *v4coSS = NULL;
+ const float *v1coSS, *v2coSS, *v3coSS, *v4coSS = NULL;
v1coSS = ps->screenCoords[mf->v1];
v2coSS = ps->screenCoords[mf->v2];
@@ -4463,6 +4390,7 @@ void PAINT_OT_project_image(wmOperatorType *ot)
prop = RNA_def_enum(ot->srna, "image", DummyRNA_NULL_items, 0, "Image", "");
RNA_def_enum_funcs(prop, RNA_image_itemf);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
ot->prop = prop;
}
@@ -4486,7 +4414,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
if (w > maxsize) w = maxsize;
if (h > maxsize) h = maxsize;
- ibuf = ED_view3d_draw_offscreen_imbuf(CTX_data_scene(C), CTX_wm_view3d(C), CTX_wm_region(C), w, h, IB_rect, false, R_ALPHAPREMUL, err_out);
+ ibuf = ED_view3d_draw_offscreen_imbuf(scene, CTX_wm_view3d(C), CTX_wm_region(C), w, h, IB_rect, false, R_ALPHAPREMUL, err_out);
if (!ibuf) {
/* Mostly happens when OpenGL offscreen buffer was failed to create, */
/* but could be other reasons. Should be handled in the future. nazgul */
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index af9ac6dd89d..d8f7a3d8e05 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -37,6 +37,7 @@ struct bContext;
struct bglMats;
struct Brush;
struct ImagePool;
+struct ColorSpace;
struct ListBase;
struct Mesh;
struct MTex;
@@ -181,12 +182,12 @@ void SCULPT_OT_uv_sculpt_stroke(struct wmOperatorType *ot);
/* Convert the object-space axis-aligned bounding box (expressed as
* its minimum and maximum corners) into a screen-space rectangle,
* returns zero if the result is empty */
-int paint_convert_bb_to_rect(struct rcti *rect,
- const float bb_min[3],
- const float bb_max[3],
- const struct ARegion *ar,
- struct RegionView3D *rv3d,
- struct Object *ob);
+bool paint_convert_bb_to_rect(struct rcti *rect,
+ const float bb_min[3],
+ const float bb_max[3],
+ const struct ARegion *ar,
+ struct RegionView3D *rv3d,
+ struct Object *ob);
/* Get four planes in object-space that describe the projection of
* screen_rect from screen into object-space (essentially converting a
@@ -199,10 +200,7 @@ void paint_calc_redraw_planes(float planes[4][4],
float paint_calc_object_space_radius(struct ViewContext *vc, const float center[3], float pixel_radius);
float paint_get_tex_pixel(struct MTex *mtex, float u, float v, struct ImagePool *pool, int thread);
-void paint_get_tex_pixel_col(struct MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool, int thread);
-int imapaint_pick_face(struct ViewContext *vc, const int mval[2], unsigned int *index, unsigned int totface);
-void imapaint_pick_uv(struct Scene *scene, struct Object *ob, unsigned int faceindex, const int xy[2], float uv[2]);
-void brush_drawcursor_texpaint_uvsculpt(struct bContext *C, int x, int y, void *customdata);
+void paint_get_tex_pixel_col(struct MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool, int thread, bool convert, struct ColorSpace *colorspace);
void paint_sample_color(const struct bContext *C, struct ARegion *ar, int x, int y);
void BRUSH_OT_curve_preset(struct wmOperatorType *ot);
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index a222c7249f7..49b62140fe6 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -32,7 +32,6 @@
#include "MEM_guardedalloc.h"
-#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
@@ -87,7 +86,7 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op)
ARegion *ar = CTX_wm_region(C);
struct Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
- struct MultiresModifierData *mmd = sculpt_multires_active(scene, ob);
+ struct MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, ob);
PaintMaskFloodMode mode;
float value;
DerivedMesh *dm;
@@ -99,7 +98,7 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op)
mode = RNA_enum_get(op->ptr, "mode");
value = RNA_float_get(op->ptr, "value");
- ED_sculpt_mask_layers_ensure(ob, mmd);
+ BKE_sculpt_mask_layers_ensure(ob, mmd);
dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
pbvh = dm->getPBVH(ob, dm);
@@ -196,7 +195,7 @@ int do_sculpt_mask_box_select(ViewContext *vc, rcti *rect, bool select, bool UNU
ARegion *ar = vc->ar;
struct Scene *scene = vc->scene;
Object *ob = vc->obact;
- struct MultiresModifierData *mmd = sculpt_multires_active(scene, ob);
+ struct MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, ob);
PaintMaskFloodMode mode;
float value;
DerivedMesh *dm;
@@ -213,7 +212,7 @@ int do_sculpt_mask_box_select(ViewContext *vc, rcti *rect, bool select, bool UNU
ED_view3d_clipping_calc(&bb, clip_planes, &mats, rect);
mul_m4_fl(clip_planes, -1.0f);
- ED_sculpt_mask_layers_ensure(ob, mmd);
+ BKE_sculpt_mask_layers_ensure(ob, mmd);
dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
pbvh = dm->getPBVH(ob, dm);
@@ -360,8 +359,8 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op)
ED_view3d_clipping_calc(&bb, clip_planes, &mats, &data.rect);
mul_m4_fl(clip_planes, -1.0f);
- mmd = sculpt_multires_active(vc.scene, ob);
- ED_sculpt_mask_layers_ensure(ob, mmd);
+ mmd = BKE_sculpt_multires_active(vc.scene, ob);
+ BKE_sculpt_mask_layers_ensure(ob, mmd);
dm = mesh_get_derived_final(vc.scene, ob, CD_MASK_BAREMESH);
pbvh = dm->getPBVH(ob, dm);
ob->sculpt->pbvh = pbvh;
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index 71a548d2f21..543463cd5f3 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -39,7 +39,6 @@
#include "BKE_context.h"
#include "BKE_paint.h"
#include "BKE_main.h"
-#include "BKE_image.h"
#include "ED_sculpt.h"
#include "ED_screen.h"
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 15f21cc44c8..7b9121446f5 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -47,6 +47,7 @@
#include "BKE_paint.h"
#include "BKE_brush.h"
#include "BKE_colortools.h"
+#include "BKE_image.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -57,6 +58,8 @@
#include "ED_screen.h"
#include "ED_view3d.h"
+#include "IMB_imbuf_types.h"
+
#include "paint_intern.h"
#include <float.h>
@@ -98,7 +101,7 @@ typedef struct PaintStroke {
bool brush_init;
float initial_mouse[2];
/* cached_pressure stores initial pressure for size pressure influence mainly */
- float cached_pressure;
+ float cached_size_pressure;
/* last pressure will store last pressure value for use in interpolation for space strokes */
float last_pressure;
@@ -166,22 +169,42 @@ static void paint_brush_update(bContext *C, Brush *brush, PaintMode mode,
* brush coord/pressure/etc.
* It's more an events design issue, which doesn't split coordinate/pressure/angle
* changing events. We should avoid this after events system re-design */
- if (paint_supports_dynamic_size(brush, mode) || !stroke->brush_init) {
+ if (!stroke->brush_init) {
copy_v2_v2(stroke->initial_mouse, mouse);
+ copy_v2_v2(ups->last_rake, mouse);
+ copy_v2_v2(ups->tex_mouse, mouse);
+ copy_v2_v2(ups->mask_tex_mouse, mouse);
+ stroke->cached_size_pressure = pressure;
+
+ /* check here if color sampling the main brush should do color conversion. This is done here
+ * to avoid locking up to get the image buffer during sampling */
+ if (brush->mtex.tex && brush->mtex.tex->type == TEX_IMAGE && brush->mtex.tex->ima) {
+ ImBuf *tex_ibuf = BKE_image_pool_acquire_ibuf(brush->mtex.tex->ima, &brush->mtex.tex->iuser, NULL);
+ if (tex_ibuf && tex_ibuf->rect_float == NULL) {
+ ups->do_linear_conversion = true;
+ ups->colorspace = tex_ibuf->rect_colorspace;
+ }
+ BKE_image_pool_release_ibuf(brush->mtex.tex->ima, tex_ibuf, NULL);
+ }
+
+ stroke->brush_init = true;
+ }
+
+ if (paint_supports_dynamic_size(brush, mode)) {
copy_v2_v2(ups->tex_mouse, mouse);
copy_v2_v2(ups->mask_tex_mouse, mouse);
- stroke->cached_pressure = pressure;
+ stroke->cached_size_pressure = pressure;
}
/* Truly temporary data that isn't stored in properties */
ups->stroke_active = true;
- ups->pressure_value = stroke->cached_pressure;
+ ups->size_pressure_value = stroke->cached_size_pressure;
ups->pixel_radius = BKE_brush_size_get(scene, brush);
if (BKE_brush_use_size_pressure(scene, brush) && paint_supports_dynamic_size(brush, mode)) {
- ups->pixel_radius *= stroke->cached_pressure;
+ ups->pixel_radius *= stroke->cached_size_pressure;
}
if (paint_supports_dynamic_tex_coords(brush, mode)) {
@@ -251,13 +274,8 @@ static void paint_brush_update(bContext *C, Brush *brush, PaintMode mode,
ups->draw_anchored = true;
}
else if (brush->flag & BRUSH_RAKE) {
- if (!stroke->brush_init)
- copy_v2_v2(ups->last_rake, mouse);
- else
- paint_calculate_rake_rotation(ups, mouse);
+ paint_calculate_rake_rotation(ups, mouse);
}
-
- stroke->brush_init = true;
}
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index 5364ac6e26a..642c1dd9529 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -49,6 +49,7 @@
#include "BKE_brush.h"
#include "BKE_context.h"
#include "BKE_DerivedMesh.h"
+#include "BKE_image.h"
#include "BKE_paint.h"
#include "BKE_report.h"
@@ -58,6 +59,9 @@
#include "BIF_gl.h"
#include "BIF_glutil.h"
+#include "IMB_colormanagement.h"
+#include "IMB_imbuf_types.h"
+
#include "RE_shader_ext.h"
#include "RE_render_ext.h"
@@ -75,12 +79,12 @@
/* Convert the object-space axis-aligned bounding box (expressed as
* its minimum and maximum corners) into a screen-space rectangle,
* returns zero if the result is empty */
-int paint_convert_bb_to_rect(rcti *rect,
- const float bb_min[3],
- const float bb_max[3],
- const ARegion *ar,
- RegionView3D *rv3d,
- Object *ob)
+bool paint_convert_bb_to_rect(rcti *rect,
+ const float bb_min[3],
+ const float bb_max[3],
+ const ARegion *ar,
+ RegionView3D *rv3d,
+ Object *ob)
{
float projection_mat[4][4];
int i, j, k;
@@ -175,7 +179,7 @@ float paint_get_tex_pixel(MTex *mtex, float u, float v, struct ImagePool *pool,
return intensity;
}
-void paint_get_tex_pixel_col(MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool, int thread)
+void paint_get_tex_pixel_col(MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool, int thread, bool convert_to_linear, struct ColorSpace *colorspace)
{
float co[3] = {u, v, 0.0f};
int hasrgb;
@@ -189,159 +193,18 @@ void paint_get_tex_pixel_col(MTex *mtex, float u, float v, float rgba[4], struct
rgba[2] = intensity;
rgba[3] = 1.0f;
}
+
+ if (convert_to_linear)
+ IMB_colormanagement_colorspace_to_scene_linear_v3(rgba, colorspace);
+
+ linearrgb_to_srgb_v3_v3(rgba, rgba);
+
CLAMP(rgba[0], 0.0f, 1.0f);
CLAMP(rgba[1], 0.0f, 1.0f);
CLAMP(rgba[2], 0.0f, 1.0f);
CLAMP(rgba[3], 0.0f, 1.0f);
}
-/* 3D Paint */
-
-static void imapaint_project(Object *ob, float model[4][4], float proj[4][4], const float co[3], float pco[4])
-{
- copy_v3_v3(pco, co);
- pco[3] = 1.0f;
-
- mul_m4_v3(ob->obmat, pco);
- mul_m4_v3(model, pco);
- mul_m4_v4(proj, pco);
-}
-
-static void imapaint_tri_weights(Object *ob,
- const float v1[3], const float v2[3], const float v3[3],
- const float co[2], float w[3])
-{
- float pv1[4], pv2[4], pv3[4], h[3], divw;
- float model[4][4], proj[4][4], wmat[3][3], invwmat[3][3];
- GLint view[4];
-
- /* compute barycentric coordinates */
-
- /* get the needed opengl matrices */
- glGetIntegerv(GL_VIEWPORT, view);
- glGetFloatv(GL_MODELVIEW_MATRIX, (float *)model);
- glGetFloatv(GL_PROJECTION_MATRIX, (float *)proj);
- view[0] = view[1] = 0;
-
- /* project the verts */
- imapaint_project(ob, model, proj, v1, pv1);
- imapaint_project(ob, model, proj, v2, pv2);
- imapaint_project(ob, model, proj, v3, pv3);
-
- /* do inverse view mapping, see gluProject man page */
- h[0] = (co[0] - view[0]) * 2.0f / view[2] - 1;
- h[1] = (co[1] - view[1]) * 2.0f / view[3] - 1;
- h[2] = 1.0f;
-
- /* solve for (w1,w2,w3)/perspdiv in:
- * h * perspdiv = Project * Model * (w1 * v1 + w2 * v2 + w3 * v3) */
-
- wmat[0][0] = pv1[0]; wmat[1][0] = pv2[0]; wmat[2][0] = pv3[0];
- wmat[0][1] = pv1[1]; wmat[1][1] = pv2[1]; wmat[2][1] = pv3[1];
- wmat[0][2] = pv1[3]; wmat[1][2] = pv2[3]; wmat[2][2] = pv3[3];
-
- invert_m3_m3(invwmat, wmat);
- mul_m3_v3(invwmat, h);
-
- copy_v3_v3(w, h);
-
- /* w is still divided by perspdiv, make it sum to one */
- divw = w[0] + w[1] + w[2];
- if (divw != 0.0f) {
- mul_v3_fl(w, 1.0f / divw);
- }
-}
-
-/* compute uv coordinates of mouse in face */
-void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, const int xy[2], float uv[2])
-{
- DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
- MTFace *tface = dm->getTessFaceDataArray(dm, CD_MTFACE), *tf;
- int numfaces = dm->getNumTessFaces(dm), a, findex;
- float p[2], w[3], absw, minabsw;
- MFace mf;
- MVert mv[4];
-
- /* double lookup */
- const int *index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
- const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX);
- if (index_mf_to_mpoly == NULL) {
- index_mp_to_orig = NULL;
- }
-
- minabsw = 1e10;
- uv[0] = uv[1] = 0.0;
-
- /* test all faces in the derivedmesh with the original index of the picked face */
- for (a = 0; a < numfaces; a++) {
- findex = index_mf_to_mpoly ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, a) : a;
-
- if (findex == faceindex) {
- dm->getTessFace(dm, a, &mf);
-
- dm->getVert(dm, mf.v1, &mv[0]);
- dm->getVert(dm, mf.v2, &mv[1]);
- dm->getVert(dm, mf.v3, &mv[2]);
- if (mf.v4)
- dm->getVert(dm, mf.v4, &mv[3]);
-
- tf = &tface[a];
-
- p[0] = xy[0];
- p[1] = xy[1];
-
- if (mf.v4) {
- /* the triangle with the largest absolute values is the one
- * with the most negative weights */
- imapaint_tri_weights(ob, mv[0].co, mv[1].co, mv[3].co, p, w);
- absw = fabsf(w[0]) + fabsf(w[1]) + fabsf(w[2]);
- if (absw < minabsw) {
- uv[0] = tf->uv[0][0] * w[0] + tf->uv[1][0] * w[1] + tf->uv[3][0] * w[2];
- uv[1] = tf->uv[0][1] * w[0] + tf->uv[1][1] * w[1] + tf->uv[3][1] * w[2];
- minabsw = absw;
- }
-
- imapaint_tri_weights(ob, mv[1].co, mv[2].co, mv[3].co, p, w);
- absw = fabsf(w[0]) + fabsf(w[1]) + fabsf(w[2]);
- if (absw < minabsw) {
- uv[0] = tf->uv[1][0] * w[0] + tf->uv[2][0] * w[1] + tf->uv[3][0] * w[2];
- uv[1] = tf->uv[1][1] * w[0] + tf->uv[2][1] * w[1] + tf->uv[3][1] * w[2];
- minabsw = absw;
- }
- }
- else {
- imapaint_tri_weights(ob, mv[0].co, mv[1].co, mv[2].co, p, w);
- absw = fabsf(w[0]) + fabsf(w[1]) + fabsf(w[2]);
- if (absw < minabsw) {
- uv[0] = tf->uv[0][0] * w[0] + tf->uv[1][0] * w[1] + tf->uv[2][0] * w[2];
- uv[1] = tf->uv[0][1] * w[0] + tf->uv[1][1] * w[1] + tf->uv[2][1] * w[2];
- minabsw = absw;
- }
- }
- }
- }
-
- dm->release(dm);
-}
-
-/* returns 0 if not found, otherwise 1 */
-int imapaint_pick_face(ViewContext *vc, const int mval[2], unsigned int *index, unsigned int totface)
-{
- if (totface == 0)
- return 0;
-
- /* sample only on the exact position */
- *index = view3d_sample_backbuf(vc, mval[0], mval[1]);
-
- if ((*index) == 0 || (*index) > (unsigned int)totface) {
- return 0;
- }
-
- (*index)--;
-
- return 1;
-}
-
/* Uses symm to selectively flip any axis of a coordinate. */
void flip_v3_v3(float out[3], const float in[3], const char symm)
{
@@ -364,7 +227,7 @@ void paint_sample_color(const bContext *C, ARegion *ar, int x, int y) /* fron
{
Brush *br = BKE_paint_brush(BKE_paint_get_active_from_context(C));
unsigned int col;
- char *cp;
+ const char *cp;
CLAMP(x, 0, ar->winx);
CLAMP(y, 0, ar->winy);
@@ -552,7 +415,7 @@ void PAINT_OT_vert_select_ungrouped(wmOperatorType *ot)
static int face_select_hide_exec(bContext *C, wmOperator *op)
{
- const int unselected = RNA_boolean_get(op->ptr, "unselected");
+ const bool unselected = RNA_boolean_get(op->ptr, "unselected");
Object *ob = CTX_data_active_object(C);
paintface_hide(ob, unselected);
ED_region_tag_redraw(CTX_wm_region(C));
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index d90f9a80b37..969c5a09a82 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -33,7 +33,6 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
-#include "BLI_memarena.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
@@ -58,7 +57,6 @@
#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
#include "BKE_modifier.h"
-#include "BKE_object.h"
#include "BKE_object_deform.h"
#include "BKE_paint.h"
#include "BKE_report.h"
@@ -217,7 +215,7 @@ static void do_shared_vertex_tesscol(Mesh *me, bool *mfacetag)
int a;
short *scolmain, *scol;
char *mcol;
- bool *mftag;
+ const bool *mftag;
if (me->mcol == NULL || me->totvert == 0 || me->totface == 0) return;
@@ -1185,8 +1183,10 @@ static EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C, PointerRNA
bool found = false;
unsigned int index;
- int mval[2] = {win->eventstate->x - vc.ar->winrct.xmin,
- win->eventstate->y - vc.ar->winrct.ymin};
+ const int mval[2] = {
+ win->eventstate->x - vc.ar->winrct.xmin,
+ win->eventstate->y - vc.ar->winrct.ymin,
+ };
view3d_operator_needs_opengl(C);
ED_view3d_init_mats_rv3d(vc.obact, vc.rv3d);
@@ -1273,6 +1273,7 @@ void PAINT_OT_weight_sample_group(wmOperatorType *ot)
/* keyingset to use (dynamic enum) */
prop = RNA_def_enum(ot->srna, "group", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use");
RNA_def_enum_funcs(prop, weight_paint_sample_enum_itemf);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
ot->prop = prop;
}
@@ -2496,11 +2497,6 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
swap_m4m4(vc->rv3d->persmat, mat);
- {
- UnifiedPaintSettings *ups = &ts->unified_paint_settings;
- ups->pressure_value = pressure;
- }
-
DAG_id_tag_update(ob->data, 0);
ED_region_tag_redraw(vc->ar);
}
@@ -3017,11 +3013,6 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
do_shared_vertexcol(me, vpd->mlooptag, vpd->mfacetag, do_tessface);
}
- {
- UnifiedPaintSettings *ups = &ts->unified_paint_settings;
- ups->pressure_value = pressure;
- }
-
ED_region_tag_redraw(vc->ar);
if (vpd->use_fast_update == false) {
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 50df1821fa2..c9101fff6e5 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -38,7 +38,6 @@
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
-#include "BLI_dynstr.h"
#include "BLI_ghash.h"
#include "BLI_threads.h"
@@ -55,8 +54,8 @@
#include "BKE_pbvh.h"
#include "BKE_brush.h"
#include "BKE_ccg.h"
-#include "BKE_cdderivedmesh.h"
#include "BKE_context.h"
+#include "BKE_crazyspace.h"
#include "BKE_depsgraph.h"
#include "BKE_image.h"
#include "BKE_key.h"
@@ -66,16 +65,11 @@
#include "BKE_modifier.h"
#include "BKE_multires.h"
#include "BKE_paint.h"
-#include "BKE_report.h"
-#include "BKE_scene.h"
-#include "BKE_lattice.h" /* for armature_deform_verts */
#include "BKE_node.h"
#include "BKE_object.h"
#include "BKE_subsurf.h"
#include "BKE_colortools.h"
-#include "BIF_glutil.h"
-
#include "WM_api.h"
#include "WM_types.h"
@@ -83,7 +77,6 @@
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_view3d.h"
-#include "ED_util.h" /* for crazyspace correction */
#include "paint_intern.h"
#include "sculpt_intern.h"
@@ -105,6 +98,19 @@
#include <omp.h>
#endif
+#if defined(__APPLE__) && defined _OPENMP
+#include <sys/sysctl.h>
+
+/* Query how many cores not counting HT aka physical cores we've got. */
+static int system_physical_thread_count(void)
+{
+ int pcount;
+ size_t pcount_len = sizeof(pcount);
+ sysctlbyname("hw.physicalcpu", &pcount, &pcount_len, NULL, 0);
+ return pcount;
+}
+#endif /* __APPLE__ */
+
void ED_sculpt_get_average_stroke(Object *ob, float stroke[3])
{
if (ob->sculpt->last_stroke_valid && ob->sculpt->average_stroke_counter > 0) {
@@ -116,7 +122,7 @@ void ED_sculpt_get_average_stroke(Object *ob, float stroke[3])
}
}
-int ED_sculpt_minmax(bContext *C, float min[3], float max[3])
+bool ED_sculpt_minmax(bContext *C, float min[3], float max[3])
{
Object *ob = CTX_data_active_object(C);
@@ -131,41 +137,9 @@ int ED_sculpt_minmax(bContext *C, float min[3], float max[3])
}
}
-/* Sculpt mode handles multires differently from regular meshes, but only if
- * it's the last modifier on the stack and it is not on the first level */
-MultiresModifierData *sculpt_multires_active(Scene *scene, Object *ob)
-{
- Mesh *me = (Mesh *)ob->data;
- ModifierData *md;
- VirtualModifierData virtualModifierData;
-
- if (ob->sculpt && ob->sculpt->bm) {
- /* can't combine multires and dynamic topology */
- return NULL;
- }
-
- if (!CustomData_get_layer(&me->ldata, CD_MDISPS)) {
- /* multires can't work without displacement layer */
- return NULL;
- }
-
- for (md = modifiers_getVirtualModifierList(ob, &virtualModifierData); md; md = md->next) {
- if (md->type == eModifierType_Multires) {
- MultiresModifierData *mmd = (MultiresModifierData *)md;
-
- if (!modifier_isEnabled(scene, md, eModifierMode_Realtime))
- continue;
-
- if (mmd->sculptlvl > 0) return mmd;
- else return NULL;
- }
- }
-
- return NULL;
-}
/* Check if there are any active modifiers in stack (used for flushing updates at enter/exit sculpt mode) */
-static int sculpt_has_active_modifiers(Scene *scene, Object *ob)
+static bool sculpt_has_active_modifiers(Scene *scene, Object *ob)
{
ModifierData *md;
VirtualModifierData virtualModifierData;
@@ -181,35 +155,7 @@ static int sculpt_has_active_modifiers(Scene *scene, Object *ob)
return 0;
}
-/* Checks if there are any supported deformation modifiers active */
-static int sculpt_modifiers_active(Scene *scene, Sculpt *sd, Object *ob)
-{
- ModifierData *md;
- Mesh *me = (Mesh *)ob->data;
- MultiresModifierData *mmd = sculpt_multires_active(scene, ob);
- VirtualModifierData virtualModifierData;
-
- if (mmd || ob->sculpt->bm)
- return 0;
-
- /* non-locked shape keys could be handled in the same way as deformed mesh */
- if ((ob->shapeflag & OB_SHAPE_LOCK) == 0 && me->key && ob->shapenr)
- return 1;
-
- md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
- /* exception for shape keys because we can edit those */
- for (; md; md = md->next) {
- ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- if (!modifier_isEnabled(scene, md, eModifierMode_Realtime)) continue;
- if (md->type == eModifierType_ShapeKey) continue;
-
- if (mti->type == eModifierTypeType_OnlyDeform) return 1;
- else if ((sd->flags & SCULPT_ONLY_DEFORM) == 0) return 1;
- }
-
- return 0;
-}
typedef enum StrokeFlags {
CLIP_X = 1,
@@ -231,7 +177,7 @@ typedef struct StrokeCache {
float initial_mouse[2];
/* Pre-allocated temporary storage used during smoothing */
- int num_threads;
+ int num_threads, max_threads;
float (**tmpgrid_co)[3], (**tmprow_co)[3];
float **tmpgrid_mask, **tmprow_mask;
@@ -249,7 +195,7 @@ typedef struct StrokeCache {
/* The rest is temporary storage that isn't saved as a property */
- int first_time; /* Beginning of stroke may do some things special */
+ bool first_time; /* Beginning of stroke may do some things special */
/* from ED_view3d_ob_project_mat_get() */
float projection_mat[4][4];
@@ -284,7 +230,7 @@ typedef struct StrokeCache {
int radial_symmetry_pass;
float symm_rot_mat[4][4];
float symm_rot_mat_inv[4][4];
- int original;
+ bool original;
float anchored_location[3];
float vertex_rotation; /* amount to rotate the vertices when using rotate brush */
@@ -297,7 +243,7 @@ typedef struct StrokeCache {
char saved_active_brush_name[MAX_ID_NAME];
char saved_mask_brush_tool;
int saved_smooth_size; /* smooth tool copies the size of the current tool */
- int alt_smooth;
+ bool alt_smooth;
float plane_trim_squared;
@@ -317,7 +263,7 @@ typedef struct {
SculptUndoNode *unode;
float (*coords)[3];
short (*normals)[3];
- float *vmasks;
+ const float *vmasks;
/* Original coordinate, normal, and mask */
const float *co;
@@ -485,9 +431,9 @@ static void paint_mesh_restore_co(Sculpt *sd, Object *ob)
}
if (ss->face_normals) {
- float *fn = ss->face_normals;
- for (i = 0; i < ss->totpoly; ++i, fn += 3)
- copy_v3_v3(fn, cache->face_norms[i]);
+ for (i = 0; i < ss->totpoly; i++) {
+ copy_v3_v3(ss->face_normals[i], cache->face_norms[i]);
+ }
}
if (nodes)
@@ -513,8 +459,8 @@ static void sculpt_extend_redraw_rect_previous(Object *ob, rcti *rect)
}
/* Get a screen-space rectangle of the modified area */
-static int sculpt_get_redraw_rect(ARegion *ar, RegionView3D *rv3d,
- Object *ob, rcti *rect)
+static bool sculpt_get_redraw_rect(ARegion *ar, RegionView3D *rv3d,
+ Object *ob, rcti *rect)
{
PBVH *pbvh = ob->sculpt->pbvh;
float bb_min[3], bb_max[3];
@@ -768,7 +714,8 @@ static float calc_overlap(StrokeCache *cache, const char symm, const char axis,
flip_v3_v3(mirror, cache->true_location, symm);
if (axis != 0) {
- float mat[4][4] = MAT4_UNITY;
+ float mat[4][4];
+ unit_m4(mat);
rotate_m4(mat, axis, angle);
mul_m4_v3(mat, mirror);
}
@@ -1613,7 +1560,7 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no
for (y = 0; y < gridsize; ++y) {
for (x = 0; x < gridsize; ++x) {
float *co;
- float *fno;
+ const float *fno;
float *mask;
int index;
@@ -3554,106 +3501,7 @@ static void sculpt_update_tex(const Scene *scene, Sculpt *sd, SculptSession *ss)
}
}
-/**
- * \param need_mask So the DerivedMesh thats returned has mask data
- */
-void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob,
- bool need_pmap, bool need_mask)
-{
- DerivedMesh *dm;
- SculptSession *ss = ob->sculpt;
- Mesh *me = ob->data;
- MultiresModifierData *mmd = sculpt_multires_active(scene, ob);
-
- ss->modifiers_active = sculpt_modifiers_active(scene, sd, ob);
- ss->show_diffuse_color = (sd->flags & SCULPT_SHOW_DIFFUSE) != 0;
-
- if (need_mask) {
- if (mmd == NULL) {
- if (!CustomData_has_layer(&me->vdata, CD_PAINT_MASK)) {
- ED_sculpt_mask_layers_ensure(ob, NULL);
- }
- }
- else {
- if (!CustomData_has_layer(&me->ldata, CD_GRID_PAINT_MASK)) {
-#if 1
- ED_sculpt_mask_layers_ensure(ob, mmd);
-#else /* if we wanted to support adding mask data while multi-res painting, we would need to do this */
- if ((ED_sculpt_mask_layers_ensure(ob, mmd) & ED_SCULPT_MASK_LAYER_CALC_LOOP)) {
- /* remake the derived mesh */
- ob->recalc |= OB_RECALC_DATA;
- BKE_object_handle_update(scene, ob);
- }
-#endif
- }
- }
- }
-
- /* BMESH ONLY --- at some point we should move sculpt code to use polygons only - but for now it needs tessfaces */
- BKE_mesh_tessface_ensure(me);
-
- if (!mmd) ss->kb = BKE_keyblock_from_object(ob);
- else ss->kb = NULL;
-
- /* needs to be called after we ensure tessface */
- dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
-
- if (mmd) {
- ss->multires = mmd;
- ss->totvert = dm->getNumVerts(dm);
- ss->totpoly = dm->getNumPolys(dm);
- ss->mvert = NULL;
- ss->mpoly = NULL;
- ss->mloop = NULL;
- ss->face_normals = NULL;
- }
- else {
- ss->totvert = me->totvert;
- ss->totpoly = me->totpoly;
- ss->mvert = me->mvert;
- ss->mpoly = me->mpoly;
- ss->mloop = me->mloop;
- ss->face_normals = NULL;
- ss->multires = NULL;
- 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_show_diffuse_color_set(ss->pbvh, ss->show_diffuse_color);
-
- if (ss->modifiers_active) {
- if (!ss->orig_cos) {
- int a;
-
- free_sculptsession_deformMats(ss);
-
- ss->orig_cos = (ss->kb) ? BKE_key_convert_to_vertcos(ob, ss->kb) : BKE_mesh_vertexCos_get(me, NULL);
- crazyspace_build_sculpt(scene, ob, &ss->deform_imats, &ss->deform_cos);
- BKE_pbvh_apply_vertCos(ss->pbvh, ss->deform_cos);
-
- for (a = 0; a < me->totvert; ++a) {
- invert_m3(ss->deform_imats[a]);
- }
- }
- }
- else {
- free_sculptsession_deformMats(ss);
- }
-
- /* if pbvh is deformed, key block is already applied to it */
- if (ss->kb && !BKE_pbvh_isDeformed(ss->pbvh)) {
- float (*vertCos)[3] = BKE_key_convert_to_vertcos(ob, ss->kb);
-
- if (vertCos) {
- /* apply shape keys coordinates to PBVH */
- BKE_pbvh_apply_vertCos(ss->pbvh, vertCos);
- MEM_freeN(vertCos);
- }
- }
-}
int sculpt_mode_poll(bContext *C)
{
@@ -3770,7 +3618,7 @@ static void sculpt_init_mirror_clipping(Object *ob, SculptSession *ss)
}
}
-static void sculpt_omp_start(Scene *scene, Sculpt *sd, SculptSession *ss)
+static void sculpt_omp_start(Sculpt *sd, SculptSession *ss)
{
StrokeCache *cache = ss->cache;
@@ -3780,14 +3628,18 @@ static void sculpt_omp_start(Scene *scene, Sculpt *sd, SculptSession *ss)
* Justification: Empirically I've found that two threads per
* processor gives higher throughput. */
if (sd->flags & SCULPT_USE_OPENMP) {
- cache->num_threads = BKE_scene_num_omp_threads(scene);
+#if defined(__APPLE__)
+ cache->num_threads = system_physical_thread_count();
+#else
+ cache->num_threads = omp_get_num_procs();
+#endif
}
else {
cache->num_threads = 1;
}
- omp_set_num_threads(cache->num_threads); /* set user-defined corecount, "AUTO" = physical cores on OSX, logical cores for other OS atm.*/
+ cache->max_threads = omp_get_max_threads();
+ omp_set_num_threads(cache->num_threads);
#else
- (void)scene;
(void)sd;
cache->num_threads = 1;
#endif
@@ -3817,6 +3669,9 @@ static void sculpt_omp_start(Scene *scene, Sculpt *sd, SculptSession *ss)
static void sculpt_omp_done(SculptSession *ss)
{
+#ifdef _OPENMP
+ omp_set_num_threads(ss->cache->max_threads);
+#endif
if (ss->multires) {
int i;
@@ -3979,10 +3834,10 @@ static void sculpt_update_cache_invariants(bContext *C, Sculpt *sd, SculptSessio
/* Make copies of the mesh vertex locations and normals for some tools */
if (brush->flag & BRUSH_ANCHORED) {
if (ss->face_normals) {
- float *fn = ss->face_normals;
cache->face_norms = MEM_mallocN(sizeof(float) * 3 * ss->totpoly, "Sculpt face norms");
- for (i = 0; i < ss->totpoly; ++i, fn += 3)
- copy_v3_v3(cache->face_norms[i], fn);
+ for (i = 0; i < ss->totpoly; ++i) {
+ copy_v3_v3(cache->face_norms[i], ss->face_normals[i]);
+ }
}
cache->original = 1;
@@ -4005,14 +3860,14 @@ static void sculpt_update_cache_invariants(bContext *C, Sculpt *sd, SculptSessio
cache->previous_vertex_rotation = 0;
cache->init_dir_set = false;
- sculpt_omp_start(scene, sd, ss);
+ sculpt_omp_start(sd, ss);
}
static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Brush *brush)
{
SculptSession *ss = ob->sculpt;
StrokeCache *cache = ss->cache;
- float mouse[2] = {
+ const float mouse[2] = {
cache->mouse[0],
cache->mouse[1]
};
@@ -4193,7 +4048,9 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
/* change of sign, we passed the 180 degree threshold. This means we need to add a turn.
* to distinguish between transition from 0 to -1 and -PI to +PI, use comparison with PI/2 */
- if (mouse_angle * cache->previous_vertex_rotation < 0 && fabs(cache->previous_vertex_rotation) > M_PI_2) {
+ if ((mouse_angle * cache->previous_vertex_rotation < 0.0f) &&
+ (fabsf(cache->previous_vertex_rotation) > (float)M_PI_2))
+ {
if (cache->previous_vertex_rotation < 0)
cache->num_vertex_turns--;
else
@@ -4218,9 +4075,9 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
/* Returns true if any of the smoothing modes are active (currently
* one of smooth brush, autosmooth, mask smooth, or shift-key
* smooth) */
-static int sculpt_any_smooth_mode(const Brush *brush,
- StrokeCache *cache,
- int stroke_mode)
+static bool sculpt_any_smooth_mode(const Brush *brush,
+ StrokeCache *cache,
+ int stroke_mode)
{
return ((stroke_mode == BRUSH_STROKE_SMOOTH) ||
(cache && cache->alt_smooth) ||
@@ -4234,25 +4091,25 @@ static void sculpt_stroke_modifiers_check(const bContext *C, Object *ob)
{
SculptSession *ss = ob->sculpt;
- if (ss->modifiers_active) {
+ if (ss->kb || ss->modifiers_active) {
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
Brush *brush = BKE_paint_brush(&sd->paint);
- sculpt_update_mesh_elements(CTX_data_scene(C), sd, ob,
+ BKE_sculpt_update_mesh_elements(CTX_data_scene(C), sd, ob,
sculpt_any_smooth_mode(brush, ss->cache, 0), false);
}
}
typedef struct {
SculptSession *ss;
- float *ray_start, *ray_normal;
+ const float *ray_start, *ray_normal;
int hit;
float dist;
int original;
} SculptRaycastData;
typedef struct {
- float *ray_start, *ray_normal;
+ const float *ray_start, *ray_normal;
int hit;
float dist;
float detail;
@@ -4393,8 +4250,8 @@ static int sculpt_brush_stroke_init(bContext *C, wmOperator *op)
SculptSession *ss = CTX_data_active_object(C)->sculpt;
Brush *brush = BKE_paint_brush(&sd->paint);
int mode = RNA_enum_get(op->ptr, "mode");
- int is_smooth = 0;
- int need_mask = false;
+ bool is_smooth;
+ bool need_mask = false;
if (brush->sculpt_tool == SCULPT_TOOL_MASK) {
need_mask = true;
@@ -4404,7 +4261,7 @@ static int sculpt_brush_stroke_init(bContext *C, wmOperator *op)
sculpt_brush_init_tex(scene, sd, ss);
is_smooth = sculpt_any_smooth_mode(brush, NULL, mode);
- sculpt_update_mesh_elements(scene, sd, ob, is_smooth, need_mask);
+ BKE_sculpt_update_mesh_elements(scene, sd, ob, is_smooth, need_mask);
zero_v3(ob->sculpt->average_stroke_accum);
ob->sculpt->average_stroke_counter = 0;
@@ -4450,7 +4307,7 @@ static void sculpt_flush_update(bContext *C)
if (ob->derivedFinal) /* VBO no longer valid */
GPU_drawobject_free(ob->derivedFinal);
- if (ss->modifiers_active) {
+ if (ss->kb || ss->modifiers_active) {
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
ED_region_tag_redraw(ar);
}
@@ -4551,8 +4408,22 @@ static void sculpt_stroke_update_step(bContext *C, struct PaintStroke *UNUSED(st
/* hack to fix noise texture tearing mesh */
sculpt_fix_noise_tear(sd, ob);
- if (ss->modifiers_active)
+ /* TODO(sergey): This is not really needed for the solid shading,
+ * which does use pBVH drawing anyway, but texture and wireframe
+ * requires this.
+ *
+ * Could be optimized later, but currently don't think it's so
+ * much common scenario.
+ *
+ * Same applies to the DAG_id_tag_update() invoked from
+ * sculpt_flush_update().
+ */
+ if (ss->modifiers_active) {
sculpt_flush_stroke_deform(sd, ob);
+ }
+ else if (ss->kb) {
+ sculpt_update_keyblock(ob);
+ }
ss->cache->first_time = false;
@@ -4603,7 +4474,6 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str
/* update last stroke position */
ob->sculpt->last_stroke_valid = 1;
ED_sculpt_get_average_stroke(ob, ob->sculpt->last_stroke);
- mul_m4_v3(ob->obmat, ob->sculpt->last_stroke);
sculpt_cache_free(ss->cache);
ss->cache = NULL;
@@ -4794,6 +4664,36 @@ void sculpt_pbvh_clear(Object *ob)
BKE_object_free_derived_caches(ob);
}
+void sculpt_dyntopo_node_layers_add(SculptSession *ss)
+{
+ int cd_node_layer_index;
+
+ char layer_id[] = "_dyntopo_node_id";
+
+ cd_node_layer_index = CustomData_get_named_layer_index(&ss->bm->vdata, CD_PROP_INT, layer_id);
+ if (cd_node_layer_index == -1) {
+ BM_data_layer_add_named(ss->bm, &ss->bm->vdata, CD_PROP_INT, layer_id);
+ cd_node_layer_index = CustomData_get_named_layer_index(&ss->bm->vdata, CD_PROP_INT, layer_id);
+ }
+
+ ss->cd_vert_node_offset = CustomData_get_n_offset(&ss->bm->vdata, CD_PROP_INT,
+ cd_node_layer_index - CustomData_get_layer_index(&ss->bm->vdata, CD_PROP_INT));
+
+ ss->bm->vdata.layers[cd_node_layer_index].flag |= CD_FLAG_TEMPORARY;
+
+ cd_node_layer_index = CustomData_get_named_layer_index(&ss->bm->pdata, CD_PROP_INT, layer_id);
+ if (cd_node_layer_index == -1) {
+ BM_data_layer_add_named(ss->bm, &ss->bm->pdata, CD_PROP_INT, layer_id);
+ cd_node_layer_index = CustomData_get_named_layer_index(&ss->bm->pdata, CD_PROP_INT, layer_id);
+ }
+
+ ss->cd_face_node_offset = CustomData_get_n_offset(&ss->bm->pdata, CD_PROP_INT,
+ cd_node_layer_index - CustomData_get_layer_index(&ss->bm->pdata, CD_PROP_INT));
+
+ ss->bm->pdata.layers[cd_node_layer_index].flag |= CD_FLAG_TEMPORARY;
+}
+
+
void sculpt_update_after_dynamic_topology_toggle(bContext *C)
{
Scene *scene = CTX_data_scene(C);
@@ -4801,7 +4701,7 @@ void sculpt_update_after_dynamic_topology_toggle(bContext *C)
Sculpt *sd = scene->toolsettings->sculpt;
/* Create the PBVH */
- sculpt_update_mesh_elements(scene, sd, ob, false, false);
+ BKE_sculpt_update_mesh_elements(scene, sd, ob, false, false);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
}
@@ -4815,8 +4715,7 @@ void sculpt_dynamic_topology_enable(bContext *C)
sculpt_pbvh_clear(ob);
- ss->bm_smooth_shading = (scene->toolsettings->sculpt->flags &
- SCULPT_DYNTOPO_SMOOTH_SHADING);
+ ss->bm_smooth_shading = (scene->toolsettings->sculpt->flags & SCULPT_DYNTOPO_SMOOTH_SHADING) != 0;
/* Dynamic topology doesn't ensure selection state is valid, so remove [#36280] */
BKE_mesh_mselect_clear(me);
@@ -4827,6 +4726,8 @@ void sculpt_dynamic_topology_enable(bContext *C)
BM_mesh_bm_from_me(ss->bm, me, true, true, ob->shapenr);
sculpt_dynamic_topology_triangulate(ss->bm);
BM_data_layer_add(ss->bm, &ss->bm->vdata, CD_PAINT_MASK);
+ sculpt_dyntopo_node_layers_add(ss);
+ /* make sure the data for existing faces are initialized */
BM_mesh_normals_update(ss->bm);
/* Enable dynamic topology */
@@ -4878,7 +4779,7 @@ void sculpt_dynamic_topology_disable(bContext *C,
BKE_mesh_update_customdata_pointers(me, false);
}
else {
- sculptsession_bm_to_me(ob, true);
+ BKE_sculptsession_bm_to_me(ob, true);
}
/* Clear data */
@@ -5046,79 +4947,9 @@ static void sculpt_init_session(Scene *scene, Object *ob)
{
ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session");
- sculpt_update_mesh_elements(scene, scene->toolsettings->sculpt, ob, 0, false);
+ BKE_sculpt_update_mesh_elements(scene, scene->toolsettings->sculpt, ob, 0, false);
}
-int ED_sculpt_mask_layers_ensure(Object *ob, MultiresModifierData *mmd)
-{
- float *paint_mask;
- Mesh *me = ob->data;
- int ret = 0;
-
- paint_mask = CustomData_get_layer(&me->vdata, CD_PAINT_MASK);
-
- /* if multires is active, create a grid paint mask layer if there
- * isn't one already */
- if (mmd && !CustomData_has_layer(&me->ldata, CD_GRID_PAINT_MASK)) {
- GridPaintMask *gmask;
- int level = max_ii(1, mmd->sculptlvl);
- int gridsize = BKE_ccg_gridsize(level);
- int gridarea = gridsize * gridsize;
- int i, j;
-
- gmask = CustomData_add_layer(&me->ldata, CD_GRID_PAINT_MASK,
- CD_CALLOC, NULL, me->totloop);
-
- for (i = 0; i < me->totloop; i++) {
- GridPaintMask *gpm = &gmask[i];
-
- gpm->level = level;
- gpm->data = MEM_callocN(sizeof(float) * gridarea,
- "GridPaintMask.data");
- }
-
- /* if vertices already have mask, copy into multires data */
- if (paint_mask) {
- for (i = 0; i < me->totpoly; i++) {
- const MPoly *p = &me->mpoly[i];
- float avg = 0;
-
- /* mask center */
- for (j = 0; j < p->totloop; j++) {
- const MLoop *l = &me->mloop[p->loopstart + j];
- avg += paint_mask[l->v];
- }
- avg /= (float)p->totloop;
-
- /* fill in multires mask corner */
- for (j = 0; j < p->totloop; j++) {
- GridPaintMask *gpm = &gmask[p->loopstart + j];
- const MLoop *l = &me->mloop[p->loopstart + j];
- const MLoop *prev = ME_POLY_LOOP_PREV(me->mloop, p, j);
- const MLoop *next = ME_POLY_LOOP_NEXT(me->mloop, p, j);
-
- gpm->data[0] = avg;
- gpm->data[1] = (paint_mask[l->v] +
- paint_mask[next->v]) * 0.5f;
- gpm->data[2] = (paint_mask[l->v] +
- paint_mask[prev->v]) * 0.5f;
- gpm->data[3] = paint_mask[l->v];
- }
- }
- }
-
- ret |= ED_SCULPT_MASK_LAYER_CALC_LOOP;
- }
-
- /* create vertex paint mask layer if there isn't one already */
- if (!paint_mask) {
- CustomData_add_layer(&me->vdata, CD_PAINT_MASK,
- CD_CALLOC, NULL, me->totvert);
- ret |= ED_SCULPT_MASK_LAYER_CALC_VERT;
- }
-
- return ret;
-}
static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op)
{
@@ -5128,7 +4959,7 @@ static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op)
const int mode_flag = OB_MODE_SCULPT;
const bool is_mode_set = (ob->mode & mode_flag) != 0;
Mesh *me;
- MultiresModifierData *mmd = sculpt_multires_active(scene, ob);
+ MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, ob);
int flush_recalc = 0;
if (!is_mode_set) {
@@ -5161,7 +4992,7 @@ static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op)
/* Leave sculptmode */
ob->mode &= ~mode_flag;
- free_sculptsession(ob);
+ BKE_free_sculptsession(ob);
paint_cursor_delete_textures();
}
@@ -5199,7 +5030,7 @@ static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op)
/* Create sculpt mode session data */
if (ob->sculpt)
- free_sculptsession(ob);
+ BKE_free_sculptsession(ob);
sculpt_init_session(scene, ob);
@@ -5207,7 +5038,7 @@ static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op)
if (mmd) {
/* XXX, we could attempt to support adding mask data mid-sculpt mode (with multi-res)
* but this ends up being quite tricky (and slow) */
- ED_sculpt_mask_layers_ensure(ob, mmd);
+ BKE_sculpt_mask_layers_ensure(ob, mmd);
}
BKE_paint_init(&ts->sculpt->paint, PAINT_CURSOR_SCULPT);
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 9c0e937c35c..cd79f525d82 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -51,22 +51,18 @@ struct Sculpt;
struct SculptStroke;
struct SculptUndoNode;
-/* Interface */
-struct MultiresModifierData *sculpt_multires_active(struct Scene *scene, struct Object *ob);
-
int sculpt_mode_poll(struct bContext *C);
int sculpt_mode_poll_view3d(struct bContext *C);
/* checks for a brush, not just sculpt mode */
int sculpt_poll(struct bContext *C);
int sculpt_poll_view3d(struct bContext *C);
-void sculpt_update_mesh_elements(struct Scene *scene, struct Sculpt *sd, struct Object *ob,
- bool need_pmap, bool need_mask);
/* Stroke */
bool sculpt_stroke_get_location(bContext *C, float out[3], const float mouse[2]);
/* Dynamic topology */
void sculpt_pbvh_clear(Object *ob);
+void sculpt_dyntopo_node_layers_add(struct SculptSession *ss);
void sculpt_update_after_dynamic_topology_toggle(bContext *C);
void sculpt_dynamic_topology_enable(struct bContext *C);
void sculpt_dynamic_topology_disable(struct bContext *C,
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index b086bff1ba7..57e852db796 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -49,10 +49,8 @@
#include "DNA_mesh_types.h"
#include "BKE_ccg.h"
-#include "BKE_cdderivedmesh.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
-#include "BKE_modifier.h"
#include "BKE_multires.h"
#include "BKE_paint.h"
#include "BKE_key.h"
@@ -74,7 +72,7 @@
static void update_cb(PBVHNode *node, void *rebuild)
{
BKE_pbvh_node_mark_update(node);
- if (*((int *)rebuild))
+ if (*((bool *)rebuild))
BKE_pbvh_node_mark_rebuild_draw(node);
BKE_pbvh_node_fully_hidden_set(node, 0);
}
@@ -114,7 +112,7 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo
if (kb) {
ob->shapenr = BLI_findindex(&key->block, kb) + 1;
- sculpt_update_mesh_elements(scene, sd, ob, 0, false);
+ BKE_sculpt_update_mesh_elements(scene, sd, ob, 0, false);
WM_event_add_notifier(C, NC_OBJECT | ND_DATA, ob);
}
else {
@@ -280,7 +278,7 @@ static void sculpt_undo_bmesh_restore_generic(bContext *C,
unode->applied = true;
}
- if (unode->type == SCULPT_UNDO_MASK) {
+ if (ELEM(unode->type, SCULPT_UNDO_MASK, SCULPT_UNDO_MASK)) {
int i, totnode;
PBVHNode **nodes;
@@ -301,8 +299,6 @@ static void sculpt_undo_bmesh_restore_generic(bContext *C,
MEM_freeN(nodes);
}
else {
- /* A bit lame, but for now just recreate the PBVH. The alternative
- * is to store changes to the PBVH in the undo stack. */
sculpt_pbvh_clear(ob);
}
}
@@ -319,6 +315,7 @@ static void sculpt_undo_bmesh_enable(Object *ob,
/* Create empty BMesh and enable logging */
ss->bm = BM_mesh_create(&bm_mesh_allocsize_default);
BM_data_layer_add(ss->bm, &ss->bm->vdata, CD_PAINT_MASK);
+ sculpt_dyntopo_node_layers_add(ss);
me->flag |= ME_SCULPT_DYNAMIC_TOPOLOGY;
/* Restore the BMLog using saved entries */
@@ -402,8 +399,8 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb)
DerivedMesh *dm;
SculptSession *ss = ob->sculpt;
SculptUndoNode *unode;
- int update = false, rebuild = false;
- int need_mask = false;
+ bool update = false, rebuild = false;
+ bool need_mask = false;
for (unode = lb->first; unode; unode = unode->next) {
if (strcmp(unode->idname, ob->id.name) == 0) {
@@ -416,7 +413,7 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb)
}
}
- sculpt_update_mesh_elements(scene, sd, ob, 0, need_mask);
+ BKE_sculpt_update_mesh_elements(scene, sd, ob, 0, need_mask);
/* call _after_ sculpt_update_mesh_elements() which may update 'ob->derivedFinal' */
dm = mesh_get_derived_final(scene, ob, 0);
@@ -465,29 +462,29 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb)
}
if (update || rebuild) {
- int tag_update = 0;
+ bool tag_update = false;
/* we update all nodes still, should be more clever, but also
* needs to work correct when exiting/entering sculpt mode and
* the nodes get recreated, though in that case it could do all */
BKE_pbvh_search_callback(ss->pbvh, NULL, NULL, update_cb, &rebuild);
BKE_pbvh_update(ss->pbvh, PBVH_UpdateBB | PBVH_UpdateOriginalBB | PBVH_UpdateRedraw, NULL);
- if (sculpt_multires_active(scene, ob)) {
+ if (BKE_sculpt_multires_active(scene, ob)) {
if (rebuild)
multires_mark_as_modified(ob, MULTIRES_HIDDEN_MODIFIED);
else
multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED);
}
- tag_update = ((Mesh *)ob->data)->id.us > 1;
+ tag_update |= ((Mesh *)ob->data)->id.us > 1;
- if (ss->modifiers_active) {
+ if (ss->kb || ss->modifiers_active) {
Mesh *mesh = ob->data;
BKE_mesh_calc_normals_tessface(mesh->mvert, mesh->totvert,
mesh->mface, mesh->totface, NULL);
- free_sculptsession_deformMats(ss);
- tag_update |= 1;
+ BKE_free_sculptsession_deformMats(ss);
+ tag_update |= true;
}
if (tag_update) {
@@ -756,16 +753,31 @@ static SculptUndoNode *sculpt_undo_bmesh_push(Object *ob,
if (node) {
switch (type) {
case SCULPT_UNDO_COORDS:
- case SCULPT_UNDO_HIDDEN:
case SCULPT_UNDO_MASK:
/* Before any vertex values get modified, ensure their
* original positions are logged */
BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_ALL) {
- BM_log_vert_before_modified(ss->bm, ss->bm_log, vd.bm_vert);
+ BM_log_vert_before_modified(ss->bm_log, vd.bm_vert, vd.cd_vert_mask_offset);
}
BKE_pbvh_vertex_iter_end;
break;
+ case SCULPT_UNDO_HIDDEN:
+ {
+ GSetIterator gs_iter;
+ GSet *faces = BKE_pbvh_bmesh_node_faces(node);
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_ALL) {
+ BM_log_vert_before_modified(ss->bm_log, vd.bm_vert, vd.cd_vert_mask_offset);
+ }
+ BKE_pbvh_vertex_iter_end;
+
+ GSET_ITER (gs_iter, faces) {
+ BMFace *f = BLI_gsetIterator_getKey(&gs_iter);
+ BM_log_face_modified(ss->bm_log, f);
+ }
+ break;
+ }
+
case SCULPT_UNDO_DYNTOPO_BEGIN:
case SCULPT_UNDO_DYNTOPO_END:
case SCULPT_UNDO_DYNTOPO_SYMMETRIZE:
diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c
index da2b62bce8b..797a881ce79 100644
--- a/source/blender/editors/sculpt_paint/sculpt_uv.c
+++ b/source/blender/editors/sculpt_paint/sculpt_uv.c
@@ -40,16 +40,13 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_brush_types.h"
-#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "BKE_brush.h"
#include "BKE_paint.h"
#include "BKE_colortools.h"
#include "BKE_context.h"
-#include "BKE_main.h"
#include "BKE_depsgraph.h"
-#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
#include "BKE_customdata.h"
#include "BKE_editmesh.h"
@@ -68,6 +65,9 @@
#include "paint_intern.h"
#include "uvedit_intern.h"
+#include "BIF_gl.h"
+#include "BIF_glutil.h"
+
#include "UI_view2d.h"
#define MARK_BOUNDARY 1
@@ -185,6 +185,45 @@ static int uv_sculpt_brush_poll(bContext *C)
return 0;
}
+static void brush_drawcursor_uvsculpt(bContext *C, int x, int y, void *UNUSED(customdata))
+{
+#define PX_SIZE_FADE_MAX 12.0f
+#define PX_SIZE_FADE_MIN 4.0f
+
+ Scene *scene = CTX_data_scene(C);
+ //Brush *brush = image_paint_brush(C);
+ Paint *paint = BKE_paint_get_active_from_context(C);
+ Brush *brush = BKE_paint_brush(paint);
+
+ if (paint && brush && paint->flags & PAINT_SHOW_BRUSH) {
+ const float size = (float)BKE_brush_size_get(scene, brush);
+ float alpha = 0.5f;
+
+ /* fade out the brush (cheap trick to work around brush interfering with sampling [#])*/
+ if (size < PX_SIZE_FADE_MIN) {
+ return;
+ }
+ else if (size < PX_SIZE_FADE_MAX) {
+ alpha *= (size - PX_SIZE_FADE_MIN) / (PX_SIZE_FADE_MAX - PX_SIZE_FADE_MIN);
+ }
+
+ glPushMatrix();
+
+ glTranslatef((float)x, (float)y, 0.0f);
+
+ glColor4f(brush->add_col[0], brush->add_col[1], brush->add_col[2], alpha);
+ glEnable(GL_LINE_SMOOTH);
+ glEnable(GL_BLEND);
+ glutil_draw_lined_arc(0, (float)(M_PI * 2.0), size, 40);
+ glDisable(GL_BLEND);
+ glDisable(GL_LINE_SMOOTH);
+
+ glPopMatrix();
+ }
+#undef PX_SIZE_FADE_MAX
+#undef PX_SIZE_FADE_MIN
+}
+
void ED_space_image_uv_sculpt_update(wmWindowManager *wm, ToolSettings *settings)
{
@@ -201,7 +240,7 @@ void ED_space_image_uv_sculpt_update(wmWindowManager *wm, ToolSettings *settings
BKE_paint_init(&settings->uvsculpt->paint, PAINT_CURSOR_SCULPT);
WM_paint_cursor_activate(wm, uv_sculpt_brush_poll,
- brush_drawcursor_texpaint_uvsculpt, NULL);
+ brush_drawcursor_uvsculpt, NULL);
}
else {
if (settings->uvsculpt)
@@ -518,8 +557,8 @@ static int uv_element_offset_from_face_get(UvElementMap *map, BMFace *efa, BMLoo
static unsigned int uv_edge_hash(const void *key)
{
UvEdge *edge = (UvEdge *)key;
- return (BLI_ghashutil_inthash(SET_INT_IN_POINTER(edge->uv2)) +
- BLI_ghashutil_inthash(SET_INT_IN_POINTER(edge->uv1)));
+ return (BLI_ghashutil_uinthash(edge->uv2) +
+ BLI_ghashutil_uinthash(edge->uv1));
}
static int uv_edge_compare(const void *a, const void *b)
@@ -630,7 +669,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
MEM_freeN(uniqueUv);
}
if (edgeHash) {
- MEM_freeN(edgeHash);
+ BLI_ghash_free(edgeHash, NULL, NULL);
}
uv_sculpt_stroke_exit(C, op);
return NULL;
diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c
index 71a6c775774..619fbd7f4c8 100644
--- a/source/blender/editors/sound/sound_ops.c
+++ b/source/blender/editors/sound/sound_ops.c
@@ -39,7 +39,6 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
-#include "DNA_anim_types.h"
#include "DNA_packedFile_types.h"
#include "DNA_scene_types.h"
#include "DNA_space_types.h"
diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c
index b5f6fa9a23e..f15bbe0d2f1 100644
--- a/source/blender/editors/space_action/action_draw.c
+++ b/source/blender/editors/space_action/action_draw.c
@@ -38,7 +38,6 @@
#include <float.h>
#include "BLI_blenlib.h"
-#include "BLI_math.h"
#include "BLI_utildefines.h"
/* Types --------------------------------------------------------------- */
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index 6e040371037..92e727fc2d7 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -42,7 +42,6 @@
#include "DNA_anim_types.h"
#include "DNA_gpencil_types.h"
-#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_mask_types.h"
@@ -65,7 +64,6 @@
#include "ED_keyframing.h"
#include "ED_keyframes_edit.h"
#include "ED_screen.h"
-#include "ED_transform.h"
#include "ED_markers.h"
#include "ED_mask.h"
@@ -122,7 +120,7 @@ static int act_new_exec(bContext *C, wmOperator *UNUSED(op))
}
/* set notifier that keyframes have changed */
- WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
return OPERATOR_FINISHED;
}
@@ -364,7 +362,60 @@ void ACTION_OT_previewrange_set(wmOperatorType *ot)
/* ****************** View-All Operator ****************** */
-static int actkeys_viewall(bContext *C, const bool only_sel, const bool only_xaxis)
+/* Find the extents of the active channel
+ * > min: (float) bottom y-extent of channel
+ * > max: (float) top y-extent of channel
+ * > returns: success of finding a selected channel
+ */
+static bool actkeys_channels_get_selected_extents(bAnimContext *ac, float *min, float *max)
+{
+ 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;
+
+ for (ale = anim_data.first; ale; ale = ale->next) {
+ bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
+
+ /* must be selected... */
+ 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);
+ *max = (float)(y + ACHANNEL_HEIGHT_HALF);
+
+ /* 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
+ */
+ if (found == ACHANNEL_ROLE_CHANNEL) {
+ break;
+ }
+ }
+
+ /* adjust y-position for next one */
+ y -= ACHANNEL_STEP;
+ }
+
+ /* free all temp data */
+ BLI_freelistN(&anim_data);
+
+ return (found != 0);
+}
+
+static int actkeys_viewall(bContext *C, const bool only_sel)
{
bAnimContext ac;
View2D *v2d;
@@ -390,10 +441,25 @@ static int actkeys_viewall(bContext *C, const bool only_sel, const bool only_xax
v2d->cur.xmax += extra;
/* set vertical range */
- if (only_xaxis == false) {
+ if (only_sel == false) {
+ /* view all -> the summary channel is usually the shows everything, and resides right at the top... */
v2d->cur.ymax = 0.0f;
v2d->cur.ymin = (float)-BLI_rcti_size_y(&v2d->mask);
}
+ else {
+ /* 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);
@@ -409,13 +475,13 @@ static int actkeys_viewall(bContext *C, const bool only_sel, const bool only_xax
static int actkeys_viewall_exec(bContext *C, wmOperator *UNUSED(op))
{
/* whole range */
- return actkeys_viewall(C, false, false);
+ return actkeys_viewall(C, false);
}
static int actkeys_viewsel_exec(bContext *C, wmOperator *UNUSED(op))
{
/* only selected */
- return actkeys_viewall(C, true, true);
+ return actkeys_viewall(C, true);
}
void ACTION_OT_view_all(wmOperatorType *ot)
@@ -680,7 +746,7 @@ static int actkeys_insertkey_exec(bContext *C, wmOperator *op)
ANIM_editkeyframes_refresh(&ac);
/* set notifier that keyframes have changed */
- WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
return OPERATOR_FINISHED;
}
@@ -753,7 +819,7 @@ static int actkeys_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
ANIM_editkeyframes_refresh(&ac);
/* set notifier that keyframes have changed */
- WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
return OPERATOR_FINISHED;
}
@@ -843,7 +909,7 @@ static int actkeys_delete_exec(bContext *C, wmOperator *UNUSED(op))
ANIM_editkeyframes_refresh(&ac);
/* set notifier that keyframes have changed */
- WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c
index b93728a7b3e..93cd94ed892 100644
--- a/source/blender/editors/space_action/action_ops.c
+++ b/source/blender/editors/space_action/action_ops.c
@@ -35,7 +35,6 @@
#include "DNA_space_types.h"
-#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "ED_anim_api.h"
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index 14cc38ed296..1e89b304279 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -35,7 +35,6 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
-#include "BLI_math.h"
#include "BLI_dlrbTree.h"
#include "BLI_utildefines.h"
@@ -203,7 +202,7 @@ enum {
} /*eActKeys_BorderSelect_Mode*/;
-static void borderselect_action(bAnimContext *ac, rcti rect, short mode, short selectmode)
+static void borderselect_action(bAnimContext *ac, const rcti rect, short mode, short selectmode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
@@ -890,7 +889,7 @@ static int actkeys_select_leftright_invoke(bContext *C, wmOperator *op, const wm
float x;
/* determine which side of the current frame mouse is on */
- UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, NULL);
+ x = UI_view2d_region_to_view_x(v2d, event->mval[0]);
if (x < CFRA)
RNA_enum_set(op->ptr, "mode", ACTKEYS_LRSEL_LEFT);
else
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index edbe17065f1..69eeac69e85 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -374,11 +374,20 @@ static void action_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn)
saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
ED_area_tag_refresh(sa);
}
- /* for selection changes of animation data, we can just redraw... otherwise autocolor might need to be done again */
- else if (ELEM(wmn->data, ND_KEYFRAME, ND_ANIMCHAN) && (wmn->action == NA_SELECTED))
- ED_area_tag_redraw(sa);
- else
+ /* 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)) ||
+ ((wmn->data == ND_ANIMCHAN) && (wmn->action != NA_SELECTED)))
+ {
ED_area_tag_refresh(sa);
+ }
+ /* 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 {
+ ED_area_tag_redraw(sa);
+ }
break;
case NC_SCENE:
switch (wmn->data) {
@@ -448,10 +457,9 @@ static void action_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn)
}
}
-static void action_header_area_listener(bScreen *UNUSED(sc), ScrArea *sa, ARegion *ar, wmNotifier *wmn)
+static void action_header_area_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn)
{
-
- SpaceAction *saction = (SpaceAction *)sa->spacedata.first;
+ // SpaceAction *saction = (SpaceAction *)sa->spacedata.first;
/* context changes */
switch (wmn->category) {
@@ -469,7 +477,7 @@ static void action_header_area_listener(bScreen *UNUSED(sc), ScrArea *sa, ARegio
case NC_ANIMATION:
switch (wmn->data) {
case ND_KEYFRAME:
- saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
+ //saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
ED_region_tag_redraw(ar);
break;
}
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index a14ed728b1d..a00aac12fba 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -44,8 +44,8 @@
#include "DNA_node_types.h"
#include "DNA_scene_types.h"
#include "DNA_world_types.h"
-#include "DNA_speaker_types.h"
#include "DNA_brush_types.h"
+#include "DNA_linestyle_types.h"
#include "BKE_context.h"
#include "BKE_action.h"
@@ -140,6 +140,30 @@ static int buttons_context_path_world(ButsContextPath *path)
return 0;
}
+static int buttons_context_path_linestyle(ButsContextPath *path)
+{
+ Scene *scene;
+ FreestyleLineStyle *linestyle;
+ PointerRNA *ptr = &path->ptr[path->len - 1];
+
+ /* if we already have a (pinned) linestyle, we're done */
+ if (RNA_struct_is_a(ptr->type, &RNA_FreestyleLineStyle)) {
+ return 1;
+ }
+ /* if we have a scene, use the lineset's linestyle */
+ else if (buttons_context_path_scene(path)) {
+ scene = path->ptr[path->len - 1].data;
+ linestyle = CTX_data_linestyle_from_scene(scene);
+ if (linestyle) {
+ RNA_id_pointer_create(&linestyle->id, &path->ptr[path->len]);
+ path->len++;
+ return 1;
+ }
+ }
+
+ /* no path to a linestyle possible */
+ return 0;
+}
static int buttons_context_path_object(ButsContextPath *path)
{
@@ -396,6 +420,8 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur
buttons_context_path_particle(path);
else if (GS(id->name) == ID_OB)
buttons_context_path_object(path);
+ else if (GS(id->name) == ID_LS)
+ buttons_context_path_linestyle(path);
}
if (ct->texture) {
@@ -411,6 +437,7 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur
Lamp *la;
World *wo;
ParticleSystem *psys;
+ FreestyleLineStyle *ls;
Tex *tex;
PointerRNA *ptr = &path->ptr[path->len - 1];
@@ -476,12 +503,50 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur
return 1;
}
}
+ /* try linestyle */
+ else if ((path->tex_ctx == SB_TEXC_LINESTYLE) && buttons_context_path_linestyle(path)) {
+ ls = path->ptr[path->len - 1].data;
+
+ if (ls) {
+ tex = give_current_linestyle_texture(ls);
+
+ RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
+ path->len++;
+ return 1;
+ }
+ }
}
/* no path to a texture possible */
return 0;
}
+#ifdef WITH_FREESTYLE
+static bool buttons_context_linestyle_pinnable(const bContext *C)
+{
+ Scene *scene = CTX_data_scene(C);
+ SceneRenderLayer *actsrl;
+ FreestyleConfig *config;
+ SpaceButs *sbuts;
+
+ /* if Freestyle is disabled in the scene */
+ if ((scene->r.mode & R_EDGE_FRS) == 0) {
+ return false;
+ }
+ /* if Freestyle is not in the Parameter Editor mode */
+ actsrl = BLI_findlink(&scene->r.layers, scene->r.actlay);
+ config = &actsrl->freestyleConfig;
+ if (config->mode != FREESTYLE_CONTROL_EDITOR_MODE) {
+ return false;
+ }
+ /* if the scene has already been pinned */
+ sbuts = CTX_wm_space_buts(C);
+ if (sbuts->pinid && sbuts->pinid == &scene->id) {
+ return false;
+ }
+ return true;
+}
+#endif
static int buttons_context_path(const bContext *C, ButsContextPath *path, int mainb, int flag)
{
@@ -513,7 +578,17 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma
switch (mainb) {
case BCONTEXT_SCENE:
case BCONTEXT_RENDER:
+ found = buttons_context_path_scene(path);
+ break;
case BCONTEXT_RENDER_LAYER:
+#ifdef WITH_FREESTYLE
+ if (buttons_context_linestyle_pinnable(C)) {
+ found = buttons_context_path_linestyle(path);
+ if (found) {
+ break;
+ }
+ }
+#endif
found = buttons_context_path_scene(path);
break;
case BCONTEXT_WORLD:
@@ -587,13 +662,16 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts)
PointerRNA *ptr;
int a, pflag = 0, flag = 0;
- buttons_texture_context_compute(C, sbuts);
-
if (!sbuts->path)
sbuts->path = MEM_callocN(sizeof(ButsContextPath), "ButsContextPath");
-
+
path = sbuts->path;
-
+
+ /* We need to set Scene path now! Else, buttons_texture_context_compute() might not get a valid scene. */
+ buttons_context_path(C, path, BCONTEXT_SCENE, pflag);
+
+ buttons_texture_context_compute(C, sbuts);
+
/* for each context, see if we can compute a valid path to it, if
* this is the case, we know we have to display the button */
for (a = 0; a < BCONTEXT_TOT; a++) {
@@ -656,11 +734,12 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts)
/************************* Context Callback ************************/
const char *buttons_context_dir[] = {
- "texture_slot", "world", "object", "mesh", "armature", "lattice", "curve",
+ "texture_slot", "scene", "world", "object", "mesh", "armature", "lattice", "curve",
"meta_ball", "lamp", "speaker", "camera", "material", "material_slot",
"texture", "texture_user", "texture_user_property", "bone", "edit_bone",
"pose_bone", "particle_system", "particle_system_editable", "particle_settings",
- "cloth", "soft_body", "fluid", "smoke", "collision", "brush", "dynamic_paint", NULL
+ "cloth", "soft_body", "fluid", "smoke", "collision", "brush", "dynamic_paint",
+ "line_style", NULL
};
int buttons_context(const bContext *C, const char *member, bContextDataResult *result)
@@ -681,6 +760,10 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
CTX_data_dir_set(result, buttons_context_dir);
return 1;
}
+ else if (CTX_data_equals(member, "scene")) {
+ /* Do not return one here if scene not found in path, in this case we want to get default context scene! */
+ return set_pointer_type(path, result, &RNA_Scene);
+ }
else if (CTX_data_equals(member, "world")) {
set_pointer_type(path, result, &RNA_World);
return 1;
@@ -854,6 +937,12 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
if (wo)
CTX_data_pointer_set(result, &wo->id, &RNA_WorldTextureSlot, wo->mtex[(int)wo->texact]);
}
+ else if ((ptr = get_pointer_type(path, &RNA_FreestyleLineStyle))) {
+ FreestyleLineStyle *ls = ptr->data;
+
+ if (ls)
+ CTX_data_pointer_set(result, &ls->id, &RNA_LineStyleTextureSlot, ls->mtex[(int)ls->texact]);
+ }
return 1;
}
@@ -966,6 +1055,10 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
return 1;
}
}
+ else if (CTX_data_equals(member, "line_style")) {
+ set_pointer_type(path, result, &RNA_FreestyleLineStyle);
+ return 1;
+ }
else {
return 0; /* not found */
}
diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c
index 7c42ea9a13b..c558d811693 100644
--- a/source/blender/editors/space_buttons/buttons_texture.c
+++ b/source/blender/editors/space_buttons/buttons_texture.c
@@ -51,6 +51,8 @@
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "DNA_world_types.h"
+#include "DNA_linestyle_types.h"
+
#include "BKE_context.h"
#include "BKE_material.h"
@@ -59,6 +61,7 @@
#include "BKE_paint.h"
#include "BKE_particle.h"
#include "BKE_scene.h"
+#include "BKE_freestyle.h"
#include "RNA_access.h"
@@ -99,6 +102,32 @@ bool ED_texture_context_check_particles(const bContext *C)
return (ob && ob->particlesystem.first);
}
+bool ED_texture_context_check_linestyle(const bContext *C)
+{
+#ifdef WITH_FREESTYLE
+ Scene *scene = CTX_data_scene(C);
+ SceneRenderLayer *actsrl;
+ FreestyleConfig *config;
+ FreestyleLineSet *lineset;
+ FreestyleLineStyle *linestyle;
+
+ if (scene && (scene->r.mode & R_EDGE_FRS)) {
+ actsrl = BLI_findlink(&scene->r.layers, scene->r.actlay);
+ config = &actsrl->freestyleConfig;
+ if (config->mode == FREESTYLE_CONTROL_EDITOR_MODE) {
+ lineset = BKE_freestyle_lineset_get_active(config);
+ if (lineset) {
+ linestyle = lineset->linestyle;
+ return linestyle && (linestyle->flag & LS_TEXTURE);
+ }
+ }
+ }
+#else
+ (void)C;
+#endif
+ return false;
+}
+
static void texture_context_check_modifier_foreach(void *userData, Object *UNUSED(ob), ModifierData *UNUSED(md),
const char *UNUSED(propname))
{
@@ -148,6 +177,7 @@ static void set_texture_context(const bContext *C, SpaceButs *sbuts)
bool valid_material = ED_texture_context_check_material(C);
bool valid_lamp = ED_texture_context_check_lamp(C);
bool valid_particles = ED_texture_context_check_particles(C);
+ bool valid_linestyle = ED_texture_context_check_linestyle(C);
bool valid_others = ED_texture_context_check_others(C);
/* this is similar to direct user action, no need to keep "better" ctxt in _prev */
@@ -163,6 +193,9 @@ static void set_texture_context(const bContext *C, SpaceButs *sbuts)
else if ((sbuts->mainb == BCONTEXT_PARTICLE) && valid_particles) {
sbuts->texture_context = sbuts->texture_context_prev = SB_TEXC_PARTICLES;
}
+ else if ((sbuts->mainb == BCONTEXT_RENDER_LAYER) && valid_linestyle) {
+ sbuts->texture_context = sbuts->texture_context_prev = SB_TEXC_LINESTYLE;
+ }
else if ((ELEM(sbuts->mainb, BCONTEXT_MODIFIER, BCONTEXT_PHYSICS)) && valid_others) {
sbuts->texture_context = sbuts->texture_context_prev = SB_TEXC_OTHER;
}
@@ -172,6 +205,7 @@ static void set_texture_context(const bContext *C, SpaceButs *sbuts)
((sbuts->texture_context_prev == SB_TEXC_MATERIAL) && valid_material) ||
((sbuts->texture_context_prev == SB_TEXC_LAMP) && valid_lamp) ||
((sbuts->texture_context_prev == SB_TEXC_PARTICLES) && valid_particles) ||
+ ((sbuts->texture_context_prev == SB_TEXC_LINESTYLE) && valid_linestyle) ||
((sbuts->texture_context_prev == SB_TEXC_OTHER) && valid_others)))
{
sbuts->texture_context = sbuts->texture_context_prev;
@@ -181,6 +215,7 @@ static void set_texture_context(const bContext *C, SpaceButs *sbuts)
((sbuts->texture_context == SB_TEXC_MATERIAL) && !valid_material) ||
((sbuts->texture_context == SB_TEXC_LAMP) && !valid_lamp) ||
((sbuts->texture_context == SB_TEXC_PARTICLES) && !valid_particles) ||
+ ((sbuts->texture_context == SB_TEXC_LINESTYLE) && !valid_linestyle) ||
((sbuts->texture_context == SB_TEXC_OTHER) && !valid_others))
{
/* this is default fallback, do keep "better" ctxt in _prev */
@@ -194,6 +229,9 @@ static void set_texture_context(const bContext *C, SpaceButs *sbuts)
else if (valid_particles) {
sbuts->texture_context = SB_TEXC_PARTICLES;
}
+ else if (valid_linestyle) {
+ sbuts->texture_context = SB_TEXC_LINESTYLE;
+ }
else if (valid_world) {
sbuts->texture_context = SB_TEXC_WORLD;
}
@@ -284,6 +322,7 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext *
Material *ma = NULL;
Lamp *la = NULL;
World *wrld = NULL;
+ FreestyleLineStyle *linestyle = NULL;
Brush *brush = NULL;
ID *pinid = sbuts->pinid;
bool limited_mode = (sbuts->flag & SB_TEX_USER_LIMITED) != 0;
@@ -302,6 +341,8 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext *
ma = (Material *)pinid;
else if (GS(pinid->name) == ID_BR)
brush = (Brush *)pinid;
+ else if (GS(pinid->name) == ID_LS)
+ linestyle = (FreestyleLineStyle *)pinid;
}
if (!scene)
@@ -311,6 +352,7 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext *
ob = (scene->basact) ? scene->basact->object : NULL;
wrld = scene->world;
brush = BKE_paint_brush(BKE_paint_get_active_from_context(C));
+ linestyle = CTX_data_linestyle_from_scene(scene);
}
if (ob && ob->type == OB_LAMP && !la)
@@ -327,6 +369,8 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext *
buttons_texture_users_find_nodetree(users, &la->id, la->nodetree, "Lamp");
if (wrld && !limited_mode)
buttons_texture_users_find_nodetree(users, &wrld->id, wrld->nodetree, "World");
+ if (linestyle && !limited_mode)
+ buttons_texture_users_find_nodetree(users, &linestyle->id, linestyle->nodetree, "LineStyle");
if (ob) {
ParticleSystem *psys = psys_get_current(ob);
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index ea3f34b4b86..1257dcb5e4c 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -35,7 +35,6 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
-#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BKE_context.h"
@@ -44,15 +43,12 @@
#include "ED_space_api.h"
#include "ED_screen.h"
-#include "BIF_gl.h"
-
#include "WM_api.h"
#include "WM_types.h"
#include "UI_resources.h"
#include "UI_view2d.h"
-#include "ED_render.h"
#include "buttons_intern.h" /* own include */
diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c
index a5557f8150a..cda46d2a9c2 100644
--- a/source/blender/editors/space_clip/clip_buttons.c
+++ b/source/blender/editors/space_clip/clip_buttons.c
@@ -42,7 +42,6 @@
#include "BLI_utildefines.h"
#include "BLI_listbase.h"
#include "BLI_path_util.h"
-#include "BLI_rect.h"
#include "BLI_string.h"
#include "BLF_translation.h"
@@ -53,7 +52,6 @@
#include "BKE_movieclip.h"
#include "BKE_tracking.h"
-#include "ED_clip.h"
#include "ED_gpencil.h"
#include "UI_interface.h"
diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c
index a732ac69fb9..2a457bf503f 100644
--- a/source/blender/editors/space_clip/clip_dopesheet_draw.c
+++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c
@@ -33,23 +33,17 @@
#include "DNA_object_types.h" /* SELECT */
#include "DNA_scene_types.h"
-#include "MEM_guardedalloc.h"
-
#include "BLI_utildefines.h"
#include "BLI_math.h"
-#include "BLI_string.h"
-#include "BLI_listbase.h"
#include "BLI_rect.h"
#include "BKE_context.h"
#include "BKE_movieclip.h"
-#include "BKE_tracking.h"
#include "ED_screen.h"
#include "ED_clip.h"
#include "BIF_gl.h"
-#include "BIF_glutil.h"
#include "WM_types.h"
@@ -193,7 +187,7 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene)
y = (float) CHANNEL_FIRST;
- UI_view2d_getscale(v2d, &xscale, &yscale);
+ UI_view2d_scale_get(v2d, &xscale, &yscale);
/* setup colors for regular and selected strips */
UI_GetThemeColor3fv(TH_STRIP, strip);
diff --git a/source/blender/editors/space_clip/clip_dopesheet_ops.c b/source/blender/editors/space_clip/clip_dopesheet_ops.c
index 58ae0d14e4d..573b6bc9276 100644
--- a/source/blender/editors/space_clip/clip_dopesheet_ops.c
+++ b/source/blender/editors/space_clip/clip_dopesheet_ops.c
@@ -32,17 +32,12 @@
#include "DNA_object_types.h" /* SELECT */
#include "DNA_scene_types.h"
-#include "MEM_guardedalloc.h"
-
#include "BLI_utildefines.h"
#include "BLI_math.h"
-#include "BLI_listbase.h"
#include "BLI_rect.h"
#include "BKE_context.h"
-#include "BKE_movieclip.h"
#include "BKE_tracking.h"
-#include "BKE_depsgraph.h"
#include "WM_api.h"
#include "WM_types.h"
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index eaf12a8d51c..9d413e81ea8 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -32,8 +32,6 @@
#include "DNA_gpencil_types.h"
#include "DNA_movieclip_types.h"
#include "DNA_scene_types.h"
-#include "DNA_object_types.h" /* SELECT */
-#include "DNA_mask_types.h"
#include "MEM_guardedalloc.h"
@@ -44,14 +42,12 @@
#include "BLI_utildefines.h"
#include "BLI_math.h"
#include "BLI_string.h"
-#include "BLI_rect.h"
#include "BLI_math_base.h"
#include "BKE_context.h"
#include "BKE_image.h"
#include "BKE_movieclip.h"
#include "BKE_tracking.h"
-#include "BKE_mask.h"
#include "ED_screen.h"
#include "ED_clip.h"
@@ -61,7 +57,6 @@
#include "BIF_gl.h"
#include "BIF_glutil.h"
-#include "WM_api.h"
#include "WM_types.h"
#include "UI_interface.h"
@@ -279,7 +274,7 @@ static void draw_movieclip_muted(ARegion *ar, int width, int height, float zoomx
int x, y;
/* find window pixel coordinates of origin */
- UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y);
+ UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x, &y);
glColor3f(0.0f, 0.0f, 0.0f);
glRectf(x, y, x + zoomx * width, y + zoomy * height);
@@ -293,7 +288,7 @@ static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar,
int x, y;
/* find window pixel coordinates of origin */
- UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y);
+ UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x, &y);
/* checkerboard for case alpha */
if (ibuf->planes == 32) {
@@ -328,7 +323,7 @@ static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int
MovieClip *clip = ED_space_clip_get_clip(sc);
/* find window pixel coordinates of origin */
- UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y);
+ UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x, &y);
/* draw boundary border for frame if stabilization is enabled */
if (sc->flag & SC_SHOW_STABLE && clip->tracking.stabilization.flag & TRACKING_2D_STABILIZATION) {
@@ -468,7 +463,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
}
static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker,
- float marker_pos[2], int width, int height)
+ const float marker_pos[2], int width, int height)
{
int tiny = sc->flag & SC_SHOW_TINY_MARKER;
bool show_search = false;
@@ -571,7 +566,7 @@ static void track_colors(MovieTrackingTrack *track, int act, float col[3], float
}
static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker,
- float marker_pos[2], int width, int height, int act, int sel)
+ const float marker_pos[2], int width, int height, int act, int sel)
{
int tiny = sc->flag & SC_SHOW_TINY_MARKER;
bool show_search = false;
@@ -785,7 +780,7 @@ static void draw_marker_slide_triangle(float x, float y, float dx, float dy, int
}
static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker,
- float marker_pos[2], int outline, int sel, int act, int width, int height)
+ const float marker_pos[2], int outline, int sel, int act, int width, int height)
{
float dx, dy, patdx, patdy, searchdx, searchdy;
int tiny = sc->flag & SC_SHOW_TINY_MARKER;
@@ -898,7 +893,7 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
}
static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker,
- float marker_pos[2], int act, int width, int height, float zoomx, float zoomy)
+ const float marker_pos[2], int act, int width, int height, float zoomx, float zoomy)
{
char str[128] = {0}, state[64] = {0};
float dx = 0.0f, dy = 0.0f, fontsize, pos[3];
@@ -1256,12 +1251,12 @@ static void draw_tracking_tracks(SpaceClip *sc, Scene *scene, ARegion *ar, Movie
/* ** find window pixel coordinates of origin ** */
- /* UI_view2d_to_region_no_clip return integer values, this could
+ /* UI_view2d_view_to_region_no_clip return integer values, this could
* lead to 1px flickering when view is locked to selection during playbeck.
* to avoid this flickering, calculate base point in the same way as it happens
- * in UI_view2d_to_region_no_clip, but do it in floats here */
+ * in UI_view2d_view_to_region_no_clip, but do it in floats here */
- UI_view2d_to_region_float(&ar->v2d, 0.0f, 0.0f, &x, &y);
+ UI_view2d_view_to_region_fl(&ar->v2d, 0.0f, 0.0f, &x, &y);
glPushMatrix();
glTranslatef(x, y, 0);
@@ -1503,7 +1498,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
if ((sc->flag & SC_SHOW_GRID) == 0 && (sc->flag & SC_MANUAL_CALIBRATION) == 0)
return;
- UI_view2d_to_region_float(&ar->v2d, 0.0f, 0.0f, &x, &y);
+ UI_view2d_view_to_region_fl(&ar->v2d, 0.0f, 0.0f, &x, &y);
glPushMatrix();
glTranslatef(x, y, 0);
diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c
index f3938c2aebe..b7860643e1a 100644
--- a/source/blender/editors/space_clip/clip_editor.c
+++ b/source/blender/editors/space_clip/clip_editor.c
@@ -43,18 +43,15 @@
#include "MEM_guardedalloc.h"
#include "DNA_mask_types.h"
-#include "DNA_object_types.h" /* SELECT */
#include "BLI_utildefines.h"
#include "BLI_fileops.h"
#include "BLI_math.h"
-#include "BLI_string.h"
#include "BLI_rect.h"
#include "BLI_threads.h"
#include "BKE_global.h"
#include "BKE_main.h"
-#include "BKE_mask.h"
#include "BKE_movieclip.h"
#include "BKE_context.h"
#include "BKE_tracking.h"
@@ -260,10 +257,11 @@ ImBuf *ED_space_clip_get_stable_buffer(SpaceClip *sc, float loc[2], float *scale
return NULL;
}
-/* returns color in SRGB */
-/* matching ED_space_image_color_sample() */
-bool ED_space_clip_color_sample(SpaceClip *sc, ARegion *ar, int mval[2], float r_col[3])
+/* Returns color in the display space, matching ED_space_image_color_sample(). */
+bool ED_space_clip_color_sample(Scene *scene, SpaceClip *sc, ARegion *ar, int mval[2], float r_col[3])
{
+ const char *display_device = scene->display_settings.display_device;
+ struct ColorManagedDisplay *display = IMB_colormanagement_display_get_named(display_device);
ImBuf *ibuf;
float fx, fy, co[2];
bool ret = false;
@@ -280,7 +278,7 @@ bool ED_space_clip_color_sample(SpaceClip *sc, ARegion *ar, int mval[2], float r
fy = co[1];
if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) {
- float *fp;
+ const float *fp;
unsigned char *cp;
int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y);
@@ -289,16 +287,23 @@ bool ED_space_clip_color_sample(SpaceClip *sc, ARegion *ar, int mval[2], float r
if (ibuf->rect_float) {
fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
- linearrgb_to_srgb_v3_v3(r_col, fp);
+ copy_v3_v3(r_col, fp);
ret = true;
}
else if (ibuf->rect) {
cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x);
rgb_uchar_to_float(r_col, cp);
+ IMB_colormanagement_colorspace_to_scene_linear_v3(r_col, ibuf->rect_colorspace);
ret = true;
}
}
+ if (ret) {
+ IMB_colormanagement_scene_linear_to_display_v3(r_col, display);
+ }
+
+ IMB_freeImBuf(ibuf);
+
return ret;
}
@@ -445,7 +450,7 @@ void ED_clip_point_stable_pos(SpaceClip *sc, ARegion *ar, float x, float y, floa
ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy);
ED_space_clip_get_size(sc, &width, &height);
- UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy);
+ UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &sx, &sy);
pos[0] = (x - sx) / zoomx;
pos[1] = (y - sy) / zoomy;
@@ -481,7 +486,7 @@ void ED_clip_point_stable_pos__reverse(SpaceClip *sc, ARegion *ar, const float c
int width, height;
int sx, sy;
- UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy);
+ UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &sx, &sy);
ED_space_clip_get_size(sc, &width, &height);
ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy);
@@ -643,7 +648,7 @@ static unsigned char *prefetch_read_file_to_memory(MovieClip *clip, int current_
BKE_movieclip_filename_for_frame(clip, &user, name);
file = BLI_open(name, O_BINARY | O_RDONLY, 0);
- if (file < 0) {
+ if (file == -1) {
return NULL;
}
diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c
index bce671fac7a..723c8bd144a 100644
--- a/source/blender/editors/space_clip/clip_graph_draw.c
+++ b/source/blender/editors/space_clip/clip_graph_draw.c
@@ -31,13 +31,9 @@
#include "DNA_movieclip_types.h"
#include "DNA_scene_types.h"
-#include "DNA_object_types.h" /* SELECT */
-
-#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
#include "BLI_math.h"
-#include "BLI_string.h"
#include "BKE_context.h"
#include "BKE_movieclip.h"
@@ -47,7 +43,6 @@
#include "ED_clip.h"
#include "BIF_gl.h"
-#include "BIF_glutil.h"
#include "WM_types.h"
@@ -96,8 +91,10 @@ static void tracking_segment_point_cb(void *UNUSED(userdata), MovieTrackingTrack
static void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track, int coord)
{
- static float colors[2][3] = {{1.0f, 0.0f, 0.0f},
- {0.0f, 1.0f, 0.0f}};
+ const float colors[2][3] = {
+ {1.0f, 0.0f, 0.0f},
+ {0.0f, 1.0f, 0.0f},
+ };
float col[4];
copy_v3_v3(col, colors[coord]);
@@ -168,7 +165,7 @@ static void draw_tracks_motion_curves(View2D *v2d, SpaceClip *sc)
userdata.hsize = UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE);
userdata.sel = false;
userdata.act_track = act_track;
- UI_view2d_getscale(v2d, &userdata.xscale, &userdata.yscale);
+ UI_view2d_scale_get(v2d, &userdata.xscale, &userdata.yscale);
clip_graph_tracking_values_iterate(sc,
(sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0,
(sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0,
diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c
index 2aaf064ef53..95f59e79c08 100644
--- a/source/blender/editors/space_clip/clip_graph_ops.c
+++ b/source/blender/editors/space_clip/clip_graph_ops.c
@@ -29,18 +29,13 @@
* \ingroup spclip
*/
-#include "DNA_object_types.h" /* SELECT */
#include "DNA_scene_types.h"
-#include "MEM_guardedalloc.h"
-
#include "BLI_utildefines.h"
#include "BLI_math.h"
-#include "BLI_listbase.h"
#include "BLI_rect.h"
#include "BKE_context.h"
-#include "BKE_movieclip.h"
#include "BKE_tracking.h"
#include "BKE_depsgraph.h"
@@ -193,10 +188,10 @@ static bool mouse_select_knot(bContext *C, float co[2], bool extend)
if (userdata.marker) {
int x1, y1, x2, y2;
- UI_view2d_view_to_region(v2d, co[0], co[1], &x1, &y1);
- UI_view2d_view_to_region(v2d, userdata.min_co[0], userdata.min_co[1], &x2, &y2);
-
- if (abs(x2 - x1) <= delta && abs(y2 - y1) <= delta) {
+ if (UI_view2d_view_to_region_clip(v2d, co[0], co[1], &x1, &y1) &&
+ UI_view2d_view_to_region_clip(v2d, userdata.min_co[0], userdata.min_co[1], &x2, &y2) &&
+ (abs(x2 - x1) <= delta && abs(y2 - y1) <= delta))
+ {
if (!extend) {
SelectUserData selectdata = {SEL_DESELECT};
@@ -366,17 +361,15 @@ static int border_select_graph_exec(bContext *C, wmOperator *op)
MovieTracking *tracking = &clip->tracking;
MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
BorderSelectuserData userdata;
- rcti rect;
+ rctf rect;
if (act_track == NULL) {
return OPERATOR_CANCELLED;
}
/* get rectangle from operator */
- WM_operator_properties_border_to_rcti(op, &rect);
-
- UI_view2d_region_to_view(&ar->v2d, rect.xmin, rect.ymin, &userdata.rect.xmin, &userdata.rect.ymin);
- UI_view2d_region_to_view(&ar->v2d, rect.xmax, rect.ymax, &userdata.rect.xmax, &userdata.rect.ymax);
+ WM_operator_properties_border_to_rctf(op, &rect);
+ UI_view2d_region_to_view_rctf(&ar->v2d, &rect, &userdata.rect);
userdata.changed = false;
userdata.mode = RNA_int_get(op->ptr, "gesture_mode");
diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c
index 3f0a376d791..7ccee73626c 100644
--- a/source/blender/editors/space_clip/clip_ops.c
+++ b/source/blender/editors/space_clip/clip_ops.c
@@ -58,7 +58,6 @@
#include "BKE_global.h"
#include "BKE_report.h"
#include "BKE_main.h"
-#include "BKE_library.h"
#include "BKE_movieclip.h"
#include "BKE_sound.h"
#include "BKE_tracking.h"
@@ -780,7 +779,7 @@ static int view_all_exec(bContext *C, wmOperator *op)
sc->xof = sc->yof = 0.0f;
- ED_region_tag_redraw(CTX_wm_region(C));
+ ED_region_tag_redraw(ar);
return OPERATOR_FINISHED;
}
@@ -814,7 +813,7 @@ static int view_selected_exec(bContext *C, wmOperator *UNUSED(op))
sc->ylockof = 0.0f;
ED_clip_view_selection(C, ar, 1);
- ED_region_tag_redraw(CTX_wm_region(C));
+ ED_region_tag_redraw(ar);
return OPERATOR_FINISHED;
}
@@ -852,7 +851,7 @@ static void change_frame_apply(bContext *C, wmOperator *op)
SUBFRA = 0.0f;
/* do updates */
- sound_seek_scene(CTX_data_main(C), CTX_data_scene(C));
+ sound_seek_scene(CTX_data_main(C), scene);
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
}
@@ -1018,8 +1017,11 @@ static void do_movie_proxy(void *pjv, int *UNUSED(build_sizes), int UNUSED(build
if (build_undistort_count) {
int threads = BLI_system_thread_count();
+ int width, height;
+
+ BKE_movieclip_get_size(clip, NULL, &width, &height);
- distortion = BKE_tracking_distortion_new();
+ distortion = BKE_tracking_distortion_new(&clip->tracking, width, height);
BKE_tracking_distortion_set_threads(distortion, threads);
}
@@ -1053,7 +1055,7 @@ typedef struct ProxyQueue {
int efra;
SpinLock spin;
- short *stop;
+ const short *stop;
short *do_update;
float *progress;
} ProxyQueue;
@@ -1185,8 +1187,11 @@ static void do_sequence_proxy(void *pjv, int *build_sizes, int build_count,
handle->build_undistort_count = build_undistort_count;
handle->build_undistort_sizes = build_undistort_sizes;
- if (build_undistort_count)
- handle->distortion = BKE_tracking_distortion_new();
+ if (build_undistort_count) {
+ int width, height;
+ BKE_movieclip_get_size(clip, NULL, &width, &height);
+ handle->distortion = BKE_tracking_distortion_new(&clip->tracking, width, height);
+ }
if (tot_thread > 1)
BLI_insert_thread(&threads, handle);
@@ -1280,7 +1285,7 @@ static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op))
G.is_break = false;
WM_jobs_start(CTX_wm_manager(C), wm_job);
- ED_area_tag_redraw(CTX_wm_area(C));
+ ED_area_tag_redraw(sa);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c
index e4392cb579d..a79ac1f7b82 100644
--- a/source/blender/editors/space_clip/clip_utils.c
+++ b/source/blender/editors/space_clip/clip_utils.c
@@ -316,7 +316,7 @@ void clip_draw_cfra(SpaceClip *sc, ARegion *ar, Scene *scene)
UI_view2d_view_orthoSpecial(ar, v2d, 1);
/* because the frame number text is subject to the same scaling as the contents of the view */
- UI_view2d_getscale(v2d, &xscale, &yscale);
+ UI_view2d_scale_get(v2d, &xscale, &yscale);
glScalef(1.0f / xscale, 1.0f, 1.0f);
ED_region_cache_draw_curfra_label(sc->user.framenr, (float)sc->user.framenr * xscale, 18);
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index ad425d21612..d3be25050c8 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -43,7 +43,6 @@
#include "BLI_utildefines.h"
#include "BLI_math.h"
-#include "BKE_main.h"
#include "BKE_context.h"
#include "BKE_screen.h"
#include "BKE_movieclip.h"
@@ -1184,7 +1183,7 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar)
clip_draw_main(C, sc, ar);
/* TODO(sergey): would be nice to find a way to de-duplicate all this space conversions */
- UI_view2d_to_region_float(&ar->v2d, 0.0f, 0.0f, &x, &y);
+ UI_view2d_view_to_region_fl(&ar->v2d, 0.0f, 0.0f, &x, &y);
ED_space_clip_get_size(sc, &width, &height);
ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy);
ED_space_clip_get_aspect(sc, &aspx, &aspy);
@@ -1317,7 +1316,7 @@ static void dopesheet_area_draw(const bContext *C, ARegion *ar)
/* time grid */
unit = (sc->flag & SC_SHOW_SECONDS) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES;
- grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, unit, V2D_GRID_CLAMP,
+ grid = UI_view2d_grid_calc(scene, 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);
diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c
index 1c2933b823d..ce14471f608 100644
--- a/source/blender/editors/space_clip/tracking_ops.c
+++ b/source/blender/editors/space_clip/tracking_ops.c
@@ -34,7 +34,6 @@
#include "DNA_camera_types.h"
#include "DNA_constraint_types.h"
#include "DNA_gpencil_types.h"
-#include "DNA_mask_types.h"
#include "DNA_movieclip_types.h"
#include "DNA_object_types.h" /* SELECT */
#include "DNA_scene_types.h"
@@ -54,10 +53,7 @@
#include "BKE_depsgraph.h"
#include "BKE_object.h"
#include "BKE_report.h"
-#include "BKE_scene.h"
#include "BKE_library.h"
-#include "BKE_mask.h"
-#include "BKE_node.h"
#include "BKE_sound.h"
#include "WM_api.h"
@@ -65,7 +61,6 @@
#include "ED_screen.h"
#include "ED_clip.h"
-#include "ED_keyframing.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
@@ -473,7 +468,7 @@ static SlideMarkerData *create_slide_marker_data(SpaceClip *sc, MovieTrackingTra
}
static int mouse_on_slide_zone(SpaceClip *sc, MovieTrackingMarker *marker,
- int area, float co[2], float slide_zone[2],
+ int area, const float co[2], const float slide_zone[2],
float padding, int width, int height)
{
const float size = 12.0f;
@@ -504,7 +499,7 @@ static int mouse_on_slide_zone(SpaceClip *sc, MovieTrackingMarker *marker,
}
static int mouse_on_corner(SpaceClip *sc, MovieTrackingMarker *marker,
- int area, float co[2], int corner, float padding,
+ int area, const float co[2], int corner, float padding,
int width, int height)
{
float min[2], max[2], crn[2];
@@ -573,7 +568,7 @@ static int get_mouse_pattern_corner(SpaceClip *sc, MovieTrackingMarker *marker,
}
static int mouse_on_offset(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker,
- float co[2], int width, int height)
+ const float co[2], int width, int height)
{
float pos[2], dx, dy;
float pat_min[2], pat_max[2];
@@ -1440,7 +1435,7 @@ static int track_markers_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
clip = ED_space_clip_get_clip(sc);
framenr = ED_space_clip_get_clip_frame_number(sc);
- if (WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C), WM_JOB_TYPE_ANY)) {
+ if (WM_jobs_test(CTX_wm_manager(C), sa, WM_JOB_TYPE_ANY)) {
/* only one tracking is allowed at a time */
return OPERATOR_CANCELLED;
}
@@ -1716,7 +1711,7 @@ static int solve_camera_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
wmJob *wm_job;
char error_msg[256] = "\0";
- if (WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C), WM_JOB_TYPE_ANY)) {
+ if (WM_jobs_test(CTX_wm_manager(C), sa, WM_JOB_TYPE_ANY)) {
/* only one solve is allowed at a time */
return OPERATOR_CANCELLED;
}
@@ -2050,7 +2045,7 @@ static void object_solver_inverted_matrix(Scene *scene, Object *ob, float invmat
bool found = false;
for (con = ob->constraints.first; con; con = con->next) {
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
if (!cti)
continue;
@@ -2081,7 +2076,7 @@ static Object *object_solver_camera(Scene *scene, Object *ob)
bConstraint *con;
for (con = ob->constraints.first; con; con = con->next) {
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
if (!cti)
continue;
@@ -3062,7 +3057,7 @@ static int frame_jump_exec(bContext *C, wmOperator *op)
if (CFRA != sc->user.framenr) {
CFRA = sc->user.framenr;
- sound_seek_scene(CTX_data_main(C), CTX_data_scene(C));
+ sound_seek_scene(CTX_data_main(C), scene);
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
}
@@ -3501,9 +3496,10 @@ void CLIP_OT_stabilize_2d_set_rotation(wmOperatorType *ot)
/********************** clean tracks operator *********************/
-static int is_track_clean(MovieTrackingTrack *track, int frames, int del)
+static bool is_track_clean(MovieTrackingTrack *track, int frames, int del)
{
- int ok = 1, a, prev = -1, count = 0;
+ bool ok = true;
+ int a, prev = -1, count = 0;
MovieTrackingMarker *markers = track->markers, *new_markers = NULL;
int start_disabled = 0;
int markersnr = track->markersnr;
@@ -4059,7 +4055,7 @@ static int slide_plane_marker_modal(bContext *C, wmOperator *op, const wmEvent *
SlidePlaneMarkerData *data = (SlidePlaneMarkerData *) op->customdata;
float dx, dy, mdelta[2];
int next_corner_index, prev_corner_index, diag_corner_index;
- float *next_corner, *prev_corner, *diag_corner;
+ const float *next_corner, *prev_corner, *diag_corner;
float next_edge[2], prev_edge[2], next_diag_edge[2], prev_diag_edge[2];
switch (event->type) {
diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c
index ec3b10a008c..4d9c262e1ff 100644
--- a/source/blender/editors/space_clip/tracking_select.c
+++ b/source/blender/editors/space_clip/tracking_select.c
@@ -31,11 +31,7 @@
#include "MEM_guardedalloc.h"
-#include "DNA_camera_types.h"
-#include "DNA_constraint_types.h"
-#include "DNA_gpencil_types.h"
#include "DNA_movieclip_types.h"
-#include "DNA_object_types.h" /* SELECT */
#include "DNA_scene_types.h"
#include "BLI_utildefines.h"
@@ -43,27 +39,15 @@
#include "BLI_listbase.h"
#include "BLI_rect.h"
#include "BLI_lasso.h"
-#include "BLI_blenlib.h"
-#include "BKE_main.h"
#include "BKE_context.h"
-#include "BKE_constraint.h"
-#include "BKE_movieclip.h"
#include "BKE_tracking.h"
-#include "BKE_global.h"
-#include "BKE_depsgraph.h"
-#include "BKE_object.h"
-#include "BKE_report.h"
-#include "BKE_scene.h"
-#include "BKE_library.h"
-#include "BKE_sound.h"
#include "WM_api.h"
#include "WM_types.h"
#include "ED_screen.h"
#include "ED_clip.h"
-#include "ED_keyframing.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
@@ -174,8 +158,8 @@ static float dist_to_crns(float co[2], float pos[2], float crns[4][2])
{
float d1, d2, d3, d4;
float p[2] = {co[0] - pos[0], co[1] - pos[1]};
- float *v1 = crns[0], *v2 = crns[1];
- float *v3 = crns[2], *v4 = crns[3];
+ const float *v1 = crns[0], *v2 = crns[1];
+ const float *v3 = crns[2], *v4 = crns[3];
d1 = dist_squared_to_line_segment_v2(p, v1, v2);
d2 = dist_squared_to_line_segment_v2(p, v2, v3);
@@ -189,8 +173,8 @@ static float dist_to_crns(float co[2], float pos[2], float crns[4][2])
static float dist_to_crns_abs(float co[2], float corners[4][2])
{
float d1, d2, d3, d4;
- float *v1 = corners[0], *v2 = corners[1];
- float *v3 = corners[2], *v4 = corners[3];
+ const float *v1 = corners[0], *v2 = corners[1];
+ const float *v3 = corners[2], *v4 = corners[3];
d1 = dist_squared_to_line_segment_v2(co, v1, v2);
d2 = dist_squared_to_line_segment_v2(co, v2, v3);
diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c
index cb191d0b15e..635d5ea07fd 100644
--- a/source/blender/editors/space_console/console_draw.c
+++ b/source/blender/editors/space_console/console_draw.c
@@ -24,7 +24,6 @@
* \ingroup spconsole
*/
-
#include <math.h>
#include <stdlib.h>
#include <string.h>
@@ -39,16 +38,9 @@
#include "DNA_space_types.h"
#include "DNA_screen_types.h"
-#include "BKE_report.h"
-
-
#include "MEM_guardedalloc.h"
#include "BIF_gl.h"
-#include "BIF_glutil.h"
-
-#include "ED_datafiles.h"
-#include "ED_types.h"
#include "UI_interface.h"
#include "UI_resources.h"
diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c
index 213d9d79132..b8743d69762 100644
--- a/source/blender/editors/space_console/console_ops.c
+++ b/source/blender/editors/space_console/console_ops.c
@@ -43,7 +43,6 @@
#include "BLI_math.h"
#include "BKE_context.h"
-#include "BKE_text.h" /* only for character utility funcs */
#include "WM_api.h"
#include "WM_types.h"
@@ -554,7 +553,7 @@ static int console_delete_exec(bContext *C, wmOperator *op)
int stride;
const short type = RNA_enum_get(op->ptr, "type");
- int done = false;
+ bool done = false;
if (ci->len == 0) {
return OPERATOR_CANCELLED;
diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c
index 247fb997055..43313c7dd06 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -34,12 +34,10 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
-#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BKE_context.h"
#include "BKE_screen.h"
-#include "BKE_idcode.h"
#include "ED_space_api.h"
#include "ED_screen.h"
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 5c6678967b5..f0a84ef482e 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -34,7 +34,6 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
-#include "BLI_dynstr.h"
#include "BLI_fileops_types.h"
#ifdef WIN32
@@ -52,8 +51,6 @@
#include "BLF_translation.h"
#include "IMB_imbuf_types.h"
-
-#include "MEM_guardedalloc.h"
#include "DNA_userdef_types.h"
#include "DNA_windowmanager_types.h"
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 9c11fc712c8..1d3013bd8b4 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -69,18 +69,24 @@
#include <ctype.h>
/* ---------- FILE SELECTION ------------ */
-static FileSelection find_file_mouse_rect(SpaceFile *sfile, ARegion *ar, const rcti *rect)
+static FileSelection find_file_mouse_rect(SpaceFile *sfile, ARegion *ar, const rcti *rect_region)
{
FileSelection sel;
- float fxmin, fymin, fxmax, fymax;
View2D *v2d = &ar->v2d;
rcti rect_view;
+ rctf rect_view_fl;
+ rctf rect_region_fl;
- UI_view2d_region_to_view(v2d, rect->xmin, rect->ymin, &fxmin, &fymin);
- UI_view2d_region_to_view(v2d, rect->xmax, rect->ymax, &fxmax, &fymax);
+ BLI_rctf_rcti_copy(&rect_region_fl, rect_region);
- BLI_rcti_init(&rect_view, (int)(v2d->tot.xmin + fxmin), (int)(v2d->tot.xmin + fxmax), (int)(v2d->tot.ymax - fymin), (int)(v2d->tot.ymax - fymax));
+ UI_view2d_region_to_view_rctf(v2d, &rect_region_fl, &rect_view_fl);
+
+ BLI_rcti_init(&rect_view,
+ (int)(v2d->tot.xmin + rect_view_fl.xmin),
+ (int)(v2d->tot.xmin + rect_view_fl.xmax),
+ (int)(v2d->tot.ymax - rect_view_fl.ymin),
+ (int)(v2d->tot.ymax - rect_view_fl.ymax));
sel = ED_fileselect_layout_offset_rect(sfile->layout, &rect_view);
@@ -127,7 +133,7 @@ static void clamp_to_filelist(int numfiles, FileSelection *sel)
}
}
-static FileSelection file_selection_get(bContext *C, const rcti *rect, short fill)
+static FileSelection file_selection_get(bContext *C, const rcti *rect, bool fill)
{
ARegion *ar = CTX_wm_region(C);
SpaceFile *sfile = CTX_wm_space_file(C);
@@ -155,7 +161,7 @@ static FileSelection file_selection_get(bContext *C, const rcti *rect, short fil
return sel;
}
-static FileSelect file_select_do(bContext *C, int selected_idx, short do_diropen)
+static FileSelect file_select_do(bContext *C, int selected_idx, bool do_diropen)
{
FileSelect retval = FILE_SELECT_NOTHING;
SpaceFile *sfile = CTX_wm_space_file(C);
@@ -205,7 +211,7 @@ static FileSelect file_select_do(bContext *C, int selected_idx, short do_diropen
}
-static FileSelect file_select(bContext *C, const rcti *rect, FileSelType select, short fill, short do_diropen)
+static FileSelect file_select(bContext *C, const rcti *rect, FileSelType select, bool fill, bool do_diropen)
{
SpaceFile *sfile = CTX_wm_space_file(C);
FileSelect retval = FILE_SELECT_NOTHING;
@@ -851,7 +857,19 @@ int file_parent_exec(bContext *C, wmOperator *UNUSED(unused))
if (sfile->params) {
if (BLI_parent_dir(sfile->params->dir)) {
BLI_cleanup_dir(G.main->name, sfile->params->dir);
- file_change_dir(C, 0);
+ /* if not browsing in .blend file, we still want to check whether the path is a directory */
+ if (sfile->params->type == FILE_LOADLIB) {
+ char tdir[FILE_MAX], tgroup[FILE_MAX];
+ if (BLO_is_a_library(sfile->params->dir, tdir, tgroup)) {
+ file_change_dir(C, 0);
+ }
+ else {
+ file_change_dir(C, 1);
+ }
+ }
+ else {
+ file_change_dir(C, 1);
+ }
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
}
}
@@ -1042,7 +1060,7 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w
}
}
- ED_region_tag_redraw(CTX_wm_region(C));
+ ED_region_tag_redraw(ar);
/* and restore context */
CTX_wm_region_set(C, oldar);
@@ -1129,7 +1147,7 @@ int file_directory_new_exec(bContext *C, wmOperator *op)
BLI_strncpy(sfile->params->renamefile, name, FILE_MAXFILE);
/* set timer to smoothly view newly generated file */
- sfile->smoothscroll_timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER1, 1.0 / 1000.0); /* max 30 frs/sec */
+ sfile->smoothscroll_timer = WM_event_add_timer(wm, CTX_wm_window(C), TIMER1, 1.0 / 1000.0); /* max 30 frs/sec */
sfile->scroll_offset = 0;
/* reload dir to make sure we're seeing what's in the directory */
@@ -1200,10 +1218,30 @@ static void file_expand_directory(bContext *C)
sfile->params->dir[2] = '\\';
sfile->params->dir[3] = '\0';
}
+ else if (BLI_path_is_unc(sfile->params->dir)) {
+ BLI_cleanup_unc(sfile->params->dir, FILE_MAX_LIBEXTRA);
+ }
#endif
}
}
+#if defined(WIN32)
+static bool can_create_dir(const char *dir)
+{
+ /* for UNC paths we need to check whether the parent of the new
+ * directory is a proper directory itself and not a share or the
+ * UNC root (server name) itself. Calling BLI_is_dir does this
+ */
+ if (BLI_path_is_unc(dir)) {
+ char parent[PATH_MAX];
+ BLI_strncpy(parent, dir, PATH_MAX);
+ BLI_parent_dir(parent);
+ return BLI_is_dir(parent);
+ }
+ return true;
+}
+#endif
+
void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UNUSED(arg_but))
{
SpaceFile *sfile = CTX_wm_space_file(C);
@@ -1228,6 +1266,13 @@ void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UN
* placing cursor at the end */
/* UI_textbutton_activate_but(C, but); */
}
+#if defined(WIN32)
+ else if (!can_create_dir(sfile->params->dir)) {
+ const char *lastdir = folderlist_peeklastdir(sfile->folders_prev);
+ if (lastdir)
+ BLI_strncpy(sfile->params->dir, lastdir, sizeof(sfile->params->dir));
+ }
+#endif
else {
const char *lastdir = folderlist_peeklastdir(sfile->folders_prev);
diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c
index cb07db75a91..69789569912 100644
--- a/source/blender/editors/space_file/file_panels.c
+++ b/source/blender/editors/space_file/file_panels.c
@@ -58,7 +58,7 @@
static void file_panel_cb(bContext *C, void *arg_entry, void *UNUSED(arg_v))
{
PointerRNA ptr;
- char *entry = (char *)arg_entry;
+ const char *entry = (char *)arg_entry;
WM_operator_properties_create(&ptr, "FILE_OT_select_bookmark");
RNA_string_set(&ptr, "dir", entry);
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 15d177011c4..871abbda48a 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -46,7 +46,6 @@
#include "BLI_blenlib.h"
#include "BLI_linklist.h"
-#include "BLI_threads.h"
#include "BLI_utildefines.h"
#include "BLI_fileops_types.h"
@@ -94,8 +93,8 @@ typedef struct FileImage {
typedef struct ThumbnailJob {
ListBase loadimages;
- short *stop;
- short *do_update;
+ const short *stop;
+ const short *do_update;
struct FileList *filelist;
ReportList reports;
} ThumbnailJob;
@@ -1097,7 +1096,7 @@ void filelist_from_library(struct FileList *filelist)
filelist->filelist[0].type |= S_IFDIR;
for (i = 0, l = names; i < nnames; i++, l = l->next) {
- char *blockname = l->link;
+ const char *blockname = l->link;
filelist->filelist[i + 1].relname = BLI_strdup(blockname);
if (idcode) {
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 19947a9ffc9..e8371d7666b 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -45,7 +45,6 @@
# include <unistd.h>
# include <sys/times.h>
# include <dirent.h>
-# include <unistd.h>
#endif
#include "DNA_space_types.h"
@@ -55,8 +54,6 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
-#include "BLI_linklist.h"
-#include "BLI_dynstr.h"
#include "BLI_utildefines.h"
#include "BLI_fileops_types.h"
#include "BLI_fnmatch.h"
@@ -396,7 +393,7 @@ float file_shorten_string(char *string, float w, int front)
sw = file_string_width(string);
if (front == 1) {
- char *s = string;
+ const char *s = string;
BLI_strncpy(temp, "...", 4);
pad = file_string_width(temp);
while ((*s) && (sw + pad > w)) {
@@ -412,7 +409,7 @@ float file_shorten_string(char *string, float w, int front)
}
}
else {
- char *s = string;
+ const char *s = string;
while (sw > w) {
int slen = strlen(string);
string[slen - 1] = '\0';
diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c
index f6bc6f70f36..6284caf1456 100644
--- a/source/blender/editors/space_file/fsmenu.c
+++ b/source/blender/editors/space_file/fsmenu.c
@@ -37,12 +37,8 @@
#include "MEM_guardedalloc.h"
-#include "DNA_space_types.h" /* FILE_MAX */
-
#include "BLI_utildefines.h"
#include "BLI_blenlib.h"
-#include "BLI_linklist.h"
-#include "BLI_dynstr.h"
#ifdef WIN32
# include <windows.h> /* need to include windows.h so _WIN32_IE is defined */
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index c04f4a5627e..3a493c0338c 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -36,7 +36,6 @@
#include "BIF_gl.h"
#include "BLI_blenlib.h"
-#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BLI_fileops_types.h"
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c
index df2da0e78ed..8193008098e 100644
--- a/source/blender/editors/space_graph/graph_buttons.c
+++ b/source/blender/editors/space_graph/graph_buttons.c
@@ -255,6 +255,32 @@ static void graphedit_activekey_handles_cb(bContext *C, void *fcu_ptr, void *bez
graphedit_activekey_update_cb(C, fcu_ptr, bezt_ptr);
}
+/* update callback for editing coordinates of right handle in active keyframe properties
+ * NOTE: we cannot just do graphedit_activekey_handles_cb() due to "order of computation"
+ * weirdness (see calchandleNurb_intern() and T39911)
+ */
+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
+ * (i.e. it now acts as if we've just transforming the vert when it is selected by itself)
+ */
+ bezt->f1 = 0;
+ bezt->f3 = 1;
+
+ /* 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;
+}
+
static void graph_panel_key_properties(const bContext *C, Panel *pa)
{
bAnimListElem *ale;
@@ -342,20 +368,31 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa)
&bezt_ptr, "handle_left", 1, 0, 0, -1, -1, NULL);
uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
uiButSetUnitType(but, unit);
+
+ /* XXX: with label? */
+ but = uiDefButR(block, 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");
+ uiButSetFunc(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, NUM, B_REDR, "X:", 0, 0, UI_UNIT_X, UI_UNIT_Y,
&bezt_ptr, "handle_right", 0, 0, 0, -1, -1, NULL);
- uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
+ uiButSetFunc(but, graphedit_activekey_right_handle_coord_cb, fcu, bezt);
but = uiDefButR(block, NUM, B_REDR, "Y:", 0, 0, UI_UNIT_X, UI_UNIT_Y,
&bezt_ptr, "handle_right", 1, 0, 0, -1, -1, NULL);
- uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
+ uiButSetFunc(but, graphedit_activekey_right_handle_coord_cb, fcu, bezt);
uiButSetUnitType(but, unit);
+
+ /* XXX: with label? */
+ but = uiDefButR(block, 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");
+ uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
}
}
else {
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index e2b04476d46..83f87ebc174 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -32,26 +32,16 @@
#include <string.h>
#include <float.h>
-#ifndef _WIN32
-#include <unistd.h>
-#else
-#include <io.h>
-#endif
-
-
#include "BLI_blenlib.h"
-#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "DNA_anim_types.h"
-#include "DNA_object_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "DNA_windowmanager_types.h"
#include "DNA_userdef_types.h"
#include "BKE_context.h"
-#include "BKE_curve.h"
#include "BKE_fcurve.h"
@@ -215,7 +205,7 @@ static void draw_fcurve_vertices_handles(FCurve *fcu, SpaceIpo *sipo, View2D *v2
/* get view settings */
hsize = UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE) * U.pixelsize;
- UI_view2d_getscale(v2d, &xscale, &yscale);
+ UI_view2d_scale_get(v2d, &xscale, &yscale);
/* Compensate OGL scale sued for unit mapping, so circle will be circle, not ellipse */
yscale *= units_scale;
@@ -345,7 +335,7 @@ static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu)
for (sel = 0; sel < 2; sel++) {
BezTriple *bezt = fcu->bezt, *prevbezt = NULL;
int basecol = (sel) ? TH_HANDLE_SEL_FREE : TH_HANDLE_FREE;
- float *fp;
+ const float *fp;
unsigned char col[4];
for (b = 0; b < fcu->totvert; b++, prevbezt = bezt, bezt++) {
@@ -456,7 +446,7 @@ static void draw_fcurve_samples(SpaceIpo *sipo, ARegion *ar, FCurve *fcu)
/* get view settings */
hsize = UI_GetThemeValuef(TH_VERTEX_SIZE);
- UI_view2d_getscale(&ar->v2d, &xscale, &yscale);
+ UI_view2d_scale_get(&ar->v2d, &xscale, &yscale);
/* set vertex color */
if (fcu->flag & (FCURVE_ACTIVE | FCURVE_SELECTED)) UI_ThemeColor(TH_TEXT_HI);
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index c2053c15f95..364dd1d0344 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -46,7 +46,6 @@
#include "BLI_utildefines.h"
#include "DNA_anim_types.h"
-#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "RNA_access.h"
@@ -221,11 +220,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,
@@ -233,9 +232,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;
}
@@ -269,7 +268,7 @@ void GRAPH_OT_view_all(wmOperatorType *ot)
/* 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;
@@ -334,7 +333,7 @@ static void create_ghost_curves(bAnimContext *ac, int start, int end)
int cfra;
SpaceIpo *sipo = (SpaceIpo *) ac->sl;
short mapping_flag = ANIM_get_normalization_flags(ac);
-
+
/* disable driver so that it don't muck up the sampling process */
fcu->driver = NULL;
@@ -532,7 +531,7 @@ static int graphkeys_insertkey_exec(bContext *C, wmOperator *op)
ANIM_editkeyframes_refresh(&ac);
/* set notifier that keyframes have changed */
- WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
return OPERATOR_FINISHED;
}
@@ -839,7 +838,7 @@ static int graphkeys_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
ANIM_editkeyframes_refresh(&ac);
/* set notifier that keyframes have changed */
- WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
return OPERATOR_FINISHED;
}
@@ -924,7 +923,7 @@ static int graphkeys_delete_exec(bContext *C, wmOperator *UNUSED(op))
ANIM_editkeyframes_refresh(&ac);
/* set notifier that keyframes have changed */
- WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL);
return OPERATOR_FINISHED;
}
@@ -1661,7 +1660,7 @@ typedef struct tEulerFilter {
ID *id; /* ID-block which owns the channels */
FCurve *(fcurves[3]); /* 3 Pointers to F-Curves */
- char *rna_path; /* Pointer to one of the RNA Path's used by one of the 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)
@@ -1968,11 +1967,16 @@ static void snap_graph_keys(bAnimContext *ac, short mode)
/* snap keyframes */
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);
- float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, ale->key_data, mapping_flag);
-
- ked.f1 = cursor_value / unit_scale;
-
+
+ /* normalise cursor value (for normalised F-Curves display) */
+ if (mode == GRAPHKEYS_SNAP_VALUE) {
+ short mapping_flag = ANIM_get_normalization_flags(ac);
+ float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, ale->key_data, mapping_flag);
+
+ ked.f1 = cursor_value / unit_scale;
+ }
+
+ /* perform snapping */
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
@@ -2090,12 +2094,16 @@ static void mirror_graph_keys(bAnimContext *ac, short mode)
/* mirror keyframes */
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);
- float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, ale->key_data, mapping_flag | ANIM_UNITCONV_ONLYKEYS);
-
+
/* apply unit corrections */
- ked.f1 = cursor_value * unit_scale;
-
+ if (mode == GRAPHKEYS_MIRROR_VALUE) {
+ short mapping_flag = ANIM_get_normalization_flags(ac);
+ float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, ale->key_data, mapping_flag | ANIM_UNITCONV_ONLYKEYS);
+
+ ked.f1 = cursor_value * unit_scale;
+ }
+
+ /* perform actual mirroring */
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
@@ -2320,7 +2328,7 @@ static int graph_fmodifier_copy_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
bAnimListElem *ale;
- short ok = 0;
+ bool ok = false;
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
@@ -2394,7 +2402,7 @@ static int graph_fmodifier_paste_exec(bContext *C, wmOperator *op)
/* TODO: do we want to replace existing modifiers? add user pref for that! */
ok += ANIM_fmodifiers_paste_from_buf(&fcu->modifiers, 0);
}
-
+
/* clean up */
BLI_freelistN(&anim_data);
diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c
index 907bcc3154b..cfd82b67289 100644
--- a/source/blender/editors/space_graph/graph_ops.c
+++ b/source/blender/editors/space_graph/graph_ops.c
@@ -33,9 +33,7 @@
#include <math.h>
#include "DNA_scene_types.h"
-#include "DNA_anim_types.h"
-#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "BLI_math_base.h"
@@ -112,19 +110,27 @@ static int graphview_cursor_exec(bContext *C, wmOperator *op)
/* set the operator properties from the initial event */
static void graphview_cursor_setprops(bContext *C, wmOperator *op, const wmEvent *event)
{
+ Scene *scene = CTX_data_scene(C);
ARegion *ar = CTX_wm_region(C);
float viewx, viewy;
-
+ int frame;
+
/* 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 */
/* frame is rounded to the nearest int, since frames are ints */
- RNA_int_set(op->ptr, "frame", iroundf(viewx));
+ frame = iroundf(viewx);
+
+ if (scene->r.flag & SCER_LOCK_FRAME_SELECTION) {
+ CLAMP(frame, PSFRA, PEFRA);
+ }
+
+ /* store the values in the operator properties */
+ RNA_int_set(op->ptr, "frame", frame);
RNA_float_set(op->ptr, "value", viewy);
}
diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c
index 23bc8e94ef8..82eddfbe4a9 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -40,7 +40,6 @@
#include "BLI_lasso.h"
#include "DNA_anim_types.h"
-#include "DNA_object_types.h"
#include "DNA_screen_types.h"
#include "DNA_scene_types.h"
#include "DNA_space_types.h"
@@ -233,8 +232,7 @@ static void borderselect_graphkeys(
rctf rectf, scaled_rectf;
/* convert mouse coordinates to frame ranges and channel coordinates corrected for view pan/zoom */
- UI_view2d_region_to_view(v2d, rectf_view->xmin, rectf_view->ymin, &rectf.xmin, &rectf.ymin);
- UI_view2d_region_to_view(v2d, rectf_view->xmax, rectf_view->ymax, &rectf.xmax, &rectf.ymax);
+ UI_view2d_region_to_view_rctf(v2d, rectf_view, &rectf);
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
@@ -952,7 +950,7 @@ static int graphkeys_select_leftright_invoke(bContext *C, wmOperator *op, const
float x;
/* determine which side of the current frame mouse is on */
- UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, NULL);
+ x = UI_view2d_region_to_view_x(v2d, event->mval[0]);
if (x < CFRA)
RNA_enum_set(op->ptr, "mode", GRAPHKEYS_LRSEL_LEFT);
else
@@ -1036,7 +1034,9 @@ static bool fcurve_handle_sel_check(SpaceIpo *sipo, BezTriple *bezt)
/* check if the given vertex is within bounds or not */
// TODO: should we return if we hit something?
-static void nearest_fcurve_vert_store(ListBase *matches, View2D *v2d, FCurve *fcu, BezTriple *bezt, FPoint *fpt, short hpoint, const int mval[2], float unit_scale)
+static void nearest_fcurve_vert_store(
+ ListBase *matches, View2D *v2d, FCurve *fcu,
+ BezTriple *bezt, FPoint *fpt, short hpoint, const int mval[2], float unit_scale)
{
/* Keyframes or Samples? */
if (bezt) {
@@ -1047,17 +1047,14 @@ static void nearest_fcurve_vert_store(ListBase *matches, View2D *v2d, FCurve *fc
* needed to access the relevant vertex coordinates in the 3x3
* 'vec' matrix
*/
- UI_view2d_view_to_region(v2d, bezt->vec[hpoint + 1][0], bezt->vec[hpoint + 1][1] * unit_scale, &screen_co[0], &screen_co[1]);
-
- /* check if distance from mouse cursor to vert in screen space is within tolerance */
- // XXX: inlined distance calculation, since we cannot do this on ints using the math lib...
- //dist = len_v2v2(mval, screen_co);
- dist = sqrt((mval[0] - screen_co[0]) * (mval[0] - screen_co[0]) +
- (mval[1] - screen_co[1]) * (mval[1] - screen_co[1]));
-
- if (dist <= GVERTSEL_TOL) {
+ if (UI_view2d_view_to_region_clip(v2d,
+ bezt->vec[hpoint + 1][0], bezt->vec[hpoint + 1][1] * unit_scale,
+ &screen_co[0], &screen_co[1]) &&
+ /* check if distance from mouse cursor to vert in screen space is within tolerance */
+ ((dist = len_v2v2_int(mval, screen_co)) <= GVERTSEL_TOL))
+ {
tNearestVertInfo *nvi = (tNearestVertInfo *)matches->last;
- short replace = 0;
+ 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)) {
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c
index c7876bb44c4..c2b9d92d00a 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -30,24 +30,18 @@
#include <string.h>
#include <stdio.h>
-#include "DNA_meshdata_types.h"
-#include "DNA_object_types.h"
#include "DNA_node_types.h"
#include "DNA_scene_types.h"
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
-#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BLF_translation.h"
-#include "BKE_colortools.h"
#include "BKE_context.h"
-#include "BKE_customdata.h"
#include "BKE_image.h"
-#include "BKE_mesh.h"
#include "BKE_node.h"
#include "BKE_screen.h"
@@ -57,7 +51,6 @@
#include "IMB_imbuf_types.h"
#include "ED_gpencil.h"
-#include "ED_image.h"
#include "ED_screen.h"
#include "RNA_access.h"
@@ -839,7 +832,7 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, int color_man
const bool is_render_out = (id && GS(id->name) == ID_SCE);
uiLayout *col, *row, *split, *sub;
- int show_preview = false;
+ bool show_preview = false;
col = uiLayoutColumn(layout, false);
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index 27d2a19016d..016143f640b 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -74,9 +74,6 @@
#include "UI_resources.h"
#include "UI_view2d.h"
-#include "WM_api.h"
-#include "WM_types.h"
-
#include "RE_pipeline.h"
#include "RE_engine.h"
@@ -107,7 +104,7 @@ static void draw_render_info(Scene *scene, Image *ima, ARegion *ar, float zoomx,
rcti *tile;
/* find window pixel coordinates of origin */
- UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y);
+ UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x, &y);
glPushMatrix();
glTranslatef(x, y, 0.0f);
@@ -509,7 +506,7 @@ static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar,
glaDefine2DArea(&ar->winrct);
/* find window pixel coordinates of origin */
- UI_view2d_to_region_no_clip(&ar->v2d, fx, fy, &x, &y);
+ UI_view2d_view_to_region(&ar->v2d, fx, fy, &x, &y);
/* this part is generic image display */
if (sima->flag & SI_SHOW_ALPHA) {
@@ -600,7 +597,7 @@ static void draw_image_buffer_tiled(SpaceImage *sima, ARegion *ar, Scene *scene,
/* draw repeated */
for (sy = 0; sy + dy <= ibuf->y; sy += dy) {
for (sx = 0; sx + dx <= ibuf->x; sx += dx) {
- UI_view2d_to_region_no_clip(&ar->v2d, fx + (float)sx / (float)ibuf->x, fy + (float)sy / (float)ibuf->y, &x, &y);
+ UI_view2d_view_to_region(&ar->v2d, fx + (float)sx / (float)ibuf->x, fy + (float)sy / (float)ibuf->y, &x, &y);
glaDrawPixelsSafe(x, y, dx, dy, dx, GL_RGBA, GL_UNSIGNED_BYTE, rect);
}
@@ -779,7 +776,7 @@ static void draw_image_paint_helpers(const bContext *C, ARegion *ar, Scene *scen
clonerect = get_alpha_clone_image(C, scene, &w, &h);
if (clonerect) {
- UI_view2d_to_region_no_clip(&ar->v2d, brush->clone.offset[0], brush->clone.offset[1], &x, &y);
+ UI_view2d_view_to_region(&ar->v2d, brush->clone.offset[0], brush->clone.offset[1], &x, &y);
glPixelZoom(zoomx, zoomy);
@@ -885,7 +882,18 @@ void draw_image_main(const bContext *C, ARegion *ar)
/* render info */
if (ima && show_render)
- draw_render_info(scene, ima, ar, zoomx, zoomy);
+ draw_render_info(sima->iuser.scene, ima, ar, zoomx, zoomy);
+}
+
+static bool show_image_cache(Image *image, Mask *mask)
+{
+ if (image == NULL && mask == NULL) {
+ return false;
+ }
+ if (mask == NULL) {
+ return ELEM(image->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE);
+ }
+ return true;
}
void draw_image_cache(const bContext *C, ARegion *ar)
@@ -900,7 +908,7 @@ void draw_image_cache(const bContext *C, ARegion *ar)
mask = ED_space_image_get_mask(sima);
}
- if (image == NULL && mask == NULL) {
+ if (!show_image_cache(image, mask)) {
return;
}
diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c
index deabcfa85f4..a2f7d9e7d6c 100644
--- a/source/blender/editors/space_image/image_edit.c
+++ b/source/blender/editors/space_image/image_edit.c
@@ -32,13 +32,11 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
-#include "BLI_math.h"
#include "BLI_rect.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_image.h"
-#include "BKE_main.h"
#include "BKE_editmesh.h"
#include "BKE_library.h"
@@ -257,7 +255,7 @@ void ED_image_mouse_pos(SpaceImage *sima, ARegion *ar, const int mval[2], float
ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy);
ED_space_image_get_size(sima, &width, &height);
- UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy);
+ UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &sx, &sy);
co[0] = ((mval[0] - sx) / zoomx) / width;
co[1] = ((mval[1] - sy) / zoomy) / height;
@@ -271,7 +269,7 @@ void ED_image_point_pos(SpaceImage *sima, ARegion *ar, float x, float y, float *
ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy);
ED_space_image_get_size(sima, &width, &height);
- UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy);
+ UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &sx, &sy);
*xr = ((x - sx) / zoomx) / width;
*yr = ((y - sy) / zoomy) / height;
@@ -283,7 +281,7 @@ void ED_image_point_pos__reverse(SpaceImage *sima, ARegion *ar, const float co[2
int width, height;
int sx, sy;
- UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy);
+ UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &sx, &sy);
ED_space_image_get_size(sima, &width, &height);
ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy);
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index c9dda074667..57be15f23fb 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -53,7 +53,6 @@
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_main.h"
-#include "BKE_node.h"
#include "BKE_packedFile.h"
#include "BKE_report.h"
#include "BKE_screen.h"
@@ -157,7 +156,7 @@ static int space_image_file_exists_poll(bContext *C)
SpaceImage *sima = CTX_wm_space_image(C);
ImBuf *ibuf;
void *lock;
- int ret = false;
+ bool ret = false;
char name[FILE_MAX];
ibuf = ED_space_image_acquire_buffer(sima, &lock);
@@ -440,7 +439,7 @@ static int image_view_zoom_exec(bContext *C, wmOperator *op)
sima_zoom_set_factor(sima, ar, RNA_float_get(op->ptr, "factor"), NULL);
- ED_region_tag_redraw(CTX_wm_region(C));
+ ED_region_tag_redraw(ar);
/* XXX notifier? */
#if 0
@@ -477,7 +476,7 @@ static int image_view_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev
factor = 1.0f + delta / 300.0f;
RNA_float_set(op->ptr, "factor", factor);
sima_zoom_set(sima, ar, sima->zoom * factor, location);
- ED_region_tag_redraw(CTX_wm_region(C));
+ ED_region_tag_redraw(ar);
return OPERATOR_FINISHED;
}
@@ -685,7 +684,7 @@ static int image_view_all_exec(bContext *C, wmOperator *op)
sima->xof = sima->yof = 0.0f;
- ED_region_tag_redraw(CTX_wm_region(C));
+ ED_region_tag_redraw(ar);
return OPERATOR_FINISHED;
}
@@ -748,7 +747,7 @@ static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
if (size <= 0.01f) size = 0.01f;
sima_zoom_set(sima, ar, 0.7f / size, NULL);
- ED_region_tag_redraw(CTX_wm_region(C));
+ ED_region_tag_redraw(ar);
return OPERATOR_FINISHED;
}
@@ -782,7 +781,7 @@ static int image_view_zoom_in_exec(bContext *C, wmOperator *op)
sima_zoom_set_factor(sima, ar, powf(2.0f, 1.0f / 3.0f), location);
- ED_region_tag_redraw(CTX_wm_region(C));
+ ED_region_tag_redraw(ar);
return OPERATOR_FINISHED;
}
@@ -827,7 +826,7 @@ static int image_view_zoom_out_exec(bContext *C, wmOperator *op)
sima_zoom_set_factor(sima, ar, powf(0.5f, 1.0f / 3.0f), location);
- ED_region_tag_redraw(CTX_wm_region(C));
+ ED_region_tag_redraw(ar);
return OPERATOR_FINISHED;
}
@@ -884,7 +883,7 @@ static int image_view_zoom_ratio_exec(bContext *C, wmOperator *op)
}
#endif
- ED_region_tag_redraw(CTX_wm_region(C));
+ ED_region_tag_redraw(ar);
return OPERATOR_FINISHED;
}
@@ -1125,7 +1124,7 @@ static int image_open_exec(bContext *C, wmOperator *op)
static int image_open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
SpaceImage *sima = CTX_wm_space_image(C); /* XXX other space types can call */
- char *path = U.textudir;
+ const char *path = U.textudir;
Image *ima = NULL;
if (sima) {
@@ -1449,13 +1448,16 @@ static void save_image_options_to_op(SaveImageOptions *simopts, wmOperator *op)
RNA_string_set(op->ptr, "filepath", simopts->filepath);
}
-/* assumes name is FILE_MAX */
-/* ima->name and ibuf->name should end up the same */
-static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveImageOptions *simopts, int do_newpath)
+/**
+ * \return success.
+ * \note ``ima->name`` and ``ibuf->name`` should end up the same.
+ */
+static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveImageOptions *simopts, bool do_newpath)
{
Image *ima = ED_space_image(sima);
void *lock;
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
+ bool ok = false;
if (ibuf) {
ImBuf *colormanaged_ibuf;
@@ -1464,7 +1466,6 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
const bool save_copy = (RNA_struct_find_property(op->ptr, "copy") && RNA_boolean_get(op->ptr, "copy"));
const bool save_as_render = (RNA_struct_find_property(op->ptr, "save_as_render") && RNA_boolean_get(op->ptr, "save_as_render"));
ImageFormatData *imf = &simopts->im_format;
- bool ok = false;
/* old global to ensure a 2nd save goes to same dir */
BLI_strncpy(G.ima, simopts->filepath, sizeof(G.ima));
@@ -1494,8 +1495,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
Scene *scene = CTX_data_scene(C);
RenderResult *rr = BKE_image_acquire_renderresult(scene, ima);
if (rr) {
- RE_WriteRenderResult(op->reports, rr, simopts->filepath, simopts->im_format.exr_codec);
- ok = true;
+ ok = RE_WriteRenderResult(op->reports, rr, simopts->filepath, simopts->im_format.exr_codec);
}
else {
BKE_report(op->reports, RPT_ERROR, "Did not write, no Multilayer Image");
@@ -1503,9 +1503,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
BKE_image_release_renderresult(scene, ima);
}
else {
- if (BKE_imbuf_write_as(colormanaged_ibuf, simopts->filepath, &simopts->im_format, save_copy)) {
- ok = true;
- }
+ ok = BKE_imbuf_write_as(colormanaged_ibuf, simopts->filepath, &simopts->im_format, save_copy);
}
if (ok) {
@@ -1568,6 +1566,8 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
}
ED_space_image_release_buffer(sima, ibuf, lock);
+
+ return ok;
}
static void image_save_as_free(wmOperator *op)
@@ -1731,7 +1731,10 @@ static int image_save_exec(bContext *C, wmOperator *op)
save_image_options_from_op(&simopts, op);
if (BLI_exists(simopts.filepath) && BLI_file_is_writable(simopts.filepath)) {
- save_image_doit(C, sima, op, &simopts, false);
+ if (save_image_doit(C, sima, op, &simopts, false)) {
+ /* report since this can be called from key-shortcuts */
+ BKE_reportf(op->reports, RPT_INFO, "Saved Image '%s'", simopts.filepath);
+ }
}
else {
BKE_reportf(op->reports, RPT_ERROR, "Cannot save image, path '%s' is not writable", simopts.filepath);
@@ -2300,7 +2303,7 @@ typedef struct ImageSampleInfo {
float zf;
unsigned char *colp;
- float *colfp;
+ const float *colfp;
int *zp;
float *zfp;
@@ -2320,10 +2323,11 @@ static void image_sample_draw(const bContext *C, ARegion *ar, void *arg_info)
}
}
-/* returns color in SRGB */
-/* matching ED_space_node_color_sample() */
-bool ED_space_image_color_sample(SpaceImage *sima, ARegion *ar, int mval[2], float r_col[3])
+/* Returns color in the display space, matching ED_space_node_color_sample(). */
+bool ED_space_image_color_sample(Scene *scene, SpaceImage *sima, ARegion *ar, int mval[2], float r_col[3])
{
+ const char *display_device = scene->display_settings.display_device;
+ struct ColorManagedDisplay *display = IMB_colormanagement_display_get_named(display_device);
void *lock;
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
float fx, fy;
@@ -2337,7 +2341,7 @@ bool ED_space_image_color_sample(SpaceImage *sima, ARegion *ar, int mval[2], flo
UI_view2d_region_to_view(&ar->v2d, mval[0], mval[1], &fx, &fy);
if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) {
- float *fp;
+ const float *fp;
unsigned char *cp;
int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y);
@@ -2346,16 +2350,21 @@ bool ED_space_image_color_sample(SpaceImage *sima, ARegion *ar, int mval[2], flo
if (ibuf->rect_float) {
fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
- linearrgb_to_srgb_v3_v3(r_col, fp);
+ copy_v3_v3(r_col, fp);
ret = true;
}
else if (ibuf->rect) {
cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x);
rgb_uchar_to_float(r_col, cp);
+ IMB_colormanagement_colorspace_to_scene_linear_v3(r_col, ibuf->rect_colorspace);
ret = true;
}
}
+ if (ret) {
+ IMB_colormanagement_scene_linear_to_display_v3(r_col, display);
+ }
+
ED_space_image_release_buffer(sima, ibuf, lock);
return ret;
}
@@ -2380,7 +2389,7 @@ static void image_sample_apply(bContext *C, wmOperator *op, const wmEvent *event
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fx, &fy);
if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) {
- float *fp;
+ const float *fp;
unsigned char *cp;
int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y);
Image *image = ED_space_image(sima);
@@ -2895,7 +2904,7 @@ static void change_frame_apply(bContext *C, wmOperator *op)
SUBFRA = 0.0f;
/* do updates */
- sound_seek_scene(CTX_data_main(C), CTX_data_scene(C));
+ sound_seek_scene(CTX_data_main(C), scene);
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
}
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 6419baab425..f60705ca52a 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -43,12 +43,8 @@
#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BKE_image.h"
-#include "BKE_global.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
-#include "BKE_editmesh.h"
-#include "BKE_sequencer.h"
-#include "BKE_node.h"
#include "IMB_imbuf_types.h"
diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c
index 575f44b61a9..86af89bd6a9 100644
--- a/source/blender/editors/space_info/info_draw.c
+++ b/source/blender/editors/space_info/info_draw.c
@@ -27,8 +27,6 @@
* \ingroup spinfo
*/
-
-
#include <math.h>
#include <stdlib.h>
#include <string.h>
@@ -37,7 +35,6 @@
#include "BLF_api.h"
-#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "DNA_space_types.h"
@@ -46,11 +43,7 @@
// #include "BKE_suggestions.h"
#include "BKE_report.h"
-
-#include "MEM_guardedalloc.h"
-
#include "BIF_gl.h"
-#include "BIF_glutil.h"
#include "ED_datafiles.h"
#include "ED_types.h"
diff --git a/source/blender/editors/space_info/info_report.c b/source/blender/editors/space_info/info_report.c
index 2135166abe9..0cc01646e82 100644
--- a/source/blender/editors/space_info/info_report.c
+++ b/source/blender/editors/space_info/info_report.c
@@ -41,7 +41,6 @@
#include "WM_types.h"
#include "ED_screen.h"
-#include "ED_types.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -236,15 +235,6 @@ static int borderselect_exec(bContext *C, wmOperator *op)
WM_operator_properties_border_to_rcti(op, &rect);
-#if 0
- mval[0] = rect.xmin;
- mval[1] = rect.ymin;
- UI_view2d_region_to_view(v2d, mval[0], mval[1], &rectf.xmin, &rectf.ymin);
- mval[0] = rect.xmax;
- mval[1] = rect.ymax;
- UI_view2d_region_to_view(v2d, mval[0], mval[1], &rectf.xmax, &rectf.ymax);
-#endif
-
if (!extend) {
for (report = reports->list.first; report; report = report->next) {
diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c
index 1fd47219463..8664ebf30b7 100644
--- a/source/blender/editors/space_info/info_stats.c
+++ b/source/blender/editors/space_info/info_stats.c
@@ -34,7 +34,6 @@
#include "DNA_curve_types.h"
#include "DNA_group_types.h"
#include "DNA_lattice_types.h"
-#include "DNA_mesh_types.h"
#include "DNA_meta_types.h"
#include "DNA_scene_types.h"
@@ -50,14 +49,12 @@
#include "BKE_displist.h"
#include "BKE_DerivedMesh.h"
#include "BKE_key.h"
-#include "BKE_mesh.h"
#include "BKE_paint.h"
#include "BKE_particle.h"
#include "BKE_editmesh.h"
#include "ED_info.h"
#include "ED_armature.h"
-#include "ED_mesh.h"
#define MAX_INFO_LEN 512
diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c
index f23e50a8650..062fc0cd42e 100644
--- a/source/blender/editors/space_info/space_info.c
+++ b/source/blender/editors/space_info/space_info.c
@@ -35,7 +35,6 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
-#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BLF_translation.h"
diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c
index 879c99c35d5..c09c684ac7a 100644
--- a/source/blender/editors/space_info/textview.c
+++ b/source/blender/editors/space_info/textview.c
@@ -40,12 +40,9 @@
#include "BLI_string_utf8.h"
#include "BIF_gl.h"
-#include "BIF_glutil.h"
#include "BKE_text.h"
-#include "ED_datafiles.h"
-
#include "textview.h"
static void console_font_begin(TextViewContext *sc)
@@ -64,7 +61,7 @@ typedef struct ConsoleDrawContext {
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 *mval; // [2]
+ const int *mval; // [2]
int draw;
} ConsoleDrawContext;
diff --git a/source/blender/editors/space_logic/logic_ops.c b/source/blender/editors/space_logic/logic_ops.c
index 5fe3c57a4c8..62703ba517e 100644
--- a/source/blender/editors/space_logic/logic_ops.c
+++ b/source/blender/editors/space_logic/logic_ops.c
@@ -42,7 +42,6 @@
#include "BKE_context.h"
#include "BKE_main.h"
#include "BKE_sca.h"
-#include "BKE_material.h" //for texface convert
#include "ED_logic.h"
#include "ED_object.h"
@@ -59,11 +58,6 @@
#include "logic_intern.h"
-// temporary new includes for texface functions
-#include "DNA_mesh_types.h"
-#include "DNA_material_types.h"
-#include "DNA_meshdata_types.h"
-
/* ************* Generic Operator Helpers ************* */
static int edit_sensor_poll(bContext *C)
{
diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c
index d1164c61869..4b533292a95 100644
--- a/source/blender/editors/space_logic/logic_window.c
+++ b/source/blender/editors/space_logic/logic_window.c
@@ -42,7 +42,6 @@
#include "DNA_screen_types.h"
#include "DNA_sensor_types.h"
#include "DNA_constraint_types.h"
-#include "DNA_windowmanager_types.h"
#include "DNA_object_types.h"
#include "MEM_guardedalloc.h"
@@ -52,18 +51,11 @@
#include "BKE_action.h"
#include "BKE_context.h"
-#include "BKE_global.h"
-#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_sca.h"
-#include "BKE_screen.h"
#include "ED_util.h"
-#include "WM_types.h"
-
-#include "BIF_gl.h"
-
#include "BLF_translation.h"
#include "UI_interface.h"
@@ -121,7 +113,7 @@ void make_unique_prop_names(bContext *C, char *str)
bActuator *act;
ID **idar;
short a, obcount, propcount=0, nr;
- char **names;
+ const char **names;
/* this function is called by a Button, and gives the current
* stringpointer as an argument, this is the one that can change
@@ -454,7 +446,7 @@ static const char *sensor_name(int type)
case SENS_JOYSTICK:
return N_("Joystick");
}
- return N_("unknown");
+ return N_("Unknown");
}
static const char *controller_name(int type)
@@ -477,7 +469,7 @@ static const char *controller_name(int type)
case CONT_PYTHON:
return N_("Python");
}
- return N_("unknown");
+ return N_("Unknown");
}
static const char *actuator_name(int type)
@@ -528,7 +520,7 @@ static const char *actuator_name(int type)
case ACT_STEERING:
return N_("Steering");
}
- return N_("unknown");
+ return N_("Unknown");
}
static void set_sca_ob(Object *ob)
@@ -922,7 +914,7 @@ static uiBlock *controller_state_mask_menu(bContext *C, ARegion *ar, void *arg_c
return block;
}
-static int is_sensor_linked(uiBlock *block, bSensor *sens)
+static bool is_sensor_linked(uiBlock *block, bSensor *sens)
{
bController *cont;
int i;
@@ -945,28 +937,37 @@ static void draw_sensor_header(uiLayout *layout, PointerRNA *ptr, PointerRNA *lo
box = uiLayoutBox(layout);
row = uiLayoutRow(box, false);
- uiItemR(row, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE);
+ sub = uiLayoutRow(row, false);
+ uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
+ uiItemR(sub, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE);
if (RNA_boolean_get(ptr, "show_expanded")) {
- uiItemR(row, ptr, "type", 0, "", ICON_NONE);
- uiItemR(row, ptr, "name", 0, "", ICON_NONE);
+ uiItemR(sub, ptr, "type", 0, "", ICON_NONE);
+ uiItemR(sub, ptr, "name", 0, "", ICON_NONE);
}
else {
- uiItemL(row, IFACE_(sensor_name(sens->type)), ICON_NONE);
- uiItemL(row, sens->name, ICON_NONE);
+ uiItemL(sub, IFACE_(sensor_name(sens->type)), ICON_NONE);
+ uiItemL(sub, sens->name, ICON_NONE);
}
sub = uiLayoutRow(row, false);
- uiLayoutSetActive(sub, ((RNA_boolean_get(logic_ptr, "show_sensors_active_states") &&
- RNA_boolean_get(ptr, "show_expanded")) || RNA_boolean_get(ptr, "pin")));
+ uiLayoutSetActive(sub, (((RNA_boolean_get(logic_ptr, "show_sensors_active_states") &&
+ RNA_boolean_get(ptr, "show_expanded")) || RNA_boolean_get(ptr, "pin")) &&
+ RNA_boolean_get(ptr, "active")));
uiItemR(sub, ptr, "pin", UI_ITEM_R_NO_BG, "", ICON_NONE);
if (RNA_boolean_get(ptr, "show_expanded")==0) {
sub = uiLayoutRow(row, true);
+ uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
uiItemEnumO(sub, "LOGIC_OT_sensor_move", "", ICON_TRIA_UP, "direction", 1); // up
uiItemEnumO(sub, "LOGIC_OT_sensor_move", "", ICON_TRIA_DOWN, "direction", 2); // down
}
- uiItemO(row, "", ICON_X, "LOGIC_OT_sensor_remove");
+ sub = uiLayoutRow(row, false);
+ uiItemR(sub, ptr, "active", 0, "", ICON_NONE);
+
+ sub = uiLayoutRow(row, false);
+ uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
+ uiItemO(sub, "", ICON_X, "LOGIC_OT_sensor_remove");
}
static void draw_sensor_internal_header(uiLayout *layout, PointerRNA *ptr)
@@ -974,6 +975,7 @@ static void draw_sensor_internal_header(uiLayout *layout, PointerRNA *ptr)
uiLayout *box, *split, *sub, *row;
box = uiLayoutBox(layout);
+ uiLayoutSetActive(box, RNA_boolean_get(ptr, "active"));
split = uiLayoutSplit(box, 0.45f, false);
row = uiLayoutRow(split, true);
@@ -1241,6 +1243,7 @@ static void draw_brick_sensor(uiLayout *layout, PointerRNA *ptr, bContext *C)
draw_sensor_internal_header(layout, ptr);
box = uiLayoutBox(layout);
+ uiLayoutSetActive(box, RNA_boolean_get(ptr, "active"));
switch (RNA_enum_get(ptr, "type")) {
@@ -1300,27 +1303,38 @@ static void draw_controller_header(uiLayout *layout, PointerRNA *ptr, int xco, i
box = uiLayoutBox(layout);
row = uiLayoutRow(box, false);
- uiItemR(row, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE);
+ sub = uiLayoutRow(row, false);
+ uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
+ uiItemR(sub, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE);
if (RNA_boolean_get(ptr, "show_expanded")) {
- uiItemR(row, ptr, "type", 0, "", ICON_NONE);
- uiItemR(row, ptr, "name", 0, "", ICON_NONE);
+ uiItemR(sub, ptr, "type", 0, "", ICON_NONE);
+ uiItemR(sub, ptr, "name", 0, "", ICON_NONE);
/* XXX provisory for Blender 2.50Beta */
uiDefBlockBut(uiLayoutGetBlock(layout), controller_state_mask_menu, cont, state, (short)(xco+width-44), yco, 22+22, UI_UNIT_Y, IFACE_("Set controller state index (from 1 to 30)"));
}
else {
- uiItemL(row, IFACE_(controller_name(cont->type)), ICON_NONE);
- uiItemL(row, cont->name, ICON_NONE);
- uiItemL(row, state, ICON_NONE);
+ uiItemL(sub, IFACE_(controller_name(cont->type)), ICON_NONE);
+ uiItemL(sub, cont->name, ICON_NONE);
+ uiItemL(sub, state, ICON_NONE);
}
- uiItemR(row, ptr, "use_priority", 0, "", ICON_NONE);
+ sub = uiLayoutRow(row, false);
+ uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
+ uiItemR(sub, ptr, "use_priority", 0, "", ICON_NONE);
if (RNA_boolean_get(ptr, "show_expanded")==0) {
sub = uiLayoutRow(row, true);
+ uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
uiItemEnumO(sub, "LOGIC_OT_controller_move", "", ICON_TRIA_UP, "direction", 1); // up
uiItemEnumO(sub, "LOGIC_OT_controller_move", "", ICON_TRIA_DOWN, "direction", 2); // down
}
- uiItemO(row, "", ICON_X, "LOGIC_OT_controller_remove");
+
+ sub = uiLayoutRow(row, false);
+ uiItemR(sub, ptr, "active", 0, "", ICON_NONE);
+
+ sub = uiLayoutRow(row, false);
+ uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
+ uiItemO(sub, "", ICON_X, "LOGIC_OT_controller_remove");
}
static void draw_controller_expression(uiLayout *layout, PointerRNA *ptr)
@@ -1357,6 +1371,7 @@ static void draw_brick_controller(uiLayout *layout, PointerRNA *ptr)
return;
box = uiLayoutBox(layout);
+ uiLayoutSetActive(box, RNA_boolean_get(ptr, "active"));
draw_controller_state(box, ptr);
@@ -1390,28 +1405,38 @@ static void draw_actuator_header(uiLayout *layout, PointerRNA *ptr, PointerRNA *
box = uiLayoutBox(layout);
row = uiLayoutRow(box, false);
-
- uiItemR(row, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE);
+
+ sub = uiLayoutRow(row, false);
+ uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
+ uiItemR(sub, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE);
if (RNA_boolean_get(ptr, "show_expanded")) {
- uiItemR(row, ptr, "type", 0, "", ICON_NONE);
- uiItemR(row, ptr, "name", 0, "", ICON_NONE);
+ uiItemR(sub, ptr, "type", 0, "", ICON_NONE);
+ uiItemR(sub, ptr, "name", 0, "", ICON_NONE);
}
else {
- uiItemL(row, IFACE_(actuator_name(act->type)), ICON_NONE);
- uiItemL(row, act->name, ICON_NONE);
+ uiItemL(sub, IFACE_(actuator_name(act->type)), ICON_NONE);
+ uiItemL(sub, act->name, ICON_NONE);
}
sub = uiLayoutRow(row, false);
- uiLayoutSetActive(sub, ((RNA_boolean_get(logic_ptr, "show_actuators_active_states") &&
- RNA_boolean_get(ptr, "show_expanded")) || RNA_boolean_get(ptr, "pin")));
+ uiLayoutSetActive(sub, (((RNA_boolean_get(logic_ptr, "show_actuators_active_states") &&
+ RNA_boolean_get(ptr, "show_expanded")) || RNA_boolean_get(ptr, "pin")) &&
+ RNA_boolean_get(ptr, "active")));
uiItemR(sub, ptr, "pin", UI_ITEM_R_NO_BG, "", ICON_NONE);
if (RNA_boolean_get(ptr, "show_expanded")==0) {
sub = uiLayoutRow(row, true);
+ uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
uiItemEnumO(sub, "LOGIC_OT_actuator_move", "", ICON_TRIA_UP, "direction", 1); // up
uiItemEnumO(sub, "LOGIC_OT_actuator_move", "", ICON_TRIA_DOWN, "direction", 2); // down
}
- uiItemO(row, "", ICON_X, "LOGIC_OT_actuator_remove");
+
+ sub = uiLayoutRow(row, false);
+ uiItemR(sub, ptr, "active", 0, "", ICON_NONE);
+
+ sub = uiLayoutRow(row, false);
+ uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
+ uiItemO(sub, "", ICON_X, "LOGIC_OT_actuator_remove");
}
static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr)
@@ -2160,6 +2185,7 @@ static void draw_brick_actuator(uiLayout *layout, PointerRNA *ptr, bContext *C)
return;
box = uiLayoutBox(layout);
+ uiLayoutSetActive(box, RNA_boolean_get(ptr, "active"));
switch (RNA_enum_get(ptr, "type")) {
case ACT_ACTION:
@@ -2361,8 +2387,12 @@ void logic_buttons(bContext *C, ARegion *ar)
/* put inlink button to the left */
col = uiLayoutColumn(split, false);
+ uiLayoutSetActive(col, RNA_boolean_get(&ptr, "active"));
uiLayoutSetAlignment(col, UI_LAYOUT_ALIGN_LEFT);
- uiDefIconBut(block, INLINK, 0, ICON_INLINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, cont, LINK_CONTROLLER, 0, 0, 0, "");
+ but = uiDefIconBut(block, INLINK, 0, ICON_INLINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, cont, LINK_CONTROLLER, 0, 0, 0, "");
+ if (!RNA_boolean_get(&ptr, "active")) {
+ uiButSetFlag(but, UI_BUT_SCA_LINK_GREY);
+ }
//col = uiLayoutColumn(split, true);
/* nested split for middle and right columns */
@@ -2378,12 +2408,17 @@ void logic_buttons(bContext *C, ARegion *ar)
/* draw the brick contents */
draw_brick_controller(col, &ptr);
-
/* put link button to the right */
col = uiLayoutColumn(subsplit, false);
+ uiLayoutSetActive(col, RNA_boolean_get(&ptr, "active"));
uiLayoutSetAlignment(col, UI_LAYOUT_ALIGN_LEFT);
but = uiDefIconBut(block, LINK, 0, ICON_LINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
+ if (!RNA_boolean_get(&ptr, "active")) {
+ uiButSetFlag(but, UI_BUT_SCA_LINK_GREY);
+ }
+
uiSetButLink(but, NULL, (void ***)&(cont->links), &cont->totlinks, LINK_CONTROLLER, LINK_ACTUATOR);
+
}
}
uiBlockLayoutResolve(block, NULL, &yco); /* stores final height in yco */
@@ -2433,7 +2468,7 @@ void logic_buttons(bContext *C, ARegion *ar)
)
{ // gotta check if the current state is visible or not
uiLayout *split, *col;
-
+
/* make as visible, for move operator */
sens->flag |= SENS_VISIBLE;
@@ -2449,9 +2484,14 @@ void logic_buttons(bContext *C, ARegion *ar)
/* put link button to the right */
col = uiLayoutColumn(split, false);
- /* use old-school uiButtons for links for now */
+ uiLayoutSetActive(col, RNA_boolean_get(&ptr, "active"));
but = uiDefIconBut(block, LINK, 0, ICON_LINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
- uiSetButLink(but, NULL, (void ***)&(sens->links), &sens->totlinks, LINK_SENSOR, LINK_CONTROLLER);
+ if (!RNA_boolean_get(&ptr, "active")) {
+ uiButSetFlag(but, UI_BUT_SCA_LINK_GREY);
+ }
+
+ /* use old-school uiButtons for links for now */
+ uiSetButLink(but, NULL, (void ***)&sens->links, &sens->totlinks, LINK_SENSOR, LINK_CONTROLLER);
}
}
}
@@ -2513,7 +2553,11 @@ void logic_buttons(bContext *C, ARegion *ar)
/* put inlink button to the left */
col = uiLayoutColumn(split, false);
- uiDefIconBut(block, INLINK, 0, ICON_INLINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, act, LINK_ACTUATOR, 0, 0, 0, "");
+ uiLayoutSetActive(col, RNA_boolean_get(&ptr, "active"));
+ but = uiDefIconBut(block, INLINK, 0, ICON_INLINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, act, LINK_ACTUATOR, 0, 0, 0, "");
+ if (!RNA_boolean_get(&ptr, "active")) {
+ uiButSetFlag(but, UI_BUT_SCA_LINK_GREY);
+ }
col = uiLayoutColumn(split, true);
uiLayoutSetContextPointer(col, "actuator", &ptr);
diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c
index daeab030990..733cac7794e 100644
--- a/source/blender/editors/space_logic/space_logic.c
+++ b/source/blender/editors/space_logic/space_logic.c
@@ -36,7 +36,6 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
-#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BKE_context.h"
diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c
index 0c4f08c9199..808bd622c0d 100644
--- a/source/blender/editors/space_nla/nla_buttons.c
+++ b/source/blender/editors/space_nla/nla_buttons.c
@@ -40,7 +40,6 @@
#include "MEM_guardedalloc.h"
-#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLF_translation.h"
@@ -81,19 +80,19 @@ static void do_nla_region_buttons(bContext *C, void *UNUSED(arg), int UNUSED(eve
WM_event_add_notifier(C, NC_SCENE | ND_TRANSFORM, NULL);
}
-static int nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA *nlt_ptr, PointerRNA *strip_ptr)
+bool nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA *nlt_ptr, PointerRNA *strip_ptr)
{
bAnimContext ac;
bAnimListElem *ale = NULL;
ListBase anim_data = {NULL, NULL};
- short found = 0;
+ 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)
* to work correctly is able to be correctly retrieved. There's no point showing empty panels?
*/
if (ANIM_animdata_get_context(C, &ac) == 0)
- return 0;
+ return false;
/* 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
@@ -177,7 +176,7 @@ static int nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA
/* free temp data */
BLI_freelistN(&anim_data);
- return found;
+ return (found != 0);
}
#if 0
diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c
index 1f2fe6b1ecf..16572f1790b 100644
--- a/source/blender/editors/space_nla/nla_channels.c
+++ b/source/blender/editors/space_nla/nla_channels.c
@@ -39,7 +39,6 @@
#include "DNA_scene_types.h"
#include "BLI_blenlib.h"
-#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BKE_animsys.h"
@@ -399,6 +398,106 @@ void NLA_OT_channels_click(wmOperatorType *ot)
/* *********************************************** */
/* Special Operators */
+/* ******************** Action Push Down ******************************** */
+
+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. "
+ "Select a datablock expander first or set the appropriate flags on an AnimData block");
+ return OPERATOR_CANCELLED;
+ }
+ else {
+ adt = adt_ptr.data;
+ }
+ }
+ else {
+ /* indexed channel */
+ 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) {
+ BKE_reportf(op->reports, RPT_ERROR, "No animation channel found at index = %d", channel_index);
+ BLI_freelistN(&anim_data);
+ return OPERATOR_CANCELLED;
+ }
+ else if (ale->type != ANIMTYPE_NLAACTION) {
+ BKE_reportf(op->reports, RPT_ERROR, "Animation channel at index = %d is not a NLA 'Active Action' channel", channel_index);
+ BLI_freelistN(&anim_data);
+ return OPERATOR_CANCELLED;
+ }
+
+ /* grab AnimData from the channel */
+ adt = ale->adt;
+
+ /* we don't need anything here anymore, so free it all */
+ BLI_freelistN(&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");
+ return OPERATOR_CANCELLED;
+ }
+ else if (nlaedit_is_tweakmode_on(&ac)) {
+ BKE_report(op->reports, RPT_WARNING, "Cannot push down actions while tweaking a strip's action. Exit tweakmode first");
+ return OPERATOR_CANCELLED;
+ }
+ else if (adt->action == NULL) {
+ BKE_report(op->reports, RPT_WARNING, "No active action to push down");
+ return OPERATOR_CANCELLED;
+ }
+ else {
+ /* '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;
+}
+
+void NLA_OT_action_pushdown(wmOperatorType *ot)
+{
+ /* identifiers */
+ 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",
+ 0, INT_MAX);
+ RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE);
+}
+
/* ******************** Add Tracks Operator ***************************** */
/* Add NLA Tracks to the same AnimData block as a selected track, or above the selected tracks */
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c
index cf01ebd6976..943112624cd 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -42,7 +42,6 @@
#include "DNA_windowmanager_types.h"
#include "BLI_blenlib.h"
-#include "BLI_math.h"
#include "BLI_dlrbTree.h"
#include "BLI_utildefines.h"
@@ -76,7 +75,7 @@
/* get colors for drawing Action-Line
* NOTE: color returned includes fine-tuned alpha!
*/
-static void nla_action_get_color(AnimData *adt, bAction *act, float color[4])
+void nla_action_get_color(AnimData *adt, bAction *act, float color[4])
{
if (adt && (adt->flag & ADT_NLA_EDIT_ON)) {
/* greenish color (same as tweaking strip) */
@@ -132,7 +131,7 @@ static void nla_action_draw_keyframes(AnimData *adt, bAction *act, View2D *v2d,
/* get View2D scaling factor */
- UI_view2d_getscale(v2d, &xscale, NULL);
+ UI_view2d_scale_get(v2d, &xscale, NULL);
/* for now, color is hardcoded to be black */
glColor3f(0.0f, 0.0f, 0.0f);
@@ -428,16 +427,17 @@ static void nla_draw_strip_text(AnimData *adt, NlaTrack *nlt, NlaStrip *strip, i
{
short notSolo = ((adt && (adt->flag & ADT_NLA_SOLO_TRACK)) && (nlt->flag & NLATRACK_SOLO) == 0);
char str[256];
+ size_t str_len;
char col[4];
float xofs;
rctf rect;
/* just print the name and the range */
if (strip->flag & NLASTRIP_FLAG_TEMP_META) {
- BLI_snprintf(str, sizeof(str), "%d) Temp-Meta", index);
+ str_len = BLI_snprintf(str, sizeof(str), "%d) Temp-Meta", index);
}
else {
- BLI_strncpy(str, strip->name, sizeof(str));
+ 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 */
@@ -470,7 +470,7 @@ static void nla_draw_strip_text(AnimData *adt, NlaTrack *nlt, NlaStrip *strip, i
rect.ymax = ymaxc;
/* add this string to the cache of texts to draw */
- UI_view2d_text_cache_rectf(v2d, &rect, str, col);
+ UI_view2d_text_cache_add_rectf(v2d, &rect, str, str_len, col);
}
/* add frame extents to cache of text-strings to draw in pixelspace
@@ -480,7 +480,8 @@ static void nla_draw_strip_frames_text(NlaTrack *UNUSED(nlt), NlaStrip *strip, V
{
const float ytol = 1.0f; /* small offset to vertical positioning of text, for legibility */
const char col[4] = {220, 220, 220, 255}; /* light gray */
- char numstr[32] = "";
+ char numstr[32];
+ size_t numstr_len;
/* Always draw times above the strip, whereas sequencer drew below + above.
@@ -490,12 +491,12 @@ static void nla_draw_strip_frames_text(NlaTrack *UNUSED(nlt), NlaStrip *strip, V
* while also preserving some accuracy, since we do use floats
*/
/* start frame */
- BLI_snprintf(numstr, sizeof(numstr), "%.1f", strip->start);
- UI_view2d_text_cache_add(v2d, strip->start - 1.0f, ymaxc + ytol, numstr, col);
+ numstr_len = BLI_snprintf(numstr, sizeof(numstr), "%.1f", strip->start);
+ UI_view2d_text_cache_add(v2d, strip->start - 1.0f, ymaxc + ytol, numstr, numstr_len, col);
/* end frame */
- BLI_snprintf(numstr, sizeof(numstr), "%.1f", strip->end);
- UI_view2d_text_cache_add(v2d, strip->end, ymaxc + ytol, numstr, col);
+ numstr_len = BLI_snprintf(numstr, sizeof(numstr), "%.1f", strip->end);
+ UI_view2d_text_cache_add(v2d, strip->end, ymaxc + ytol, numstr, numstr_len, col);
}
/* ---------------------- */
@@ -618,200 +619,6 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar)
/* *********************************************** */
/* Channel List */
-/* old code for drawing NLA channels using GL only */
-// TODO: depreceate this code...
-static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View2D *v2d, float y)
-{
- SpaceNla *snla = (SpaceNla *)ac->sl;
- bAnimListElem *ale;
- float x = 0.0f;
-
- /* 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));
- const float ydatac = (float)(y - 0.35f * U.widget_unit);
-
- /* check if visible */
- if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
- IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) )
- {
- AnimData *adt = ale->adt;
-
- short indent = 0, offset = 0, sel = 0, group = 0;
- int special = -1;
- char name[128];
- bool do_draw = false;
-
- /* determine what needs to be drawn */
- switch (ale->type) {
- case ANIMTYPE_NLAACTION: /* NLA Action-Line */
- {
- bAction *act = (bAction *)ale->data;
-
- group = 5;
-
- special = ICON_ACTION;
-
- BLI_strncpy(name, act ? act->id.name + 2 : "<No Action>", sizeof(name));
-
- /* draw manually still */
- do_draw = true;
- break;
- }
- default: /* handled by standard channel-drawing API */
- /* (draw backdrops only...) */
- ANIM_channel_draw(ac, ale, yminc, ymaxc);
- break;
- }
-
- /* if special types, draw manually for now... */
- if (do_draw) {
- if (ale->id) {
- /* special exception for textures */
- if (GS(ale->id->name) == ID_TE) {
- offset = 0.7f * U.widget_unit;
- indent = 1;
- }
- /* special exception for nodetrees */
- else if (GS(ale->id->name) == ID_NT) {
- bNodeTree *ntree = (bNodeTree *)ale->id;
-
- switch (ntree->type) {
- case NTREE_SHADER:
- {
- /* same as for textures */
- offset = 0.7f * U.widget_unit;
- indent = 1;
- break;
- }
- case NTREE_TEXTURE:
- {
- /* even more */
- offset = U.widget_unit;
- indent = 1;
- break;
- }
- default:
- /* normal will do */
- offset = 0.7f * U.widget_unit;
- break;
- }
- }
- else {
- offset = 0.7f * U.widget_unit;
- }
- }
- else {
- offset = 0;
- }
-
- /* now, start drawing based on this information */
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
-
- /* draw backing strip behind channel name */
- if (group == 5) {
- float color[4];
-
- /* Action Line
- * 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)) {
- /* Yes, the color vector has 4 components, BUT we only want to be using 3 of them! */
- glColor3fv(color);
- }
- else {
- float alpha = (adt && (adt->flag & ADT_NLA_SOLO_TRACK)) ? 0.3f : 1.0f;
- glColor4f(color[0], color[1], color[2], alpha);
- }
-
- offset += 0.35f * U.widget_unit * indent;
-
- /* only on top two corners, to show that this channel sits on top of the preceding ones */
- uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT);
-
- /* draw slightly shifted up vertically to look like it has more separation from other channels,
- * but we then need to slightly shorten it so that it doesn't look like it overlaps
- */
- uiDrawBox(GL_POLYGON, x + offset, yminc + NLACHANNEL_SKIP, (float)v2d->cur.xmax, ymaxc + NLACHANNEL_SKIP - 1, 8);
-
- /* clear group value, otherwise we cause errors... */
- group = 0;
- }
-
-
- /* draw special icon indicating certain data-types */
- if (special > -1) {
- /* for normal channels */
- UI_icon_draw(x + offset, ydatac, special);
- offset += 0.85f * U.widget_unit;
- }
- glDisable(GL_BLEND);
-
- /* draw name */
- if (sel)
- UI_ThemeColor(TH_TEXT_HI);
- else
- UI_ThemeColor(TH_TEXT);
- offset += 3;
- UI_DrawString(x + offset, y - 4, name);
-
- /* reset offset - for RHS of panel */
- offset = 0;
-
- /* set blending again, as text drawing may clear it */
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
-
-
- /* draw NLA-action line 'status-icons' - only when there's an action */
- if ((ale->type == ANIMTYPE_NLAACTION) && (ale->data)) {
- offset += 0.8f * U.widget_unit;
-
- /* now draw some indicator icons */
- if ((adt) && (adt->flag & ADT_NLA_EDIT_ON)) {
- /* toggle for tweaking with mapping/no-mapping (i.e. 'in place editing' toggle) */
- // for now, use pin icon to symbolise this
- if (adt->flag & ADT_NLA_EDIT_NOMAP)
- UI_icon_draw((float)(v2d->cur.xmax - offset), ydatac, ICON_PINNED);
- else
- UI_icon_draw((float)(v2d->cur.xmax - offset), ydatac, ICON_UNPINNED);
-
- fdrawline((float)(v2d->cur.xmax - offset), yminc,
- (float)(v2d->cur.xmax - offset), ymaxc);
- offset += 0.8f * U.widget_unit;
-
- /* 'tweaking action' indicator - not a button */
- UI_icon_draw((float)(v2d->cur.xmax - offset), ydatac, ICON_EDIT);
- }
- else {
- /* XXX firstly draw a little rect to help identify that it's different from the toggles */
- glBegin(GL_LINE_LOOP);
- glVertex2f((float)v2d->cur.xmax - offset - 1, y - 0.35f * U.widget_unit);
- glVertex2f((float)v2d->cur.xmax - offset - 1, y + 0.45f * U.widget_unit);
- glVertex2f((float)v2d->cur.xmax - 1, y + 0.45f * U.widget_unit);
- glVertex2f((float)v2d->cur.xmax - 1, y - 0.35f * U.widget_unit);
- glEnd();
-
- /* 'push down' icon for normal active-actions */
- UI_icon_draw((float)v2d->cur.xmax - offset, ydatac, ICON_FREEZE);
- }
- }
-
- glDisable(GL_BLEND);
- }
- }
-
- /* adjust y-position for next one */
- y -= NLACHANNEL_STEP(snla);
- }
-}
-
void draw_nla_channel_list(bContext *C, bAnimContext *ac, ARegion *ar)
{
ListBase anim_data = {NULL, NULL};
@@ -843,10 +650,24 @@ void draw_nla_channel_list(bContext *C, bAnimContext *ac, ARegion *ar)
UI_view2d_sync(NULL, ac->sa, v2d, V2D_LOCK_COPY);
/* draw channels */
- { /* first pass: backdrops + oldstyle drawing */
+ { /* first pass: just the standard GL-drawing for backdrop + text */
y = (float)(-NLACHANNEL_HEIGHT(snla));
- draw_nla_channel_list_gl(ac, &anim_data, v2d, y);
+ 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) )
+ {
+ /* draw all channels using standard channel-drawing API */
+ ANIM_channel_draw(ac, ale, yminc, ymaxc);
+ }
+
+ /* adjust y-position for next one */
+ y -= NLACHANNEL_STEP(snla);
+ }
}
{ /* second pass: UI widgets */
uiBlock *block = uiBeginBlock(C, ar, __func__, UI_EMBOSS);
@@ -882,7 +703,7 @@ void draw_nla_channel_list(bContext *C, bAnimContext *ac, ARegion *ar)
glDisable(GL_BLEND);
}
- /* free tempolary channels */
+ /* free temporary channels */
BLI_freelistN(&anim_data);
}
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index 80b1918ff8e..93d0f7527ef 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -49,6 +49,7 @@
#include "BKE_fcurve.h"
#include "BKE_nla.h"
#include "BKE_context.h"
+#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_report.h"
#include "BKE_screen.h"
@@ -110,7 +111,7 @@ static int nlaedit_enable_tweakmode_exec(bContext *C, wmOperator *op)
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
- int ok = 0;
+ bool ok = false;
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
@@ -131,7 +132,7 @@ static int nlaedit_enable_tweakmode_exec(bContext *C, wmOperator *op)
AnimData *adt = ale->data;
/* try entering tweakmode if valid */
- ok += BKE_nla_tweakmode_enter(adt);
+ ok |= BKE_nla_tweakmode_enter(adt);
}
/* free temp data */
@@ -161,7 +162,7 @@ void NLA_OT_tweakmode_enter(wmOperatorType *ot)
/* 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";
+ 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;
@@ -257,11 +258,12 @@ void NLA_OT_tweakmode_exit(wmOperatorType *ot)
/* *************************** Calculate Range ************************** */
/* Get the min/max strip extents */
-static void get_nlastrip_extents(bAnimContext *ac, float *min, float *max, const short onlySel)
+static void get_nlastrip_extents(bAnimContext *ac, float *min, float *max, const bool only_sel)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
+ bool found_bounds = false;
/* get data to filter */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS);
@@ -280,10 +282,12 @@ static void get_nlastrip_extents(bAnimContext *ac, float *min, float *max, const
for (strip = nlt->strips.first; strip; strip = strip->next) {
/* only consider selected strips? */
- if ((onlySel == 0) || (strip->flag & NLASTRIP_FLAG_SELECT)) {
+ 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;
}
}
}
@@ -291,8 +295,9 @@ static void get_nlastrip_extents(bAnimContext *ac, float *min, float *max, const
/* free memory */
BLI_freelistN(&anim_data);
}
- else {
- /* set default range */
+
+ /* set default range if nothing happened */
+ if (found_bounds == false) {
if (ac->scene) {
*min = (float)ac->scene->r.sfra;
*max = (float)ac->scene->r.efra;
@@ -304,9 +309,109 @@ static void get_nlastrip_extents(bAnimContext *ac, float *min, float *max, const
}
}
+/* ****************** Automatic Preview-Range Operator ****************** */
+
+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 = iroundf(min);
+ scene->r.pefra = iroundf(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;
+}
+
/* ****************** View-All Operator ****************** */
-static int nlaedit_viewall(bContext *C, const short onlySel)
+/* Find the extents of the active channel
+ * > min: (float) bottom y-extent of channel
+ * > max: (float) top y-extent of channel
+ * > returns: success of finding a selected channel
+ */
+static bool nla_channels_get_selected_extents(bAnimContext *ac, float *min, float *max)
+{
+ 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) {
+ bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
+
+ /* must be selected... */
+ 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
+ */
+ if (found == ACHANNEL_ROLE_CHANNEL) {
+ break;
+ }
+ }
+
+ /* adjust y-position for next one */
+ y -= NLACHANNEL_STEP(snla);
+ }
+
+ /* free all temp data */
+ BLI_freelistN(&anim_data);
+
+ return (found != 0);
+}
+
+static int nlaedit_viewall(bContext *C, const bool only_sel)
{
bAnimContext ac;
View2D *v2d;
@@ -318,15 +423,32 @@ static int nlaedit_viewall(bContext *C, const short onlySel)
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, onlySel);
+ 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 */
- v2d->cur.ymax = 0.0f;
- v2d->cur.ymin = (float)-BLI_rcti_size_y(&v2d->mask);
+ if (only_sel == false) {
+ /* view all -> the summary channel is usually the shows everything, and resides right at the top... */
+ v2d->cur.ymax = 0.0f;
+ v2d->cur.ymin = (float)-BLI_rcti_size_y(&v2d->mask);
+ }
+ else {
+ /* 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);
@@ -513,6 +635,7 @@ void NLA_OT_actionclip_add(wmOperatorType *ot)
// TODO: this would be nicer as an ID-pointer...
prop = RNA_def_enum(ot->srna, "action", DummyRNA_NULL_items, 0, "Action", "");
RNA_def_enum_funcs(prop, RNA_action_itemf);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
ot->prop = prop;
}
@@ -527,7 +650,7 @@ static int nlaedit_add_transition_exec(bContext *C, wmOperator *op)
bAnimListElem *ale;
int filter;
- int done = false;
+ bool done = false;
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
@@ -595,7 +718,7 @@ static int nlaedit_add_transition_exec(bContext *C, wmOperator *op)
BKE_nlastrip_validate_name(adt, strip);
/* make note of this */
- done++;
+ done = true;
}
}
@@ -838,7 +961,7 @@ void NLA_OT_meta_remove(wmOperatorType *ot)
* the originals were housed in.
*/
-static int nlaedit_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
+static int nlaedit_duplicate_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
@@ -846,6 +969,7 @@ static int nlaedit_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
bAnimListElem *ale;
int filter;
+ bool linked = RNA_boolean_get(op->ptr, "linked");
bool done = false;
/* get editor data */
@@ -871,7 +995,7 @@ static int nlaedit_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
/* if selected, split the strip at its midpoint */
if (strip->flag & NLASTRIP_FLAG_SELECT) {
/* make a copy (assume that this is possible) */
- nstrip = copy_nlastrip(strip);
+ nstrip = copy_nlastrip(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) {
@@ -936,6 +1060,9 @@ void NLA_OT_duplicate(wmOperatorType *ot)
/* 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", transform_mode_types, TFM_TRANSLATION, "Mode", "");
}
@@ -1053,7 +1180,7 @@ static void nlaedit_split_strip_actclip(AnimData *adt, NlaTrack *nlt, NlaStrip *
/* make a copy (assume that this is possible) and append
* it immediately after the current strip
*/
- nstrip = copy_nlastrip(strip);
+ nstrip = copy_nlastrip(strip, true);
BLI_insertlinkafter(&nlt->strips, strip, nstrip);
/* set the endpoint of the first strip and the start of the new strip
@@ -1656,6 +1783,80 @@ void NLA_OT_action_sync_length(wmOperatorType *ot)
ot->prop = RNA_def_boolean(ot->srna, "active", 1, "Active Strip Only", "Only sync the active length for the active strip");
}
+/* ******************** Make Single User ********************************* */
+/* Ensure that each strip has its own action */
+
+static int nlaedit_make_single_user_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);
+
+ /* 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
+ */
+ 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)
+ 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(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 */
+ BLI_freelistN(&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_make_single_user(wmOperatorType *ot)
+{
+ /* identifiers */
+ 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;
+}
+
/* ******************** Apply Scale Operator ***************************** */
/* Reset the scaling of the selected strips to 1.0f */
@@ -2087,7 +2288,8 @@ static int nla_fmodifier_copy_exec(bContext *C, wmOperator *op)
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
- int filter, ok = 0;
+ int filter;
+ bool ok = false;
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
@@ -2111,7 +2313,7 @@ static int nla_fmodifier_copy_exec(bContext *C, wmOperator *op)
continue;
// TODO: when 'active' vs 'all' boolean is added, change last param!
- ok += ANIM_fmodifiers_copy_to_buf(&strip->modifiers, 0);
+ ok |= ANIM_fmodifiers_copy_to_buf(&strip->modifiers, 0);
}
}
diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h
index dedd6404a2c..766ae28da6f 100644
--- a/source/blender/editors/space_nla/nla_intern.h
+++ b/source/blender/editors/space_nla/nla_intern.h
@@ -41,6 +41,8 @@
ARegion *nla_has_buttons_region(ScrArea *sa);
+bool nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA *nlt_ptr, PointerRNA *strip_ptr);
+
void nla_buttons_register(ARegionType *art);
void NLA_OT_properties(wmOperatorType *ot);
@@ -88,6 +90,8 @@ void NLA_OT_tweakmode_exit(wmOperatorType *ot);
/* --- */
+void NLA_OT_previewrange_set(wmOperatorType *ot);
+
void NLA_OT_view_all(wmOperatorType *ot);
void NLA_OT_view_selected(wmOperatorType *ot);
@@ -110,6 +114,8 @@ void NLA_OT_move_down(wmOperatorType *ot);
void NLA_OT_action_sync_length(wmOperatorType *ot);
+void NLA_OT_make_single_user(wmOperatorType *ot);
+
void NLA_OT_apply_scale(wmOperatorType *ot);
void NLA_OT_clear_scale(wmOperatorType *ot);
@@ -130,6 +136,8 @@ bool nlaedit_add_tracks_empty(bAnimContext *ac);
void NLA_OT_channels_click(wmOperatorType *ot);
+void NLA_OT_action_pushdown(wmOperatorType *ot);
+
void NLA_OT_tracks_add(wmOperatorType *ot);
void NLA_OT_tracks_delete(wmOperatorType *ot);
diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c
index 0a010ffb819..295a7ab2e04 100644
--- a/source/blender/editors/space_nla/nla_ops.c
+++ b/source/blender/editors/space_nla/nla_ops.c
@@ -36,7 +36,6 @@
#include "BLI_blenlib.h"
-#include "BLI_math.h"
#include "BKE_context.h"
#include "BKE_screen.h"
@@ -118,6 +117,8 @@ void nla_operatortypes(void)
/* channels */
WM_operatortype_append(NLA_OT_channels_click);
+ WM_operatortype_append(NLA_OT_action_pushdown);
+
WM_operatortype_append(NLA_OT_tracks_add);
WM_operatortype_append(NLA_OT_tracks_delete);
@@ -133,6 +134,8 @@ void nla_operatortypes(void)
WM_operatortype_append(NLA_OT_view_all);
WM_operatortype_append(NLA_OT_view_selected);
+ WM_operatortype_append(NLA_OT_previewrange_set);
+
/* edit */
WM_operatortype_append(NLA_OT_tweakmode_enter);
WM_operatortype_append(NLA_OT_tweakmode_exit);
@@ -156,6 +159,8 @@ void nla_operatortypes(void)
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);
@@ -236,7 +241,8 @@ static void nla_keymap_main(wmKeyConfig *keyconf, wmKeyMap *keymap)
/* 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_previewrange_set", PKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
+
WM_keymap_add_item(keymap, "NLA_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "NLA_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "NLA_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
@@ -253,7 +259,14 @@ static void nla_keymap_main(wmKeyConfig *keyconf, wmKeyMap *keymap)
WM_keymap_add_item(keymap, "NLA_OT_meta_remove", GKEY, KM_PRESS, KM_ALT, 0);
/* duplicate */
- WM_keymap_add_item(keymap, "NLA_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
+ 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);
diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c
index 2bd2b660bcd..3e7a6f4578c 100644
--- a/source/blender/editors/space_nla/nla_select.c
+++ b/source/blender/editors/space_nla/nla_select.c
@@ -38,7 +38,6 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
-#include "BLI_math.h"
#include "BKE_nla.h"
#include "BKE_context.h"
@@ -464,7 +463,7 @@ static int nlaedit_select_leftright_invoke(bContext *C, wmOperator *op, const wm
float x;
/* determine which side of the current frame mouse is on */
- UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, NULL);
+ x = UI_view2d_region_to_view_x(v2d, event->mval[0]);
if (x < CFRA)
RNA_int_set(op->ptr, "mode", NLAEDIT_LRSEL_LEFT);
else
@@ -515,7 +514,7 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s
Scene *scene = ac->scene;
NlaStrip *strip = NULL;
int channel_index;
- float xmin, xmax, dummy;
+ float xmin, xmax;
float x, y;
@@ -526,8 +525,8 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s
/* 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)
*/
- UI_view2d_region_to_view(v2d, mval[0] - 7, mval[1], &xmin, &dummy);
- UI_view2d_region_to_view(v2d, mval[0] + 7, mval[1], &xmax, &dummy);
+ 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);
@@ -576,14 +575,6 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s
/* deselect all other channels first */
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
-
- /* 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);
- }
}
/* only select strip if we clicked on a valid channel and hit something */
@@ -595,10 +586,21 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s
/* if we selected it, we can make it active too
* - 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)
+
+ 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 */
diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c
index d0ba33358e4..134e5dd80a2 100644
--- a/source/blender/editors/space_nla/space_nla.c
+++ b/source/blender/editors/space_nla/space_nla.c
@@ -38,7 +38,6 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
-#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BKE_context.h"
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index eb5c23a60f7..8ef1d0bef99 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -44,7 +44,6 @@
#include "BKE_image.h"
#include "BKE_main.h"
#include "BKE_node.h"
-#include "BKE_scene.h"
#include "BKE_tracking.h"
#include "BLF_api.h"
@@ -53,8 +52,6 @@
#include "BIF_gl.h"
#include "BIF_glutil.h"
-#include "MEM_guardedalloc.h"
-
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
@@ -338,7 +335,7 @@ static void node_draw_frame_prepare(const bContext *UNUSED(C), bNodeTree *ntree,
{
const float margin = 1.5f * U.widget_unit;
NodeFrame *data = (NodeFrame *)node->storage;
- int bbinit;
+ bool bbinit;
bNode *tnode;
rctf rect, noderect;
float xmax, ymax;
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index f3d02c179ff..b3cf5ce0c81 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -32,11 +32,11 @@
#include "DNA_lamp_types.h"
#include "DNA_node_types.h"
#include "DNA_material_types.h"
-#include "DNA_object_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "DNA_texture_types.h"
#include "DNA_world_types.h"
+#include "DNA_linestyle_types.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
@@ -58,7 +58,6 @@
#include "ED_node.h"
#include "ED_gpencil.h"
-#include "ED_screen.h"
#include "ED_space_api.h"
#include "UI_resources.h"
@@ -108,6 +107,8 @@ static bNodeTree *node_tree_from_ID(ID *id)
return ((Scene *)id)->nodetree;
case ID_TE:
return ((Tex *)id)->nodetree;
+ case ID_LS:
+ return ((FreestyleLineStyle *)id)->nodetree;
}
}
@@ -587,14 +588,14 @@ static void node_draw_mute_line(View2D *v2d, SpaceNode *snode, bNode *node)
static void node_circle_draw(float x, float y, float size, const float col[4], int highlight)
{
/* 16 values of sin function */
- static float si[16] = {
+ static const float si[16] = {
0.00000000f, 0.39435585f, 0.72479278f, 0.93775213f,
0.99871650f, 0.89780453f, 0.65137248f, 0.29936312f,
-0.10116832f, -0.48530196f, -0.79077573f, -0.96807711f,
-0.98846832f, -0.84864425f, -0.57126821f, -0.20129852f
};
/* 16 values of cos function */
- static float co[16] = {
+ static const float co[16] = {
1.00000000f, 0.91895781f, 0.68896691f, 0.34730525f,
-0.05064916f, -0.44039415f, -0.75875812f, -0.95413925f,
-0.99486932f, -0.87434661f, -0.61210598f, -0.25065253f,
@@ -1204,7 +1205,7 @@ 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_setcenter(v2d, center[0], center[1]);
+ UI_view2d_center_set(v2d, center[0], center[1]);
UI_view2d_view_ortho(v2d);
/* aspect+font, set each time */
@@ -1289,7 +1290,7 @@ void drawnodespace(const bContext *C, ARegion *ar)
path = snode->treepath.last;
/* current View2D center, will be set temporarily for parent node trees */
- UI_view2d_getcenter(v2d, &center[0], &center[1]);
+ 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);
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index 7c5ffa54f92..fc0c82faba8 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -32,30 +32,24 @@
#include "MEM_guardedalloc.h"
#include "DNA_action_types.h"
-#include "DNA_anim_types.h"
#include "DNA_lamp_types.h"
#include "DNA_material_types.h"
#include "DNA_node_types.h"
-#include "DNA_object_types.h"
#include "DNA_text_types.h"
#include "DNA_world_types.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
-#include "BKE_blender.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
#include "BKE_global.h"
#include "BKE_image.h"
#include "BKE_library.h"
#include "BKE_main.h"
-#include "BKE_material.h"
#include "BKE_node.h"
-#include "BKE_paint.h"
#include "BKE_report.h"
#include "BKE_scene.h"
-#include "BKE_texture.h"
#include "RE_engine.h"
#include "RE_pipeline.h"
@@ -99,7 +93,7 @@ typedef struct CompoJob {
Scene *scene;
bNodeTree *ntree;
bNodeTree *localtree;
- short *stop;
+ const short *stop;
short *do_update;
float *progress;
short need_sync;
@@ -257,7 +251,6 @@ static void compo_startjob(void *cjv, short *stop, short *do_update, float *prog
ntree->udh = cj;
// XXX BIF_store_spare();
-
/* 1 is do_previews */
ntreeCompositExecTree(cj->scene, ntree, &cj->scene->r, false, true, &scene->view_settings, &scene->display_settings);
@@ -278,6 +271,7 @@ void ED_node_composite_job(const bContext *C, struct bNodeTree *nodetree, Scene
{
wmJob *wm_job;
CompoJob *cj;
+ Scene *scene = CTX_data_scene(C);
/* to fix bug: [#32272] */
if (G.is_rendering) {
@@ -288,12 +282,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"));
+
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->scene = CTX_data_scene(C);
+ cj->scene = scene;
cj->ntree = nodetree;
cj->recalc_flags = compo_get_recalc_flags(C);
@@ -878,37 +874,38 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event)
dy = (my - nsw->mystart) / UI_DPI_FAC;
if (node) {
- if (node->flag & NODE_HIDDEN) {
- float widthmin = 0.0f;
- float widthmax = 100.0f;
- if (nsw->directions & NODE_RESIZE_RIGHT) {
- node->miniwidth = nsw->oldminiwidth + dx;
- CLAMP(node->miniwidth, widthmin, widthmax);
- }
- if (nsw->directions & NODE_RESIZE_LEFT) {
- float locmax = nsw->oldlocx + nsw->oldminiwidth;
-
- node->locx = nsw->oldlocx + dx;
- CLAMP(node->locx, locmax - widthmax, locmax - widthmin);
- node->miniwidth = locmax - node->locx;
- }
+ /* width can use node->width or node->miniwidth (hidden nodes) */
+ float *pwidth;
+ float oldwidth, widthmin, widthmax;
+ /* ignore hidden flag for frame nodes */
+ bool use_hidden = (node->type != NODE_FRAME);
+ if (use_hidden && node->flag & NODE_HIDDEN) {
+ pwidth = &node->miniwidth;
+ oldwidth = nsw->oldminiwidth;
+ widthmin = 0.0f;
+ widthmax = 100.0f;
}
else {
- float widthmin = node->typeinfo->minwidth;
- float widthmax = node->typeinfo->maxwidth;
+ pwidth = &node->width;
+ oldwidth = nsw->oldwidth;
+ widthmin = node->typeinfo->minwidth;
+ widthmax = node->typeinfo->maxwidth;
+ }
+
+ {
if (nsw->directions & NODE_RESIZE_RIGHT) {
- node->width = nsw->oldwidth + dx;
- CLAMP(node->width, widthmin, widthmax);
+ *pwidth = oldwidth + dx;
+ CLAMP(*pwidth, widthmin, widthmax);
}
if (nsw->directions & NODE_RESIZE_LEFT) {
- float locmax = nsw->oldlocx + nsw->oldwidth;
+ float locmax = nsw->oldlocx + oldwidth;
node->locx = nsw->oldlocx + dx;
CLAMP(node->locx, locmax - widthmax, locmax - widthmin);
- node->width = locmax - node->locx;
+ *pwidth = locmax - node->locx;
}
}
-
+
/* height works the other way round ... */
{
float heightmin = UI_DPI_FAC * node->typeinfo->minheight;
@@ -2323,9 +2320,9 @@ static int node_shader_script_update_poll(bContext *C)
}
/* recursively check for script nodes in groups using this text and update */
-static int node_shader_script_update_text_recursive(RenderEngine *engine, RenderEngineType *type, bNodeTree *ntree, Text *text)
+static bool node_shader_script_update_text_recursive(RenderEngine *engine, RenderEngineType *type, bNodeTree *ntree, Text *text)
{
- int found = false;
+ bool found = false;
bNode *node;
ntree->done = true;
@@ -2356,7 +2353,7 @@ static int node_shader_script_update_exec(bContext *C, wmOperator *op)
bNode *node = NULL;
RenderEngine *engine;
RenderEngineType *type;
- int found = false;
+ bool found = false;
/* setup render engine */
type = RE_engines_find(scene->r.engine);
diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c
index 05348acfae7..39aba921f72 100644
--- a/source/blender/editors/space_node/node_group.c
+++ b/source/blender/editors/space_node/node_group.c
@@ -34,12 +34,9 @@
#include "MEM_guardedalloc.h"
#include "DNA_node_types.h"
-#include "DNA_object_types.h"
#include "DNA_anim_types.h"
#include "BLI_listbase.h"
-#include "BLI_string.h"
-#include "BLI_rect.h"
#include "BLI_math.h"
#include "BLF_translation.h"
@@ -684,7 +681,7 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
ListBase anim_basepaths = {NULL, NULL};
float min[2], max[2], center[2];
int totselect;
- int expose_all = false;
+ bool expose_all = false;
bNode *input_node, *output_node;
/* XXX rough guess, not nice but we don't have access to UI constants here ... */
@@ -831,7 +828,7 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
if (node_group_make_use_node(node, gnode)) {
for (sock = node->inputs.first; sock; sock = sock->next) {
bNodeSocket *iosock, *input_sock;
- int skip = false;
+ bool skip = false;
for (link = ngroup->links.first; link; link = link->next) {
if (link->tosock == sock) {
skip = true;
@@ -852,7 +849,7 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
for (sock = node->outputs.first; sock; sock = sock->next) {
bNodeSocket *iosock, *output_sock;
- int skip = false;
+ bool skip = false;
for (link = ngroup->links.first; link; link = link->next)
if (link->fromsock == sock)
skip = true;
diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c
index 7d9bf4b67f2..6a0e1f35d24 100644
--- a/source/blender/editors/space_node/node_relationships.c
+++ b/source/blender/editors/space_node/node_relationships.c
@@ -29,17 +29,17 @@
* \ingroup spnode
*/
+#include <ctype.h>
+
#include "MEM_guardedalloc.h"
#include "DNA_node_types.h"
-#include "DNA_object_types.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BKE_context.h"
#include "BKE_global.h"
-#include "BKE_main.h"
#include "BKE_node.h"
#include "ED_node.h" /* own include */
@@ -54,6 +54,8 @@
#include "UI_view2d.h"
+#include "BLF_translation.h"
+
#include "node_intern.h" /* own include */
#include "NOD_common.h"
@@ -206,7 +208,7 @@ static void snode_autoconnect(SpaceNode *snode, const bool allow_multiple, const
for (nli = nodelist->first; nli; nli = nli->next) {
bNode *node_fr, *node_to;
bNodeSocket *sock_fr, *sock_to;
- int has_selected_inputs = 0;
+ bool has_selected_inputs = false;
if (nli->next == NULL) break;
@@ -395,12 +397,87 @@ void NODE_OT_link_viewer(wmOperatorType *ot)
/* *************************** add link op ******************** */
-static void node_remove_extra_links(SpaceNode *snode, bNodeLink *link)
+static void node_link_update_header(bContext *C, bNodeLinkDrag *UNUSED(nldrag))
+{
+#define HEADER_LENGTH 256
+ char header[HEADER_LENGTH];
+
+ BLI_strncpy(header, IFACE_("LMB: drag node link, RMB: cancel"), HEADER_LENGTH);
+ ED_area_headerprint(CTX_wm_area(C), header);
+#undef HEADER_LENGTH
+}
+
+/* update link_count fields to avoid repeated link counting */
+static int node_count_links(bNodeTree *ntree, bNodeSocket *sock)
+{
+ bNodeLink *link;
+ int count = 0;
+ for (link = ntree->links.first; link; link = link->next) {
+ if (link->fromsock == sock)
+ ++count;
+ if (link->tosock == sock)
+ ++count;
+ }
+ return count;
+}
+
+/* test if two sockets are interchangeable
+ * XXX this could be made into a tree-type callback for flexibility
+ */
+static bool node_link_socket_match(bNodeSocket *a, bNodeSocket *b)
+{
+ /* tests if alphabetic prefix matches
+ * this allows for imperfect matches, such as numeric suffixes,
+ * like Color1/Color2
+ */
+ int prefix_len = 0;
+ char *ca = a->name, *cb = b->name;
+ for (; *ca != '\0' && *cb != '\0'; ++ca, ++cb) {
+ /* end of common prefix? */
+ if (*ca != *cb) {
+ /* prefix delimited by non-alphabetic char */
+ if (isalpha(*ca) || isalpha(*cb))
+ return false;
+ break;
+ }
+ ++prefix_len;
+ }
+ return prefix_len > 0;
+}
+
+/* find an eligible socket for linking */
+static bNodeSocket *node_find_linkable_socket(bNodeTree *ntree, bNode *node, bNodeSocket *cur, bool use_swap)
+{
+ int cur_link_count = node_count_links(ntree, cur);
+ if (cur_link_count <= cur->limit) {
+ /* current socket is fine, use it */
+ return cur;
+ }
+ else if (use_swap) {
+ /* 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 (node_link_socket_match(sock, cur)) {
+ int link_count = node_count_links(ntree, sock);
+ /* take +1 into account since we would add a new link */
+ 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;
+}
+
+static void node_remove_extra_links(SpaceNode *snode, bNodeLink *link, bool use_swap)
{
bNodeTree *ntree = snode->edittree;
bNodeSocket *from = link->fromsock, *to = link->tosock;
- int max_from = from->limit, max_to = to->limit;
- int count_from = 1, count_to = 1; /* start at 1, link is included */
bNodeLink *tlink, *tlink_next;
for (tlink = ntree->links.first; tlink; tlink = tlink_next) {
@@ -409,16 +486,28 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeLink *link)
continue;
if (tlink && tlink->fromsock == from) {
- ++count_from;
- if (count_from > max_from) {
+ bNodeSocket *new_from = node_find_linkable_socket(ntree, tlink->fromnode, from, use_swap);
+ if (new_from && new_from != from) {
+ /* redirect existing link */
+ tlink->fromsock = new_from;
+ new_from->flag &= ~SOCK_HIDDEN;
+ }
+ else if (!new_from) {
+ /* no possible replacement, remove tlink */
nodeRemLink(ntree, tlink);
tlink = NULL;
}
}
if (tlink && tlink->tosock == to) {
- ++count_to;
- if (count_to > max_to) {
+ bNodeSocket *new_to = node_find_linkable_socket(ntree, tlink->tonode, to, use_swap);
+ if (new_to && new_to != to) {
+ /* redirect existing link */
+ tlink->tosock = new_to;
+ new_to->flag &= ~SOCK_HIDDEN;
+ }
+ else if (!new_to) {
+ /* no possible replacement, remove tlink */
nodeRemLink(ntree, tlink);
tlink = NULL;
}
@@ -426,82 +515,120 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeLink *link)
}
}
-/* loop that adds a nodelink, called by function below */
-/* in_out = starting socket */
-static int node_link_modal(bContext *C, wmOperator *op, const wmEvent *event)
+static void node_link_exit(bContext *C, wmOperator *op, bool apply_links)
{
SpaceNode *snode = CTX_wm_space_node(C);
- ARegion *ar = CTX_wm_region(C);
- bNodeLinkDrag *nldrag = op->customdata;
bNodeTree *ntree = snode->edittree;
+ bNodeLinkDrag *nldrag = op->customdata;
+ LinkData *linkdata;
+
+ for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) {
+ bNodeLink *link = linkdata->data;
+
+ if (apply_links && link->tosock && link->fromsock) {
+ /* 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, true);
+ }
+ else
+ nodeRemLink(ntree, link);
+ }
+
+ ntreeUpdateTree(CTX_data_main(C), ntree);
+ snode_notify(C, snode);
+ 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);
+ MEM_freeN(nldrag);
+}
+
+static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2])
+{
+ SpaceNode *snode = CTX_wm_space_node(C);
+ bNodeLinkDrag *nldrag = op->customdata;
bNode *tnode;
bNodeSocket *tsock = NULL;
- bNodeLink *link;
LinkData *linkdata;
- float cursor[2];
- int in_out;
- in_out = nldrag->in_out;
+ if (nldrag->in_out == SOCK_OUT) {
+ 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;
+ }
+ }
+ else {
+ for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) {
+ bNodeLink *link = linkdata->data;
+
+ link->tonode = NULL;
+ link->tosock = NULL;
+ }
+ }
+ }
+ else {
+ 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;
+ }
+ }
+ else {
+ for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) {
+ bNodeLink *link = linkdata->data;
+
+ link->fromnode = NULL;
+ link->fromsock = NULL;
+ }
+ }
+ }
+}
+
+/* loop that adds a nodelink, called by function below */
+/* in_out = starting socket */
+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);
- if (in_out == SOCK_OUT) {
- if (node_find_indicated_socket(snode, &tnode, &tsock, cursor, SOCK_IN)) {
- for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) {
- 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;
- }
- }
- else {
- for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) {
- link = linkdata->data;
-
- link->tonode = NULL;
- link->tosock = NULL;
- }
- }
- }
- else {
- if (node_find_indicated_socket(snode, &tnode, &tsock, cursor, SOCK_OUT)) {
- for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) {
- 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;
- }
- }
- else {
- for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) {
- link = linkdata->data;
-
- link->fromnode = NULL;
- link->fromsock = NULL;
- }
- }
- }
-
+ node_link_update_header(C, nldrag);
ED_region_tag_redraw(ar);
break;
@@ -509,34 +636,10 @@ static int node_link_modal(bContext *C, wmOperator *op, const wmEvent *event)
case RIGHTMOUSE:
case MIDDLEMOUSE:
{
- for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) {
- link = linkdata->data;
-
- if (link->tosock && link->fromsock) {
- /* 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);
- }
- else
- nodeRemLink(ntree, link);
- }
-
- ntreeUpdateTree(CTX_data_main(C), ntree);
- snode_notify(C, snode);
- 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);
- MEM_freeN(nldrag);
+ node_link_exit(C, op, true);
+ ED_area_headerprint(CTX_wm_area(C), NULL);
+ ED_region_tag_redraw(ar);
return OPERATOR_FINISHED;
}
}
@@ -545,7 +648,7 @@ static int node_link_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
/* return 1 when socket clicked */
-static bNodeLinkDrag *node_link_init(SpaceNode *snode, float cursor[2], const bool detach)
+static bNodeLinkDrag *node_link_init(SpaceNode *snode, float cursor[2], bool detach)
{
bNode *node;
bNodeSocket *sock;
@@ -630,7 +733,7 @@ static bNodeLinkDrag *node_link_init(SpaceNode *snode, float cursor[2], const bo
BLI_addtail(&nldrag->links, linkdata);
}
}
-
+
return nldrag;
}
@@ -641,7 +744,7 @@ static int node_link_invoke(bContext *C, wmOperator *op, const wmEvent *event)
bNodeLinkDrag *nldrag;
float cursor[2];
- const bool detach = RNA_boolean_get(op->ptr, "detach");
+ 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]);
@@ -770,7 +873,7 @@ static int cut_links_exec(bContext *C, wmOperator *op)
RNA_END;
if (i > 1) {
- int found = false;
+ bool found = false;
bNodeLink *link, *next;
ED_preview_kill_jobs(C);
@@ -1329,7 +1432,7 @@ void ED_node_link_insert(ScrArea *sa)
link->tonode = select;
link->tosock = best_input;
- node_remove_extra_links(snode, link);
+ node_remove_extra_links(snode, link, false);
link->flag &= ~NODE_LINKFLAG_HILITE;
nodeAddLink(snode->edittree, select, best_output, node, sockto);
diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c
index d9e1f4fa611..7371a3ef070 100644
--- a/source/blender/editors/space_node/node_select.c
+++ b/source/blender/editors/space_node/node_select.c
@@ -43,7 +43,6 @@
#include "ED_node.h" /* own include */
#include "ED_screen.h"
-#include "ED_types.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -445,15 +444,12 @@ static int node_borderselect_exec(bContext *C, wmOperator *op)
SpaceNode *snode = CTX_wm_space_node(C);
ARegion *ar = CTX_wm_region(C);
bNode *node;
- rcti rect;
rctf rectf;
int gesture_mode = RNA_int_get(op->ptr, "gesture_mode");
const bool extend = RNA_boolean_get(op->ptr, "extend");
- WM_operator_properties_border_to_rcti(op, &rect);
-
- UI_view2d_region_to_view(&ar->v2d, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin);
- UI_view2d_region_to_view(&ar->v2d, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax);
+ 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) {
if (BLI_rctf_isect(&rectf, &node->totr, NULL)) {
@@ -593,11 +589,8 @@ static bool do_lasso_select_node(bContext *C, const int mcords[][2], short moves
BLI_rctf_cent_y(&node->totr)};
/* marker in screen coords */
- UI_view2d_view_to_region(&ar->v2d,
- cent[0], cent[1],
- &screen_co[0], &screen_co[1]);
-
- if (BLI_rcti_isect_pt(&rect, screen_co[0], screen_co[1]) &&
+ if (UI_view2d_view_to_region_clip(&ar->v2d, cent[0], cent[1], &screen_co[0], &screen_co[1]) &&
+ BLI_rcti_isect_pt(&rect, screen_co[0], screen_co[1]) &&
BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], INT_MAX))
{
nodeSetSelected(node, select);
diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c
index 90b9c2071de..3491ecc86af 100644
--- a/source/blender/editors/space_node/node_view.c
+++ b/source/blender/editors/space_node/node_view.c
@@ -417,15 +417,18 @@ static void sample_draw(const bContext *C, ARegion *ar, void *arg_info)
}
}
-/* returns color in SRGB */
-/* matching ED_space_image_color_sample() */
-bool ED_space_node_color_sample(SpaceNode *snode, ARegion *ar, int mval[2], float r_col[3])
+/* Returns color in the display space, matching ED_space_image_color_sample().
+ * And here we've got recursion in the comments tips...
+ */
+bool ED_space_node_color_sample(Scene *scene, SpaceNode *snode, ARegion *ar, int mval[2], float r_col[3])
{
+ const char *display_device = scene->display_settings.display_device;
+ struct ColorManagedDisplay *display = IMB_colormanagement_display_get_named(display_device);
void *lock;
Image *ima;
ImBuf *ibuf;
float fx, fy, bufx, bufy;
- int ret = false;
+ bool ret = false;
if (STREQ(snode->tree_idname, ntreeType_Composite->idname) || (snode->flag & SNODE_BACKDRAW) == 0) {
/* use viewer image for color sampling only if we're in compositor tree
@@ -447,7 +450,7 @@ bool ED_space_node_color_sample(SpaceNode *snode, ARegion *ar, int mval[2], floa
fy = (bufy > 0.0f ? ((float)mval[1] - 0.5f * ar->winy - snode->yof) / bufy + 0.5f : 0.0f);
if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) {
- float *fp;
+ const float *fp;
unsigned char *cp;
int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y);
@@ -457,16 +460,21 @@ bool ED_space_node_color_sample(SpaceNode *snode, ARegion *ar, int mval[2], floa
if (ibuf->rect_float) {
fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
/* IB_PROFILE_NONE is default but infact its linear */
- linearrgb_to_srgb_v3_v3(r_col, fp);
+ copy_v3_v3(r_col, fp);
ret = true;
}
else if (ibuf->rect) {
cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x);
rgb_uchar_to_float(r_col, cp);
+ IMB_colormanagement_colorspace_to_scene_linear_v3(r_col, ibuf->rect_colorspace);
ret = true;
}
}
+ if (ret) {
+ IMB_colormanagement_scene_linear_to_display_v3(r_col, display);
+ }
+
BKE_image_release_ibuf(ima, ibuf, lock);
return ret;
@@ -500,7 +508,7 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
fy = (bufy > 0.0f ? ((float)event->mval[1] - 0.5f * ar->winy - snode->yof) / bufy + 0.5f : 0.0f);
if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) {
- float *fp;
+ const float *fp;
unsigned char *cp;
int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y);
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index e9531ea0020..ddfbe3bebf2 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -401,7 +401,7 @@ static void node_area_listener(bScreen *sc, ScrArea *sa, wmNotifier *wmn)
bNodeTreePath *path = snode->treepath.last;
/* shift view to node tree center */
if (ar && path)
- UI_view2d_setcenter(&ar->v2d, path->view_center[0], path->view_center[1]);
+ UI_view2d_center_set(&ar->v2d, path->view_center[0], path->view_center[1]);
ED_area_tag_refresh(sa);
break;
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 4db63a462e7..1f728b380d6 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -39,7 +39,6 @@
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
-#include "BLI_ghash.h"
#include "BLI_mempool.h"
#include "BLF_translation.h"
@@ -755,10 +754,21 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa
if (tselem->type == TSE_RNA_PROPERTY) {
ptr = &te->rnaptr;
prop = te->directdata;
-
- if (!(RNA_property_type(prop) == PROP_POINTER && (TSELEM_OPEN(tselem, soops)))) {
- uiDefAutoButR(block, ptr, prop, -1, "", ICON_NONE, sizex, te->ys, OL_RNA_COL_SIZEX,
- UI_UNIT_Y - 1);
+
+ if (!TSELEM_OPEN(tselem, soops)) {
+ if (RNA_property_type(prop) == PROP_POINTER) {
+ uiBut *but = uiDefAutoButR(block, ptr, prop, -1, "", ICON_NONE, sizex, te->ys,
+ OL_RNA_COL_SIZEX, UI_UNIT_Y - 1);
+ uiButSetFlag(but, UI_BUT_DISABLED);
+ }
+ else if (RNA_property_type(prop) == PROP_ENUM) {
+ uiDefAutoButR(block, ptr, prop, -1, NULL, ICON_NONE, sizex, te->ys, OL_RNA_COL_SIZEX,
+ UI_UNIT_Y - 1);
+ }
+ else {
+ uiDefAutoButR(block, ptr, prop, -1, "", ICON_NONE, sizex, te->ys, OL_RNA_COL_SIZEX,
+ UI_UNIT_Y - 1);
+ }
}
}
else if (tselem->type == TSE_RNA_ARRAY_ELEM) {
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index 117730cdb9e..17e1e032bbf 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -185,7 +185,7 @@ static int outliner_item_openclose(bContext *C, wmOperator *op, const wmEvent *e
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, fmval + 1);
+ 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))
@@ -275,7 +275,7 @@ static int outliner_item_rename(bContext *C, wmOperator *UNUSED(op), const wmEve
float fmval[2];
bool changed = false;
- UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval + 1);
+ 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(C, ar, soops, te, fmval)) {
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 9fa17cd1120..d7521edd57a 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -31,8 +31,6 @@
#include <stdlib.h>
-#include "MEM_guardedalloc.h"
-
#include "DNA_armature_types.h"
#include "DNA_group_types.h"
#include "DNA_lamp_types.h"
@@ -47,7 +45,6 @@
#include "BKE_context.h"
#include "BKE_depsgraph.h"
-#include "BKE_main.h"
#include "BKE_object.h"
#include "BKE_scene.h"
#include "BKE_sequencer.h"
@@ -985,7 +982,7 @@ int outliner_item_do_activate(bContext *C, int x, int y, bool extend, bool recur
TreeElement *te;
float fmval[2];
- UI_view2d_region_to_view(&ar->v2d, x, y, fmval, fmval + 1);
+ UI_view2d_region_to_view(&ar->v2d, x, y, &fmval[0], &fmval[1]);
if (!ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF) &&
!(soops->flag & SO_HIDE_RESTRICTCOLS) &&
@@ -1079,14 +1076,11 @@ static int outliner_border_select_exec(bContext *C, wmOperator *op)
SpaceOops *soops = CTX_wm_space_outliner(C);
ARegion *ar = CTX_wm_region(C);
TreeElement *te;
- rcti rect;
rctf rectf;
int gesture_mode = RNA_int_get(op->ptr, "gesture_mode");
- WM_operator_properties_border_to_rcti(op, &rect);
-
- UI_view2d_region_to_view(&ar->v2d, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin);
- UI_view2d_region_to_view(&ar->v2d, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax);
+ WM_operator_properties_border_to_rctf(op, &rectf);
+ UI_view2d_region_to_view_rctf(&ar->v2d, &rectf, &rectf);
for (te = soops->tree.first; te; te = te->next) {
outliner_item_border_select(scene, soops, &rectf, te, gesture_mode);
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index 9f31bbb3320..8f5e2ad3693 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -35,6 +35,7 @@
#include "DNA_armature_types.h"
#include "DNA_group_types.h"
#include "DNA_lamp_types.h"
+#include "DNA_linestyle_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meta_types.h"
@@ -45,7 +46,6 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
-#include "BLI_ghash.h"
#include "BKE_animsys.h"
#include "BKE_context.h"
@@ -57,7 +57,6 @@
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_sequencer.h"
-#include "BKE_treehash.h"
#include "ED_armature.h"
#include "ED_object.h"
@@ -193,6 +192,10 @@ static void unlink_texture_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeEle
World *wrld = (World *)tsep->id;
mtex = wrld->mtex;
}
+ else if (GS(tsep->id->name) == ID_LS) {
+ FreestyleLineStyle *ls = (FreestyleLineStyle *)tsep->id;
+ mtex = ls->mtex;
+ }
else {
return;
}
@@ -1064,6 +1067,7 @@ void OUTLINER_OT_action_set(wmOperatorType *ot)
// TODO: this would be nicer as an ID-pointer...
prop = RNA_def_enum(ot->srna, "action", DummyRNA_NULL_items, 0, "Action", "");
RNA_def_enum_funcs(prop, RNA_action_itemf);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
ot->prop = prop;
}
@@ -1345,7 +1349,7 @@ static int outliner_operation(bContext *C, wmOperator *UNUSED(op), const wmEvent
TreeElement *te;
float fmval[2];
- UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval + 1);
+ 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, scene, ar, soops, te, event, fmval)) {
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 721eb626cdf..520cd9a544d 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -54,8 +54,6 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
-#include "BLI_math.h"
-#include "BLI_ghash.h"
#include "BLI_mempool.h"
#include "BLI_fnmatch.h"
@@ -79,6 +77,10 @@
#include "outliner_intern.h"
+#ifdef WIN32
+# include "BLI_math_base.h" /* M_PI */
+#endif
+
/* ********************************************************* */
/* Persistent Data */
@@ -377,6 +379,7 @@ static bool outliner_animdata_test(AnimData *adt)
return false;
}
+#ifdef WITH_FREESTYLE
static void outliner_add_line_styles(SpaceOops *soops, ListBase *lb, Scene *sce, TreeElement *te)
{
SceneRenderLayer *srl;
@@ -402,6 +405,7 @@ static void outliner_add_line_styles(SpaceOops *soops, ListBase *lb, Scene *sce,
}
}
}
+#endif
static void outliner_add_scene_contents(SpaceOops *soops, ListBase *lb, Scene *sce, TreeElement *te)
{
@@ -429,8 +433,10 @@ static void outliner_add_scene_contents(SpaceOops *soops, ListBase *lb, Scene *s
outliner_add_element(soops, lb, sce->world, te, 0, 0);
+#ifdef WITH_FREESTYLE
if (STREQ(sce->r.engine, "BLENDER_RENDER") && (sce->r.mode & R_EDGE_FRS))
outliner_add_line_styles(soops, lb, sce, te);
+#endif
}
// can be inlined if necessary
@@ -792,9 +798,15 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor
case ID_LS:
{
FreestyleLineStyle *linestyle = (FreestyleLineStyle *)id;
+ int a;
if (outliner_animdata_test(linestyle->adt))
outliner_add_element(soops, &te->subtree, linestyle, te, TSE_ANIM_DATA, 0);
+
+ for (a = 0; a < MAX_MTEX; a++) {
+ if (linestyle->mtex[a])
+ outliner_add_element(soops, &te->subtree, linestyle->mtex[a]->tex, te, 0, a);
+ }
break;
}
}
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index eede11cb51c..e25e67a9f3e 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -35,10 +35,8 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
-#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BLI_mempool.h"
-#include "BLI_ghash.h"
#include "BKE_context.h"
#include "BKE_screen.h"
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c
index c266563cd6f..8fe9dbe3eb9 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -27,18 +27,10 @@
* \ingroup spseq
*/
-
#include <stdlib.h>
#include <math.h>
#include <string.h>
-#ifndef WIN32
-#include <unistd.h>
-#else
-#include <io.h>
-#endif
-#include <sys/types.h>
-
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
@@ -47,13 +39,11 @@
#include "DNA_scene_types.h"
#include "DNA_mask_types.h"
-#include "DNA_userdef_types.h"
#include "BLF_translation.h"
#include "BKE_context.h"
#include "BKE_global.h"
-#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_sequencer.h"
#include "BKE_movieclip.h"
@@ -327,6 +317,7 @@ void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot)
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_itemf);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
ot->prop = prop;
}
@@ -419,7 +410,7 @@ void SEQUENCER_OT_movieclip_strip_add(struct wmOperatorType *ot)
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
prop = RNA_def_enum(ot->srna, "clip", DummyRNA_NULL_items, 0, "Clip", "");
RNA_def_enum_funcs(prop, RNA_movieclip_itemf);
- RNA_def_property_translation_context(prop, BLF_I18NCONTEXT_ID_MOVIECLIP);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
ot->prop = prop;
}
@@ -512,6 +503,7 @@ void SEQUENCER_OT_mask_strip_add(struct wmOperatorType *ot)
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
prop = RNA_def_enum(ot->srna, "mask", DummyRNA_NULL_items, 0, "Mask", "");
RNA_def_enum_funcs(prop, RNA_mask_itemf);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
ot->prop = prop;
}
@@ -893,7 +885,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op)
/* add color */
static int sequencer_add_effect_strip_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- short is_type_set = RNA_struct_property_is_set(op->ptr, "type");
+ bool is_type_set = RNA_struct_property_is_set(op->ptr, "type");
int type = -1;
int prop_flag = SEQPROP_ENDFRAME;
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 9f7f40899b2..e2830fca4bb 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -31,8 +31,6 @@
#include <string.h>
#include <math.h>
-#include "MEM_guardedalloc.h"
-
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
@@ -63,7 +61,6 @@
#include "ED_markers.h"
#include "ED_mask.h"
#include "ED_sequencer.h"
-#include "ED_types.h"
#include "ED_space_api.h"
#include "UI_interface.h"
@@ -71,7 +68,6 @@
#include "UI_view2d.h"
#include "WM_api.h"
-#include "WM_types.h"
/* own include */
#include "sequencer_intern.h"
@@ -342,7 +338,6 @@ 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;
- char numstr[32];
unsigned int whichsel = 0;
x1 = seq->startdisp;
@@ -401,17 +396,20 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, const float handsize_cla
if ((G.moving & G_TRANSFORM_SEQ) || (seq->flag & whichsel)) {
const char col[4] = {255, 255, 255, 255};
+ char numstr[32];
+ size_t numstr_len;
+
if (direction == SEQ_LEFTHANDLE) {
- BLI_snprintf(numstr, sizeof(numstr), "%d", seq->startdisp);
+ numstr_len = BLI_snprintf(numstr, sizeof(numstr), "%d", seq->startdisp);
x1 = rx1;
y1 -= 0.45f;
}
else {
- BLI_snprintf(numstr, sizeof(numstr), "%d", seq->enddisp - 1);
+ numstr_len = BLI_snprintf(numstr, sizeof(numstr), "%d", seq->enddisp - 1);
x1 = x2 - handsize_clamped * 0.75f;
y1 = y2 + 0.05f;
}
- UI_view2d_text_cache_add(v2d, x1, y1, numstr, col);
+ UI_view2d_text_cache_add(v2d, x1, y1, numstr, numstr_len, col);
}
}
@@ -526,6 +524,7 @@ static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float
{
rctf rect;
char str[32 + FILE_MAX];
+ size_t str_len;
const char *name = seq->name + 2;
char col[4];
@@ -534,67 +533,76 @@ static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float
name = BKE_sequence_give_name(seq);
if (seq->type == SEQ_TYPE_META || seq->type == SEQ_TYPE_ADJUSTMENT) {
- BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len);
+ str_len = BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len);
}
else if (seq->type == SEQ_TYPE_SCENE) {
if (seq->scene) {
if (seq->scene_camera) {
- BLI_snprintf(str, sizeof(str), "%s: %s (%s) | %d",
- name, seq->scene->id.name + 2, ((ID *)seq->scene_camera)->name + 2, seq->len);
+ str_len = BLI_snprintf(str, sizeof(str), "%s: %s (%s) | %d",
+ name, seq->scene->id.name + 2, ((ID *)seq->scene_camera)->name + 2, seq->len);
}
else {
- BLI_snprintf(str, sizeof(str), "%s: %s | %d",
- name, seq->scene->id.name + 2, seq->len);
+ str_len = BLI_snprintf(str, sizeof(str), "%s: %s | %d",
+ name, seq->scene->id.name + 2, seq->len);
}
}
else {
- BLI_snprintf(str, sizeof(str), "%s | %d",
- name, seq->len);
+ str_len = BLI_snprintf(str, sizeof(str), "%s | %d",
+ name, seq->len);
}
}
else if (seq->type == SEQ_TYPE_MOVIECLIP) {
if (seq->clip && strcmp(name, seq->clip->id.name + 2) != 0) {
- BLI_snprintf(str, sizeof(str), "%s: %s | %d",
- name, seq->clip->id.name + 2, seq->len);
+ str_len = BLI_snprintf(str, sizeof(str), "%s: %s | %d",
+ name, seq->clip->id.name + 2, seq->len);
}
else {
- BLI_snprintf(str, sizeof(str), "%s | %d",
- name, seq->len);
+ str_len = BLI_snprintf(str, sizeof(str), "%s | %d",
+ name, seq->len);
}
}
else if (seq->type == SEQ_TYPE_MASK) {
if (seq->mask && strcmp(name, seq->mask->id.name + 2) != 0) {
- BLI_snprintf(str, sizeof(str), "%s: %s | %d",
- name, seq->mask->id.name + 2, seq->len);
+ str_len = BLI_snprintf(str, sizeof(str), "%s: %s | %d",
+ name, seq->mask->id.name + 2, seq->len);
}
else {
- BLI_snprintf(str, sizeof(str), "%s | %d",
- name, seq->len);
+ str_len = BLI_snprintf(str, sizeof(str), "%s | %d",
+ name, seq->len);
}
}
else if (seq->type == SEQ_TYPE_MULTICAM) {
- BLI_snprintf(str, sizeof(str), "Cam %s: %d",
- name, seq->multicam_source);
+ str_len = BLI_snprintf(str, sizeof(str), "Cam %s: %d",
+ name, seq->multicam_source);
}
else if (seq->type == SEQ_TYPE_IMAGE) {
- BLI_snprintf(str, sizeof(str), "%s: %s%s | %d",
- name, seq->strip->dir, seq->strip->stripdata->name, seq->len);
+ str_len = BLI_snprintf(str, sizeof(str), "%s: %s%s | %d",
+ name, seq->strip->dir, seq->strip->stripdata->name, seq->len);
}
else if (seq->type & SEQ_TYPE_EFFECT) {
- BLI_snprintf(str, sizeof(str), "%s | %d",
- name, seq->len);
+ str_len = BLI_snprintf(str, sizeof(str), "%s | %d",
+ name, seq->len);
}
else if (seq->type == SEQ_TYPE_SOUND_RAM) {
- if (seq->sound)
- BLI_snprintf(str, sizeof(str), "%s: %s | %d",
- name, seq->sound->name, seq->len);
- else
- BLI_snprintf(str, sizeof(str), "%s | %d",
- name, seq->len);
+ if (seq->sound) {
+ str_len = BLI_snprintf(str, sizeof(str), "%s: %s | %d",
+ name, seq->sound->name, seq->len);
+ }
+ else {
+ str_len = BLI_snprintf(str, sizeof(str), "%s | %d",
+ name, seq->len);
+ }
}
else if (seq->type == SEQ_TYPE_MOVIE) {
- BLI_snprintf(str, sizeof(str), "%s: %s%s | %d",
- name, seq->strip->dir, seq->strip->stripdata->name, seq->len);
+ str_len = BLI_snprintf(str, sizeof(str), "%s: %s%s | %d",
+ name, seq->strip->dir, seq->strip->stripdata->name, seq->len);
+ }
+ else {
+ /* should never get here!, but might with files from future */
+ BLI_assert(0);
+
+ str_len = BLI_snprintf(str, sizeof(str), "%s | %d",
+ name, seq->len);
}
if (seq->flag & SELECT) {
@@ -612,7 +620,8 @@ static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float
rect.ymin = y1;
rect.xmax = x2;
rect.ymax = y2;
- UI_view2d_text_cache_rectf(v2d, &rect, str, col);
+
+ UI_view2d_text_cache_add_rectf(v2d, &rect, str, str_len, col);
}
/* draws a shaded strip, made from gradient + flat color + gradient */
@@ -918,7 +927,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
GLuint last_texid;
void *display_buffer;
void *cache_handle = NULL;
- const int is_imbuf = ED_space_sequencer_check_show_imbuf(sseq);
+ const bool is_imbuf = ED_space_sequencer_check_show_imbuf(sseq);
int format, type;
bool glsl_used = false;
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index c5f01f88706..50efa881b39 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -32,24 +32,15 @@
#include <math.h>
#include <string.h>
-#ifndef WIN32
-#include <unistd.h>
-#else
-#include <io.h>
-#endif
-#include <sys/types.h>
-
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
-#include "BLI_threads.h"
#include "BLF_translation.h"
#include "DNA_scene_types.h"
-#include "DNA_userdef_types.h"
#include "BKE_context.h"
#include "BKE_global.h"
@@ -57,7 +48,6 @@
#include "BKE_sequencer.h"
#include "BKE_report.h"
#include "BKE_sound.h"
-#include "BKE_movieclip.h"
#include "IMB_imbuf.h"
@@ -219,7 +209,7 @@ static void seq_proxy_build_job(const bContext *C)
WM_jobs_start(CTX_wm_manager(C), wm_job);
}
- ED_area_tag_redraw(CTX_wm_area(C));
+ ED_area_tag_redraw(sa);
}
/* ********************************************************************** */
@@ -2296,7 +2286,7 @@ static int sequencer_view_zoom_ratio_exec(bContext *C, wmOperator *op)
float facx = BLI_rcti_size_x(&v2d->mask) / winx;
float facy = BLI_rcti_size_y(&v2d->mask) / winy;
- BLI_rctf_resize(&v2d->cur, floorf(winx * facx * ratio + 0.5f), floorf(winy * facy * ratio + 0.5f));
+ BLI_rctf_resize(&v2d->cur, floorf(winx * facx / ratio + 0.5f), floorf(winy * facy / ratio + 0.5f));
ED_region_tag_redraw(CTX_wm_region(C));
@@ -2955,17 +2945,13 @@ void SEQUENCER_OT_swap_data(wmOperatorType *ot)
static int view_ghost_border_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);
rctf rect;
/* convert coordinates of rect to 'tot' rect coordinates */
- UI_view2d_region_to_view(v2d, RNA_int_get(op->ptr, "xmin"), RNA_int_get(op->ptr, "ymin"), &rect.xmin, &rect.ymin);
- UI_view2d_region_to_view(v2d, RNA_int_get(op->ptr, "xmax"), RNA_int_get(op->ptr, "ymax"), &rect.xmax, &rect.ymax);
-
- if (ed == NULL)
- return OPERATOR_CANCELLED;
+ WM_operator_properties_border_to_rctf(op, &rect);
+ UI_view2d_region_to_view_rctf(v2d, &rect, &rect);
rect.xmin /= fabsf(BLI_rctf_size_x(&v2d->tot));
rect.ymin /= fabsf(BLI_rctf_size_y(&v2d->tot));
@@ -3168,7 +3154,7 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
Sequence *seq = BKE_sequencer_active_get(scene);
- const int is_relative_path = RNA_boolean_get(op->ptr, "relative_path");
+ const bool is_relative_path = RNA_boolean_get(op->ptr, "relative_path");
if (seq->type == SEQ_TYPE_IMAGE) {
char directory[FILE_MAX];
diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c
index f022e78a0ad..e69a02aa3df 100644
--- a/source/blender/editors/space_sequencer/sequencer_ops.c
+++ b/source/blender/editors/space_sequencer/sequencer_ops.c
@@ -28,18 +28,11 @@
* \ingroup spseq
*/
-
#include <stdlib.h>
#include <math.h>
-
#include "DNA_space_types.h"
-#include "BLI_math.h"
-#include "BLI_blenlib.h"
-
-
-
#include "WM_api.h"
#include "WM_types.h"
diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c
index 9199c6de343..9b3b9f23036 100644
--- a/source/blender/editors/space_sequencer/sequencer_scopes.c
+++ b/source/blender/editors/space_sequencer/sequencer_scopes.c
@@ -206,7 +206,7 @@ static ImBuf *make_waveform_view_from_ibuf_float(ImBuf *ibuf)
unsigned char *last_p = NULL;
for (x = 0; x < ibuf->x; x++) {
- float *rgb = src + 4 * (ibuf->x * y + x);
+ const float *rgb = src + 4 * (ibuf->x * y + x);
float v = rgb_to_luma(rgb);
unsigned char *p = tgt;
@@ -309,7 +309,7 @@ static ImBuf *make_sep_waveform_view_from_ibuf_float(ImBuf *ibuf)
for (x = 0; x < ibuf->x; x++) {
int c;
- float *rgb = src + 4 * (ibuf->x * y + x);
+ const float *rgb = src + 4 * (ibuf->x * y + x);
for (c = 0; c < 3; c++) {
unsigned char *p = tgt;
float v = rgb[c];
@@ -379,7 +379,7 @@ static void draw_zebra_byte(ImBuf *src, ImBuf *ibuf, float perc)
static void draw_zebra_float(ImBuf *src, ImBuf *ibuf, float perc)
{
float limit = perc / 100.0f;
- float *p = src->rect_float;
+ const float *p = src->rect_float;
unsigned char *o = (unsigned char *) ibuf->rect;
int x;
int y;
@@ -545,7 +545,7 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf)
memset(cur_bins, 0, sizeof(cur_bins));
for (x = 0; x < ibuf->x; x++) {
- float *pixel = src + (y * ibuf->x + x) * 4;
+ const float *pixel = src + (y * ibuf->x + x) * 4;
cur_bins[0][get_bin_float(pixel[0])]++;
cur_bins[1][get_bin_float(pixel[1])]++;
@@ -658,8 +658,8 @@ static ImBuf *make_vectorscope_view_from_ibuf_byte(ImBuf *ibuf)
for (y = 0; y < ibuf->y; y++) {
for (x = 0; x < ibuf->x; x++) {
- char *src1 = src + 4 * (ibuf->x * y + x);
- char *p;
+ const char *src1 = src + 4 * (ibuf->x * y + x);
+ const char *p;
rgb[0] = (float)src1[0] / 255.0f;
rgb[1] = (float)src1[1] / 255.0f;
@@ -704,8 +704,8 @@ static ImBuf *make_vectorscope_view_from_ibuf_float(ImBuf *ibuf)
for (y = 0; y < ibuf->y; y++) {
for (x = 0; x < ibuf->x; x++) {
- float *src1 = src + 4 * (ibuf->x * y + x);
- char *p;
+ const float *src1 = src + 4 * (ibuf->x * y + x);
+ const char *p;
memcpy(rgb, src1, 3 * sizeof(float));
diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c
index 9edf8433fca..9826ef10902 100644
--- a/source/blender/editors/space_sequencer/sequencer_select.c
+++ b/source/blender/editors/space_sequencer/sequencer_select.c
@@ -32,15 +32,7 @@
#include <math.h>
#include <string.h>
-#ifndef WIN32
-#include <unistd.h>
-#else
-#include <io.h>
-#endif
-#include <sys/types.h>
-
#include "BLI_blenlib.h"
-#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "DNA_scene_types.h"
@@ -56,7 +48,6 @@
/* for menu/popup icons etc etc*/
-#include "ED_types.h"
#include "ED_screen.h"
#include "ED_sequencer.h"
@@ -361,7 +352,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
/* use different logic for this */
float x;
ED_sequencer_deselect_all(scene);
- UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, NULL);
+ x = UI_view2d_region_to_view_x(v2d, event->mval[0]);
SEQP_BEGIN (ed, seq)
{
@@ -849,23 +840,15 @@ static int sequencer_borderselect_exec(bContext *C, wmOperator *op)
View2D *v2d = UI_view2d_fromcontext(C);
Sequence *seq;
- rcti rect;
rctf rectf, rq;
const bool select = (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT);
const bool extend = RNA_boolean_get(op->ptr, "extend");
- int mval[2];
if (ed == NULL)
return OPERATOR_CANCELLED;
- WM_operator_properties_border_to_rcti(op, &rect);
-
- mval[0] = rect.xmin;
- mval[1] = rect.ymin;
- UI_view2d_region_to_view(v2d, mval[0], mval[1], &rectf.xmin, &rectf.ymin);
- mval[0] = rect.xmax;
- mval[1] = rect.ymax;
- UI_view2d_region_to_view(v2d, mval[0], mval[1], &rectf.xmax, &rectf.ymax);
+ WM_operator_properties_border_to_rctf(op, &rectf);
+ UI_view2d_region_to_view_rctf(v2d, &rectf, &rectf);
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
seq_rectf(seq, &rq);
@@ -952,7 +935,7 @@ static bool select_grouped_type_basic(Editing *ed, Sequence *actseq)
{
Sequence *seq;
bool changed = false;
- short is_sound = SEQ_IS_SOUND(actseq);
+ const bool is_sound = SEQ_IS_SOUND(actseq);
SEQP_BEGIN (ed, seq)
{
@@ -988,7 +971,7 @@ static bool select_grouped_data(Editing *ed, Sequence *actseq)
{
Sequence *seq;
bool changed = false;
- char *dir = actseq->strip ? actseq->strip->dir : NULL;
+ const char *dir = actseq->strip ? actseq->strip->dir : NULL;
if (!SEQ_USE_DATA(actseq))
return changed;
diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c
index cad25663609..7fdbc9cc7de 100644
--- a/source/blender/editors/space_sequencer/sequencer_view.c
+++ b/source/blender/editors/space_sequencer/sequencer_view.c
@@ -70,7 +70,7 @@ typedef struct ImageSampleInfo {
float linearcol[4];
unsigned char *colp;
- float *colfp;
+ const float *colfp;
int draw;
int color_manage;
@@ -110,7 +110,7 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
fy += (float) ibuf->y / 2.0f;
if (fx >= 0.0f && fy >= 0.0f && fx < ibuf->x && fy < ibuf->y) {
- float *fp;
+ const float *fp;
unsigned char *cp;
int x = (int) fx, y = (int) fy;
diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c
index f24d853369c..a94b73802b2 100644
--- a/source/blender/editors/space_sequencer/space_sequencer.c
+++ b/source/blender/editors/space_sequencer/space_sequencer.c
@@ -38,7 +38,6 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
-#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BKE_context.h"
@@ -47,7 +46,6 @@
#include "BKE_global.h"
#include "ED_space_api.h"
-#include "ED_sequencer.h"
#include "ED_screen.h"
#include "ED_view3d.h" /* only for sequencer view3d drawing callback */
diff --git a/source/blender/editors/space_text/text_autocomplete.c b/source/blender/editors/space_text/text_autocomplete.c
index d3b494631bb..99e1606c9bd 100644
--- a/source/blender/editors/space_text/text_autocomplete.c
+++ b/source/blender/editors/space_text/text_autocomplete.c
@@ -232,7 +232,7 @@ static GHash *text_autocomplete_build(Text *text)
static void get_suggest_prefix(Text *text, int offset)
{
int i, len;
- char *line;
+ const char *line;
if (!text) return;
if (!texttool_text_is_active(text)) return;
@@ -494,7 +494,7 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
}
if (draw) {
- ED_area_tag_redraw(CTX_wm_area(C));
+ ED_area_tag_redraw(sa);
}
// if (swallow) {
diff --git a/source/blender/editors/space_text/text_header.c b/source/blender/editors/space_text/text_header.c
index aaeea40c1a5..b1d57f5a75e 100644
--- a/source/blender/editors/space_text/text_header.c
+++ b/source/blender/editors/space_text/text_header.c
@@ -28,14 +28,6 @@
* \ingroup sptext
*/
-
-
-/* file time checking */
-
-#ifndef _WIN32
-#else
-#endif
-
#include "DNA_windowmanager_types.h"
#include "MEM_guardedalloc.h"
@@ -51,10 +43,6 @@
#include "WM_types.h"
-#ifdef WITH_PYTHON
-// XXX #include "BPY_menus.h"
-#endif
-
#include "text_intern.h"
/* ************************ header area region *********************** */
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index b45838e0bac..0263b6cd912 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -38,7 +38,6 @@
#include "DNA_text_types.h"
#include "BLI_blenlib.h"
-#include "BLI_math.h"
#include "BLF_translation.h"
@@ -272,7 +271,7 @@ static int text_open_exec(bContext *C, wmOperator *op)
static int text_open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
Text *text = CTX_data_edit_text(C);
- char *path = (text && text->name) ? text->name : G.main->name;
+ const char *path = (text && text->name) ? text->name : G.main->name;
if (RNA_struct_property_is_set(op->ptr, "filepath"))
return text_open_exec(C, op);
@@ -472,18 +471,18 @@ static void txt_write_file(Text *text, ReportList *reports)
return;
}
- tmp = text->lines.first;
- while (tmp) {
- if (tmp->next) fprintf(fp, "%s\n", tmp->line);
- else fprintf(fp, "%s", tmp->line);
-
- tmp = tmp->next;
+ for (tmp = text->lines.first; tmp; tmp = tmp->next) {
+ fputs(tmp->line, fp);
+ fputc('\n', fp);
}
fclose(fp);
if (BLI_stat(filepath, &st) == 0) {
text->mtime = st.st_mtime;
+
+ /* report since this can be called from key-shortcuts */
+ BKE_reportf(reports, RPT_INFO, "Saved Text '%s'", filepath);
}
else {
text->mtime = 0;
@@ -545,7 +544,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))
{
Text *text = CTX_data_edit_text(C);
- char *str;
+ const char *str;
if (RNA_struct_property_is_set(op->ptr, "filepath"))
return text_save_as_exec(C, op);
@@ -2845,7 +2844,7 @@ static int text_insert_exec(bContext *C, wmOperator *op)
SpaceText *st = CTX_wm_space_text(C);
Text *text = CTX_data_edit_text(C);
char *str;
- int done = false;
+ bool done = false;
size_t i = 0;
unsigned int code;
diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c
index eba4451502e..2fd4b0bc21d 100644
--- a/source/blender/editors/space_time/space_time.c
+++ b/source/blender/editors/space_time/space_time.c
@@ -42,7 +42,6 @@
#include "BLI_utildefines.h"
#include "BKE_context.h"
-#include "BKE_global.h"
#include "BKE_screen.h"
#include "BKE_pointcache.h"
@@ -67,20 +66,17 @@
/* ************************ main time area region *********************** */
static void time_draw_sfra_efra(Scene *scene, View2D *v2d)
-{
- /* Draw darkened area outside of active timeline frame range used is preview range or scene range.
- * Note we use STFRA - 0.5 and PEFRA + 0.5, else visible 'active' area is one frame less than what's expected!
+{
+ /* draw darkened area outside of active timeline
+ * frame range used is preview range or scene range
*/
- const float psfra = ((float)PSFRA) - 0.5f;
- const float pefra = ((float)PEFRA) + 0.5f;
-
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
-
- if (psfra < pefra) {
- glRectf(v2d->cur.xmin, v2d->cur.ymin, psfra, v2d->cur.ymax);
- glRectf(pefra, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
+
+ if (PSFRA < PEFRA) {
+ glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
+ glRectf((float)PEFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
}
else {
glRectf(v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
@@ -89,8 +85,8 @@ static void time_draw_sfra_efra(Scene *scene, View2D *v2d)
UI_ThemeColorShade(TH_BACK, -60);
/* thin lines where the actual frames are */
- fdrawline(psfra, v2d->cur.ymin, psfra, v2d->cur.ymax);
- fdrawline(pefra, v2d->cur.ymin, pefra, v2d->cur.ymax);
+ fdrawline((float)PSFRA, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
+ fdrawline((float)PEFRA, v2d->cur.ymin, (float)PEFRA, v2d->cur.ymax);
}
#define CACHE_DRAW_HEIGHT 3.0f
@@ -339,18 +335,18 @@ static void time_draw_idblock_keyframes(View2D *v2d, ID *id, short onlysel)
}
/* draw keyframe lines for timeline */
-static void time_draw_keyframes(const bContext *C, SpaceTime *stime, ARegion *ar)
+static void time_draw_keyframes(const bContext *C, ARegion *ar)
{
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
View2D *v2d = &ar->v2d;
- short onlysel = (stime->flag & TIME_ONLYACTSEL);
+ bool onlysel = ((scene->flag & SCE_KEYS_NO_SELONLY) == 0);
/* draw scene keyframes first
* - don't try to do this when only drawing active/selected data keyframes,
* since this can become quite slow
*/
- if (scene && onlysel == 0) {
+ if (onlysel == 0) {
/* set draw color */
glColor3ub(0xDD, 0xA7, 0x00);
time_draw_idblock_keyframes(v2d, (ID *)scene, onlysel);
@@ -519,7 +515,7 @@ static void time_main_area_draw(const bContext *C, ARegion *ar)
UI_view2d_view_ortho(v2d);
/* keyframes */
- time_draw_keyframes(C, stime, ar);
+ time_draw_keyframes(C, ar);
/* markers */
UI_view2d_view_orthoSpecial(ar, v2d, 1);
diff --git a/source/blender/editors/space_time/time_ops.c b/source/blender/editors/space_time/time_ops.c
index 0de9c296d3e..e2e861fda38 100644
--- a/source/blender/editors/space_time/time_ops.c
+++ b/source/blender/editors/space_time/time_ops.c
@@ -147,8 +147,8 @@ static int time_view_all_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
/* set extents of view to start/end frames (Preview Range too) */
- v2d->cur.xmin = ((float)PSFRA) - 0.5f;
- v2d->cur.xmax = ((float)PEFRA) + 0.5f;
+ v2d->cur.xmin = (float)PSFRA;
+ v2d->cur.xmax = (float)PEFRA;
/* we need an extra "buffer" factor on either side so that the endpoints are visible */
extra = 0.01f * BLI_rctf_size_x(&v2d->cur);
diff --git a/source/blender/editors/space_view3d/drawanimviz.c b/source/blender/editors/space_view3d/drawanimviz.c
index 82e85e3a449..17f90fc54e3 100644
--- a/source/blender/editors/space_view3d/drawanimviz.c
+++ b/source/blender/editors/space_view3d/drawanimviz.c
@@ -238,22 +238,25 @@ void draw_motion_path_instance(Scene *scene,
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];
/* only draw framenum if several consecutive highlighted points don't occur on same point */
if (i == 0) {
- sprintf(numstr, " %d", frame);
+ numstr_len = sprintf(numstr, " %d", frame);
mul_v3_m4v3(co, ob->imat, mpv->co);
- view3d_cached_text_draw_add(co, numstr, 0, V3D_CACHE_TEXT_WORLDSPACE | V3D_CACHE_TEXT_ASCII, col);
+ view3d_cached_text_draw_add(co, numstr, numstr_len,
+ 0, V3D_CACHE_TEXT_WORLDSPACE | V3D_CACHE_TEXT_ASCII, col);
}
else if ((i >= stepsize) && (i < len - stepsize)) {
bMotionPathVert *mpvP = (mpv - stepsize);
bMotionPathVert *mpvN = (mpv + stepsize);
if ((equals_v3v3(mpv->co, mpvP->co) == 0) || (equals_v3v3(mpv->co, mpvN->co) == 0)) {
- sprintf(numstr, " %d", frame);
+ numstr_len = sprintf(numstr, " %d", frame);
mul_v3_m4v3(co, ob->imat, mpv->co);
- view3d_cached_text_draw_add(co, numstr, 0, V3D_CACHE_TEXT_WORLDSPACE | V3D_CACHE_TEXT_ASCII, col);
+ view3d_cached_text_draw_add(co, numstr, numstr_len,
+ 0, V3D_CACHE_TEXT_WORLDSPACE | V3D_CACHE_TEXT_ASCII, col);
}
}
}
@@ -314,10 +317,12 @@ void draw_motion_path_instance(Scene *scene,
if (BLI_dlrbTree_search_exact(&keys, compare_ak_cfraPtr, &mframe)) {
char numstr[32];
+ size_t numstr_len;
- sprintf(numstr, " %d", (sfra + i));
+ numstr_len = sprintf(numstr, " %d", (sfra + i));
mul_v3_m4v3(co, ob->imat, mpv->co);
- view3d_cached_text_draw_add(co, numstr, 0, V3D_CACHE_TEXT_WORLDSPACE | V3D_CACHE_TEXT_ASCII, col);
+ view3d_cached_text_draw_add(co, numstr, numstr_len,
+ 0, V3D_CACHE_TEXT_WORLDSPACE | V3D_CACHE_TEXT_ASCII, col);
}
}
}
diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c
index 4a2fd5f7004..245cdadc7a2 100644
--- a/source/blender/editors/space_view3d/drawarmature.c
+++ b/source/blender/editors/space_view3d/drawarmature.c
@@ -271,7 +271,7 @@ static bool set_pchan_glColor(short colCode, int boneflag, short constflag)
}
else {
if (bcolor) {
- char *cp = bcolor->solid;
+ const char *cp = bcolor->solid;
glColor4ub(cp[0], cp[1], cp[2], 204);
}
else
@@ -1467,7 +1467,7 @@ static void bgl_sphere_project(float ax, float az)
static void draw_dof_ellipse(float ax, float az)
{
- static float staticSine[16] = {
+ const float staticSine[16] = {
0.0f, 0.104528463268f, 0.207911690818f, 0.309016994375f,
0.406736643076f, 0.5f, 0.587785252292f, 0.669130606359f,
0.743144825477f, 0.809016994375f, 0.866025403784f,
@@ -2065,7 +2065,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
/* Draw names of bone */
if (arm->flag & ARM_DRAWNAMES) {
mid_v3_v3v3(vec, pchan->pose_head, pchan->pose_tail);
- view3d_cached_text_draw_add(vec, pchan->name, 10, 0, col);
+ view3d_cached_text_draw_add(vec, pchan->name, strlen(pchan->name), 10, 0, col);
}
/* Draw additional axes on the bone tail */
@@ -2270,7 +2270,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt)
if (arm->flag & ARM_DRAWNAMES) {
mid_v3_v3v3(vec, eBone->head, eBone->tail);
glRasterPos3fv(vec);
- view3d_cached_text_draw_add(vec, eBone->name, 10, 0, col);
+ view3d_cached_text_draw_add(vec, eBone->name, strlen(eBone->name), 10, 0, col);
}
/* Draw additional axes */
if (arm->flag & ARM_DRAWAXES) {
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c
index bc9a9aacd03..03f2fa86ecb 100644
--- a/source/blender/editors/space_view3d/drawmesh.c
+++ b/source/blender/editors/space_view3d/drawmesh.c
@@ -33,7 +33,6 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
-#include "BLI_blenlib.h"
#include "BLI_bitmap.h"
#include "BLI_math.h"
@@ -46,10 +45,8 @@
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_view3d_types.h"
-#include "DNA_windowmanager_types.h"
#include "BKE_DerivedMesh.h"
-#include "BKE_effect.h"
#include "BKE_global.h"
#include "BKE_image.h"
#include "BKE_material.h"
@@ -70,7 +67,6 @@
#include "RE_engine.h"
-#include "ED_mesh.h"
#include "ED_uvedit.h"
#include "view3d_intern.h" /* own include */
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 84b39356089..7f56b4a9822 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -43,8 +43,11 @@
#include "DNA_world_types.h"
#include "DNA_object_types.h"
-#include "BLI_blenlib.h"
+#include "BLI_listbase.h"
+#include "BLI_link_utils.h"
+#include "BLI_string.h"
#include "BLI_math.h"
+#include "BLI_memarena.h"
#include "BKE_anim.h" /* for the where_on_path function */
#include "BKE_armature.h"
@@ -153,8 +156,8 @@ typedef struct drawDMFacesSel_userData {
BMesh *bm;
BMFace *efa_act;
- int *orig_index_mf_to_mpoly;
- int *orig_index_mp_to_orig;
+ const int *orig_index_mf_to_mpoly;
+ const int *orig_index_mp_to_orig;
} drawDMFacesSel_userData;
typedef struct drawDMNormal_userData {
@@ -742,11 +745,9 @@ static void drawcentercircle(View3D *v3d, RegionView3D *rv3d, const float co[3],
}
/* *********** text drawing for object/particles/armature ************* */
-static ListBase CachedText[3];
-static int CachedTextLevel = 0;
typedef struct ViewCachedString {
- struct ViewCachedString *next, *prev;
+ struct ViewCachedString *next;
float vec[3];
union {
unsigned char ub[4];
@@ -759,43 +760,61 @@ typedef struct ViewCachedString {
/* str is allocated past the end */
} ViewCachedString;
+/* one arena for all 3 string lists */
+static MemArena *g_v3d_strings_arena = NULL;
+static ViewCachedString *g_v3d_strings[3] = {NULL, NULL, NULL};
+static int g_v3d_string_level = -1;
+
void view3d_cached_text_draw_begin(void)
{
- ListBase *strings = &CachedText[CachedTextLevel];
- BLI_listbase_clear(strings);
- CachedTextLevel++;
+ g_v3d_string_level++;
+
+ BLI_assert(g_v3d_string_level >= 0);
+
+ if (g_v3d_string_level == 0) {
+ BLI_assert(g_v3d_strings_arena == NULL);
+ }
}
void view3d_cached_text_draw_add(const float co[3],
- const char *str,
+ const char *str, const size_t str_len,
short xoffs, short flag,
const unsigned char col[4])
{
- int alloc_len = strlen(str) + 1;
- ListBase *strings = &CachedText[CachedTextLevel - 1];
+ int alloc_len = str_len + 1;
/* TODO, replace with more efficient malloc, perhaps memarena per draw? */
- ViewCachedString *vos = MEM_callocN(sizeof(ViewCachedString) + alloc_len, "ViewCachedString");
+ ViewCachedString *vos;
+
+ BLI_assert(str_len == strlen(str));
+
+ if (g_v3d_strings_arena == NULL) {
+ g_v3d_strings_arena = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 14), __func__);
+ }
+
+ vos = BLI_memarena_alloc(g_v3d_strings_arena, sizeof(ViewCachedString) + alloc_len);
+
+ BLI_LINKS_PREPEND(g_v3d_strings[g_v3d_string_level], vos);
- BLI_addtail(strings, vos);
copy_v3_v3(vos->vec, co);
copy_v4_v4_char((char *)vos->col.ub, (const char *)col);
vos->xoffs = xoffs;
vos->flag = flag;
- vos->str_len = alloc_len - 1;
+ vos->str_len = str_len;
/* allocate past the end */
- memcpy(++vos, str, alloc_len);
+ memcpy(vos + 1, str, alloc_len);
}
void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, bool depth_write, float mat[4][4])
{
RegionView3D *rv3d = ar->regiondata;
- ListBase *strings = &CachedText[CachedTextLevel - 1];
ViewCachedString *vos;
int tot = 0;
+ BLI_assert(g_v3d_string_level >= 0 && g_v3d_string_level <= 2);
+
/* project first and test */
- for (vos = strings->first; vos; vos = vos->next) {
+ for (vos = g_v3d_strings[g_v3d_string_level]; vos; vos = vos->next) {
if (mat && !(vos->flag & V3D_CACHE_TEXT_WORLDSPACE))
mul_m4_v3(mat, vos->vec);
@@ -840,7 +859,7 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, bool depth_write, flo
glDepthMask(0);
}
- for (vos = strings->first; vos; vos = vos->next) {
+ for (vos = g_v3d_strings[g_v3d_string_level]; vos; vos = vos->next) {
if (vos->sco[0] != IS_CLIPPED) {
const char *str = (char *)(vos + 1);
@@ -859,7 +878,7 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, bool depth_write, flo
vos->str_len);
}
}
-
+
if (depth_write) {
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
}
@@ -876,11 +895,17 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, bool depth_write, flo
ED_view3d_clipping_enable();
}
}
-
- if (strings->first)
- BLI_freelistN(strings);
-
- CachedTextLevel--;
+
+ g_v3d_strings[g_v3d_string_level] = NULL;
+
+ if (g_v3d_string_level == 0) {
+ if (g_v3d_strings_arena) {
+ BLI_memarena_free(g_v3d_strings_arena);
+ g_v3d_strings_arena = NULL;
+ }
+ }
+
+ g_v3d_string_level--;
}
/* ******************** primitive drawing ******************* */
@@ -1091,8 +1116,8 @@ static void draw_transp_spot_volume(Lamp *la, float x, float z)
glCullFace(GL_BACK);
}
-static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
- const char dt, const short dflag, const unsigned char ob_wire_col[4])
+static void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base,
+ const char dt, const short dflag, const unsigned char ob_wire_col[4], const bool is_obact)
{
Object *ob = base->object;
const float pixsize = ED_view3d_pixel_size(rv3d, ob->obmat[3]);
@@ -1147,8 +1172,12 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
if ((dflag & DRAW_CONSTCOLOR) == 0) {
if (ob->id.us > 1) {
- if (ob == OBACT || (ob->flag & SELECT)) glColor4ub(0x88, 0xFF, 0xFF, 155);
- else glColor4ub(0x77, 0xCC, 0xCC, 155);
+ if (is_obact || (ob->flag & SELECT)) {
+ glColor4ub(0x88, 0xFF, 0xFF, 155);
+ }
+ else {
+ glColor4ub(0x77, 0xCC, 0xCC, 155);
+ }
}
}
@@ -1188,7 +1217,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
short axis;
/* setup a 45 degree rotation matrix */
- axis_angle_normalized_to_mat3(mat, imat[2], (float)M_PI / 4.0f);
+ axis_angle_normalized_to_mat3_ex(mat, imat[2], M_SQRT1_2, M_SQRT1_2);
/* vectors */
mul_v3_v3fl(v1, imat[0], circrad * 1.2f);
@@ -1228,7 +1257,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
copy_v3_fl3(lvec, 0.0f, 0.0f, 1.0f);
copy_v3_fl3(vvec, rv3d->persmat[0][2], rv3d->persmat[1][2], rv3d->persmat[2][2]);
- mul_mat3_m4_v3(ob->obmat, vvec);
+ mul_transposed_mat3_m4_v3(ob->obmat, vvec);
x = -la->dist;
y = cosf(la->spotsize * 0.5f);
@@ -1272,7 +1301,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
/* draw the circle/square representing spotbl */
if (la->type == LA_SPOT) {
- float spotblcirc = fabs(z) * (1 - pow(la->spotblend, 2));
+ float spotblcirc = fabsf(z) * (1.0f - powf(la->spotblend, 2));
/* hide line if it is zero size or overlaps with outer border,
* previously it adjusted to always to show it but that seems
* confusing because it doesn't show the actual blend size */
@@ -1601,7 +1630,10 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D
float pos[3];
mul_v3_m4v3(pos, mat, track->bundle_pos);
- view3d_cached_text_draw_add(pos, track->name, 10, V3D_CACHE_TEXT_GLOBALSPACE, selected ? col_sel : col_unsel);
+ view3d_cached_text_draw_add(pos,
+ track->name, strlen(track->name),
+ 10, V3D_CACHE_TEXT_GLOBALSPACE,
+ selected ? col_sel : col_unsel);
}
tracknr++;
@@ -1850,7 +1882,7 @@ static void drawspeaker(Scene *UNUSED(scene), View3D *UNUSED(v3d), RegionView3D
static void lattice_draw_verts(Lattice *lt, DispList *dl, BPoint *actbp, short sel)
{
BPoint *bp = lt->def;
- float *co = dl ? dl->verts : NULL;
+ const float *co = dl ? dl->verts : NULL;
int u, v, w;
const int color = sel ? TH_VERTEX_SELECT : TH_VERTEX;
@@ -2399,6 +2431,47 @@ static int draw_dm_test_freestyle_face_mark(BMesh *bm, BMFace *efa)
#endif
+/* Draw loop normals. */
+static void draw_dm_loop_normals__mapFunc(void *userData, int vertex_index, int face_index,
+ const float co[3], const float no[3])
+{
+ if (no) {
+ const drawDMNormal_userData *data = userData;
+ const BMVert *eve = BM_vert_at_index(data->bm, vertex_index);
+ const BMFace *efa = BM_face_at_index(data->bm, face_index);
+ float vec[3];
+
+ if (!(BM_elem_flag_test(eve, BM_ELEM_HIDDEN) || BM_elem_flag_test(efa, BM_ELEM_HIDDEN))) {
+ if (!data->uniform_scale) {
+ mul_v3_m3v3(vec, (float(*)[3])data->tmat, no);
+ normalize_v3(vec);
+ mul_m3_v3((float(*)[3])data->imat, vec);
+ }
+ else {
+ copy_v3_v3(vec, no);
+ }
+ mul_v3_fl(vec, data->normalsize);
+ add_v3_v3(vec, co);
+ glVertex3fv(co);
+ glVertex3fv(vec);
+ }
+ }
+}
+
+static void draw_dm_loop_normals(BMEditMesh *em, Scene *scene, Object *ob, DerivedMesh *dm)
+{
+ drawDMNormal_userData data;
+
+ data.bm = em->bm;
+ data.normalsize = scene->toolsettings->normalsize;
+
+ calcDrawDMNormalScale(ob, &data);
+
+ glBegin(GL_LINES);
+ dm->foreachMappedLoop(dm, draw_dm_loop_normals__mapFunc, &data, DM_FOREACH_USE_NORMAL);
+ glEnd();
+}
+
/* Draw faces with color set based on selection
* return 2 for the active face so it renders with stipple enabled */
static DMDrawOption draw_dm_faces_sel__setDrawOptions(void *userData, int index)
@@ -2734,6 +2807,7 @@ static void draw_em_measure_stats(ARegion *ar, View3D *v3d, Object *ob, BMEditMe
Mesh *me = ob->data;
float v1[3], v2[3], v3[3], vmid[3], fvec[3];
char numstr[32]; /* Stores the measurement display text here */
+ size_t numstr_len;
const char *conv_float; /* Use a float conversion matching the grid size */
unsigned char col[4] = {0, 0, 0, 255}; /* color of the text to draw */
float area; /* area of the face */
@@ -2811,14 +2885,14 @@ static void draw_em_measure_stats(ARegion *ar, View3D *v3d, Object *ob, BMEditMe
}
if (unit->system) {
- bUnit_AsString(numstr, sizeof(numstr), len_v3v3(v1, v2) * unit->scale_length, 3,
- unit->system, B_UNIT_LENGTH, do_split, false);
+ numstr_len = bUnit_AsString(numstr, sizeof(numstr), len_v3v3(v1, v2) * unit->scale_length, 3,
+ unit->system, B_UNIT_LENGTH, do_split, false);
}
else {
- BLI_snprintf(numstr, sizeof(numstr), conv_float, len_v3v3(v1, v2));
+ numstr_len = BLI_snprintf(numstr, sizeof(numstr), conv_float, len_v3v3(v1, v2));
}
- view3d_cached_text_draw_add(vmid, numstr, 0, txt_flag, col);
+ view3d_cached_text_draw_add(vmid, numstr, numstr_len, 0, txt_flag, col);
}
}
}
@@ -2894,9 +2968,9 @@ static void draw_em_measure_stats(ARegion *ar, View3D *v3d, Object *ob, BMEditMe
angle = angle_normalized_v3v3(no_a, no_b);
- BLI_snprintf(numstr, sizeof(numstr), "%.3f", is_rad ? angle : RAD2DEGF(angle));
+ numstr_len = BLI_snprintf(numstr, sizeof(numstr), "%.3f", is_rad ? angle : RAD2DEGF(angle));
- view3d_cached_text_draw_add(vmid, numstr, 0, txt_flag, col);
+ view3d_cached_text_draw_add(vmid, numstr, numstr_len, 0, txt_flag, col);
}
}
}
@@ -2913,14 +2987,15 @@ static void draw_em_measure_stats(ARegion *ar, View3D *v3d, Object *ob, BMEditMe
if (BM_elem_flag_test(f, BM_ELEM_SELECT)) { \
mul_v3_fl(vmid, 1.0f / (float)n); \
if (unit->system) { \
- bUnit_AsString(numstr, sizeof(numstr), \
- (double)(area * unit->scale_length * unit->scale_length), \
- 3, unit->system, B_UNIT_AREA, do_split, false); \
+ numstr_len = bUnit_AsString( \
+ numstr, sizeof(numstr), \
+ (double)(area * unit->scale_length * unit->scale_length), \
+ 3, unit->system, B_UNIT_AREA, do_split, false); \
} \
else { \
- BLI_snprintf(numstr, sizeof(numstr), conv_float, area); \
+ numstr_len = BLI_snprintf(numstr, sizeof(numstr), conv_float, area); \
} \
- view3d_cached_text_draw_add(vmid, numstr, 0, txt_flag, col); \
+ view3d_cached_text_draw_add(vmid, numstr, numstr_len, 0, txt_flag, col); \
} (void)0
UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEAREA, col);
@@ -3036,9 +3111,9 @@ static void draw_em_measure_stats(ARegion *ar, View3D *v3d, Object *ob, BMEditMe
angle = angle_v3v3v3(v1, v2, v3);
- BLI_snprintf(numstr, sizeof(numstr), "%.3f", is_rad ? angle : RAD2DEGF(angle));
+ numstr_len = BLI_snprintf(numstr, sizeof(numstr), "%.3f", is_rad ? angle : RAD2DEGF(angle));
interp_v3_v3v3(fvec, vmid, v2_local, 0.8f);
- view3d_cached_text_draw_add(fvec, numstr, 0, txt_flag, col);
+ view3d_cached_text_draw_add(fvec, numstr, numstr_len, 0, txt_flag, col);
}
}
}
@@ -3054,6 +3129,7 @@ static void draw_em_indices(BMEditMesh *em)
BMVert *v;
int i;
char numstr[32];
+ size_t numstr_len;
float pos[3];
unsigned char col[4];
@@ -3066,8 +3142,8 @@ static void draw_em_indices(BMEditMesh *em)
UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col);
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
- BLI_snprintf(numstr, sizeof(numstr), "%d", i);
- view3d_cached_text_draw_add(v->co, numstr, 0, txt_flag, col);
+ numstr_len = BLI_snprintf(numstr, sizeof(numstr), "%d", i);
+ view3d_cached_text_draw_add(v->co, numstr, numstr_len, 0, txt_flag, col);
}
i++;
}
@@ -3078,9 +3154,9 @@ static void draw_em_indices(BMEditMesh *em)
UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGELEN, col);
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
if (BM_elem_flag_test(e, BM_ELEM_SELECT)) {
- BLI_snprintf(numstr, sizeof(numstr), "%d", i);
+ numstr_len = BLI_snprintf(numstr, sizeof(numstr), "%d", i);
mid_v3_v3v3(pos, e->v1->co, e->v2->co);
- view3d_cached_text_draw_add(pos, numstr, 0, txt_flag, col);
+ view3d_cached_text_draw_add(pos, numstr, numstr_len, 0, txt_flag, col);
}
i++;
}
@@ -3092,8 +3168,8 @@ static void draw_em_indices(BMEditMesh *em)
BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
if (BM_elem_flag_test(f, BM_ELEM_SELECT)) {
BM_face_calc_center_mean(f, pos);
- BLI_snprintf(numstr, sizeof(numstr), "%d", i);
- view3d_cached_text_draw_add(pos, numstr, 0, txt_flag, col);
+ numstr_len = BLI_snprintf(numstr, sizeof(numstr), "%d", i);
+ view3d_cached_text_draw_add(pos, numstr, numstr_len, 0, txt_flag, col);
}
i++;
}
@@ -3347,6 +3423,10 @@ static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d,
UI_ThemeColor(TH_VNORMAL);
draw_dm_vert_normals(em, scene, ob, cageDM);
}
+ if (me->drawflag & ME_DRAW_LNORMALS) {
+ UI_ThemeColor(TH_VNORMAL);
+ draw_dm_loop_normals(em, scene, ob, cageDM);
+ }
if ((me->drawflag & (ME_DRAWEXTRA_EDGELEN |
ME_DRAWEXTRA_FACEAREA |
@@ -3406,7 +3486,11 @@ static void draw_mesh_object_outline(View3D *v3d, Object *ob, DerivedMesh *dm)
static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base,
const char dt, const unsigned char ob_wire_col[4], const short dflag)
{
- Object *ob = BKE_object_lod_meshob_get(base->object, scene);
+#ifdef WITH_GAMEENGINE
+ Object *ob = (rv3d->rflag & RV3D_IS_GAME_ENGINE) ? BKE_object_lod_meshob_get(base->object, scene) : base->object;
+#else
+ Object *ob = base->object;
+#endif
Mesh *me = ob->data;
Material *ma = give_current_material(ob, 1);
const bool hasHaloMat = (ma && (ma->material_type == MA_TYPE_HALO) && !BKE_scene_use_new_shading_nodes(scene));
@@ -3419,6 +3503,8 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
if (!dm)
return;
+ DM_update_materials(dm, ob);
+
/* Check to draw dynamic paint colors (or weights from WeightVG modifiers).
* Note: Last "preview-active" modifier in stack will win! */
if (DM_get_tessface_data_layer(dm, CD_PREVIEW_MCOL) && modifiers_isPreview(ob))
@@ -3469,14 +3555,12 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
Paint *p;
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
- /* this will get ignored mostly, will only be relevant for matcaps */
- glColor3f(1.0, 1.0, 1.0);
if ((v3d->flag2 & V3D_SHOW_SOLID_MATCAP) && ob->sculpt && (p = BKE_paint_get_active(scene))) {
GPUVertexAttribs gattribs;
float planes[4][4];
float (*fpl)[4] = NULL;
- int fast = (p->flags & PAINT_FAST_NAVIGATE) && (rv3d->rflag & RV3D_NAVIGATING);
+ const bool fast = (p->flags & PAINT_FAST_NAVIGATE) && (rv3d->rflag & RV3D_NAVIGATING);
if (ob->sculpt->partial_redraw) {
if (ar->do_draw & RGN_DRAW_PARTIAL) {
@@ -3574,7 +3658,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
if (ob->sculpt && (p = BKE_paint_get_active(scene))) {
float planes[4][4];
float (*fpl)[4] = NULL;
- int fast = (p->flags & PAINT_FAST_NAVIGATE) && (rv3d->rflag & RV3D_NAVIGATING);
+ const bool fast = (p->flags & PAINT_FAST_NAVIGATE) && (rv3d->rflag & RV3D_NAVIGATING);
if (ob->sculpt->partial_redraw) {
if (ar->do_draw & RGN_DRAW_PARTIAL) {
@@ -3642,7 +3726,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
glDepthMask(0); /* disable write in zbuffer, selected edge wires show better */
}
- dm->drawEdges(dm, (dt == OB_WIRE || totface == 0), (ob->dtx & OB_DRAW_ALL_EDGES));
+ dm->drawEdges(dm, (dt == OB_WIRE || totface == 0), (ob->dtx & OB_DRAW_ALL_EDGES) != 0);
if (dt != OB_WIRE && (draw_wire == OBDRAW_WIRE_ON_DEPTH)) {
glDepthMask(1);
@@ -3682,7 +3766,7 @@ static bool draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3
if (v3d->flag2 & V3D_RENDER_SHADOW) {
for (i = 0; i < ob->totcol; ++i) {
Material *ma = give_current_material(ob, i);
- if (ma && !(ma->mode & MA_SHADBUF)) {
+ if (ma && !(ma->mode2 & MA_CASTSHADOW)) {
return true;
}
}
@@ -3709,6 +3793,9 @@ static bool draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3
cageDM = editbmesh_get_derived_cage_and_final(scene, ob, em, &finalDM,
scene->customdata_mask);
+ DM_update_materials(finalDM, ob);
+ DM_update_materials(cageDM, ob);
+
if (dt > OB_WIRE) {
const bool glsl = draw_glsl_material(scene, ob, v3d, dt);
@@ -3775,7 +3862,7 @@ static bool drawDispListwire(ListBase *dlbase)
{
DispList *dl;
int parts, nr;
- float *data;
+ const float *data;
if (dlbase == NULL) return 1;
@@ -3869,8 +3956,8 @@ static void drawDispListsolid(ListBase *lb, Object *ob, const short dflag,
{
DispList *dl;
GPUVertexAttribs gattribs;
- float *data;
- float *ndata;
+ const float *data;
+ const float *ndata;
if (lb == NULL) return;
@@ -3997,6 +4084,8 @@ static bool drawCurveDerivedMesh(Scene *scene, View3D *v3d, RegionView3D *rv3d,
return true;
}
+ DM_update_materials(dm, ob);
+
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
if (dt > OB_WIRE && dm->getNumTessFaces(dm)) {
@@ -4425,6 +4514,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
bool select = (ob->flag & SELECT) != 0, create_cdata = false, need_v = false;
GLint polygonmode[2];
char numstr[32];
+ size_t numstr_len;
unsigned char tcol[4] = {0, 0, 0, 255};
/* 1. */
@@ -4772,28 +4862,32 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
if ((part->draw & PART_DRAW_NUM || part->draw & PART_DRAW_HEALTH) &&
(v3d->flag2 & V3D_RENDER_OVERRIDE) == 0)
{
+ size_t numstr_len;
float vec_txt[3];
char *val_pos = numstr;
numstr[0] = '\0';
if (part->draw & PART_DRAW_NUM) {
if (a < totpart && (part->draw & PART_DRAW_HEALTH) && (part->phystype == PART_PHYS_BOIDS)) {
- BLI_snprintf(val_pos, sizeof(numstr), "%d:%.2f", a, pa_health);
+ numstr_len = BLI_snprintf(val_pos, sizeof(numstr), "%d:%.2f", a, pa_health);
}
else {
- BLI_snprintf(val_pos, sizeof(numstr), "%d", a);
+ numstr_len = BLI_snprintf(val_pos, sizeof(numstr), "%d", a);
}
}
else {
if (a < totpart && (part->draw & PART_DRAW_HEALTH) && (part->phystype == PART_PHYS_BOIDS)) {
- BLI_snprintf(val_pos, sizeof(numstr), "%.2f", pa_health);
+ numstr_len = BLI_snprintf(val_pos, sizeof(numstr), "%.2f", pa_health);
}
}
- /* in path drawing state.co is the end point */
- /* use worldspace beause object matrix is already applied */
- mul_v3_m4v3(vec_txt, ob->imat, state.co);
- view3d_cached_text_draw_add(vec_txt, numstr, 10, V3D_CACHE_TEXT_WORLDSPACE | V3D_CACHE_TEXT_ASCII, tcol);
+ if (numstr[0]) {
+ /* in path drawing state.co is the end point */
+ /* use worldspace beause object matrix is already applied */
+ mul_v3_m4v3(vec_txt, ob->imat, state.co);
+ view3d_cached_text_draw_add(vec_txt, numstr, numstr_len,
+ 10, V3D_CACHE_TEXT_WORLDSPACE | V3D_CACHE_TEXT_ASCII, tcol);
+ }
}
}
}
@@ -4885,10 +4979,11 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
for (a = 0, pa = psys->particles; a < totpart; a++, pa++) {
float vec_txt[3];
- BLI_snprintf(numstr, sizeof(numstr), "%i", a);
+ numstr_len = BLI_snprintf(numstr, sizeof(numstr), "%i", a);
/* use worldspace beause object matrix is already applied */
mul_v3_m4v3(vec_txt, ob->imat, cache[a]->co);
- view3d_cached_text_draw_add(vec_txt, numstr, 10, V3D_CACHE_TEXT_WORLDSPACE | V3D_CACHE_TEXT_ASCII, tcol);
+ view3d_cached_text_draw_add(vec_txt, numstr, numstr_len,
+ 10, V3D_CACHE_TEXT_WORLDSPACE | V3D_CACHE_TEXT_ASCII, tcol);
}
}
}
@@ -5332,7 +5427,7 @@ static void ob_draw_RE_motion(float com[3], float rotscale[3][3], float itw, flo
static void drawhandlesN(Nurb *nu, const char sel, const bool hide_handles)
{
BezTriple *bezt;
- float *fp;
+ const float *fp;
int a;
if (nu->hide || hide_handles) return;
@@ -5392,7 +5487,7 @@ static void drawhandlesN(Nurb *nu, const char sel, const bool hide_handles)
static void drawhandlesN_active(Nurb *nu)
{
BezTriple *bezt;
- float *fp;
+ const float *fp;
int a;
if (nu->hide) return;
@@ -6436,6 +6531,8 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
DerivedMesh *dm = ob->derivedFinal;
bool has_faces = false;
+ if (dm)
+ DM_update_materials(dm, ob);
#ifdef SEQUENCER_DAG_WORKAROUND
ensure_curve_cache(scene, ob);
#endif
@@ -6473,7 +6570,7 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
glDepthMask(1);
}
-static void draw_wire_extra(Scene *scene, RegionView3D *rv3d, Object *ob, unsigned char ob_wire_col[4])
+static void draw_wire_extra(Scene *scene, RegionView3D *rv3d, Object *ob, const unsigned char ob_wire_col[4])
{
if (ELEM4(ob->type, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL)) {
@@ -6544,7 +6641,8 @@ static void draw_hooks(Object *ob)
}
}
-static void draw_rigid_body_pivot(bRigidBodyJointConstraint *data, const short dflag, unsigned char ob_wire_col[4])
+static void draw_rigid_body_pivot(bRigidBodyJointConstraint *data,
+ const short dflag, const unsigned char ob_wire_col[4])
{
const char *axis_str[3] = {"px", "py", "pz"};
int axis;
@@ -6570,7 +6668,7 @@ static void draw_rigid_body_pivot(bRigidBodyJointConstraint *data, const short d
/* when const color is set wirecolor is NULL - we could get the current color but
* with selection and group instancing its not needed to draw the text */
if ((dflag & DRAW_CONSTCOLOR) == 0) {
- view3d_cached_text_draw_add(v, axis_str[axis], 0, V3D_CACHE_TEXT_ASCII, ob_wire_col);
+ view3d_cached_text_draw_add(v, axis_str[axis], 2, 0, V3D_CACHE_TEXT_ASCII, ob_wire_col);
}
}
glLineWidth(1.0f);
@@ -6722,8 +6820,8 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
RegionView3D *rv3d = ar->regiondata;
float vec1[3], vec2[3];
unsigned int col = 0;
- unsigned char _ob_wire_col[4]; /* dont initialize this */
- unsigned char *ob_wire_col = NULL; /* dont initialize this, use NULL crashes as a way to find invalid use */
+ unsigned char _ob_wire_col[4]; /* dont initialize this */
+ const unsigned char *ob_wire_col = NULL; /* dont initialize this, use NULL crashes as a way to find invalid use */
int i, selstart, selend, empty_object = 0;
short dtx;
char dt;
@@ -6872,7 +6970,10 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
switch (ob->type) {
case OB_MESH:
empty_object = draw_mesh_object(scene, ar, v3d, rv3d, base, dt, ob_wire_col, dflag);
- if (dflag != DRAW_CONSTCOLOR) dtx &= ~OB_DRAWWIRE; // mesh draws wire itself
+ if ((dflag & DRAW_CONSTCOLOR) == 0) {
+ /* mesh draws wire itself */
+ dtx &= ~OB_DRAWWIRE;
+ }
break;
case OB_FONT:
@@ -7064,7 +7165,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
break;
case OB_LAMP:
if (!render_override) {
- drawlamp(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
+ drawlamp(v3d, rv3d, base, dt, dflag, ob_wire_col, is_obact);
}
break;
case OB_CAMERA:
@@ -7344,7 +7445,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
/* but, we also don't draw names for sets or duplicators */
if (dflag == 0) {
const float zero[3] = {0, 0, 0};
- view3d_cached_text_draw_add(zero, ob->id.name + 2, 10, 0, ob_wire_col);
+ view3d_cached_text_draw_add(zero, ob->id.name + 2, strlen(ob->id.name + 2), 10, 0, ob_wire_col);
}
}
/*if (dtx & OB_DRAWIMAGE) drawDispListwire(&ob->disp);*/
@@ -7488,7 +7589,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
}
}
else {
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(curcon);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(curcon);
if ((cti && cti->get_constraint_targets) && (curcon->flag & CONSTRAINT_EXPAND)) {
ListBase targets = {NULL, NULL};
@@ -7703,6 +7804,8 @@ static void bbs_mesh_solid_verts(Scene *scene, Object *ob)
DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask);
glColor3ub(0, 0, 0);
+ DM_update_materials(dm, ob);
+
dm->drawMappedFaces(dm, bbs_mesh_solid_hide2__setDrawOpts, GPU_enable_material, NULL, me, 0);
bbs_obmode_mesh_verts(ob, dm, 1);
@@ -7717,6 +7820,8 @@ static void bbs_mesh_solid_faces(Scene *scene, Object *ob)
glColor3ub(0, 0, 0);
+ DM_update_materials(dm, ob);
+
if ((me->editflag & ME_EDIT_PAINT_FACE_SEL))
dm->drawMappedFaces(dm, bbs_mesh_solid_hide__setDrawOpts, GPU_enable_material, NULL, me, 0);
else
@@ -7744,6 +7849,8 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec
BM_mesh_elem_table_ensure(em->bm, BM_VERT | BM_EDGE | BM_FACE);
+ DM_update_materials(dm, ob);
+
bbs_mesh_solid_EM(em, scene, v3d, ob, dm, ts->selectmode & SCE_SELECT_FACE);
if (ts->selectmode & SCE_SELECT_FACE)
bm_solidoffs = 1 + em->bm->totface;
@@ -7802,10 +7909,14 @@ static void draw_object_mesh_instance(Scene *scene, View3D *v3d, RegionView3D *r
DerivedMesh *dm = NULL, *edm = NULL;
int glsl;
- if (ob->mode & OB_MODE_EDIT)
+ if (ob->mode & OB_MODE_EDIT) {
edm = editbmesh_get_derived_base(ob, me->edit_btmesh);
- else
+ DM_update_materials(edm, ob);
+ }
+ else {
dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
+ DM_update_materials(dm, ob);
+ }
if (dt <= OB_WIRE) {
if (dm)
diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c
index 32e21a0fbbe..59798f97d93 100644
--- a/source/blender/editors/space_view3d/drawvolume.c
+++ b/source/blender/editors/space_view3d/drawvolume.c
@@ -41,29 +41,9 @@
#include "DNA_property_types.h"
#include "BLI_utildefines.h"
-#include "BLI_blenlib.h"
#include "BLI_math.h"
-#include "BLI_edgehash.h"
-
-#include "BKE_curve.h"
-#include "BKE_constraint.h" /* for the get_constraint_target function */
-#include "BKE_DerivedMesh.h"
-#include "BKE_displist.h"
-#include "BKE_effect.h"
-#include "BKE_font.h"
-#include "BKE_global.h"
-#include "BKE_image.h"
-#include "BKE_key.h"
-#include "BKE_lattice.h"
-#include "BKE_mesh.h"
-#include "BKE_material.h"
-#include "BKE_mball.h"
-#include "BKE_modifier.h"
-#include "BKE_object.h"
-#include "BKE_paint.h"
+
#include "BKE_particle.h"
-#include "BKE_property.h"
-#include "BKE_smoke.h"
#include "smoke_API.h"
@@ -116,8 +96,8 @@ static bool convex(const float p0[3], const float up[3], const float a[3], const
}
void draw_smoke_volume(SmokeDomainSettings *sds, Object *ob,
- GPUTexture *tex, float min[3], float max[3],
- int res[3], float dx, float UNUSED(base_scale), float viewnormal[3],
+ GPUTexture *tex, const float min[3], const float max[3],
+ const int res[3], float dx, float UNUSED(base_scale), const float viewnormal[3],
GPUTexture *tex_shadow, GPUTexture *tex_flame)
{
const float ob_sizei[3] = {
@@ -410,9 +390,9 @@ void draw_smoke_volume(SmokeDomainSettings *sds, Object *ob,
}
if (!GPU_non_power_of_two_support()) {
- cor[0] = (float)res[0] / (float)power_of_2_max_i(res[0]);
- cor[1] = (float)res[1] / (float)power_of_2_max_i(res[1]);
- cor[2] = (float)res[2] / (float)power_of_2_max_i(res[2]);
+ cor[0] = (float)res[0] / (float)power_of_2_max_u(res[0]);
+ cor[1] = (float)res[1] / (float)power_of_2_max_u(res[1]);
+ cor[2] = (float)res[2] / (float)power_of_2_max_u(res[2]);
}
cor[0] /= size[0];
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 187919e9ff3..4d958a50857 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -49,10 +49,8 @@
#include "BKE_scene.h"
#include "BKE_screen.h"
-#include "ED_render.h"
#include "ED_space_api.h"
#include "ED_screen.h"
-#include "ED_object.h"
#include "GPU_extensions.h"
#include "GPU_material.h"
@@ -706,7 +704,6 @@ static void *view3d_main_area_duplicate(void *poin)
new->gpuoffscreen = NULL;
new->ri = NULL;
new->render_engine = NULL;
- new->gpd = NULL;
new->sms = NULL;
new->smooth_timer = NULL;
diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c
index d61017fb80e..dfbae90655c 100644
--- a/source/blender/editors/space_view3d/view3d_buttons.c
+++ b/source/blender/editors/space_view3d/view3d_buttons.c
@@ -56,8 +56,6 @@
#include "BKE_curve.h"
#include "BKE_customdata.h"
#include "BKE_depsgraph.h"
-#include "BKE_main.h"
-#include "BKE_mesh.h"
#include "BKE_screen.h"
#include "BKE_editmesh.h"
#include "BKE_deform.h"
@@ -73,8 +71,6 @@
#include "ED_object.h"
#include "ED_mesh.h"
#include "ED_screen.h"
-#include "ED_transform.h"
-#include "ED_curve.h"
#include "UI_interface.h"
#include "UI_resources.h"
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 9b455748713..9ce6bf58a0a 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -150,7 +150,7 @@ static void view3d_draw_clipping(RegionView3D *rv3d)
BoundBox *bb = rv3d->clipbb;
if (bb) {
- static unsigned int clipping_index[6][4] = {
+ const unsigned int clipping_index[6][4] = {
{0, 1, 2, 3},
{0, 4, 5, 1},
{4, 7, 6, 5},
@@ -836,7 +836,7 @@ static void draw_selected_name(Scene *scene, Object *ob, rcti *rect)
const char *msg_sep = " : ";
char info[300];
- char *markern;
+ const char *markern;
char *s = info;
short offset = 1.5f * UI_UNIT_X + rect->xmin;
@@ -1062,7 +1062,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
rctf viewborder;
Camera *ca = NULL;
- RegionView3D *rv3d = (RegionView3D *)ar->regiondata;
+ RegionView3D *rv3d = ar->regiondata;
if (v3d->camera == NULL)
return;
@@ -1802,7 +1802,7 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
glColor4f(1.0f, 1.0f, 1.0f, 1.0f - bgpic->blend);
/* could not use glaDrawPixelsAuto because it could fallback to
- * glaDrawPixelsSafe in some cases, which will end up in misssing
+ * glaDrawPixelsSafe in some cases, which will end up in missing
* alpha transparency for the background image (sergey)
*/
glaDrawPixelsTex(x1, y1, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, ibuf->rect);
@@ -1892,7 +1892,7 @@ static void view3d_draw_transp(Scene *scene, ARegion *ar, View3D *v3d)
}
/* clears zbuffer and draws it over */
-static void view3d_draw_xray(Scene *scene, ARegion *ar, View3D *v3d, int clear)
+static void view3d_draw_xray(Scene *scene, ARegion *ar, View3D *v3d, const bool clear)
{
View3DAfter *v3da, *next;
@@ -1911,7 +1911,7 @@ static void view3d_draw_xray(Scene *scene, ARegion *ar, View3D *v3d, int clear)
/* clears zbuffer and draws it over */
-static void view3d_draw_xraytransp(Scene *scene, ARegion *ar, View3D *v3d, int clear)
+static void view3d_draw_xraytransp(Scene *scene, ARegion *ar, View3D *v3d, const bool clear)
{
View3DAfter *v3da, *next;
@@ -1966,7 +1966,6 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas
RegionView3D *rv3d = ar->regiondata;
ListBase *lb;
LodLevel *savedlod;
- float savedobmat[4][4];
DupliObject *dob_prev = NULL, *dob, *dob_next = NULL;
Base tbase = {NULL};
BoundBox bb, *bb_tmp; /* use a copy because draw_object, calls clear_mesh_caches */
@@ -1974,13 +1973,16 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas
short transflag, use_displist = -1; /* -1 is initialize */
char dt;
short dtx;
-
+ DupliApplyData *apply_data;
+
if (base->object->restrictflag & OB_RESTRICT_VIEW) return;
tbase.flag = OB_FROMDUPLI | base->flag;
lb = object_duplilist(G.main->eval_ctx, scene, base->object);
// BLI_sortlist(lb, dupli_ob_sort); /* might be nice to have if we have a dupli list with mixed objects. */
+ apply_data = duplilist_apply_matrix(lb);
+
dob = dupli_step(lb->first);
if (dob) dob_next = dupli_step(dob->next);
@@ -1989,11 +1991,13 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas
/* Make sure lod is updated from dupli's position */
- copy_m4_m4(savedobmat, dob->ob->obmat);
- copy_m4_m4(dob->ob->obmat, dob->mat);
savedlod = dob->ob->currentlod;
- BKE_object_lod_update(dob->ob, rv3d->viewinv[3]);
-
+
+#ifdef WITH_GAMEENGINE
+ if (rv3d->rflag & RV3D_IS_GAME_ENGINE) {
+ BKE_object_lod_update(dob->ob, rv3d->viewinv[3]);
+ }
+#endif
/* extra service: draw the duplicator in drawtype of parent, minimum taken
* to allow e.g. boundbox box objects in groups for LOD */
@@ -2072,6 +2076,7 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas
}
}
else {
+ copy_m4_m4(dob->ob->obmat, dob->mat);
draw_object(scene, ar, v3d, &tbase, DRAW_CONSTCOLOR);
}
@@ -2079,11 +2084,13 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas
tbase.object->dtx = dtx;
tbase.object->transflag = transflag;
tbase.object->currentlod = savedlod;
- copy_m4_m4(tbase.object->obmat, savedobmat);
}
-
- /* Transp afterdraw disabled, afterdraw only stores base pointers, and duplis can be same obj */
-
+
+ if (apply_data) {
+ duplilist_restore_matrix(lb, apply_data);
+ duplilist_free_apply_data(apply_data);
+ }
+
free_object_duplilist(lb);
if (use_displist)
@@ -2219,8 +2226,8 @@ void draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d)
short zbuf = v3d->zbuf;
RegionView3D *rv3d = ar->regiondata;
- setwinmatrixview3d(ar, v3d, NULL);
- setviewmatrixview3d(scene, v3d, rv3d); /* note: calls BKE_object_where_is_calc for camera... */
+ view3d_winmatrix_set(ar, v3d, NULL);
+ view3d_viewmatrix_set(scene, v3d, rv3d); /* note: calls BKE_object_where_is_calc for camera... */
mul_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
invert_m4_m4(rv3d->persinv, rv3d->persmat);
@@ -2256,8 +2263,8 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (*func)(void *), boo
U.glalphaclip = alphaoverride ? 0.5f : glalphaclip; /* not that nice but means we wont zoom into billboards */
U.obcenter_dia = 0;
- setwinmatrixview3d(ar, v3d, NULL);
- setviewmatrixview3d(scene, v3d, rv3d); /* note: calls BKE_object_where_is_calc for camera... */
+ view3d_winmatrix_set(ar, v3d, NULL);
+ view3d_viewmatrix_set(scene, v3d, rv3d); /* note: calls BKE_object_where_is_calc for camera... */
mul_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
invert_m4_m4(rv3d->persinv, rv3d->persmat);
@@ -2377,11 +2384,12 @@ typedef struct View3DShadow {
} View3DShadow;
static void gpu_render_lamp_update(Scene *scene, View3D *v3d, Object *ob, Object *par,
- float obmat[4][4], ListBase *shadows)
+ float obmat[4][4], ListBase *shadows, SceneRenderLayer *srl)
{
GPULamp *lamp;
Lamp *la = (Lamp *)ob->data;
View3DShadow *shadow;
+ unsigned int layers;
lamp = GPU_lamp_from_blender(scene, ob, par);
@@ -2389,7 +2397,11 @@ static void gpu_render_lamp_update(Scene *scene, View3D *v3d, Object *ob, Object
GPU_lamp_update(lamp, ob->lay, (ob->restrictflag & OB_RESTRICT_RENDER), obmat);
GPU_lamp_update_colors(lamp, la->r, la->g, la->b, la->energy);
- if ((ob->lay & v3d->lay) && GPU_lamp_has_shadow_buffer(lamp)) {
+ layers = ob->lay & v3d->lay;
+ if (srl)
+ layers &= srl->lay;
+
+ if (layers && GPU_lamp_override_visible(lamp, srl, NULL) && GPU_lamp_has_shadow_buffer(lamp)) {
shadow = MEM_callocN(sizeof(View3DShadow), "View3DShadow");
shadow->lamp = lamp;
BLI_addtail(shadows, shadow);
@@ -2404,6 +2416,7 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d)
Scene *sce_iter;
Base *base;
Object *ob;
+ SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay);
BLI_listbase_clear(&shadows);
@@ -2412,7 +2425,7 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d)
ob = base->object;
if (ob->type == OB_LAMP)
- gpu_render_lamp_update(scene, v3d, ob, NULL, ob->obmat, &shadows);
+ gpu_render_lamp_update(scene, v3d, ob, NULL, ob->obmat, &shadows, srl);
if (ob->transflag & OB_DUPLI) {
DupliObject *dob;
@@ -2420,7 +2433,7 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d)
for (dob = lb->first; dob; dob = dob->next)
if (dob->ob->type == OB_LAMP)
- gpu_render_lamp_update(scene, v3d, dob->ob, ob, dob->mat, &shadows);
+ gpu_render_lamp_update(scene, v3d, dob->ob, ob, dob->mat, &shadows, srl);
free_object_duplilist(lb);
}
@@ -2515,13 +2528,13 @@ void ED_view3d_update_viewmat(Scene *scene, View3D *v3d, ARegion *ar, float view
if (winmat)
copy_m4_m4(rv3d->winmat, winmat);
else
- setwinmatrixview3d(ar, v3d, NULL);
+ view3d_winmatrix_set(ar, v3d, NULL);
/* setup view matrix */
if (viewmat)
copy_m4_m4(rv3d->viewmat, viewmat);
else
- setviewmatrixview3d(scene, v3d, rv3d); /* note: calls BKE_object_where_is_calc for camera... */
+ view3d_viewmatrix_set(scene, v3d, rv3d); /* note: calls BKE_object_where_is_calc for camera... */
/* update utilitity matrices */
mul_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
@@ -2550,6 +2563,172 @@ void ED_view3d_update_viewmat(Scene *scene, View3D *v3d, ARegion *ar, float view
}
}
+
+
+/**
+ * Shared by #ED_view3d_draw_offscreen and #view3d_main_area_draw_objects
+ *
+ * \note \a C and \a grid_unit will be NULL when \a draw_offscreen is set.
+ * \note Drawing lamps and opengl render uses this, so dont do grease pencil or view widgets here.
+ */
+static void view3d_draw_objects(
+ const bContext *C,
+ Scene *scene, View3D *v3d, ARegion *ar,
+ const char **grid_unit,
+ const bool do_bgpic, const bool draw_offscreen)
+{
+ RegionView3D *rv3d = ar->regiondata;
+ Base *base;
+ const bool do_camera_frame = !draw_offscreen;
+
+ if (!draw_offscreen) {
+ ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
+ }
+
+ if (rv3d->rflag & RV3D_CLIPPING)
+ view3d_draw_clipping(rv3d);
+
+ /* set zbuffer after we draw clipping region */
+ if (v3d->drawtype > OB_WIRE) {
+ v3d->zbuf = true;
+ glEnable(GL_DEPTH_TEST);
+ }
+ else {
+ v3d->zbuf = false;
+ }
+
+ if (!draw_offscreen) {
+ /* needs to be done always, gridview is adjusted in drawgrid() now, but only for ortho views. */
+ rv3d->gridview = v3d->grid;
+ if (scene->unit.system) {
+ rv3d->gridview /= scene->unit.scale_length;
+ }
+
+ if ((rv3d->view == RV3D_VIEW_USER) || (rv3d->persp != RV3D_ORTHO)) {
+ if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
+ drawfloor(scene, v3d, grid_unit);
+ }
+ }
+ else {
+ if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
+ ED_region_pixelspace(ar);
+ drawgrid(&scene->unit, ar, v3d, grid_unit);
+ /* XXX make function? replaces persp(1) */
+ glMatrixMode(GL_PROJECTION);
+ glLoadMatrixf(rv3d->winmat);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadMatrixf(rv3d->viewmat);
+ }
+ }
+ }
+
+ /* important to do before clipping */
+ if (do_bgpic) {
+ view3d_draw_bgpic_test(scene, ar, v3d, false, do_camera_frame);
+ }
+
+ if (rv3d->rflag & RV3D_CLIPPING) {
+ ED_view3d_clipping_set(rv3d);
+ }
+
+ /* draw set first */
+ if (scene->set) {
+ Scene *sce_iter;
+ for (SETLOOPER(scene->set, sce_iter, base)) {
+ if (v3d->lay & base->lay) {
+ UI_ThemeColorBlend(TH_WIRE, TH_BACK, 0.6f);
+ draw_object(scene, ar, v3d, base, DRAW_CONSTCOLOR | DRAW_SCENESET);
+
+ if (base->object->transflag & OB_DUPLI) {
+ draw_dupli_objects_color(scene, ar, v3d, base, TH_WIRE);
+ }
+ }
+ }
+
+ /* Transp and X-ray afterdraw stuff for sets is done later */
+ }
+
+
+ if (draw_offscreen) {
+ for (base = scene->base.first; base; base = base->next) {
+ if (v3d->lay & base->lay) {
+ /* dupli drawing */
+ if (base->object->transflag & OB_DUPLI)
+ draw_dupli_objects(scene, ar, v3d, base);
+
+ draw_object(scene, ar, v3d, base, 0);
+ }
+ }
+ }
+ else {
+ unsigned int lay_used = 0;
+
+ /* then draw not selected and the duplis, but skip editmode object */
+ for (base = scene->base.first; base; base = base->next) {
+ lay_used |= base->lay;
+
+ if (v3d->lay & base->lay) {
+
+ /* dupli drawing */
+ if (base->object->transflag & OB_DUPLI) {
+ draw_dupli_objects(scene, ar, v3d, base);
+ }
+ if ((base->flag & SELECT) == 0) {
+ if (base->object != scene->obedit)
+ draw_object(scene, ar, v3d, base, 0);
+ }
+ }
+ }
+
+ /* mask out localview */
+ v3d->lay_used = lay_used & ((1 << 20) - 1);
+
+ /* draw selected and editmode */
+ for (base = scene->base.first; base; base = base->next) {
+ if (v3d->lay & base->lay) {
+ if (base->object == scene->obedit || (base->flag & SELECT)) {
+ draw_object(scene, ar, v3d, base, 0);
+ }
+ }
+ }
+ }
+
+ /* must be before xray draw which clears the depth buffer */
+ if (v3d->flag2 & V3D_SHOW_GPENCIL) {
+ /* must be before xray draw which clears the depth buffer */
+ if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
+ draw_gpencil_view3d(scene, v3d, ar, true);
+ if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
+ }
+
+ /* transp and X-ray afterdraw stuff */
+ if (v3d->afterdraw_transp.first) view3d_draw_transp(scene, ar, v3d);
+ if (v3d->afterdraw_xray.first) view3d_draw_xray(scene, ar, v3d, true);
+ if (v3d->afterdraw_xraytransp.first) view3d_draw_xraytransp(scene, ar, v3d, true);
+
+ if (!draw_offscreen) {
+ ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
+ }
+
+ if (rv3d->rflag & RV3D_CLIPPING)
+ ED_view3d_clipping_disable();
+
+ /* important to do after clipping */
+ if (do_bgpic) {
+ view3d_draw_bgpic_test(scene, ar, v3d, true, do_camera_frame);
+ }
+
+ if (!draw_offscreen) {
+ BIF_draw_manipulator(C);
+ }
+
+ /* cleanup */
+ if (v3d->zbuf) {
+ v3d->zbuf = false;
+ glDisable(GL_DEPTH_TEST);
+ }
+}
+
static void view3d_main_area_setup_view(Scene *scene, View3D *v3d, ARegion *ar, float viewmat[4][4], float winmat[4][4])
{
RegionView3D *rv3d = ar->regiondata;
@@ -2574,10 +2753,9 @@ void ED_view3d_draw_offscreen_init(Scene *scene, View3D *v3d)
* stuff like shadow buffers
*/
void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, int winy,
- float viewmat[4][4], float winmat[4][4], bool do_bgpic, bool do_sky)
+ float viewmat[4][4], float winmat[4][4],
+ bool do_bgpic, bool do_sky)
{
- RegionView3D *rv3d = ar->regiondata;
- Base *base;
int bwinx, bwiny;
rcti brect;
@@ -2587,7 +2765,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx,
bwinx = ar->winx;
bwiny = ar->winy;
brect = ar->winrct;
-
+
ar->winx = winx;
ar->winy = winy;
ar->winrct.xmin = 0;
@@ -2597,13 +2775,15 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx,
/* set theme */
UI_SetTheme(SPACE_VIEW3D, RGN_TYPE_WINDOW);
-
+
/* set flags */
G.f |= G_RENDER_OGL;
- /* free images which can have changed on frame-change
- * warning! can be slow so only free animated images - campbell */
- GPU_free_images_anim();
+ if ((v3d->flag2 & V3D_RENDER_SHADOW) == 0) {
+ /* free images which can have changed on frame-change
+ * warning! can be slow so only free animated images - campbell */
+ GPU_free_images_anim();
+ }
/* clear opengl buffers */
if (do_sky) {
@@ -2618,91 +2798,28 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx,
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
/* setup view matrices */
view3d_main_area_setup_view(scene, v3d, ar, viewmat, winmat);
- if (rv3d->rflag & RV3D_CLIPPING)
- view3d_draw_clipping(rv3d);
- /* set zbuffer */
- if (v3d->drawtype > OB_WIRE) {
- v3d->zbuf = true;
- glEnable(GL_DEPTH_TEST);
- }
- else
- v3d->zbuf = false;
+ /* main drawing call */
+ view3d_draw_objects(NULL, scene, v3d, ar, NULL, do_bgpic, true);
- /* important to do before clipping */
- if (do_bgpic) {
- view3d_draw_bgpic_test(scene, ar, v3d, false, false);
- }
-
- if (rv3d->rflag & RV3D_CLIPPING)
- ED_view3d_clipping_set(rv3d);
+ if ((v3d->flag2 & V3D_RENDER_SHADOW) == 0) {
+ /* draw grease-pencil stuff */
+ ED_region_pixelspace(ar);
- /* draw set first */
- if (scene->set) {
- Scene *sce_iter;
- for (SETLOOPER(scene->set, sce_iter, base)) {
- if (v3d->lay & base->lay) {
- UI_ThemeColorBlend(TH_WIRE, TH_BACK, 0.6f);
- draw_object(scene, ar, v3d, base, DRAW_CONSTCOLOR | DRAW_SCENESET);
-
- if (base->object->transflag & OB_DUPLI)
- draw_dupli_objects_color(scene, ar, v3d, base, TH_WIRE);
- }
- }
- }
-
- /* then draw not selected and the duplis, but skip editmode object */
- for (base = scene->base.first; base; base = base->next) {
- if (v3d->lay & base->lay) {
- /* dupli drawing */
- if (base->object->transflag & OB_DUPLI)
- draw_dupli_objects(scene, ar, v3d, base);
- draw_object(scene, ar, v3d, base, 0);
+ if (v3d->flag2 & V3D_SHOW_GPENCIL) {
+ /* draw grease-pencil stuff - needed to get paint-buffer shown too (since it's 2D) */
+ draw_gpencil_view3d(scene, v3d, ar, false);
}
- }
-
- /* must be before xray draw which clears the depth buffer */
- if (v3d->flag2 & V3D_SHOW_GPENCIL) {
- if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
- draw_gpencil_view3d(scene, v3d, ar, true);
- if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
- }
-
- /* transp and X-ray afterdraw stuff */
- if (v3d->afterdraw_transp.first) view3d_draw_transp(scene, ar, v3d);
- if (v3d->afterdraw_xray.first) view3d_draw_xray(scene, ar, v3d, 1); /* clears zbuffer if it is used! */
- if (v3d->afterdraw_xraytransp.first) view3d_draw_xraytransp(scene, ar, v3d, 1);
-
- if (rv3d->rflag & RV3D_CLIPPING)
- ED_view3d_clipping_disable();
-
- /* important to do after clipping */
- if (do_bgpic) {
- view3d_draw_bgpic_test(scene, ar, v3d, true, false);
- }
-
- /* cleanup */
- if (v3d->zbuf) {
- v3d->zbuf = false;
- glDisable(GL_DEPTH_TEST);
- }
-
- /* draw grease-pencil stuff */
- ED_region_pixelspace(ar);
-
- if (v3d->flag2 & V3D_SHOW_GPENCIL) {
- /* draw grease-pencil stuff - needed to get paint-buffer shown too (since it's 2D) */
- draw_gpencil_view3d(scene, v3d, ar, false);
+ /* freeing the images again here could be done after the operator runs, leaving for now */
+ GPU_free_images_anim();
}
- /* freeing the images again here could be done after the operator runs, leaving for now */
- GPU_free_images_anim();
-
/* restore size */
ar->winx = bwinx;
ar->winy = bwiny;
@@ -2892,8 +3009,6 @@ void ED_scene_draw_fps(Scene *scene, rcti *rect)
#endif
}
-static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const char **grid_unit);
-
static bool view3d_main_area_do_render_draw(Scene *scene)
{
RenderEngineType *type = RE_engines_find(scene->r.engine);
@@ -2942,11 +3057,11 @@ bool ED_view3d_calc_render_border(Scene *scene, View3D *v3d, ARegion *ar, rcti *
return true;
}
-static bool view3d_main_area_draw_engine(const bContext *C, ARegion *ar, bool clip_border, rcti *border_rect)
+static bool view3d_main_area_draw_engine(const bContext *C, Scene *scene,
+ ARegion *ar, View3D *v3d,
+ bool clip_border, const rcti *border_rect)
{
- Scene *scene = CTX_data_scene(C);
- View3D *v3d = CTX_wm_view3d(C);
- RegionView3D *rv3d = CTX_wm_region_view3d(C);
+ RegionView3D *rv3d = ar->regiondata;
RenderEngineType *type;
GLint scissor[4];
@@ -3208,6 +3323,8 @@ static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar)
}
}
+
+#ifdef WITH_GAMEENGINE
static void update_lods(Scene *scene, float camera_pos[3])
{
Scene *sce_iter;
@@ -3219,15 +3336,14 @@ static void update_lods(Scene *scene, float camera_pos[3])
BKE_object_lod_update(ob, camera_pos);
}
}
+#endif
+
-/* warning: this function has duplicate drawing in ED_view3d_draw_offscreen() */
-static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const char **grid_unit)
+static void view3d_main_area_draw_objects(const bContext *C, Scene *scene, View3D *v3d,
+ ARegion *ar, const char **grid_unit)
{
- Scene *scene = CTX_data_scene(C);
- View3D *v3d = CTX_wm_view3d(C);
- RegionView3D *rv3d = CTX_wm_region_view3d(C);
- Base *base;
- unsigned int lay_used;
+ RegionView3D *rv3d = ar->regiondata;
+ unsigned int lay_used = v3d->lay_used;
/* shadow buffers, before we setup matrices */
if (draw_glsl_material(scene, NULL, v3d, v3d->drawtype))
@@ -3242,94 +3358,30 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const
/* setup view matrices */
view3d_main_area_setup_view(scene, v3d, ar, NULL, NULL);
- /* Make sure LoDs are up to date */
- update_lods(scene, rv3d->viewinv[3]);
+ rv3d->rflag &= ~RV3D_IS_GAME_ENGINE;
+#ifdef WITH_GAMEENGINE
+ if (STREQ(scene->r.engine, "BLENDER_GAME")) {
+ rv3d->rflag |= RV3D_IS_GAME_ENGINE;
+
+ /* Make sure LoDs are up to date */
+ update_lods(scene, rv3d->viewinv[3]);
+ }
+#endif
/* clear the background */
view3d_main_area_clear(scene, v3d, ar);
- ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
-
- if (rv3d->rflag & RV3D_CLIPPING)
- view3d_draw_clipping(rv3d);
-
- /* set zbuffer after we draw clipping region */
- if (v3d->drawtype > OB_WIRE) {
- v3d->zbuf = true;
- glEnable(GL_DEPTH_TEST);
- }
- else
- v3d->zbuf = false;
-
/* enables anti-aliasing for 3D view drawing */
if (U.ogl_multisamples != USER_MULTISAMPLE_NONE) {
glEnable(GL_MULTISAMPLE_ARB);
}
- /* needs to be done always, gridview is adjusted in drawgrid() now, but only for ortho views. */
- rv3d->gridview = v3d->grid;
- if (scene->unit.system) {
- rv3d->gridview /= scene->unit.scale_length;
- }
-
- if ((rv3d->view == RV3D_VIEW_USER) || (rv3d->persp != RV3D_ORTHO)) {
- if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
- drawfloor(scene, v3d, grid_unit);
- }
- }
- else {
- if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
- ED_region_pixelspace(ar);
- drawgrid(&scene->unit, ar, v3d, grid_unit);
- /* XXX make function? replaces persp(1) */
- glMatrixMode(GL_PROJECTION);
- glLoadMatrixf(rv3d->winmat);
- glMatrixMode(GL_MODELVIEW);
- glLoadMatrixf(rv3d->viewmat);
- }
- }
-
- view3d_draw_bgpic_test(scene, ar, v3d, false, true);
+ /* main drawing call */
+ view3d_draw_objects(C, scene, v3d, ar, grid_unit, true, false);
- if (rv3d->rflag & RV3D_CLIPPING)
- ED_view3d_clipping_set(rv3d);
-
- /* draw set first */
- if (scene->set) {
- Scene *sce_iter;
- for (SETLOOPER(scene->set, sce_iter, base)) {
-
- if (v3d->lay & base->lay) {
-
- UI_ThemeColorBlend(TH_WIRE, TH_BACK, 0.6f);
- draw_object(scene, ar, v3d, base, DRAW_CONSTCOLOR | DRAW_SCENESET);
-
- if (base->object->transflag & OB_DUPLI) {
- draw_dupli_objects_color(scene, ar, v3d, base, TH_WIRE);
- }
- }
- }
-
- /* Transp and X-ray afterdraw stuff for sets is done later */
- }
-
- lay_used = 0;
-
- /* then draw not selected and the duplis, but skip editmode object */
- for (base = scene->base.first; base; base = base->next) {
- lay_used |= base->lay & ((1 << 20) - 1);
-
- if (v3d->lay & base->lay) {
-
- /* dupli drawing */
- if (base->object->transflag & OB_DUPLI) {
- draw_dupli_objects(scene, ar, v3d, base);
- }
- if ((base->flag & SELECT) == 0) {
- if (base->object != scene->obedit)
- draw_object(scene, ar, v3d, base, 0);
- }
- }
+ /* Disable back anti-aliasing */
+ if (U.ogl_multisamples != USER_MULTISAMPLE_NONE) {
+ glDisable(GL_MULTISAMPLE_ARB);
}
if (v3d->lay_used != lay_used) { /* happens when loading old files or loading with UI load */
@@ -3337,51 +3389,6 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const
ScrArea *sa = CTX_wm_area(C);
ARegion *ar_header = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
ED_region_tag_redraw(ar_header); /* can be NULL */
- v3d->lay_used = lay_used;
- }
-
- /* draw selected and editmode */
- for (base = scene->base.first; base; base = base->next) {
- if (v3d->lay & base->lay) {
- if (base->object == scene->obedit || (base->flag & SELECT)) {
- draw_object(scene, ar, v3d, base, 0);
- }
- }
- }
-
-// REEB_draw();
-
- if (v3d->flag2 & V3D_SHOW_GPENCIL) {
- /* must be before xray draw which clears the depth buffer */
- if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
- draw_gpencil_view3d(scene, v3d, ar, true);
- if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
- }
-
- /* Transp and X-ray afterdraw stuff */
- if (v3d->afterdraw_transp.first) view3d_draw_transp(scene, ar, v3d);
- if (v3d->afterdraw_xray.first) view3d_draw_xray(scene, ar, v3d, 1); /* clears zbuffer if it is used! */
- if (v3d->afterdraw_xraytransp.first) view3d_draw_xraytransp(scene, ar, v3d, 1);
-
- ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
-
- if (rv3d->rflag & RV3D_CLIPPING)
- ED_view3d_clipping_disable();
-
- /* important to do after clipping */
- view3d_draw_bgpic_test(scene, ar, v3d, true, true);
-
- BIF_draw_manipulator(C);
-
- /* Disable back anti-aliasing */
- if (U.ogl_multisamples != USER_MULTISAMPLE_NONE) {
- glDisable(GL_MULTISAMPLE_ARB);
- }
-
-
- if (v3d->zbuf) {
- v3d->zbuf = false;
- glDisable(GL_DEPTH_TEST);
}
if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
@@ -3394,12 +3401,11 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const
}
-static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const char *grid_unit, bool render_border)
+static void view3d_main_area_draw_info(const bContext *C, Scene *scene,
+ ARegion *ar, View3D *v3d,
+ const char *grid_unit, bool render_border)
{
- wmWindowManager *wm = CTX_wm_manager(C);
- Scene *scene = CTX_data_scene(C);
- View3D *v3d = CTX_wm_view3d(C);
- RegionView3D *rv3d = CTX_wm_region_view3d(C);
+ RegionView3D *rv3d = ar->regiondata;
rcti rect;
/* local coordinate visible rect inside region, to accomodate overlapping ui */
@@ -3446,6 +3452,8 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha
}
if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
+ wmWindowManager *wm = CTX_wm_manager(C);
+
if ((U.uiflag & USER_SHOW_FPS) && ED_screen_animation_playing(wm)) {
ED_scene_draw_fps(scene, &rect);
}
@@ -3483,7 +3491,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
/* draw viewport using opengl */
if (v3d->drawtype != OB_RENDER || !view3d_main_area_do_render_draw(scene) || clip_border) {
- view3d_main_area_draw_objects(C, ar, &grid_unit);
+ view3d_main_area_draw_objects(C, scene, v3d, ar, &grid_unit);
#ifdef DEBUG_DRAW
bl_debug_draw();
#endif
@@ -3492,9 +3500,9 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
/* draw viewport using external renderer */
if (v3d->drawtype == OB_RENDER)
- view3d_main_area_draw_engine(C, ar, clip_border, &border_rect);
+ view3d_main_area_draw_engine(C, scene, ar, v3d, clip_border, &border_rect);
- view3d_main_area_draw_info(C, ar, grid_unit, render_border);
+ view3d_main_area_draw_info(C, scene, ar, v3d, grid_unit, render_border);
v3d->flag |= V3D_INVALID_BACKBUF;
}
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 6b08ae98677..6099ef49149 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -35,10 +35,10 @@
#include <float.h>
#include "DNA_armature_types.h"
+#include "DNA_curve_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_camera_types.h"
-#include "DNA_lamp_types.h"
#include "MEM_guardedalloc.h"
@@ -48,6 +48,7 @@
#include "BKE_camera.h"
#include "BKE_context.h"
+#include "BKE_font.h"
#include "BKE_image.h"
#include "BKE_library.h"
#include "BKE_object.h"
@@ -56,7 +57,6 @@
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_action.h"
-#include "BKE_armature.h"
#include "BKE_depsgraph.h" /* for ED_view3d_camera_lock_sync */
@@ -528,6 +528,69 @@ static void viewops_data_alloc(bContext *C, wmOperator *op)
vod->rv3d = vod->ar->regiondata;
}
+static void view3d_orbit_apply_dyn_ofs(
+ float r_ofs[3], const float dyn_ofs[3],
+ const float oldquat[4], const float viewquat[4])
+{
+ float q1[4];
+ conjugate_qt_qt(q1, oldquat);
+ mul_qt_qtqt(q1, q1, viewquat);
+
+ conjugate_qt(q1); /* conj == inv for unit quat */
+
+ sub_v3_v3(r_ofs, dyn_ofs);
+ mul_qt_v3(q1, r_ofs);
+ add_v3_v3(r_ofs, dyn_ofs);
+}
+
+static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3])
+{
+ static float lastofs[3] = {0, 0, 0};
+ bool is_set = false;
+
+ Scene *scene = CTX_data_scene(C);
+ Object *ob = OBACT;
+
+ if (ob && (ob->mode & OB_MODE_ALL_PAINT) && (BKE_object_pose_armature_get(ob) == NULL)) {
+ /* in case of sculpting use last average stroke position as a rotation
+ * center, in other cases it's not clear what rotation center shall be
+ * so just rotate around object origin
+ */
+ if (ob->mode & OB_MODE_SCULPT) {
+ float stroke[3];
+ ED_sculpt_get_average_stroke(ob, stroke);
+ copy_v3_v3(lastofs, stroke);
+ }
+ else {
+ copy_v3_v3(lastofs, ob->obmat[3]);
+ }
+ is_set = true;
+ }
+ else if (ob && (ob->mode & OB_MODE_EDIT) && (ob->type == OB_FONT)) {
+ Curve *cu = ob->data;
+ EditFont *ef = cu->editfont;
+ int i;
+
+ zero_v3(lastofs);
+ for (i = 0; i < 4; i++) {
+ add_v2_v2(lastofs, ef->textcurs[i]);
+ }
+ mul_v2_fl(lastofs, 1.0f / 4.0f);
+
+ mul_m4_v3(ob->obmat, lastofs);
+
+ is_set = true;
+ }
+ else {
+ /* If there's no selection, lastofs is unmodified and last value since static */
+ is_set = calculateTransformCenter(C, V3D_CENTROID, lastofs, NULL);
+ }
+
+ copy_v3_v3(r_dyn_ofs, lastofs);
+
+ return is_set;
+}
+
/**
* Calculate the values for #ViewOpsData
*/
@@ -536,7 +599,6 @@ static void viewops_data_create_ex(bContext *C, wmOperator *op, const wmEvent *e
const bool use_orbit_zbuf)
{
ViewOpsData *vod = op->customdata;
- static float lastofs[3] = {0, 0, 0};
RegionView3D *rv3d = vod->rv3d;
/* set the view from the camera, if view locking is enabled.
@@ -554,31 +616,12 @@ static void viewops_data_create_ex(bContext *C, wmOperator *op, const wmEvent *e
copy_v3_v3(vod->ofs, rv3d->ofs);
if (use_orbit_select) {
- Scene *scene = CTX_data_scene(C);
- Object *ob = OBACT;
vod->use_dyn_ofs = true;
- if (ob && (ob->mode & OB_MODE_ALL_PAINT) && (BKE_object_pose_armature_get(ob) == NULL)) {
- /* in case of sculpting use last average stroke position as a rotation
- * center, in other cases it's not clear what rotation center shall be
- * so just rotate around object origin
- */
- if (ob->mode & OB_MODE_SCULPT) {
- float stroke[3];
- ED_sculpt_get_average_stroke(ob, stroke);
- copy_v3_v3(lastofs, stroke);
- }
- else {
- copy_v3_v3(lastofs, ob->obmat[3]);
- }
- }
- else {
- /* If there's no selection, lastofs is unmodified and last value since static */
- calculateTransformCenter(C, V3D_CENTROID, lastofs, NULL);
- }
+ view3d_orbit_calc_center(C, vod->dyn_ofs);
- negate_v3_v3(vod->dyn_ofs, lastofs);
+ negate_v3(vod->dyn_ofs);
}
else if (use_orbit_zbuf) {
Scene *scene = CTX_data_scene(C);
@@ -621,7 +664,7 @@ static void viewops_data_create_ex(bContext *C, wmOperator *op, const wmEvent *e
negate_v3_v3(rv3d->ofs, dvec);
}
else {
- float mval_ar_mid[2] = {
+ const float mval_ar_mid[2] = {
(float)vod->ar->winx / 2.0f,
(float)vod->ar->winy / 2.0f};
@@ -752,19 +795,10 @@ void viewrotate_modal_keymap(wmKeyConfig *keyconf)
static void viewrotate_apply_dyn_ofs(ViewOpsData *vod, const float viewquat[4])
{
- RegionView3D *rv3d = vod->rv3d;
-
if (vod->use_dyn_ofs) {
- float q1[4];
- conjugate_qt_qt(q1, vod->oldquat);
- mul_qt_qtqt(q1, q1, viewquat);
-
- conjugate_qt(q1); /* conj == inv for unit quat */
-
+ RegionView3D *rv3d = vod->rv3d;
copy_v3_v3(rv3d->ofs, vod->ofs);
- sub_v3_v3(rv3d->ofs, vod->dyn_ofs);
- mul_qt_v3(q1, rv3d->ofs);
- add_v3_v3(rv3d->ofs, vod->dyn_ofs);
+ view3d_orbit_apply_dyn_ofs(rv3d->ofs, vod->dyn_ofs, vod->oldquat, viewquat);
}
}
@@ -3685,10 +3719,14 @@ static int vieworbit_exec(bContext *C, wmOperator *op)
if ((rv3d->viewlock & RV3D_LOCKED) == 0) {
if ((rv3d->persp != RV3D_CAMOB) || ED_view3d_camera_lock_check(v3d, rv3d)) {
- const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
+ int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
float angle = DEG2RADF((float)U.pad_rot_angle);
float quat_mul[4];
float quat_new[4];
+ float ofs_new[3];
+ float *ofs_new_pt = NULL;
+
+ view3d_ensure_persp(v3d, ar);
if (ELEM(orbitdir, V3D_VIEW_STEPLEFT, V3D_VIEW_STEPRIGHT)) {
const float zvec[3] = {0.0f, 0.0f, 1.0f};
@@ -3713,8 +3751,24 @@ static int vieworbit_exec(bContext *C, wmOperator *op)
mul_qt_qtqt(quat_new, rv3d->viewquat, quat_mul);
rv3d->view = RV3D_VIEW_USER;
- ED_view3d_smooth_view(C, CTX_wm_view3d(C), ar, NULL, NULL,
- NULL, quat_new, NULL, NULL,
+ if (U.uiflag & USER_ORBIT_SELECTION) {
+ float dyn_ofs[3];
+
+ view3d_orbit_calc_center(C, dyn_ofs);
+ negate_v3(dyn_ofs);
+
+ copy_v3_v3(ofs_new, rv3d->ofs);
+
+ view3d_orbit_apply_dyn_ofs(ofs_new, dyn_ofs, rv3d->viewquat, quat_new);
+ ofs_new_pt = ofs_new;
+
+ /* disable smoothview in this case
+ * although it works OK, it looks a little odd. */
+ smooth_viewtx = 0;
+ }
+
+ ED_view3d_smooth_view(C, v3d, ar, NULL, NULL,
+ ofs_new_pt, quat_new, NULL, NULL,
smooth_viewtx);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c
index 6c04f836349..e3d0e87066b 100644
--- a/source/blender/editors/space_view3d/view3d_header.c
+++ b/source/blender/editors/space_view3d/view3d_header.c
@@ -34,9 +34,6 @@
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
-#include "DNA_mesh_types.h"
-
-#include "MEM_guardedalloc.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
@@ -46,11 +43,8 @@
#include "BKE_context.h"
#include "BKE_depsgraph.h"
-#include "BKE_effect.h"
#include "BKE_main.h"
-#include "BKE_mesh.h"
#include "BKE_modifier.h"
-#include "BKE_paint.h"
#include "BKE_screen.h"
#include "BKE_editmesh.h"
@@ -64,8 +58,6 @@
#include "ED_mesh.h"
#include "ED_util.h"
#include "ED_screen.h"
-#include "ED_transform.h"
-#include "ED_types.h"
#include "UI_interface.h"
#include "UI_resources.h"
@@ -278,10 +270,10 @@ void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C)
block = uiLayoutGetBlock(row);
uiDefIconButBitS(block, TOG, SCE_SELECT_VERTEX, B_SEL_VERT, ICON_VERTEXSEL,
0, 0, UI_UNIT_X, UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0,
- TIP_("Vertex select - Shift-Click for multiple modes"));
+ TIP_("Vertex select - Shift-Click for multiple modes, Ctrl-Click contracts selection"));
uiDefIconButBitS(block, TOG, SCE_SELECT_EDGE, B_SEL_EDGE, ICON_EDGESEL,
0, 0, UI_UNIT_X, UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0,
- TIP_("Edge select - Shift-Click for multiple modes, Ctrl-Click expands selection"));
+ TIP_("Edge select - Shift-Click for multiple modes, Ctrl-Click expands/contracts selection"));
uiDefIconButBitS(block, TOG, SCE_SELECT_FACE, B_SEL_FACE, ICON_FACESEL,
0, 0, UI_UNIT_X, UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0,
TIP_("Face select - Shift-Click for multiple modes, Ctrl-Click expands selection"));
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index 9bc498808ec..2c6fc1cfe02 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -140,7 +140,9 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, struc
void drawaxes(float size, char drawtype);
void view3d_cached_text_draw_begin(void);
-void view3d_cached_text_draw_add(const float co[3], const char *str, short xoffs, short flag, const unsigned char col[4]);
+void view3d_cached_text_draw_add(const float co[3],
+ const char *str, const size_t str_len,
+ short xoffs, short flag, const unsigned char col[4]);
void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, bool depth_write, float mat[4][4]);
bool check_object_draw_texture(struct Scene *scene, struct View3D *v3d, const char drawtype);
@@ -202,12 +204,22 @@ void VIEW3D_OT_game_start(struct wmOperatorType *ot);
bool ED_view3d_boundbox_clip_ex(RegionView3D *rv3d, const struct BoundBox *bb, float obmat[4][4]);
bool ED_view3d_boundbox_clip(RegionView3D *rv3d, const struct BoundBox *bb);
-void ED_view3d_smooth_view(struct bContext *C, struct View3D *v3d, struct ARegion *ar, struct Object *, struct Object *,
- float *ofs, float *quat, float *dist, float *lens,
- const int smooth_viewtx);
+void ED_view3d_smooth_view_ex(
+ struct wmWindowManager *wm, struct wmWindow *win, struct ScrArea *sa,
+ struct View3D *v3d, struct ARegion *ar,
+ struct Object *camera_old, struct Object *camera,
+ const float *ofs, const float *quat, const float *dist, const float *lens,
+ const int smooth_viewtx);
-void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect);
-void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d);
+void ED_view3d_smooth_view(
+ struct bContext *C,
+ struct View3D *v3d, struct ARegion *ar,
+ struct Object *camera_old, struct Object *camera,
+ const float *ofs, const float *quat, const float *dist, const float *lens,
+ const int smooth_viewtx);
+
+void view3d_winmatrix_set(ARegion *ar, View3D *v3d, rctf *rect);
+void view3d_viewmatrix_set(Scene *scene, View3D *v3d, RegionView3D *rv3d);
void fly_modal_keymap(struct wmKeyConfig *keyconf);
void walk_modal_keymap(struct wmKeyConfig *keyconf);
@@ -257,8 +269,8 @@ extern const char *view3d_context_dir[]; /* doc access */
/* draw_volume.c */
void draw_smoke_volume(struct SmokeDomainSettings *sds, struct Object *ob,
- struct GPUTexture *tex, float min[3], float max[3],
- int res[3], float dx, float base_scale, float viewnormal[3],
+ struct GPUTexture *tex, const float min[3], const float max[3],
+ const int res[3], float dx, float base_scale, const float viewnormal[3],
struct GPUTexture *tex_shadow, struct GPUTexture *tex_flame);
//#define SMOKE_DEBUG_VELOCITY
diff --git a/source/blender/editors/space_view3d/view3d_iterators.c b/source/blender/editors/space_view3d/view3d_iterators.c
index 4df8010be9d..ce4b7f7deeb 100644
--- a/source/blender/editors/space_view3d/view3d_iterators.c
+++ b/source/blender/editors/space_view3d/view3d_iterators.c
@@ -33,7 +33,6 @@
#include "DNA_scene_types.h"
#include "BLI_utildefines.h"
-#include "BLI_listbase.h"
#include "BLI_rect.h"
#include "BKE_armature.h"
@@ -44,10 +43,8 @@
#include "bmesh.h"
-#include "ED_mesh.h"
#include "ED_screen.h"
#include "ED_armature.h"
-#include "ED_object.h"
#include "ED_view3d.h"
typedef struct foreachScreenObjectVert_userData {
@@ -370,7 +367,7 @@ void lattice_foreachScreenVert(
Lattice *lt = obedit->data;
BPoint *bp = lt->editlatt->latt->def;
DispList *dl = obedit->curve_cache ? BKE_displist_find(&obedit->curve_cache->disp, DL_VERTS) : NULL;
- float *co = dl ? dl->verts : NULL;
+ const float *co = dl ? dl->verts : NULL;
int i, N = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;
ED_view3d_check_mats_rv3d(vc->rv3d);
diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c
index 3383ac3660a..a8128ba7ae8 100644
--- a/source/blender/editors/space_view3d/view3d_ops.c
+++ b/source/blender/editors/space_view3d/view3d_ops.c
@@ -39,7 +39,6 @@
#include "DNA_space_types.h"
#include "DNA_view3d_types.h"
-#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
@@ -58,6 +57,10 @@
#include "view3d_intern.h"
+#ifdef WIN32
+# include "BLI_math_base.h" /* M_PI */
+#endif
+
/* ************************** copy paste ***************************** */
static int view3d_copybuffer_exec(bContext *C, wmOperator *op)
@@ -71,7 +74,6 @@ static int view3d_copybuffer_exec(bContext *C, wmOperator *op)
CTX_DATA_BEGIN (C, Object *, ob, selected_objects)
{
BKE_copybuffer_tag_ID(&ob->id);
-
}
CTX_DATA_END;
@@ -99,15 +101,19 @@ static void VIEW3D_OT_copybuffer(wmOperatorType *ot)
static int view3d_pastebuffer_exec(bContext *C, wmOperator *op)
{
char str[FILE_MAX];
-
+
BLI_make_file_string("/", str, BLI_temporary_dir(), "copybuffer.blend");
- BKE_copybuffer_paste(C, str, op->reports);
+ if (BKE_copybuffer_paste(C, str, op->reports)) {
+ WM_event_add_notifier(C, NC_WINDOW, NULL);
- WM_event_add_notifier(C, NC_WINDOW, NULL);
-
- BKE_report(op->reports, RPT_INFO, "Objects pasted from buffer");
+ BKE_report(op->reports, RPT_INFO, "Objects pasted from buffer");
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
+ }
+
+ BKE_report(op->reports, RPT_INFO, "No buffer to paste from");
+
+ return OPERATOR_CANCELLED;
}
static void VIEW3D_OT_pastebuffer(wmOperatorType *ot)
diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c
index 8eb9c9be40b..9d0a70ea9d0 100644
--- a/source/blender/editors/space_view3d/view3d_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_ruler.c
@@ -222,7 +222,7 @@ static void ruler_item_active_set(RulerInfo *ruler_info, RulerItem *ruler_item)
static void ruler_item_as_string(RulerItem *ruler_item, UnitSettings *unit,
char *numstr, size_t numstr_size, int prec)
{
- const int do_split = unit->flag & USER_UNIT_OPT_SPLIT;
+ const bool do_split = (unit->flag & USER_UNIT_OPT_SPLIT) != 0;
if (ruler_item->flag & RULERITEM_USE_ANGLE) {
const float ruler_angle = angle_v3v3v3(ruler_item->co[0],
@@ -282,9 +282,11 @@ static bool view3d_ruler_pick(RulerInfo *ruler_info, const float mval[2],
ruler_item_best = ruler_item;
{
- float dist_points[3] = {len_squared_v2v2(co_ss[0], mval),
- len_squared_v2v2(co_ss[1], mval),
- len_squared_v2v2(co_ss[2], mval)};
+ const float dist_points[3] = {
+ len_squared_v2v2(co_ss[0], mval),
+ len_squared_v2v2(co_ss[1], mval),
+ len_squared_v2v2(co_ss[2], mval),
+ };
if (min_fff(UNPACK3(dist_points)) < RULER_PICK_DIST_SQ) {
co_index_best = min_axis_v3(dist_points);
}
@@ -301,8 +303,10 @@ static bool view3d_ruler_pick(RulerInfo *ruler_info, const float mval[2],
ruler_item_best = ruler_item;
{
- float dist_points[2] = {len_squared_v2v2(co_ss[0], mval),
- len_squared_v2v2(co_ss[2], mval)};
+ const float dist_points[2] = {
+ len_squared_v2v2(co_ss[0], mval),
+ len_squared_v2v2(co_ss[2], mval),
+ };
if (min_ff(UNPACK2(dist_points)) < RULER_PICK_DIST_SQ) {
co_index_best = (dist_points[0] < dist_points[1]) ? 0 : 2;
}
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 9467eae930f..d18eab6da48 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -66,7 +66,6 @@
#include "BKE_depsgraph.h"
#include "BKE_mball.h"
#include "BKE_mesh.h"
-#include "BKE_movieclip.h"
#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_editmesh.h"
@@ -1066,7 +1065,7 @@ void VIEW3D_OT_select_menu(wmOperatorType *ot)
/* keyingset to use (dynamic enum) */
prop = RNA_def_enum(ot->srna, "name", DummyRNA_NULL_items, 0, "Object Name", "");
RNA_def_enum_funcs(prop, object_select_menu_enum_itemf);
- RNA_def_property_flag(prop, PROP_HIDDEN);
+ RNA_def_property_flag(prop, PROP_HIDDEN | PROP_ENUM_NO_TRANSLATE);
ot->prop = prop;
RNA_def_boolean(ot->srna, "toggle", 0, "Toggle", "Toggle selection instead of deselecting everything first");
@@ -1141,7 +1140,7 @@ static Base *object_mouse_select_menu(bContext *C, ViewContext *vc, unsigned int
for (node = linklist, i = 0; node; node = node->next, i++) {
Base *base = node->link;
Object *ob = base->object;
- char *name = ob->id.name + 2;
+ const char *name = ob->id.name + 2;
BLI_strncpy(object_mouse_select_menu_data[i].idname, name, MAX_ID_NAME - 2);
object_mouse_select_menu_data[i].icon = uiIconFromID(&ob->id);
@@ -1388,7 +1387,7 @@ static bool mouse_select(bContext *C, const int mval[2],
Base *base, *startbase = NULL, *basact = NULL, *oldbasact = NULL;
bool is_obedit;
float dist = ED_view3d_select_dist_px() * 1.3333f;
- int retval = false;
+ bool retval = false;
short hits;
const float mval_fl[2] = {(float)mval[0], (float)mval[1]};
diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c
index 3486e930466..8e6deeddc39 100644
--- a/source/blender/editors/space_view3d/view3d_snap.c
+++ b/source/blender/editors/space_view3d/view3d_snap.c
@@ -413,8 +413,8 @@ static void bundle_midpoint(Scene *scene, Object *ob, float vec[3])
MovieClip *clip = BKE_object_movieclip_get(scene, ob, false);
MovieTracking *tracking;
MovieTrackingObject *object;
- int ok = 0;
- float min[3], max[3], mat[4][4], pos[3], cammat[4][4] = MAT4_UNITY;
+ bool ok = false;
+ float min[3], max[3], mat[4][4], pos[3], cammat[4][4];
if (!clip)
return;
diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c
index 8946559bca8..3f7f12d2020 100644
--- a/source/blender/editors/space_view3d/view3d_toolbar.c
+++ b/source/blender/editors/space_view3d/view3d_toolbar.c
@@ -47,8 +47,6 @@
#include "BLF_translation.h"
#include "BKE_context.h"
-#include "BKE_idprop.h"
-#include "BKE_global.h"
#include "BKE_screen.h"
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index fdfce062adc..ebdcc757acc 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -32,7 +32,6 @@
#include "DNA_camera_types.h"
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
-#include "DNA_lamp_types.h"
#include "MEM_guardedalloc.h"
@@ -52,7 +51,6 @@
#include "BKE_main.h"
#include "BKE_report.h"
#include "BKE_scene.h"
-#include "BKE_screen.h"
#include "BIF_gl.h"
#include "BIF_glutil.h"
@@ -163,14 +161,14 @@ static void view3d_smooth_view_state_restore(const struct SmoothView3DState *sms
/* will start timer if appropriate */
/* the arguments are the desired situation */
-void ED_view3d_smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Object *camera,
- float *ofs, float *quat, float *dist, float *lens,
- const int smooth_viewtx)
-{
- wmWindowManager *wm = CTX_wm_manager(C);
- wmWindow *win = CTX_wm_window(C);
- ScrArea *sa = CTX_wm_area(C);
+void ED_view3d_smooth_view_ex(
+ /* avoid passing in the context */
+ wmWindowManager *wm, wmWindow *win, ScrArea *sa,
+ View3D *v3d, ARegion *ar, Object *oldcamera, Object *camera,
+ const float *ofs, const float *quat, const float *dist, const float *lens,
+ const int smooth_viewtx)
+{
RegionView3D *rv3d = ar->regiondata;
struct SmoothView3DStore sms = {{0}};
bool ok = false;
@@ -312,6 +310,22 @@ void ED_view3d_smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcam
}
}
+void ED_view3d_smooth_view(
+ bContext *C,
+ View3D *v3d, ARegion *ar, Object *oldcamera, Object *camera,
+ const float *ofs, const float *quat, const float *dist, const float *lens,
+ const int smooth_viewtx)
+{
+ wmWindowManager *wm = CTX_wm_manager(C);
+ wmWindow *win = CTX_wm_window(C);
+ ScrArea *sa = CTX_wm_area(C);
+
+ ED_view3d_smooth_view_ex(
+ wm, win, sa,
+ v3d, ar, oldcamera, camera,
+ ofs, quat, dist, lens, smooth_viewtx);
+}
+
/* only meant for timer usage */
static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
{
@@ -553,7 +567,10 @@ static int view3d_setobjectascamera_exec(bContext *C, wmOperator *op)
if (v3d->scenelock)
scene->camera = ob;
- if (camera_old != ob) { /* unlikely but looks like a glitch when set to the same */
+ /* unlikely but looks like a glitch when set to the same */
+ if (camera_old != ob) {
+ ED_view3d_lastview_store(rv3d);
+
ED_view3d_smooth_view(C, v3d, ar, camera_old, v3d->camera,
rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens,
smooth_viewtx);
@@ -764,10 +781,10 @@ void ED_view3d_polygon_offset(const RegionView3D *rv3d, const float dist)
bglPolygonOffset(viewdist, dist);
}
-/*!
- * \param rect for picking, NULL not to use.
+/**
+ * \param rect, optional for picking (can be NULL).
*/
-void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect)
+void view3d_winmatrix_set(ARegion *ar, View3D *v3d, rctf *rect)
{
RegionView3D *rv3d = ar->regiondata;
rctf viewplane;
@@ -880,7 +897,7 @@ bool ED_view3d_lock(RegionView3D *rv3d)
}
/* don't set windows active in here, is used by renderwin too */
-void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d)
+void view3d_viewmatrix_set(Scene *scene, View3D *v3d, RegionView3D *rv3d)
{
if (rv3d->persp == RV3D_CAMOB) { /* obs/camera */
if (v3d->camera) {
@@ -977,7 +994,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b
BLI_rctf_rcti_copy(&rect, input);
}
- setwinmatrixview3d(ar, v3d, &rect);
+ view3d_winmatrix_set(ar, v3d, &rect);
mul_m4_m4m4(vc->rv3d->persmat, vc->rv3d->winmat, vc->rv3d->viewmat);
if (v3d->drawtype > OB_WIRE) {
@@ -1061,7 +1078,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b
hits = glRenderMode(GL_RENDER);
G.f &= ~G_PICKSEL;
- setwinmatrixview3d(ar, v3d, NULL);
+ view3d_winmatrix_set(ar, v3d, NULL);
mul_m4_m4m4(vc->rv3d->persmat, vc->rv3d->winmat, vc->rv3d->viewmat);
if (v3d->drawtype > OB_WIRE) {
@@ -1152,11 +1169,14 @@ int ED_view3d_scene_layer_set(int lay, const int *values, int *active)
return lay;
}
-static bool view3d_localview_init(Main *bmain, Scene *scene, ScrArea *sa, ReportList *reports)
+static bool view3d_localview_init(
+ wmWindowManager *wm, wmWindow *win,
+ Main *bmain, Scene *scene, ScrArea *sa, const int smooth_viewtx,
+ ReportList *reports)
{
View3D *v3d = sa->spacedata.first;
Base *base;
- float min[3], max[3], box[3];
+ float min[3], max[3], box[3], mid[3];
float size = 0.0f, size_persp = 0.0f, size_ortho = 0.0f;
unsigned int locallay;
bool ok = false;
@@ -1211,34 +1231,48 @@ static bool view3d_localview_init(Main *bmain, Scene *scene, ScrArea *sa, Report
memcpy(v3d->localvd, v3d, sizeof(View3D));
+ mid_v3_v3v3(mid, min, max);
+
+ copy_v3_v3(v3d->cursor, mid);
+
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = ar->regiondata;
+ /* new view values */
+ Object *camera_old = NULL;
+ float dist_new, ofs_new[3];
+
rv3d->localvd = MEM_mallocN(sizeof(RegionView3D), "localview region");
memcpy(rv3d->localvd, rv3d, sizeof(RegionView3D));
-
- mid_v3_v3v3(v3d->cursor, min, max);
- negate_v3_v3(rv3d->ofs, v3d->cursor);
+
+ negate_v3_v3(ofs_new, mid);
if (rv3d->persp == RV3D_CAMOB) {
rv3d->persp = RV3D_PERSP;
+ camera_old = v3d->camera;
}
/* perspective should be a bit farther away to look nice */
if (rv3d->persp != RV3D_ORTHO) {
- rv3d->dist = size_persp;
+ dist_new = size_persp;
}
else {
- rv3d->dist = size_ortho;
+ dist_new = size_ortho;
}
/* correction for window aspect ratio */
if (ar->winy > 2 && ar->winx > 2) {
float asp = (float)ar->winx / (float)ar->winy;
if (asp < 1.0f) asp = 1.0f / asp;
- rv3d->dist *= asp;
+ dist_new *= asp;
}
+
+ ED_view3d_smooth_view_ex(
+ wm, win, sa,
+ v3d, ar, camera_old, NULL,
+ ofs_new, NULL, &dist_new, NULL,
+ smooth_viewtx);
}
}
@@ -1259,13 +1293,18 @@ static bool view3d_localview_init(Main *bmain, Scene *scene, ScrArea *sa, Report
return ok;
}
-static void restore_localviewdata(Main *bmain, ScrArea *sa, int free)
+static void restore_localviewdata(wmWindowManager *wm, wmWindow *win, Main *bmain, ScrArea *sa, const int smooth_viewtx)
{
+ const bool free = true;
ARegion *ar;
View3D *v3d = sa->spacedata.first;
+ Object *camera_old, *camera_new;
if (v3d->localvd == NULL) return;
+ camera_old = v3d->camera;
+ camera_new = v3d->localvd->camera;
+
v3d->near = v3d->localvd->near;
v3d->far = v3d->localvd->far;
v3d->lay = v3d->localvd->lay;
@@ -1283,13 +1322,21 @@ static void restore_localviewdata(Main *bmain, ScrArea *sa, int free)
RegionView3D *rv3d = ar->regiondata;
if (rv3d->localvd) {
- rv3d->dist = rv3d->localvd->dist;
- copy_v3_v3(rv3d->ofs, rv3d->localvd->ofs);
- copy_qt_qt(rv3d->viewquat, rv3d->localvd->viewquat);
+ Object *camera_old_rv3d, *camera_new_rv3d;
+
+ camera_old_rv3d = (rv3d->persp == RV3D_CAMOB) ? camera_old : NULL;
+ camera_new_rv3d = (rv3d->localvd->persp == RV3D_CAMOB) ? camera_new : NULL;
+
rv3d->view = rv3d->localvd->view;
rv3d->persp = rv3d->localvd->persp;
rv3d->camzoom = rv3d->localvd->camzoom;
+ ED_view3d_smooth_view_ex(
+ wm, win, sa,
+ v3d, ar, camera_old_rv3d, camera_new_rv3d,
+ rv3d->localvd->ofs, rv3d->localvd->viewquat, &rv3d->localvd->dist, NULL,
+ smooth_viewtx);
+
if (free) {
MEM_freeN(rv3d->localvd);
rv3d->localvd = NULL;
@@ -1301,7 +1348,9 @@ static void restore_localviewdata(Main *bmain, ScrArea *sa, int free)
}
}
-static bool view3d_localview_exit(Main *bmain, Scene *scene, ScrArea *sa)
+static bool view3d_localview_exit(
+ wmWindowManager *wm, wmWindow *win,
+ Main *bmain, Scene *scene, ScrArea *sa, const int smooth_viewtx)
{
View3D *v3d = sa->spacedata.first;
struct Base *base;
@@ -1310,8 +1359,8 @@ static bool view3d_localview_exit(Main *bmain, Scene *scene, ScrArea *sa)
if (v3d->localvd) {
locallay = v3d->lay & 0xFF000000;
-
- restore_localviewdata(bmain, sa, 1); /* 1 = free */
+
+ restore_localviewdata(wm, win, bmain, sa, smooth_viewtx);
/* for when in other window the layers have changed */
if (v3d->scenelock) v3d->lay = scene->lay;
@@ -1339,6 +1388,9 @@ static bool view3d_localview_exit(Main *bmain, Scene *scene, ScrArea *sa)
static int localview_exec(bContext *C, wmOperator *op)
{
+ const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
+ wmWindowManager *wm = CTX_wm_manager(C);
+ wmWindow *win = CTX_wm_window(C);
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ScrArea *sa = CTX_wm_area(C);
@@ -1346,15 +1398,20 @@ static int localview_exec(bContext *C, wmOperator *op)
bool changed;
if (v3d->localvd) {
- changed = view3d_localview_exit(bmain, scene, sa);
+ changed = view3d_localview_exit(wm, win, bmain, scene, sa, smooth_viewtx);
}
else {
- changed = view3d_localview_init(bmain, scene, sa, op->reports);
+ changed = view3d_localview_init(wm, win, bmain, scene, sa, smooth_viewtx, op->reports);
}
if (changed) {
DAG_id_type_tag(bmain, ID_OB);
- ED_area_tag_redraw(CTX_wm_area(C));
+ ED_area_tag_redraw(sa);
+
+ /* unselected objects become selected when exiting */
+ if (v3d->localvd == NULL) {
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
+ }
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c
index 6c981fe86d0..1c3e223f3ed 100644
--- a/source/blender/editors/space_view3d/view3d_walk.c
+++ b/source/blender/editors/space_view3d/view3d_walk.c
@@ -30,7 +30,6 @@
//#define NDOF_WALK_DRAW_TOOMUCH /* is this needed for ndof? - commented so redraw doesnt thrash - campbell */
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
-#include "DNA_camera_types.h"
#include "MEM_guardedalloc.h"
@@ -372,9 +371,9 @@ static void walk_navigation_mode_set(bContext *C, WalkInfo *walk, eWalkMethod mo
}
/**
- * \param ray_distance Distance to the hit point
+ * \param r_distance Distance to the hit point
*/
-static bool walk_floor_distance_get(bContext *C, RegionView3D *rv3d, WalkInfo *walk, float dvec[3], float *ray_distance)
+static bool walk_floor_distance_get(bContext *C, RegionView3D *rv3d, WalkInfo *walk, const float dvec[3], float *r_distance)
{
float dummy_dist_px = 0;
float ray_normal[3] = {0, 0, -1}; /* down */
@@ -384,22 +383,20 @@ static bool walk_floor_distance_get(bContext *C, RegionView3D *rv3d, WalkInfo *w
float dvec_tmp[3];
bool ret;
- *ray_distance = TRANSFORM_DIST_MAX_RAY;
+ *r_distance = TRANSFORM_DIST_MAX_RAY;
copy_v3_v3(ray_start, rv3d->viewinv[3]);
- if (dvec) {
- mul_v3_v3fl(dvec_tmp, dvec, walk->grid);
- add_v3_v3(ray_start, dvec_tmp);
- }
+ mul_v3_v3fl(dvec_tmp, dvec, walk->grid);
+ add_v3_v3(ray_start, dvec_tmp);
ret = snapObjectsRayEx(CTX_data_scene(C), NULL, NULL, NULL, NULL, SCE_SNAP_MODE_FACE,
NULL, NULL,
- ray_start, ray_normal, ray_distance,
+ ray_start, ray_normal, r_distance,
NULL, &dummy_dist_px, r_location, r_normal, SNAP_ALL);
/* artifically scale the distance to the scene size */
- *ray_distance /= walk->grid;
+ *r_distance /= walk->grid;
return ret;
}
@@ -545,7 +542,7 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op)
copy_v2_v2_int(walk->prev_mval, walk->center_mval);
- WM_cursor_warp(CTX_wm_window(C),
+ WM_cursor_warp(win,
walk->ar->winrct.xmin + walk->center_mval[0],
walk->ar->winrct.ymin + walk->center_mval[1]);
@@ -1122,7 +1119,7 @@ static int walkApply(bContext *C, WalkInfo *walk)
/* Falling or jumping) */
if (ELEM(walk->gravity, WALK_GRAVITY_STATE_ON, WALK_GRAVITY_STATE_JUMP)) {
float t;
- float z_old, z_new;
+ float z_cur, z_new;
bool ret;
float ray_distance, difference = -100.0f;
@@ -1132,16 +1129,15 @@ static int walkApply(bContext *C, WalkInfo *walk)
/* keep moving if we were moving */
copy_v2_v2(dvec, walk->teleport.direction);
- z_old = walk->rv3d->viewinv[3][2];
+ z_cur = walk->rv3d->viewinv[3][2];
z_new = walk->teleport.origin[2] - getFreeFallDistance(t) * walk->grid;
/* jump */
z_new += t * walk->speed_jump * walk->grid;
- dvec[2] = z_old - z_new;
-
/* duration is the jump duration */
if (t > walk->teleport.duration) {
+
/* check to see if we are landing */
ret = walk_floor_distance_get(C, rv3d, walk, dvec, &ray_distance);
@@ -1149,12 +1145,20 @@ static int walkApply(bContext *C, WalkInfo *walk)
difference = walk->view_height - ray_distance;
}
- if (ray_distance < walk->view_height) {
- /* quit falling */
+ if (difference > 0.0f) {
+ /* quit falling, lands at "view_height" from the floor */
dvec[2] -= difference;
walk->gravity = WALK_GRAVITY_STATE_OFF;
walk->speed_jump = 0.0f;
}
+ else {
+ /* keep falling */
+ dvec[2] = z_cur - z_new;
+ }
+ }
+ else {
+ /* keep going up (jump) */
+ dvec[2] = z_cur - z_new;
}
}
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 13f030a3650..b88c388c257 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -35,19 +35,11 @@
#include <math.h>
#include <float.h>
-#ifndef WIN32
-# include <unistd.h>
-#else
-# include <io.h>
-#endif
-
#include "MEM_guardedalloc.h"
#include "DNA_anim_types.h"
#include "DNA_armature_types.h"
#include "DNA_constraint_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
#include "DNA_mask_types.h"
#include "DNA_movieclip_types.h"
#include "DNA_scene_types.h" /* PET modes */
@@ -58,15 +50,12 @@
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_ghash.h"
-#include "BLI_linklist.h"
#include "BKE_nla.h"
#include "BKE_editmesh_bvh.h"
#include "BKE_context.h"
#include "BKE_constraint.h"
-#include "BKE_global.h"
#include "BKE_particle.h"
-#include "BKE_pointcache.h"
#include "BKE_unit.h"
#include "BKE_mask.h"
@@ -81,7 +70,6 @@
#include "ED_view3d.h"
#include "ED_mesh.h"
#include "ED_clip.h"
-#include "ED_mask.h"
#include "ED_node.h"
#include "WM_types.h"
@@ -374,7 +362,7 @@ void projectIntViewEx(TransInfo *t, const float vec[3], int adr[2], const eV3DPr
v[0] = vec[0] / aspx;
v[1] = vec[1] / aspy;
- UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr + 1);
+ UI_view2d_view_to_region(t->view, v[0], v[1], &adr[0], &adr[1]);
}
}
else if (t->spacetype == SPACE_ACTION) {
@@ -385,12 +373,12 @@ void projectIntViewEx(TransInfo *t, const float vec[3], int adr[2], const eV3DPr
if (sact->flag & SACTION_DRAWTIME) {
//vec[0] = vec[0]/((t->scene->r.frs_sec / t->scene->r.frs_sec_base));
/* same as below */
- UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out + 1);
+ UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], &out[0], &out[1]);
}
else
#endif
{
- UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out + 1);
+ UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], &out[0], &out[1]);
}
adr[0] = out[0];
@@ -399,14 +387,14 @@ void projectIntViewEx(TransInfo *t, const float vec[3], int adr[2], const eV3DPr
else if (ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) {
int out[2] = {0, 0};
- UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out + 1);
+ UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], &out[0], &out[1]);
adr[0] = out[0];
adr[1] = out[1];
}
else if (t->spacetype == SPACE_SEQ) { /* XXX not tested yet, but should work */
int out[2] = {0, 0};
- UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out + 1);
+ UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], &out[0], &out[1]);
adr[0] = out[0];
adr[1] = out[1];
}
@@ -452,14 +440,14 @@ void projectIntViewEx(TransInfo *t, const float vec[3], int adr[2], const eV3DPr
v[0] /= aspx;
v[1] /= aspy;
- UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr + 1);
+ UI_view2d_view_to_region(t->view, v[0], v[1], &adr[0], &adr[1]);
}
else {
BLI_assert(0);
}
}
else if (t->spacetype == SPACE_NODE) {
- UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], adr, adr + 1);
+ UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], &adr[0], &adr[1]);
}
}
void projectIntView(TransInfo *t, const float vec[3], int adr[2])
@@ -945,7 +933,6 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cm
int transformEvent(TransInfo *t, const wmEvent *event)
{
- float mati[3][3] = MAT3_UNITY;
char cmode = constraintModeToChar(t);
bool handled = false;
@@ -1007,7 +994,11 @@ int transformEvent(TransInfo *t, const wmEvent *event)
}
else {
if (t->obedit && t->obedit->type == OB_MESH) {
- if ((t->mode == TFM_TRANSLATION) && (t->spacetype == SPACE_VIEW3D)) {
+ if ((t->mode == TFM_TRANSLATION) &&
+ (t->spacetype == SPACE_VIEW3D) &&
+ /* prevents accidental select-tweak, gkey. see: T40102 */
+ (ISMOUSE(t->launch_event) == 0))
+ {
resetTransModal(t);
resetTransRestrictions(t);
restoreTransObjects(t);
@@ -1067,6 +1058,12 @@ int transformEvent(TransInfo *t, const wmEvent *event)
case TFM_MODAL_RESIZE:
/* only switch when... */
if (ELEM5(t->mode, TFM_ROTATION, TFM_TRANSLATION, TFM_TRACKBALL, TFM_EDGE_SLIDE, TFM_VERT_SLIDE)) {
+
+ /* Scale isn't normally very useful after extrude along normals, see T39756 */
+ if ((t->con.mode & CON_APPLY) && (t->con.orientation == V3D_MANIP_NORMAL)) {
+ stopConstraint(t);
+ }
+
resetTransModal(t);
resetTransRestrictions(t);
restoreTransObjects(t);
@@ -1300,7 +1297,9 @@ int transformEvent(TransInfo *t, const wmEvent *event)
}
else {
/* bit hackish... but it prevents mmb select to print the orientation from menu */
+ float mati[3][3];
strcpy(t->spacename, "global");
+ unit_m3(mati);
initSelectConstraint(t, mati);
}
postSelectConstraint(t);
@@ -1484,7 +1483,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 fucks this up, will test when fixed */
+ /* 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)) {
t->state = TRANS_CONFIRM;
}
@@ -1516,7 +1515,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
}
}
-int calculateTransformCenter(bContext *C, int centerMode, float cent3d[3], float cent2d[2])
+bool calculateTransformCenter(bContext *C, int centerMode, float cent3d[3], float cent2d[2])
{
TransInfo *t = MEM_callocN(sizeof(TransInfo), "TransInfo data");
bool success;
@@ -1556,7 +1555,7 @@ int calculateTransformCenter(bContext *C, int centerMode, float cent3d[3], float
}
- /* aftertrans does insert ipos and action channels, and clears base flags, doesnt read transdata */
+ /* aftertrans does insert keyframes, and clears base flags; doesn't read transdata */
special_aftertrans_update(C, t);
postTrans(C, t);
@@ -1878,7 +1877,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
}
if ((prop = RNA_struct_find_property(op->ptr, "value"))) {
- float *values = (t->flag & T_AUTOVALUES) ? t->auto_values : t->values;
+ const float *values = (t->flag & T_AUTOVALUES) ? t->auto_values : t->values;
if (RNA_property_array_check(prop)) {
RNA_property_float_set_array(op->ptr, prop, values);
}
@@ -1994,7 +1993,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
}
/* note: caller needs to free 't' on a 0 return */
-int initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event, int mode)
+bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event, int mode)
{
int options = 0;
PropertyRNA *prop;
@@ -2330,7 +2329,7 @@ int transformEnd(bContext *C, TransInfo *t)
exit_code = OPERATOR_FINISHED;
}
- /* aftertrans does insert keyframes, and clears base flags, doesnt read transdata */
+ /* aftertrans does insert keyframes, and clears base flags; doesn't read transdata */
special_aftertrans_update(C, t);
/* free data */
@@ -2478,8 +2477,8 @@ static void protectedQuaternionBits(short protectflag, float quat[4], const floa
static void constraintTransLim(TransInfo *t, TransData *td)
{
if (td->con) {
- bConstraintTypeInfo *ctiLoc = BKE_get_constraint_typeinfo(CONSTRAINT_TYPE_LOCLIMIT);
- bConstraintTypeInfo *ctiDist = BKE_get_constraint_typeinfo(CONSTRAINT_TYPE_DISTLIMIT);
+ bConstraintTypeInfo *ctiLoc = BKE_constraint_typeinfo_from_type(CONSTRAINT_TYPE_LOCLIMIT);
+ bConstraintTypeInfo *ctiDist = BKE_constraint_typeinfo_from_type(CONSTRAINT_TYPE_DISTLIMIT);
bConstraintOb cob = {NULL};
bConstraint *con;
@@ -2529,7 +2528,7 @@ static void constraintTransLim(TransInfo *t, TransData *td)
}
/* get constraint targets if needed */
- BKE_get_constraint_targets_for_solving(con, &cob, &targets, ctime);
+ BKE_constraint_targets_for_solving_get(con, &cob, &targets, ctime);
/* do constraint */
cti->evaluate_constraint(con, &cob, &targets);
@@ -2581,10 +2580,10 @@ static void constraintob_from_transdata(bConstraintOb *cob, TransData *td)
static void constraintRotLim(TransInfo *UNUSED(t), TransData *td)
{
if (td->con) {
- bConstraintTypeInfo *cti = BKE_get_constraint_typeinfo(CONSTRAINT_TYPE_ROTLIMIT);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_from_type(CONSTRAINT_TYPE_ROTLIMIT);
bConstraintOb cob;
bConstraint *con;
- int do_limit = false;
+ bool do_limit = false;
/* Evaluate valid constraints */
for (con = td->con; con; con = con->next) {
@@ -2648,7 +2647,7 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td)
static void constraintSizeLim(TransInfo *t, TransData *td)
{
if (td->con && td->ext) {
- bConstraintTypeInfo *cti = BKE_get_constraint_typeinfo(CONSTRAINT_TYPE_SIZELIMIT);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_from_type(CONSTRAINT_TYPE_SIZELIMIT);
bConstraintOb cob = {NULL};
bConstraint *con;
float size_sign[3], size_abs[3];
@@ -2775,7 +2774,7 @@ static void initBend(TransInfo *t)
t->flag |= T_NO_CONSTRAINT;
//copy_v3_v3(t->center, ED_view3d_cursor3d_get(t->scene, t->view));
- calculateCenterCursor(t);
+ calculateCenterCursor(t, t->center);
t->val = 0.0f;
@@ -4107,7 +4106,8 @@ static void headerTranslation(TransInfo *t, float vec[3], char str[MAX_INFO_LEN]
dist = len_v3(vec);
if (!(t->flag & T_2D_EDIT) && t->scene->unit.system) {
- int i, do_split = t->scene->unit.flag & USER_UNIT_OPT_SPLIT ? 1 : 0;
+ const bool do_split = (t->scene->unit.flag & USER_UNIT_OPT_SPLIT) != 0;
+ int i;
for (i = 0; i < 3; i++) {
bUnit_AsString(&tvec[NUM_STR_REP_LEN * i], NUM_STR_REP_LEN, dvec[i] * t->scene->unit.scale_length,
@@ -4121,13 +4121,18 @@ static void headerTranslation(TransInfo *t, float vec[3], char str[MAX_INFO_LEN]
}
}
- if (!(t->flag & T_2D_EDIT) && t->scene->unit.system)
+ if (!(t->flag & T_2D_EDIT) && t->scene->unit.system) {
+ const bool do_split = (t->scene->unit.flag & USER_UNIT_OPT_SPLIT) != 0;
bUnit_AsString(distvec, sizeof(distvec), dist * t->scene->unit.scale_length, 4, t->scene->unit.system,
- B_UNIT_LENGTH, t->scene->unit.flag & USER_UNIT_OPT_SPLIT, false);
- else if (dist > 1e10f || dist < -1e10f) /* prevent string buffer overflow */
+ B_UNIT_LENGTH, do_split, false);
+ }
+ else if (dist > 1e10f || dist < -1e10f) {
+ /* prevent string buffer overflow */
BLI_snprintf(distvec, NUM_STR_REP_LEN, "%.4e", dist);
- else
+ }
+ else {
BLI_snprintf(distvec, NUM_STR_REP_LEN, "%.4f", dist);
+ }
if (t->flag & T_AUTOIK) {
short chainlen = t->settings->autoik_chainlen;
@@ -4190,7 +4195,7 @@ static void applyTranslationValue(TransInfo *t, float vec[3])
/* handle snapping rotation before doing the translation */
if (usingSnappingNormal(t)) {
if (validSnappingNormal(t)) {
- float *original_normal;
+ const float *original_normal;
float axis[3];
float quat[4];
float mat[3][3];
@@ -4571,7 +4576,8 @@ static void applyMaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
{
TransData *td;
float ratio;
- int i, initial_feather = false;
+ int i;
+ bool initial_feather = false;
char str[MAX_INFO_LEN];
ratio = t->values[0];
@@ -6236,8 +6242,8 @@ static void calcVertSlideCustomPoints(struct TransInfo *t)
{
VertSlideData *sld = t->customData;
TransDataVertSlideVert *sv = &sld->sv[sld->curr_sv_index];
- float *co_orig = sv->co_orig_2d;
- float *co_curr = sv->co_link_orig_2d[sv->co_link_curr];
+ const float *co_orig = sv->co_orig_2d;
+ const float *co_curr = sv->co_link_orig_2d[sv->co_link_curr];
const int mval_start[2] = {co_orig[0], co_orig[1]};
const int mval_end[2] = {co_curr[0], co_curr[1]};
@@ -7188,55 +7194,15 @@ static short getAnimEdit_SnapMode(TransInfo *t)
return autosnap;
}
-/* This function is used for testing if an Animation Editor is displaying
- * its data in frames or seconds (and the data needing to be edited as such).
- * Returns 1 if in seconds, 0 if in frames
- */
-static short getAnimEdit_DrawTime(TransInfo *t)
-{
- short drawtime;
-
- if (t->spacetype == SPACE_ACTION) {
- SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first;
-
- drawtime = (saction->flag & SACTION_DRAWTIME) ? 1 : 0;
- }
- else if (t->spacetype == SPACE_NLA) {
- SpaceNla *snla = (SpaceNla *)t->sa->spacedata.first;
-
- drawtime = (snla->flag & SNLA_DRAWTIME) ? 1 : 0;
- }
- else if (t->spacetype == SPACE_IPO) {
- SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first;
-
- drawtime = (sipo->flag & SIPO_DRAWTIME) ? 1 : 0;
- }
- else {
- drawtime = 0;
- }
-
- return drawtime;
-}
-
-
/* This function is used by Animation Editor specific transform functions to do
* the Snap Keyframe to Nearest Frame/Marker
*/
static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, TransData2D *td2d, AnimData *adt, short autosnap)
{
- /* snap key to nearest frame? */
- if (autosnap == SACTSNAP_FRAME) {
-
-#if 0 /* 'do_time' disabled for now */
-
+ /* snap key to nearest frame or second? */
+ if (ELEM(autosnap, SACTSNAP_FRAME, SACTSNAP_SECOND)) {
const Scene *scene = t->scene;
-#if 0 /* NOTE: this works, but may be confusing behavior given the option's label, hence disabled */
- const short do_time = getAnimEdit_DrawTime(t);
-#else
- const short do_time = 0;
-#endif
const double secf = FPS;
-#endif
double val;
/* convert frame to nla-action time (if needed) */
@@ -7245,16 +7211,12 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, TransData2D *td2d,
else
val = *(td->val);
-#if 0 /* 'do_time' disabled for now */
-
/* do the snapping to nearest frame/second */
- if (do_time) {
- val = (float)(floor((val / secf) + 0.5f) * secf);
+ if (autosnap == SACTSNAP_FRAME) {
+ val = floorf(val + 0.5);
}
- else
-#endif
- {
- val = floor(val + 0.5);
+ else if (autosnap == SACTSNAP_SECOND) {
+ val = (float)(floor((val / secf) + 0.5) * secf);
}
/* convert frame out of nla-action time */
@@ -7342,20 +7304,21 @@ static void headerTimeTranslate(TransInfo *t, char str[MAX_INFO_LEN])
else {
const Scene *scene = t->scene;
const short autosnap = getAnimEdit_SnapMode(t);
- const short do_time = getAnimEdit_DrawTime(t);
const double secf = FPS;
float val = t->values[0];
/* apply snapping + frame->seconds conversions */
if (autosnap == SACTSNAP_STEP) {
- if (do_time)
- val = floorf((double)val / secf + 0.5);
- else
- val = floorf(val + 0.5f);
+ /* frame step */
+ val = floorf(val + 0.5f);
+ }
+ else if (autosnap == SACTSNAP_TSTEP) {
+ /* second step */
+ val = floorf((double)val / secf + 0.5);
}
else {
- if (do_time)
- val = (float)((double)val / secf);
+ /* nearest frame/second/marker */
+ val = (float)((double)val / secf);
}
if (autosnap == SACTSNAP_FRAME)
@@ -7373,11 +7336,9 @@ static void applyTimeTranslateValue(TransInfo *t, float UNUSED(sval))
TransData2D *td2d = t->data2d;
Scene *scene = t->scene;
int i;
-
- const short do_time = getAnimEdit_DrawTime(t);
- const double secf = FPS;
-
+
const short autosnap = getAnimEdit_SnapMode(t);
+ const double secf = FPS;
float deltax, val /* , valprev */;
@@ -7392,14 +7353,14 @@ static void applyTimeTranslateValue(TransInfo *t, float UNUSED(sval))
/* valprev = *td->val; */ /* UNUSED */
/* check if any need to apply nla-mapping */
- if (adt && t->spacetype != SPACE_SEQ) {
+ if (adt && (t->spacetype != SPACE_SEQ)) {
deltax = t->values[0];
- if (autosnap == SACTSNAP_STEP) {
- if (do_time)
- deltax = (float)(floor(((double)deltax / secf) + 0.5) * secf);
- else
- deltax = (float)(floor(deltax + 0.5f));
+ if (autosnap == SACTSNAP_TSTEP) {
+ deltax = (float)(floor(((double)deltax / secf) + 0.5) * secf);
+ }
+ else if (autosnap == SACTSNAP_STEP) {
+ deltax = (float)(floor(deltax + 0.5f));
}
val = BKE_nla_tweakedit_remap(adt, td->ival, NLATIME_CONVERT_MAP);
@@ -7409,11 +7370,11 @@ static void applyTimeTranslateValue(TransInfo *t, float UNUSED(sval))
else {
deltax = val = t->values[0];
- if (autosnap == SACTSNAP_STEP) {
- if (do_time)
- val = (float)(floor(((double)deltax / secf) + 0.5) * secf);
- else
- val = (float)(floor(val + 0.5f));
+ if (autosnap == SACTSNAP_TSTEP) {
+ val = (float)(floor(((double)deltax / secf) + 0.5) * secf);
+ }
+ else if (autosnap == SACTSNAP_STEP) {
+ val = (float)(floor(val + 0.5f));
}
*(td->val) = td->ival + val;
@@ -7661,7 +7622,6 @@ static void applyTimeScaleValue(TransInfo *t)
int i;
const short autosnap = getAnimEdit_SnapMode(t);
- const short do_time = getAnimEdit_DrawTime(t);
const double secf = FPS;
@@ -7674,11 +7634,11 @@ static void applyTimeScaleValue(TransInfo *t)
float startx = CFRA;
float fac = t->values[0];
- if (autosnap == SACTSNAP_STEP) {
- if (do_time)
- fac = (float)(floor((double)fac / secf + 0.5) * secf);
- else
- fac = (float)(floor(fac + 0.5f));
+ if (autosnap == SACTSNAP_TSTEP) {
+ fac = (float)(floor((double)fac / secf + 0.5) * secf);
+ }
+ else if (autosnap == SACTSNAP_STEP) {
+ fac = (float)(floor(fac + 0.5f));
}
/* check if any need to apply nla-mapping */
@@ -7715,12 +7675,13 @@ static void applyTimeScale(TransInfo *t, const int UNUSED(mval[2]))
/* TODO, move to: transform_queries.c */
bool checkUseLocalCenter_GraphEdit(TransInfo *t)
{
- return ((t->around == V3D_LOCAL) && !ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE));
+ return ((t->around == V3D_LOCAL) &&
+ !ELEM4(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE, TFM_TIME_DUPLICATE));
}
bool checkUseAxisMatrix(TransInfo *t)
{
- /* currenly only checks for editmode */
+ /* currently only checks for editmode */
if (t->flag & T_EDIT) {
if ((t->around == V3D_LOCAL) && (ELEM4(t->obedit->type, OB_MESH, OB_CURVE, OB_MBALL, OB_ARMATURE))) {
/* not all editmode supports axis-matrix */
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index e574d1ad469..f34d2050853 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -80,9 +80,9 @@ typedef struct TransSnap {
short modePoint;
short modeSelect;
bool align;
- char project;
- char snap_self;
- short peel;
+ bool project;
+ bool snap_self;
+ bool peel;
short status;
float snapPoint[3]; /* snapping from this point */
float snapTarget[3]; /* to this point */
@@ -96,7 +96,8 @@ typedef struct TransSnap {
void (*applySnap)(struct TransInfo *, float *);
void (*calcSnap)(struct TransInfo *, float *);
void (*targetSnap)(struct TransInfo *);
- float (*distance)(struct TransInfo *, float p1[3], float p2[3]); // Get the transform distance between two points (used by Closest snap)
+ /* Get the transform distance between two points (used by Closest snap) */
+ float (*distance)(struct TransInfo *, const float p1[3], const float p2[3]);
} TransSnap;
typedef struct TransCon {
@@ -276,7 +277,7 @@ typedef struct MouseInput {
void (*post)(struct TransInfo *t, float values[3]);
int imval[2]; /* initial mouse position */
- char precision;
+ bool precision;
int precision_mval[2]; /* mouse position when precision key was pressed */
float center[2];
float factor;
@@ -349,7 +350,7 @@ typedef struct TransInfo {
float axis[3];
float axis_orig[3]; /* TransCon can change 'axis', store the original value here */
- short remove_on_cancel; /* remove elements if operator is canceled */
+ bool remove_on_cancel; /* remove elements if operator is canceled */
void *view;
struct bContext *context; /* Only valid (non null) during an operator called function. */
@@ -460,7 +461,6 @@ typedef struct TransInfo {
/* transdata->flag */
#define TD_SELECTED 1
-#define TD_ACTIVE (1 << 1)
#define TD_NOACTION (1 << 2)
#define TD_USEQUAT (1 << 3)
#define TD_NOTCONNECTED (1 << 4)
@@ -485,7 +485,7 @@ typedef struct TransInfo {
#define POINT_INIT 4
#define MULTI_POINTS 8
-int initTransform(struct bContext *C, struct TransInfo *t, struct wmOperator *op, const struct wmEvent *event, int mode);
+bool initTransform(struct bContext *C, struct TransInfo *t, struct wmOperator *op, const struct wmEvent *event, int mode);
void saveTransform(struct bContext *C, struct TransInfo *t, struct wmOperator *op);
int transformEvent(TransInfo *t, const struct wmEvent *event);
void transformApply(struct bContext *C, TransInfo *t);
@@ -522,7 +522,7 @@ void flushTransTracking(TransInfo *t);
void flushTransMasking(TransInfo *t);
/*********************** exported from transform_manipulator.c ********** */
-int gimbal_axis(struct Object *ob, float gmat[3][3]); /* return 0 when no gimbal for selection */
+bool gimbal_axis(struct Object *ob, float gmat[3][3]); /* return 0 when no gimbal for selection */
int calc_manipulator_stats(const struct bContext *C);
/*********************** TransData Creation and General Handling *********** */
@@ -635,13 +635,18 @@ void applyTransObjects(TransInfo *t);
void restoreTransObjects(TransInfo *t);
void recalcData(TransInfo *t);
-void calculateCenter(TransInfo *t);
void calculateCenter2D(TransInfo *t);
-void calculateCenterBound(TransInfo *t);
-void calculateCenterMedian(TransInfo *t);
-void calculateCenterCursor(TransInfo *t);
-void calculateCenterCursor2D(TransInfo *t);
+void calculateCenter(TransInfo *t);
+
+/* API functions for getting center points */
+void calculateCenterBound(TransInfo *t, float r_center[3]);
+void calculateCenterMedian(TransInfo *t, float r_center[3]);
+void calculateCenterCursor(TransInfo *t, float r_center[3]);
+void calculateCenterCursor2D(TransInfo *t, float r_center[2]);
+void calculateCenterCursorGraph2D(TransInfo *t, float r_center[2]);
+bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3]);
+
void calculatePropRatio(TransInfo *t);
void getViewVector(TransInfo *t, float coord[3], float vec[3]);
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 9cc65c20e66..79f266df607 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -34,12 +34,6 @@
#include <string.h>
#include <math.h>
-#ifndef WIN32
-# include <unistd.h>
-#else
-# include <io.h>
-#endif
-
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
@@ -625,8 +619,9 @@ void setUserConstraint(TransInfo *t, short orientation, int mode, const char fte
switch (orientation) {
case V3D_MANIP_GLOBAL:
{
- float mtx[3][3] = MAT3_UNITY;
+ float mtx[3][3];
BLI_snprintf(text, sizeof(text), ftext, IFACE_("global"));
+ unit_m3(mtx);
setConstraint(t, mtx, mode, text);
break;
}
@@ -969,13 +964,13 @@ static void setNearestAxis3d(TransInfo *t)
sub_v2_v2v2(axis, axis_2d, t->center2d);
axis[2] = 0.0f;
- if (normalize_v3(axis) != 0.0f) {
+ if (normalize_v3(axis) > 1e-3f) {
project_v3_v3v3(proj, mvec, axis);
sub_v3_v3v3(axis, mvec, proj);
len[i] = normalize_v3(axis);
}
else {
- len[i] = 10000000000.0f;
+ len[i] = 1e10f;
}
}
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 4dd7f3c3fdf..949ee79a3dc 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -29,12 +29,6 @@
* \ingroup edtransform
*/
-
-#ifndef WIN32
-#include <unistd.h>
-#else
-#include <io.h>
-#endif
#include <string.h>
#include <math.h>
@@ -63,7 +57,6 @@
#include "BLI_listbase.h"
#include "BLI_linklist_stack.h"
#include "BLI_string.h"
-#include "BLI_rect.h"
#include "BLI_bitmap.h"
#include "BKE_DerivedMesh.h"
@@ -71,6 +64,7 @@
#include "BKE_armature.h"
#include "BKE_constraint.h"
#include "BKE_context.h"
+#include "BKE_crazyspace.h"
#include "BKE_curve.h"
#include "BKE_depsgraph.h"
#include "BKE_fcurve.h"
@@ -108,11 +102,9 @@
#include "ED_markers.h"
#include "ED_mesh.h"
#include "ED_node.h"
-#include "ED_types.h"
#include "ED_uvedit.h"
#include "ED_clip.h"
#include "ED_mask.h"
-#include "ED_util.h" /* for crazyspace correction */
#include "WM_api.h" /* for WM_event_add_notifier to deal with stabilization nodes */
#include "WM_types.h"
@@ -884,7 +876,7 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
}
}
- con = BKE_add_pose_constraint(NULL, pchan, "TempConstraint", CONSTRAINT_TYPE_KINEMATIC);
+ con = BKE_constraint_add_for_pose(NULL, pchan, "TempConstraint", CONSTRAINT_TYPE_KINEMATIC);
pchan->constflag |= (PCHAN_HAS_IK | PCHAN_HAS_TARGET); /* for draw, but also for detecting while pose solving */
data = con->data;
if (targetless) {
@@ -1620,7 +1612,7 @@ static void createTransLatticeVerts(TransInfo *t)
{
Lattice *latt = ((Lattice *)t->obedit->data)->editlatt->latt;
TransData *td = NULL;
- BPoint *bp, *actbp = BKE_lattice_active_point_get(latt);
+ BPoint *bp;
float mtx[3][3], smtx[3][3];
int a;
int count = 0, countsel = 0;
@@ -1657,7 +1649,6 @@ static void createTransLatticeVerts(TransInfo *t)
copy_v3_v3(td->center, td->loc);
if (bp->f1 & SELECT) {
td->flag = TD_SELECTED;
- if (actbp && bp == actbp) td->flag |= TD_ACTIVE;
}
else td->flag = 0;
copy_m3_m3(td->smtx, smtx);
@@ -2059,9 +2050,13 @@ static struct TransIslandData *editmesh_islands_info_calc(BMEditMesh *em, int *r
/* pass */
}
else {
- normalize_v3(no);
- axis_dominant_v3_to_m3(trans_islands[i].axismtx, no);
- invert_m3(trans_islands[i].axismtx);
+ if (normalize_v3(no) != 0.0f) {
+ axis_dominant_v3_to_m3(trans_islands[i].axismtx, no);
+ invert_m3(trans_islands[i].axismtx);
+ }
+ else {
+ unit_m3(trans_islands[i].axismtx);
+ }
}
}
@@ -2142,7 +2137,6 @@ static void createTransEditVerts(TransInfo *t)
BMesh *bm = em->bm;
BMVert *eve;
BMIter iter;
- BMVert *eve_act = NULL;
float (*mappedcos)[3] = NULL, (*quats)[4] = NULL;
float mtx[3][3], smtx[3][3], (*defmats)[3][3] = NULL, (*defcos)[3] = NULL;
float *dists = NULL;
@@ -2182,10 +2176,6 @@ static void createTransEditVerts(TransInfo *t)
BLI_assert(0);
}
-
- /* check active */
- eve_act = BM_mesh_active_vert_get(bm);
-
if (t->mode == TFM_BWEIGHT) {
BM_mesh_cd_flag_ensure(bm, BKE_mesh_from_object(t->obedit), ME_CDFLAG_VERT_BWEIGHT);
cd_vert_bweight_offset = CustomData_get_offset(&bm->vdata, CD_BWEIGHT);
@@ -2251,9 +2241,9 @@ static void createTransEditVerts(TransInfo *t)
if (totleft > 0)
#endif
{
- mappedcos = crazyspace_get_mapped_editverts(t->scene, t->obedit);
+ mappedcos = BKE_crazyspace_get_mapped_editverts(t->scene, t->obedit);
quats = MEM_mallocN(em->bm->totvert * sizeof(*quats), "crazy quats");
- crazyspace_set_quats_editmesh(em, defcos, mappedcos, quats, !propmode);
+ BKE_crazyspace_set_quats_editmesh(em, defcos, mappedcos, quats, !propmode);
if (mappedcos)
MEM_freeN(mappedcos);
}
@@ -2291,9 +2281,6 @@ static void createTransEditVerts(TransInfo *t)
if (BM_elem_flag_test(eve, BM_ELEM_SELECT))
tob->flag |= TD_SELECTED;
- /* active */
- if (eve == eve_act) tob->flag |= TD_ACTIVE;
-
if (propmode) {
if (propmode & T_PROP_CONNECTED) {
tob->dist = dists[a];
@@ -3573,7 +3560,7 @@ static void bezt_to_transdata(TransData *td, TransData2D *td2d, AnimData *adt, B
float mtx[3][3], float smtx[3][3])
{
float *loc = bezt->vec[bi];
- float *cent = bezt->vec[1];
+ const float *cent = bezt->vec[1];
/* New location from td gets dumped onto the old-location of td2d, which then
* gets copied to the actual data at td2d->loc2d (bezt->vec[n])
@@ -3773,7 +3760,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
float xscale, yscale;
/* apply scale factors to x and y axes of space-conversion matrices */
- UI_view2d_getscale(v2d, &xscale, &yscale);
+ UI_view2d_scale_get(v2d, &xscale, &yscale);
/* mtx is data to global (i.e. view) conversion */
mul_v3_fl(mtx[0], xscale);
@@ -3862,13 +3849,13 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
}
/* special hack (must be done after initTransDataCurveHandles(), as that stores handle settings to restore...):
- * - Check if we've got entire BezTriple selected and we're rotating that point,
+ * - Check if we've got entire BezTriple selected and we're scaling/rotating that point,
* then check if we're using auto-handles.
* - If so, change them auto-handles to aligned handles so that handles get affected too
*/
- if ((t->mode == TFM_ROTATION) &&
- ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) &&
- ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM))
+ if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) &&
+ ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM) &&
+ ELEM(t->mode, TFM_ROTATION, TFM_RESIZE))
{
if (hdata && (sel1) && (sel3)) {
bezt->h1 = HD_ALIGN;
@@ -4107,14 +4094,16 @@ void flushTransGraphData(TransInfo *t)
/* handle snapping for time values
* - we should still be in NLA-mapping timespace
* - only apply to keyframes (but never to handles)
+ * - don't do this when cancelling, or else these changes won't go away
*/
- if ((td->flag & TD_NOTIMESNAP) == 0) {
+ if ((t->state != TRANS_CANCEL) && (td->flag & TD_NOTIMESNAP) == 0) {
switch (sipo->autosnap) {
- case SACTSNAP_FRAME: /* snap to nearest frame (or second if drawing seconds) */
- if (sipo->flag & SIPO_DRAWTIME)
- td2d->loc[0] = floor(((double)td2d->loc[0] / secf) + 0.5) * secf;
- else
- td2d->loc[0] = floor((double)td2d->loc[0] + 0.5);
+ case SACTSNAP_FRAME: /* snap to nearest frame */
+ td2d->loc[0] = floor((double)td2d->loc[0] + 0.5);
+ break;
+
+ case SACTSNAP_SECOND: /* snap to nearest second */
+ td2d->loc[0] = floor(((double)td2d->loc[0] / secf) + 0.5) * secf;
break;
case SACTSNAP_MARKER: /* snap to nearest marker */
@@ -4128,6 +4117,31 @@ void flushTransGraphData(TransInfo *t)
td2d->loc2d[0] = BKE_nla_tweakedit_remap(adt, td2d->loc[0], NLATIME_CONVERT_UNMAP);
else
td2d->loc2d[0] = td2d->loc[0];
+
+ /* Time-stepping auto-snapping modes don't get applied for Graph Editor transforms,
+ * as these use the generic transform modes which don't account for this sort of thing.
+ * These ones aren't affected by NLA mapping, so we do this after the conversion...
+ *
+ * NOTE: We also have to apply to td->loc, as that's what the handle-adjustment step below looks
+ * to, otherwise we get "swimming handles"
+ * NOTE: We don't do this when cancelling transforms, or else these changes don't go away
+ */
+ if ((t->state != TRANS_CANCEL) && (td->flag & TD_NOTIMESNAP) == 0 &&
+ ELEM(sipo->autosnap, SACTSNAP_STEP, SACTSNAP_TSTEP))
+ {
+ switch (sipo->autosnap) {
+ case SACTSNAP_STEP: /* frame step */
+ td2d->loc2d[0] = floor((double)td2d->loc[0] + 0.5);
+ td->loc[0] = floor((double)td->loc[0] + 0.5);
+ break;
+
+ case SACTSNAP_TSTEP: /* second step */
+ /* XXX: the handle behaviour in this case is still not quite right... */
+ td2d->loc[0] = floor(((double)td2d->loc[0] / secf) + 0.5) * secf;
+ td->loc[0] = floor(((double)td->loc[0] / secf) + 0.5) * secf;
+ break;
+ }
+ }
/* if int-values only, truncate to integers */
if (td->flag & TD_INTVALUES)
@@ -4703,8 +4717,7 @@ 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,
- const Object *ob_act)
+static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
{
Scene *scene = t->scene;
bool constinv;
@@ -4828,11 +4841,6 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob,
unit_m3(td->smtx);
unit_m3(td->mtx);
}
-
- /* set active flag */
- if (ob == ob_act) {
- td->flag |= TD_ACTIVE;
- }
}
@@ -5840,7 +5848,6 @@ int special_transform_moving(TransInfo *t)
static void createTransObject(bContext *C, TransInfo *t)
{
Scene *scene = t->scene;
- const Object *ob_act = OBACT;
TransData *td = NULL;
TransDataExtension *tx;
@@ -5883,7 +5890,7 @@ static void createTransObject(bContext *C, TransInfo *t)
td->flag |= TD_SKIP;
}
- ObjectToTransData(t, td, ob, ob_act);
+ ObjectToTransData(t, td, ob);
td->val = NULL;
td++;
tx++;
@@ -5905,7 +5912,7 @@ static void createTransObject(bContext *C, TransInfo *t)
td->ext = tx;
td->ext->rotOrder = ob->rotmode;
- ObjectToTransData(t, td, ob, ob_act);
+ ObjectToTransData(t, td, ob);
td->val = NULL;
td++;
tx++;
@@ -6026,7 +6033,7 @@ typedef struct TransDataTracking {
/* tracks transformation from main window */
int area;
- float *relative, *loc;
+ const float *relative, *loc;
float soffset[2], srelative[2];
float offset[2];
@@ -6596,7 +6603,7 @@ static void MaskHandleToTransData(MaskSplinePoint *point, eMaskWhichHandle which
/*const*/ float parent_inverse_matrix[3][3])
{
BezTriple *bezt = &point->bezt;
- short is_sel_any = MASKPOINT_ISSEL_ANY(point);
+ const bool is_sel_any = MASKPOINT_ISSEL_ANY(point);
tdm->point = point;
copy_m3_m3(tdm->vec, bezt->vec);
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 4ee9f6bd6a6..f813db04205 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -45,11 +45,11 @@
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
#include "DNA_view3d_types.h"
#include "DNA_modifier_types.h"
#include "DNA_movieclip_types.h"
#include "DNA_mask_types.h"
+#include "DNA_meta_types.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
@@ -70,10 +70,8 @@
#include "BKE_armature.h"
#include "BKE_curve.h"
#include "BKE_depsgraph.h"
-#include "BKE_displist.h"
#include "BKE_fcurve.h"
#include "BKE_lattice.h"
-#include "BKE_mesh.h"
#include "BKE_nla.h"
#include "BKE_context.h"
#include "BKE_sequencer.h"
@@ -404,7 +402,7 @@ static void recalcData_graphedit(TransInfo *t)
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
- /* ignore unselected fcurves */
+ /* ignore FC-Curves without any selected verts */
if (!fcu_test_selected(fcu))
continue;
@@ -529,23 +527,46 @@ static void recalcData_nla(TransInfo *t)
break;
}
- /* handle auto-snapping */
- switch (snla->autosnap) {
- case SACTSNAP_FRAME: /* snap to nearest frame/time */
- if (snla->flag & SNLA_DRAWTIME) {
- tdn->h1[0] = (float)(floor(((double)tdn->h1[0] / secf) + 0.5) * secf);
- tdn->h2[0] = (float)(floor(((double)tdn->h2[0] / secf) + 0.5) * secf);
- }
- else {
+ /* handle auto-snapping
+ * NOTE: only do this when transform is still running, or we can't restore
+ */
+ if (t->state != TRANS_CANCEL) {
+ switch (snla->autosnap) {
+ case SACTSNAP_FRAME: /* snap to nearest frame */
+ case SACTSNAP_STEP: /* frame step - this is basically the same, since we don't have any remapping going on */
+ {
tdn->h1[0] = floorf(tdn->h1[0] + 0.5f);
tdn->h2[0] = floorf(tdn->h2[0] + 0.5f);
+ break;
}
- break;
-
- case SACTSNAP_MARKER: /* snap to nearest marker */
- tdn->h1[0] = (float)ED_markers_find_nearest_marker_time(&t->scene->markers, tdn->h1[0]);
- tdn->h2[0] = (float)ED_markers_find_nearest_marker_time(&t->scene->markers, tdn->h2[0]);
- break;
+
+ case SACTSNAP_SECOND: /* snap to nearest second */
+ case SACTSNAP_TSTEP: /* second step - this is basically the same, since we don't have any remapping going on */
+ {
+ /* This case behaves differently from the rest, since lengths of strips
+ * may not be multiples of a second. If we just naively resize adjust
+ * the handles, things may not work correctly. Instead, we only snap
+ * the first handle, and move the other to fit.
+ *
+ * FIXME: we do run into problems here when user attempts to negatively
+ * scale the strip, as it then just compresses down and refuses
+ * to expand out the other end.
+ */
+ float h1_new = (float)(floor(((double)tdn->h1[0] / secf) + 0.5) * secf);
+ float delta = h1_new - tdn->h1[0];
+
+ tdn->h1[0] = h1_new;
+ tdn->h2[0] += delta;
+ break;
+ }
+
+ case SACTSNAP_MARKER: /* snap to nearest marker */
+ {
+ tdn->h1[0] = (float)ED_markers_find_nearest_marker_time(&t->scene->markers, tdn->h1[0]);
+ tdn->h2[0] = (float)ED_markers_find_nearest_marker_time(&t->scene->markers, tdn->h2[0]);
+ break;
+ }
+ }
}
/* Use RNA to write the values to ensure that constraints on these are obeyed
@@ -1498,31 +1519,29 @@ void calculateCenter2D(TransInfo *t)
}
}
-void calculateCenterCursor(TransInfo *t)
+void calculateCenterCursor(TransInfo *t, float r_center[3])
{
const float *cursor;
cursor = ED_view3d_cursor3d_get(t->scene, t->view);
- copy_v3_v3(t->center, cursor);
+ copy_v3_v3(r_center, cursor);
/* If edit or pose mode, move cursor in local space */
if (t->flag & (T_EDIT | T_POSE)) {
Object *ob = t->obedit ? t->obedit : t->poseobj;
float mat[3][3], imat[3][3];
- sub_v3_v3v3(t->center, t->center, ob->obmat[3]);
+ sub_v3_v3v3(r_center, r_center, ob->obmat[3]);
copy_m3_m4(mat, ob->obmat);
invert_m3_m3(imat, mat);
- mul_m3_v3(imat, t->center);
+ mul_m3_v3(imat, r_center);
}
-
- calculateCenter2D(t);
}
-void calculateCenterCursor2D(TransInfo *t)
+void calculateCenterCursor2D(TransInfo *t, float r_center[2])
{
float aspx = 1.0, aspy = 1.0;
- float *cursor = NULL;
+ const float *cursor = NULL;
if (t->spacetype == SPACE_IMAGE) {
SpaceImage *sima = (SpaceImage *)t->sa->spacedata.first;
@@ -1566,31 +1585,27 @@ void calculateCenterCursor2D(TransInfo *t)
BLI_assert(!"Shall not happen");
}
- t->center[0] = co[0] * aspx;
- t->center[1] = co[1] * aspy;
+ r_center[0] = co[0] * aspx;
+ r_center[1] = co[1] * aspy;
}
else {
- t->center[0] = cursor[0] * aspx;
- t->center[1] = cursor[1] * aspy;
+ r_center[0] = cursor[0] * aspx;
+ r_center[1] = cursor[1] * aspy;
}
}
-
- calculateCenter2D(t);
}
-static void calculateCenterCursorGraph2D(TransInfo *t)
+void calculateCenterCursorGraph2D(TransInfo *t, float r_center[2])
{
SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first;
Scene *scene = t->scene;
/* cursor is combination of current frame, and graph-editor cursor value */
- t->center[0] = (float)(scene->r.cfra);
- t->center[1] = sipo->cursorVal;
-
- calculateCenter2D(t);
+ r_center[0] = (float)(scene->r.cfra);
+ r_center[1] = sipo->cursorVal;
}
-void calculateCenterMedian(TransInfo *t)
+void calculateCenterMedian(TransInfo *t, float r_center[3])
{
float partial[3] = {0.0f, 0.0f, 0.0f};
int total = 0;
@@ -1606,12 +1621,10 @@ void calculateCenterMedian(TransInfo *t)
}
if (i)
mul_v3_fl(partial, 1.0f / total);
- copy_v3_v3(t->center, partial);
-
- calculateCenter2D(t);
+ copy_v3_v3(r_center, partial);
}
-void calculateCenterBound(TransInfo *t)
+void calculateCenterBound(TransInfo *t, float r_center[3])
{
float max[3];
float min[3];
@@ -1628,83 +1641,137 @@ void calculateCenterBound(TransInfo *t)
copy_v3_v3(min, t->data[i].center);
}
}
- mid_v3_v3v3(t->center, min, max);
+ mid_v3_v3v3(r_center, min, max);
+}
- calculateCenter2D(t);
+/**
+ * \param select_only only get active center from data being transformed.
+ */
+bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3])
+{
+ bool ok = false;
+
+ if (t->obedit) {
+ switch (t->obedit->type) {
+ case OB_MESH:
+ {
+ BMEditSelection ese;
+ BMEditMesh *em = BKE_editmesh_from_object(t->obedit);
+
+ if (BM_select_history_active_get(em->bm, &ese)) {
+ BM_editselection_center(&ese, r_center);
+ ok = true;
+ }
+ break;
+ }
+ case OB_ARMATURE:
+ {
+ bArmature *arm = t->obedit->data;
+ EditBone *ebo = arm->act_edbone;
+
+ if (ebo && (!select_only || (ebo->flag & (BONE_SELECTED | BONE_ROOTSEL)))) {
+ copy_v3_v3(r_center, ebo->head);
+ ok = true;
+ }
+
+ break;
+ }
+ case OB_CURVE:
+ case OB_SURF:
+ {
+ float center[3];
+ Curve *cu = (Curve *)t->obedit->data;
+
+ if (ED_curve_active_center(cu, center)) {
+ copy_v3_v3(r_center, center);
+ ok = true;
+ }
+ break;
+ }
+ case OB_MBALL:
+ {
+ MetaBall *mb = (MetaBall *)t->obedit->data;
+ MetaElem *ml_act = mb->lastelem;
+
+ if (ml_act && (!select_only || (ml_act->flag & SELECT))) {
+ copy_v3_v3(r_center, &ml_act->x);
+ ok = true;
+ }
+ break;
+ }
+ case OB_LATTICE:
+ {
+ BPoint *actbp = BKE_lattice_active_point_get(t->obedit->data);
+
+ if (actbp) {
+ copy_v3_v3(r_center, actbp->vec);
+ ok = true;
+ }
+ break;
+ }
+ }
+ }
+ else if (t->flag & T_POSE) {
+ Scene *scene = t->scene;
+ Object *ob = OBACT;
+ if (ob) {
+ bPoseChannel *pchan = BKE_pose_channel_active(ob);
+ if (pchan && (!select_only || (pchan->bone->flag & BONE_SELECTED))) {
+ copy_v3_v3(r_center, pchan->pose_head);
+ ok = true;
+ }
+ }
+ }
+ else {
+ /* object mode */
+ Scene *scene = t->scene;
+ Object *ob = OBACT;
+ if (ob && (!select_only || (ob->flag & SELECT))) {
+ copy_v3_v3(r_center, ob->obmat[3]);
+ ok = true;
+ }
+ }
+
+ return ok;
}
+
void calculateCenter(TransInfo *t)
{
switch (t->around) {
case V3D_CENTER:
- calculateCenterBound(t);
+ calculateCenterBound(t, t->center);
break;
case V3D_CENTROID:
- calculateCenterMedian(t);
+ calculateCenterMedian(t, t->center);
break;
case V3D_CURSOR:
if (ELEM(t->spacetype, SPACE_IMAGE, SPACE_CLIP))
- calculateCenterCursor2D(t);
+ calculateCenterCursor2D(t, t->center);
else if (t->spacetype == SPACE_IPO)
- calculateCenterCursorGraph2D(t);
+ calculateCenterCursorGraph2D(t, t->center);
else
- calculateCenterCursor(t);
+ calculateCenterCursor(t, t->center);
break;
case V3D_LOCAL:
/* Individual element center uses median center for helpline and such */
- calculateCenterMedian(t);
+ calculateCenterMedian(t, t->center);
break;
case V3D_ACTIVE:
{
- /* set median, and if if if... do object center */
-
- /* EDIT MODE ACTIVE EDITMODE ELEMENT */
-
- if (t->obedit) {
- if (t->obedit && t->obedit->type == OB_MESH) {
- BMEditSelection ese;
- BMEditMesh *em = BKE_editmesh_from_object(t->obedit);
-
- if (BM_select_history_active_get(em->bm, &ese)) {
- BM_editselection_center(&ese, t->center);
- calculateCenter2D(t);
- break;
- }
- }
- else if (ELEM(t->obedit->type, OB_CURVE, OB_SURF)) {
- float center[3];
- Curve *cu = (Curve *)t->obedit->data;
-
- if (ED_curve_active_center(cu, center)) {
- copy_v3_v3(t->center, center);
- calculateCenter2D(t);
- break;
- }
- }
- else if (t->obedit && t->obedit->type == OB_LATTICE) {
- BPoint *actbp = BKE_lattice_active_point_get(t->obedit->data);
-
- if (actbp) {
- copy_v3_v3(t->center, actbp->vec);
- calculateCenter2D(t);
- break;
- }
- }
- } /* END EDIT MODE ACTIVE ELEMENT */
-
- calculateCenterMedian(t);
- if ((t->flag & (T_EDIT | T_POSE)) == 0) {
- Scene *scene = t->scene;
- Object *ob = OBACT;
- if (ob) {
- copy_v3_v3(t->center, ob->obmat[3]);
- projectFloatView(t, t->center, t->center2d);
- }
+ if (calculateCenterActive(t, false, t->center)) {
+ /* pass */
+ }
+ else {
+ /* fallback */
+ calculateCenterMedian(t, t->center);
}
break;
}
}
-
+
+ calculateCenter2D(t);
+
/* setting constraint center */
copy_v3_v3(t->con.center, t->center);
if (t->flag & (T_EDIT | T_POSE)) {
diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c
index 02f9c636ab4..70b565859f3 100644
--- a/source/blender/editors/transform/transform_input.c
+++ b/source/blender/editors/transform/transform_input.c
@@ -183,7 +183,7 @@ static void InputCustomRatioFlip(TransInfo *UNUSED(t), MouseInput *mi, const int
double length;
double distance;
double dx, dy;
- int *data = mi->data;
+ const int *data = mi->data;
if (data) {
dx = data[2] - data[0];
@@ -232,7 +232,7 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2],
double *angle = mi->data;
- /* use doubles here, to make sure a "1.0" (no rotation) doesnt become 9.999999e-01, which gives 0.02 for acos */
+ /* use doubles here, to make sure a "1.0" (no rotation) doesn't become 9.999999e-01, which gives 0.02 for acos */
double deler = (((dx1 * dx1 + dy1 * dy1) +
(dx2 * dx2 + dy2 * dy2) -
(dx3 * dx3 + dy3 * dy3)) / (2.0 * ((A * B) ? (A * B) : 1.0)));
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index 2fa0b6b320f..125975eb32b 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -35,18 +35,9 @@
#include <math.h>
#include <float.h>
-#ifndef WIN32
-#include <unistd.h>
-#else
-#include <io.h>
-#endif
-
-#include "MEM_guardedalloc.h"
-
#include "DNA_armature_types.h"
#include "DNA_curve_types.h"
#include "DNA_lattice_types.h"
-#include "DNA_mesh_types.h"
#include "DNA_meta_types.h"
#include "DNA_screen_types.h"
#include "DNA_scene_types.h"
@@ -61,7 +52,6 @@
#include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_global.h"
-#include "BKE_mesh.h"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
#include "BKE_editmesh.h"
@@ -74,7 +64,6 @@
#include "ED_armature.h"
#include "ED_curve.h"
-#include "ED_mesh.h"
#include "ED_particle.h"
#include "ED_view3d.h"
@@ -202,7 +191,7 @@ static int test_rotmode_euler(short rotmode)
return (ELEM(rotmode, ROT_MODE_AXISANGLE, ROT_MODE_QUAT)) ? 0 : 1;
}
-int gimbal_axis(Object *ob, float gmat[3][3])
+bool gimbal_axis(Object *ob, float gmat[3][3])
{
if (ob) {
if (ob->mode & OB_MODE_POSE) {
@@ -461,16 +450,19 @@ int calc_manipulator_stats(const bContext *C)
}
else if (obedit->type == OB_MBALL) {
MetaBall *mb = (MetaBall *)obedit->data;
- MetaElem *ml /* , *ml_sel = NULL */ /* UNUSED */;
+ MetaElem *ml;
- ml = mb->editelems->first;
- while (ml) {
- if (ml->flag & SELECT) {
- calc_tw_center(scene, &ml->x);
- /* ml_sel = ml; */ /* UNUSED */
- totsel++;
+ if ((v3d->around == V3D_ACTIVE) && (ml = mb->lastelem)) {
+ calc_tw_center(scene, &ml->x);
+ totsel++;
+ }
+ else {
+ for (ml = mb->editelems->first; ml; ml = ml->next) {
+ if (ml->flag & SELECT) {
+ calc_tw_center(scene, &ml->x);
+ totsel++;
+ }
}
- ml = ml->next;
}
}
else if (obedit->type == OB_LATTICE) {
@@ -505,7 +497,7 @@ int calc_manipulator_stats(const bContext *C)
else if (ob && (ob->mode & OB_MODE_POSE)) {
bPoseChannel *pchan;
int mode = TFM_ROTATION; // mislead counting bones... bah. We don't know the manipulator mode, could be mixed
- int ok = false;
+ bool ok = false;
if ((ob->lay & v3d->lay) == 0) return 0;
@@ -1189,7 +1181,7 @@ static void draw_manipulator_rotate(
static void drawsolidcube(float size)
{
- static float cube[8][3] = {
+ const float cube[8][3] = {
{-1.0, -1.0, -1.0},
{-1.0, -1.0, 1.0},
{-1.0, 1.0, 1.0},
@@ -1507,7 +1499,9 @@ static void draw_manipulator_rotate_cyl(
/* Screen aligned view rot circle */
if (drawflags & MAN_ROT_V) {
- float unitmat[4][4] = MAT4_UNITY;
+ float unitmat[4][4];
+
+ unit_m4(unitmat);
if (is_picksel) glLoadName(MAN_ROT_V);
UI_ThemeColor(TH_TRANSFORM);
@@ -1701,7 +1695,8 @@ static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const int mval[2], fl
short hits;
const bool is_picksel = true;
- extern void setwinmatrixview3d(ARegion *, View3D *, rctf *); // XXX check a bit later on this... (ton)
+ /* XXX check a bit later on this... (ton) */
+ extern void view3d_winmatrix_set(ARegion *ar, View3D *v3d, rctf *rect);
/* when looking through a selected camera, the manipulator can be at the
* exact same position as the view, skip so we don't break selection */
@@ -1713,12 +1708,12 @@ static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const int mval[2], fl
rect.ymin = mval[1] - hotspot;
rect.ymax = mval[1] + hotspot;
- setwinmatrixview3d(ar, v3d, &rect);
+ view3d_winmatrix_set(ar, v3d, &rect);
mul_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
glSelectBuffer(64, buffer);
glRenderMode(GL_SELECT);
- glInitNames(); /* these two calls whatfor? It doesnt work otherwise */
+ glInitNames(); /* these two calls whatfor? It doesn't work otherwise */
glPushName(-2);
/* do the drawing */
@@ -1734,7 +1729,7 @@ static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const int mval[2], fl
glPopName();
hits = glRenderMode(GL_RENDER);
- setwinmatrixview3d(ar, v3d, NULL);
+ view3d_winmatrix_set(ar, v3d, NULL);
mul_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
if (hits == 1) return buffer[3];
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index d8c5339c14f..f27ea4793fe 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -36,7 +36,6 @@
#include "BKE_context.h"
#include "BKE_global.h"
-#include "BKE_armature.h"
#include "BKE_report.h"
#include "RNA_access.h"
@@ -50,12 +49,11 @@
#include "UI_resources.h"
#include "ED_screen.h"
-#include "ED_mesh.h"
#include "transform.h"
typedef struct TransformModeItem {
- char *idname;
+ const char *idname;
int mode;
void (*opfunc)(wmOperatorType *);
} TransformModeItem;
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index 1338a34749a..ba90926df3b 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -33,7 +33,6 @@
#include "DNA_armature_types.h"
#include "DNA_curve_types.h"
-#include "DNA_mesh_types.h"
#include "DNA_meta_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
@@ -47,7 +46,6 @@
#include "BLI_utildefines.h"
#include "BKE_action.h"
-#include "BKE_armature.h"
#include "BKE_curve.h"
#include "BKE_context.h"
#include "BKE_editmesh.h"
@@ -58,7 +56,6 @@
#include "BLF_translation.h"
#include "ED_armature.h"
-#include "ED_mesh.h"
#include "RNA_define.h"
@@ -798,18 +795,31 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
}
else if (obedit->type == OB_MBALL) {
MetaBall *mb = obedit->data;
+ MetaElem *ml;
+ bool ok = false;
+ float tmat[3][3];
- if (mb->lastelem) {
- float qmat[3][3];
-
- /* Rotation of MetaElem is stored in quat */
- quat_to_mat3(qmat, mb->lastelem->quat);
-
- copy_v3_v3(normal, qmat[2]);
+ if (activeOnly && (ml = mb->lastelem)) {
+ quat_to_mat3(tmat, ml->quat);
+ add_v3_v3(normal, tmat[2]);
+ add_v3_v3(plane, tmat[1]);
+ ok = true;
+ }
+ else {
+ for (ml = mb->editelems->first; ml; ml = ml->next) {
+ if (ml->flag & SELECT) {
+ quat_to_mat3(tmat, ml->quat);
+ add_v3_v3(normal, tmat[2]);
+ add_v3_v3(plane, tmat[1]);
+ ok = true;
+ }
+ }
+ }
- copy_v3_v3(plane, qmat[1]);
-
- result = ORIENTATION_FACE;
+ if (ok) {
+ if (!is_zero_v3(plane)) {
+ result = ORIENTATION_FACE;
+ }
}
}
else if (obedit->type == OB_ARMATURE) {
@@ -858,7 +868,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
bArmature *arm = ob->data;
bPoseChannel *pchan;
float imat[3][3], mat[3][3];
- int ok = false;
+ bool ok = false;
if (activeOnly && (pchan = BKE_pose_channel_active(ob))) {
add_v3_v3(normal, pchan->pose_mat[2]);
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index c9805ff82c3..9afc12a5270 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -40,7 +40,6 @@
#include "DNA_curve_types.h"
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
-#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h" /* Temporary, for snapping to other unselected meshes */
#include "DNA_node_types.h"
#include "DNA_space_types.h"
@@ -61,7 +60,6 @@
#include "BKE_context.h"
#include "BKE_editmesh.h"
#include "BKE_main.h"
-#include "BKE_mesh.h"
#include "BKE_tracking.h"
#include "RNA_access.h"
@@ -70,7 +68,6 @@
#include "ED_armature.h"
#include "ED_image.h"
-#include "ED_mesh.h"
#include "ED_node.h"
#include "ED_uvedit.h"
#include "ED_view3d.h"
@@ -105,9 +102,9 @@ static void TargetSnapCenter(TransInfo *t);
static void TargetSnapClosest(TransInfo *t);
static void TargetSnapActive(TransInfo *t);
-static float RotationBetween(TransInfo *t, float p1[3], float p2[3]);
-static float TranslationBetween(TransInfo *t, float p1[3], float p2[3]);
-static float ResizeBetween(TransInfo *t, float p1[3], float p2[3]);
+static float RotationBetween(TransInfo *t, const float p1[3], const float p2[3]);
+static float TranslationBetween(TransInfo *t, const float p1[3], const float p2[3]);
+static float ResizeBetween(TransInfo *t, const float p1[3], const float p2[3]);
/****************** IMPLEMENTATIONS *********************/
@@ -596,10 +593,10 @@ void initSnapping(TransInfo *t, wmOperator *op)
t->modifiers |= MOD_SNAP;
}
- t->tsnap.align = ((t->settings->snap_flag & SCE_SNAP_ROTATE) == SCE_SNAP_ROTATE);
- t->tsnap.project = ((t->settings->snap_flag & SCE_SNAP_PROJECT) == SCE_SNAP_PROJECT);
- t->tsnap.snap_self = !((t->settings->snap_flag & SCE_SNAP_NO_SELF) == SCE_SNAP_NO_SELF);
- t->tsnap.peel = ((t->settings->snap_flag & SCE_SNAP_PROJECT) == SCE_SNAP_PROJECT);
+ t->tsnap.align = ((t->settings->snap_flag & SCE_SNAP_ROTATE) != 0);
+ t->tsnap.project = ((t->settings->snap_flag & SCE_SNAP_PROJECT) != 0);
+ t->tsnap.snap_self = !((t->settings->snap_flag & SCE_SNAP_NO_SELF) != 0);
+ t->tsnap.peel = ((t->settings->snap_flag & SCE_SNAP_PROJECT) != 0);
}
}
@@ -798,12 +795,12 @@ static void ApplySnapResize(TransInfo *t, float vec[3])
/********************** DISTANCE **************************/
-static float TranslationBetween(TransInfo *UNUSED(t), float p1[3], float p2[3])
+static float TranslationBetween(TransInfo *UNUSED(t), const float p1[3], const float p2[3])
{
return len_v3v3(p1, p2);
}
-static float RotationBetween(TransInfo *t, float p1[3], float p2[3])
+static float RotationBetween(TransInfo *t, const float p1[3], const float p2[3])
{
float angle, start[3], end[3], center[3];
@@ -859,7 +856,7 @@ static float RotationBetween(TransInfo *t, float p1[3], float p2[3])
return angle;
}
-static float ResizeBetween(TransInfo *t, float p1[3], float p2[3])
+static float ResizeBetween(TransInfo *t, const float p1[3], const float p2[3])
{
float d1[3], d2[3], center[3], len_d1;
@@ -904,7 +901,7 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
if (t->tsnap.mode == SCE_SNAP_MODE_VOLUME) {
ListBase depth_peels;
DepthPeel *p1, *p2;
- float *last_p = NULL;
+ const float *last_p = NULL;
float max_dist = FLT_MAX;
float p[3] = {0.0f, 0.0f, 0.0f};
@@ -1011,7 +1008,7 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
Image *ima = ED_space_image(t->sa->spacedata.first);
float aspx, aspy, co[2];
- UI_view2d_region_to_view(&t->ar->v2d, t->mval[0], t->mval[1], co, co + 1);
+ UI_view2d_region_to_view(&t->ar->v2d, t->mval[0], t->mval[1], &co[0], &co[1]);
if (ED_uvedit_nearest_uv(t->scene, t->obedit, ima, co, t->tsnap.snapPoint)) {
ED_space_image_get_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
@@ -1094,27 +1091,14 @@ static void TargetSnapActive(TransInfo *t)
{
/* Only need to calculate once */
if ((t->tsnap.status & TARGET_INIT) == 0) {
- TransData *td = NULL;
- TransData *active_td = NULL;
- int i;
-
- for (td = t->data, i = 0; i < t->total && td->flag & TD_SELECTED; i++, td++) {
- if (td->flag & TD_ACTIVE) {
- active_td = td;
- break;
- }
- }
-
- if (active_td) {
- copy_v3_v3(t->tsnap.snapTarget, active_td->center);
-
+ if (calculateCenterActive(t, true, t->tsnap.snapTarget)) {
if (t->flag & (T_EDIT | T_POSE)) {
Object *ob = t->obedit ? t->obedit : t->poseobj;
mul_m4_v3(ob->obmat, t->tsnap.snapTarget);
}
-
- TargetSnapOffset(t, active_td);
-
+
+ TargetSnapOffset(t, NULL);
+
t->tsnap.status |= TARGET_INIT;
}
/* No active, default to median */
@@ -1411,8 +1395,8 @@ static bool snapArmature(short snap_mode, ARegion *ar, Object *ob, bArmature *ar
bone = pchan->bone;
/* skip hidden bones */
if (bone && !(bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG))) {
- float *head_vec = pchan->pose_head;
- float *tail_vec = pchan->pose_tail;
+ const float *head_vec = pchan->pose_head;
+ const float *tail_vec = pchan->pose_tail;
switch (snap_mode) {
case SCE_SNAP_MODE_VERTEX:
@@ -1596,7 +1580,7 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes
case SCE_SNAP_MODE_VERTEX:
{
MVert *verts = dm->getVertArray(dm);
- int *index_array = NULL;
+ const int *index_array = NULL;
int index = 0;
int i;
@@ -1645,7 +1629,7 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes
MVert *verts = dm->getVertArray(dm);
MEdge *edges = dm->getEdgeArray(dm);
int totedge = dm->getNumEdges(dm);
- int *index_array = NULL;
+ const int *index_array = NULL;
int index = 0;
int i;
@@ -2268,8 +2252,7 @@ static bool snapNode(ToolSettings *ts, SpaceNode *UNUSED(snode), ARegion *ar, bN
rcti totr;
int new_dist;
- UI_view2d_to_region_no_clip(v2d, node->totr.xmin, node->totr.ymin, &totr.xmin, &totr.ymin);
- UI_view2d_to_region_no_clip(v2d, node->totr.xmax, node->totr.ymax, &totr.xmax, &totr.ymax);
+ UI_view2d_view_to_region_rcti(v2d, &node->totr, &totr);
if (border & NODE_LEFT) {
new_dist = abs(totr.xmin - mval[0]);
diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt
index 9f515bfaf49..3c051586282 100644
--- a/source/blender/editors/util/CMakeLists.txt
+++ b/source/blender/editors/util/CMakeLists.txt
@@ -40,7 +40,6 @@ set(SRC
editmode_undo.c
numinput.c
undo.c
- crazyspace.c
util_intern.h
# general includes
@@ -53,7 +52,6 @@ set(SRC
../include/ED_curve.h
../include/ED_datafiles.h
../include/ED_fileselect.h
- ../include/ED_fluidsim.h
../include/ED_gpencil.h
../include/ED_image.h
../include/ED_info.h
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index 887cc430f69..2580836cad9 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -158,12 +158,12 @@ void ED_editors_flush_edits(const bContext *C, bool for_render)
if (for_render) {
/* flush changes from dynamic topology sculpt */
- sculptsession_bm_to_me_for_render(obact);
+ BKE_sculptsession_bm_to_me_for_render(obact);
}
else {
/* Set reorder=false so that saving the file doesn't reorder
* the BMesh's elements */
- sculptsession_bm_to_me(obact, false);
+ BKE_sculptsession_bm_to_me(obact, false);
}
}
}
diff --git a/source/blender/editors/util/editmode_undo.c b/source/blender/editors/util/editmode_undo.c
index 9be0d68e573..ef95e4cb3ff 100644
--- a/source/blender/editors/util/editmode_undo.c
+++ b/source/blender/editors/util/editmode_undo.c
@@ -36,10 +36,8 @@
#include "MEM_guardedalloc.h"
#include "DNA_object_types.h"
-#include "DNA_screen_types.h"
#include "BLI_blenlib.h"
-#include "BLI_dynstr.h"
#include "BLI_utildefines.h"
#include "BKE_blender.h"
diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c
index 850f1d1c5cc..ee391af185d 100644
--- a/source/blender/editors/util/numinput.c
+++ b/source/blender/editors/util/numinput.c
@@ -70,17 +70,20 @@ enum {
void initNumInput(NumInput *n)
{
- n->unit_sys = USER_UNIT_NONE;
- n->unit_type[0] = n->unit_type[1] = n->unit_type[2] = B_UNIT_NONE;
- n->idx = 0;
n->idx_max = 0;
+ n->unit_sys = USER_UNIT_NONE;
+ fill_vn_i(n->unit_type, NUM_MAX_ELEMENTS, B_UNIT_NONE);
+ n->unit_use_radians = false;
+
n->flag = 0;
- n->val_flag[0] = n->val_flag[1] = n->val_flag[2] = 0;
- zero_v3(n->val_org);
+ fill_vn_short(n->val_flag, NUM_MAX_ELEMENTS, 0);
zero_v3(n->val);
+ fill_vn_fl(n->val_org, NUM_MAX_ELEMENTS, 0.0f);
+ fill_vn_fl(n->val_inc, NUM_MAX_ELEMENTS, 1.0f);
+
+ n->idx = 0;
n->str[0] = '\0';
n->str_cur = 0;
- copy_v3_fl(n->val_inc, 1.0f);
}
/* str must be NUM_STR_REP_LEN * (idx_max + 1) length. */
diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c
index 434f1e30188..a4f2c36f250 100644
--- a/source/blender/editors/util/undo.c
+++ b/source/blender/editors/util/undo.c
@@ -37,12 +37,9 @@
#include "MEM_guardedalloc.h"
-#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
-#include "BLI_blenlib.h"
-#include "BLI_dynstr.h"
#include "BLI_utildefines.h"
#include "BLF_translation.h"
@@ -533,14 +530,20 @@ static int undo_history_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
uiLayout *layout = uiPupMenuLayout(pup);
uiLayout *split = uiLayoutSplit(layout, 0.0f, false);
uiLayout *column = NULL;
+ const int col_size = 20 + totitem / 12;
int i, c;
+ bool add_col = true;
- for (c = 0, i = totitem - 1; i >= 0; i--, c++) {
- if ( (c % 20) == 0)
+ for (c = 0, i = totitem; i--;) {
+ if (add_col && !(c % col_size)) {
column = uiLayoutColumn(split, false);
- if (item[i].identifier)
+ add_col = false;
+ }
+ if (item[i].identifier) {
uiItemIntO(column, item[i].name, item[i].icon, op->type->idname, "item", item[i].value);
-
+ ++c;
+ add_col = true;
+ }
}
MEM_freeN(item);
diff --git a/source/blender/editors/uvedit/uvedit_buttons.c b/source/blender/editors/uvedit/uvedit_buttons.c
index e648caf51d2..78e3811a5fc 100644
--- a/source/blender/editors/uvedit/uvedit_buttons.c
+++ b/source/blender/editors/uvedit/uvedit_buttons.c
@@ -32,7 +32,6 @@
#include "MEM_guardedalloc.h"
-#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
@@ -47,7 +46,6 @@
#include "BKE_context.h"
#include "BKE_customdata.h"
-#include "BKE_mesh.h"
#include "BKE_screen.h"
#include "BKE_editmesh.h"
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index 7735c0b1b51..ce4b97e7108 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -33,8 +33,6 @@
#include <stdlib.h>
#include <string.h>
-#include "MEM_guardedalloc.h"
-
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
@@ -46,7 +44,6 @@
#include "BLI_utildefines.h"
#include "BKE_DerivedMesh.h"
-#include "BKE_mesh.h"
#include "BKE_editmesh.h"
#include "BLI_buffer.h"
@@ -54,7 +51,6 @@
#include "BIF_gl.h"
#include "BIF_glutil.h"
-#include "ED_util.h"
#include "ED_image.h"
#include "ED_mesh.h"
#include "ED_uvedit.h"
@@ -73,7 +69,7 @@ void draw_image_cursor(ARegion *ar, const float cursor[2])
{
float zoom[2], x_fac, y_fac;
- UI_view2d_getscale_inverse(&ar->v2d, &zoom[0], &zoom[1]);
+ UI_view2d_scale_get_inverse(&ar->v2d, &zoom[0], &zoom[1]);
mul_v2_fl(zoom, 256.0f * UI_DPI_FAC);
x_fac = zoom[0];
@@ -489,6 +485,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
/* 1. draw shadow mesh */
if (sima->flag & SI_DRAWSHADOW) {
+ DM_update_materials(em->derivedFinal, obedit);
/* first try existing derivedmesh */
if (!draw_uvs_dm_shadow(em->derivedFinal)) {
/* create one if it does not exist */
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index f5dcac7e062..5169cc73052 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -60,7 +60,6 @@
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_material.h"
-#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
#include "BKE_node.h"
#include "BKE_report.h"
@@ -991,7 +990,7 @@ static bool uv_select_edgeloop_edge_tag_faces(BMEditMesh *em, UvMapVert *first1,
}
static int uv_select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestHit *hit,
- float limit[2], const bool extend)
+ const float limit[2], const bool extend)
{
BMFace *efa;
BMIter iter, liter;
@@ -1582,8 +1581,8 @@ static void uv_weld_align(bContext *C, int tool)
if (BLI_array_count(eve_line) > 2) {
/* we know the returns from these must be valid */
- float *uv_start = uv_sel_co_from_eve(scene, ima, em, eve_line[0]);
- float *uv_end = uv_sel_co_from_eve(scene, ima, em, eve_line[BLI_array_count(eve_line) - 1]);
+ const float *uv_start = uv_sel_co_from_eve(scene, ima, em, eve_line[0]);
+ const float *uv_end = uv_sel_co_from_eve(scene, ima, em, eve_line[BLI_array_count(eve_line) - 1]);
/* For t & u modes */
float a = 0.0f;
@@ -1684,7 +1683,7 @@ typedef struct UVvert {
static int uv_remove_doubles_exec(bContext *C, wmOperator *op)
{
const float threshold = RNA_float_get(op->ptr, "threshold");
- const int use_unselected = RNA_boolean_get(op->ptr, "use_unselected");
+ const bool use_unselected = RNA_boolean_get(op->ptr, "use_unselected");
SpaceImage *sima;
Scene *scene;
@@ -1695,7 +1694,7 @@ static int uv_remove_doubles_exec(bContext *C, wmOperator *op)
int uv_a_index;
int uv_b_index;
float *uv_a;
- float *uv_b;
+ const float *uv_b;
BMIter iter, liter;
BMFace *efa;
@@ -2796,7 +2795,6 @@ static int uv_border_select_exec(bContext *C, wmOperator *op)
BMIter iter, liter;
MTexPoly *tf;
MLoopUV *luv;
- rcti rect;
rctf rectf;
bool changed, pinned, select, extend;
const bool use_face_center = (ts->uv_flag & UV_SYNC_SELECTION) ?
@@ -2807,10 +2805,8 @@ static int uv_border_select_exec(bContext *C, wmOperator *op)
const int cd_poly_tex_offset = CustomData_get_offset(&em->bm->pdata, CD_MTEXPOLY);
/* get rectangle from operator */
- WM_operator_properties_border_to_rcti(op, &rect);
-
- UI_view2d_region_to_view(&ar->v2d, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin);
- UI_view2d_region_to_view(&ar->v2d, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax);
+ WM_operator_properties_border_to_rctf(op, &rectf);
+ UI_view2d_region_to_view_rctf(&ar->v2d, &rectf, &rectf);
/* figure out what to select/deselect */
select = (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT);
@@ -3071,8 +3067,9 @@ static bool do_lasso_select_mesh_uv(bContext *C, const int mcords[][2], short mo
if (select != uvedit_face_select_test(scene, efa, cd_loop_uv_offset)) {
float cent[2];
uv_poly_center(efa, cent, cd_loop_uv_offset);
- UI_view2d_view_to_region(&ar->v2d, cent[0], cent[1], &screen_uv[0], &screen_uv[1]);
- if (BLI_rcti_isect_pt_v(&rect, screen_uv) &&
+
+ if (UI_view2d_view_to_region_clip(&ar->v2d, cent[0], cent[1], &screen_uv[0], &screen_uv[1]) &&
+ BLI_rcti_isect_pt_v(&rect, screen_uv) &&
BLI_lasso_is_point_inside(mcords, moves, screen_uv[0], screen_uv[1], V2D_IS_CLIPPED))
{
BM_elem_flag_enable(efa, BM_ELEM_TAG);
@@ -3093,8 +3090,10 @@ static bool do_lasso_select_mesh_uv(bContext *C, const int mcords[][2], short mo
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if ((select) != (uvedit_uv_select_test(scene, l, cd_loop_uv_offset))) {
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- UI_view2d_view_to_region(&ar->v2d, luv->uv[0], luv->uv[1], &screen_uv[0], &screen_uv[1]);
- if (BLI_rcti_isect_pt_v(&rect, screen_uv) &&
+ if (UI_view2d_view_to_region_clip(&ar->v2d,
+ luv->uv[0], luv->uv[1],
+ &screen_uv[0], &screen_uv[1]) &&
+ BLI_rcti_isect_pt_v(&rect, screen_uv) &&
BLI_lasso_is_point_inside(mcords, moves, screen_uv[0], screen_uv[1], V2D_IS_CLIPPED))
{
uvedit_uv_select_set(em, scene, l, select, false, cd_loop_uv_offset);
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index 64de56206c2..5f22a201600 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -1886,7 +1886,7 @@ static PBool p_collapse_allowed_geometric(PEdge *edge, PEdge *pair)
if (p_vert_interior(oldv)) {
/* hlscm criterion: angular defect smaller than threshold */
- if (fabs(angulardefect) > (M_PI * 30.0 / 180.0))
+ if (fabsf(angulardefect) > (float)(M_PI * 30.0 / 180.0))
return P_FALSE;
}
else {
@@ -1952,7 +1952,7 @@ static float p_collapse_cost(PEdge *edge, PEdge *pair)
sub_v3_v3v3(tetrav3, co2, oldv->co);
cross_v3_v3v3(c, tetrav2, tetrav3);
- volumecost += fabs(dot_v3v3(edgevec, c) / 6.0f);
+ volumecost += fabsf(dot_v3v3(edgevec, c) / 6.0f);
#if 0
shapecost += dot_v3v3(co1, keepv->co);
diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c
index 630b601b69d..ba4b65f4ed4 100644
--- a/source/blender/editors/uvedit/uvedit_smart_stitch.c
+++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c
@@ -37,7 +37,6 @@
#include "MEM_guardedalloc.h"
#include "DNA_object_types.h"
-#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_scene_types.h"
@@ -52,7 +51,6 @@
#include "BKE_context.h"
#include "BKE_customdata.h"
#include "BKE_depsgraph.h"
-#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
#include "BKE_editmesh.h"
@@ -634,7 +632,7 @@ static void state_delete(StitchState *state)
static void stitch_uv_edge_generate_linked_edges(GHash *edge_hash, StitchState *state)
{
UvEdge *edges = state->edges;
- int *map = state->map;
+ const int *map = state->map;
UvElementMap *element_map = state->element_map;
UvElement *first_element = element_map->buf;
int i;
@@ -1358,8 +1356,8 @@ static unsigned int uv_edge_hash(const void *key)
{
UvEdge *edge = (UvEdge *)key;
return
- BLI_ghashutil_inthash(SET_INT_IN_POINTER(edge->uv2)) +
- BLI_ghashutil_inthash(SET_INT_IN_POINTER(edge->uv1));
+ BLI_ghashutil_uinthash(edge->uv2) +
+ BLI_ghashutil_uinthash(edge->uv1);
}
static int uv_edge_compare(const void *a, const void *b)
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 7f43ca01f4a..21e7bb00204 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -46,10 +46,8 @@
#include "BLI_utildefines.h"
#include "BLI_alloca.h"
#include "BLI_math.h"
-#include "BLI_edgehash.h"
#include "BLI_uvproject.h"
#include "BLI_string.h"
-#include "BLI_scanfill.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_subsurf.h"
@@ -58,7 +56,6 @@
#include "BKE_depsgraph.h"
#include "BKE_image.h"
#include "BKE_main.h"
-#include "BKE_mesh.h"
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_editmesh.h"
@@ -361,7 +358,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, Object *ob, B
/* Used to hold subsurfed Mesh */
DerivedMesh *derivedMesh, *initialDerived;
/* holds original indices for subsurfed mesh */
- int *origVertIndices, *origEdgeIndices, *origFaceIndices, *origPolyIndices;
+ const int *origVertIndices, *origEdgeIndices, *origFaceIndices, *origPolyIndices;
/* Holds vertices of subsurfed mesh */
MVert *subsurfedVerts;
MEdge *subsurfedEdges;
diff --git a/source/blender/freestyle/CMakeLists.txt b/source/blender/freestyle/CMakeLists.txt
index 39267a6548c..c94a5ac9f92 100644
--- a/source/blender/freestyle/CMakeLists.txt
+++ b/source/blender/freestyle/CMakeLists.txt
@@ -38,8 +38,6 @@ set(SRC
intern/blender_interface/BlenderStrokeRenderer.cpp
intern/blender_interface/BlenderStrokeRenderer.h
intern/blender_interface/BlenderStyleModule.h
- intern/blender_interface/BlenderTextureManager.cpp
- intern/blender_interface/BlenderTextureManager.h
intern/blender_interface/FRS_freestyle.cpp
intern/geometry/BBox.h
intern/geometry/Bezier.cpp
@@ -185,6 +183,8 @@ set(SRC
intern/python/StrokeShader/BPy_BackboneStretcherShader.h
intern/python/StrokeShader/BPy_BezierCurveShader.cpp
intern/python/StrokeShader/BPy_BezierCurveShader.h
+ intern/python/StrokeShader/BPy_BlenderTextureShader.cpp
+ intern/python/StrokeShader/BPy_BlenderTextureShader.h
intern/python/StrokeShader/BPy_CalligraphicShader.cpp
intern/python/StrokeShader/BPy_CalligraphicShader.h
intern/python/StrokeShader/BPy_ColorNoiseShader.cpp
@@ -213,6 +213,8 @@ set(SRC
intern/python/StrokeShader/BPy_SpatialNoiseShader.h
intern/python/StrokeShader/BPy_StrokeTextureShader.cpp
intern/python/StrokeShader/BPy_StrokeTextureShader.h
+ intern/python/StrokeShader/BPy_StrokeTextureStepShader.cpp
+ intern/python/StrokeShader/BPy_StrokeTextureStepShader.h
intern/python/StrokeShader/BPy_TextureAssignerShader.cpp
intern/python/StrokeShader/BPy_TextureAssignerShader.h
intern/python/StrokeShader/BPy_ThicknessNoiseShader.cpp
@@ -445,7 +447,9 @@ set(SRC
intern/stroke/Operators.h
intern/stroke/PSStrokeRenderer.cpp
intern/stroke/PSStrokeRenderer.h
+ intern/stroke/Predicates0D.cpp
intern/stroke/Predicates0D.h
+ intern/stroke/Predicates1D.cpp
intern/stroke/Predicates1D.h
intern/stroke/QInformationMap.h
intern/stroke/Stroke.cpp
@@ -460,6 +464,7 @@ set(SRC
intern/stroke/StrokeRenderer.h
intern/stroke/StrokeRep.cpp
intern/stroke/StrokeRep.h
+ intern/stroke/StrokeShader.cpp
intern/stroke/StrokeShader.h
intern/stroke/StrokeTesselator.cpp
intern/stroke/StrokeTesselator.h
@@ -509,7 +514,9 @@ set(SRC
intern/view_map/GridDensityProvider.h
intern/view_map/HeuristicGridDensityProviderFactory.cpp
intern/view_map/HeuristicGridDensityProviderFactory.h
+ intern/view_map/Interface0D.cpp
intern/view_map/Interface0D.h
+ intern/view_map/Interface1D.cpp
intern/view_map/Interface1D.h
intern/view_map/OccluderSource.cpp
intern/view_map/OccluderSource.h
diff --git a/source/blender/freestyle/intern/application/AppConfig.cpp b/source/blender/freestyle/intern/application/AppConfig.cpp
index 967cb400241..cf7959ffaef 100644
--- a/source/blender/freestyle/intern/application/AppConfig.cpp
+++ b/source/blender/freestyle/intern/application/AppConfig.cpp
@@ -25,6 +25,7 @@
#include "AppConfig.h"
#include <iostream>
+#include "../system/FreestyleConfig.h"
#include "../system/StringUtils.h"
using namespace std;
diff --git a/source/blender/freestyle/intern/application/AppConfig.h b/source/blender/freestyle/intern/application/AppConfig.h
index 94ae0c3c348..ae1d96e06d8 100644
--- a/source/blender/freestyle/intern/application/AppConfig.h
+++ b/source/blender/freestyle/intern/application/AppConfig.h
@@ -30,7 +30,6 @@
#include <string>
#include <algorithm>
-#include "../system/FreestyleConfig.h"
#include "../system/Precision.h"
#ifdef WITH_CXX_GUARDEDALLOC
diff --git a/source/blender/freestyle/intern/application/AppView.h b/source/blender/freestyle/intern/application/AppView.h
index 3f6d0b8e93e..14101909ca1 100644
--- a/source/blender/freestyle/intern/application/AppView.h
+++ b/source/blender/freestyle/intern/application/AppView.h
@@ -31,6 +31,8 @@
#include "../scene_graph/NodeDrawingStyle.h"
#include "../system/Precision.h"
+#include "BLI_math.h"
+
#ifdef WITH_CXX_GUARDEDALLOC
#include "MEM_guardedalloc.h"
#endif
diff --git a/source/blender/freestyle/intern/application/Controller.cpp b/source/blender/freestyle/intern/application/Controller.cpp
index 81034c1502c..2bd31ea03a1 100644
--- a/source/blender/freestyle/intern/application/Controller.cpp
+++ b/source/blender/freestyle/intern/application/Controller.cpp
@@ -22,6 +22,10 @@
* \ingroup freestyle
*/
+extern "C" {
+#include <Python.h>
+}
+
#include <string>
#include <fstream>
#include <float.h>
@@ -62,6 +66,7 @@
#include "../blender_interface/BlenderStyleModule.h"
#include "BKE_global.h"
+#include "BLI_utildefines.h"
#include "DNA_freestyle_types.h"
@@ -190,14 +195,14 @@ void Controller::setRenderMonitor(RenderMonitor *iRenderMonitor)
void Controller::setPassDiffuse(float *buf, int width, int height)
{
AppCanvas *app_canvas = dynamic_cast<AppCanvas *>(_Canvas);
- assert(app_canvas != 0);
+ BLI_assert(app_canvas != 0);
app_canvas->setPassDiffuse(buf, width, height);
}
void Controller::setPassZ(float *buf, int width, int height)
{
AppCanvas *app_canvas = dynamic_cast<AppCanvas *>(_Canvas);
- assert(app_canvas != 0);
+ BLI_assert(app_canvas != 0);
app_canvas->setPassZ(buf, width, height);
}
@@ -850,6 +855,18 @@ Render *Controller::RenderStrokes(Render *re, bool render)
d = _Chrono.stop();
if (G.debug & G_DEBUG_FREESTYLE) {
cout << "Stroke rendering : " << d << endl;
+
+ uintptr_t mem_in_use = MEM_get_memory_in_use();
+ uintptr_t mmap_in_use = MEM_get_mapped_memory_in_use();
+ uintptr_t peak_memory = MEM_get_peak_memory();
+
+ float megs_used_memory = (mem_in_use - mmap_in_use) / (1024.0 * 1024.0);
+ float mmap_used_memory = (mmap_in_use) / (1024.0 * 1024.0);
+ float megs_peak_memory = (peak_memory) / (1024.0 * 1024.0);
+
+ printf("%d verts, %d faces, mem %.2fM (%.2fM, peak %.2fM)\n",
+ freestyle_render->i.totvert, freestyle_render->i.totface,
+ megs_used_memory, mmap_used_memory, megs_peak_memory);
}
delete blenderRenderer;
@@ -1024,7 +1041,6 @@ void Controller::init_options()
// Directories
ViewMapIO::Options::setModelsPath(cpath->getModelsPath());
- PythonInterpreter::Options::setPythonPath(cpath->getPythonPath());
TextureManager::Options::setPatternsPath(cpath->getPatternsPath());
TextureManager::Options::setBrushesPath(cpath->getModelsPath());
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
index 9adf6239305..a26bb0fa81e 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
+++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
@@ -761,7 +761,7 @@ void BlenderFileLoader::insertShapeNode(ObjectInstanceRen *obi, int id)
}
if (G.debug & G_DEBUG_FREESTYLE) {
printf("Warning: Object %s contains %lu degenerated triangle%s (strokes may be incorrect)\n",
- name, detriList.size(), (detriList.size() > 1) ? "s" : "");
+ name, (long unsigned int)detriList.size(), (detriList.size() > 1) ? "s" : "");
}
}
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h
index 17c0dd0c6db..d16a311991a 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h
+++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h
@@ -74,7 +74,7 @@ struct LoaderState {
float maxBBox[3];
};
-class LIB_SCENE_GRAPH_EXPORT BlenderFileLoader
+class BlenderFileLoader
{
public:
/*! Builds a MaxFileLoader */
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
index 760c5c93455..6fff2feec95 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
+++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
@@ -23,18 +23,14 @@
*/
#include "BlenderStrokeRenderer.h"
-#include "BlenderTextureManager.h"
#include "../application/AppConfig.h"
#include "../stroke/Canvas.h"
-#include "BKE_global.h"
-
extern "C" {
#include "MEM_guardedalloc.h"
#include "DNA_camera_types.h"
-#include "DNA_customdata_types.h"
#include "DNA_listBase.h"
#include "DNA_meshdata_types.h"
#include "DNA_mesh_types.h"
@@ -51,19 +47,19 @@ extern "C" {
#include "BKE_object.h"
#include "BKE_scene.h"
+#include "BLI_utildefines.h"
+
#include "RE_pipeline.h"
}
+#include <limits.h>
+
namespace Freestyle {
BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : StrokeRenderer()
{
freestyle_bmain = &re->freestyle_bmain;
- // TEMPORARY - need a texture manager
- _textureManager = new BlenderTextureManager;
- _textureManager->load();
-
// for stroke mesh generation
_width = re->winx;
_height = re->winy;
@@ -135,24 +131,12 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : Str
freestyle_scene->camera = object_camera;
- // Material
- material = BKE_material_add(freestyle_bmain, "stroke_material");
- material->mode |= MA_VERTEXCOLP;
- material->mode |= MA_TRANSP;
- material->mode |= MA_SHLESS;
- material->vcol_alpha = 1;
-
// Reset serial mesh ID (used for BlenderStrokeRenderer::NewMesh())
_mesh_id = 0xffffffff;
}
BlenderStrokeRenderer::~BlenderStrokeRenderer()
{
- if (0 != _textureManager) {
- delete _textureManager;
- _textureManager = NULL;
- }
-
// The freestyle_scene object is not released here. Instead,
// the scene is released in free_all_freestyle_renders() in
// source/blender/render/intern/source/pipeline.c, after the
@@ -184,8 +168,24 @@ BlenderStrokeRenderer::~BlenderStrokeRenderer()
}
BLI_freelistN(&freestyle_scene->base);
- // release material
- BKE_libblock_free(freestyle_bmain, material);
+ // release materials
+ Link *lnk = (Link *)freestyle_bmain->mat.first;
+
+ while (lnk)
+ {
+ Material *ma = (Material*)lnk;
+ // We want to retain the linestyle mtexs, so let's detach them first
+ for (int a = 0; a < MAX_MTEX; a++) {
+ if (ma->mtex[a]) {
+ ma->mtex[a] = NULL;
+ }
+ else {
+ break; // Textures are ordered, no empty slots between two textures
+ }
+ }
+ lnk = lnk->next;
+ BKE_libblock_free(freestyle_bmain, ma);
+ }
}
float BlenderStrokeRenderer::get_stroke_vertex_z(void) const
@@ -208,132 +208,225 @@ unsigned int BlenderStrokeRenderer::get_stroke_mesh_id(void) const
void BlenderStrokeRenderer::RenderStrokeRep(StrokeRep *iStrokeRep) const
{
+ bool has_mat = false;
+ int a = 0;
+
+ // Look for a good existing material
+ for (Link *lnk = (Link *)freestyle_bmain->mat.first; lnk; lnk = lnk->next) {
+ Material *ma = (Material*) lnk;
+ bool texs_are_good = true;
+ // as soon as textures differ it's not the right one
+ for (int a = 0; a < MAX_MTEX; a++) {
+ if (ma->mtex[a] != iStrokeRep->getMTex(a)) {
+ texs_are_good = false;
+ break;
+ }
+ }
+
+ if (texs_are_good) {
+ iStrokeRep->setMaterial(ma);
+ has_mat = true;
+ break; // if textures are good, no need to search anymore
+ }
+ }
+
+ // If still no material, create one
+ if (!has_mat) {
+ Material *ma = BKE_material_add(freestyle_bmain, "stroke_material");
+
+ ma->mode |= MA_VERTEXCOLP;
+ ma->mode |= MA_TRANSP;
+ ma->mode |= MA_SHLESS;
+ ma->vcol_alpha = 1;
+
+ // Textures
+ //for (int a = 0; a < MAX_MTEX; a++) {
+ while (iStrokeRep->getMTex(a)) {
+ ma->mtex[a] = (MTex *) iStrokeRep->getMTex(a);
+
+ // We'll generate both with tips and without tips
+ // coordinates, on two different UV layers.
+ if (ma->mtex[a]->texflag & MTEX_TIPS) {
+ BLI_strncpy(ma->mtex[a]->uvname, "along_stroke_tips", sizeof(ma->mtex[a]->uvname));
+ }
+ else {
+ BLI_strncpy(ma->mtex[a]->uvname, "along_stroke", sizeof(ma->mtex[a]->uvname));
+ }
+ a++;
+ }
+ iStrokeRep->setMaterial(ma);
+ }
+
RenderStrokeRepBasic(iStrokeRep);
}
-void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
+// Check if the triangle is visible (i.e., within the render image boundary)
+bool BlenderStrokeRenderer::test_triangle_visibility(StrokeVertexRep *svRep[3]) const
{
- ////////////////////
- // Build up scene
- ////////////////////
+ int xl, xu, yl, yu;
+ Vec2r p;
+
+ xl = xu = yl = yu = 0;
+ for (int i = 0; i < 3; i++) {
+ p = svRep[i]->point2d();
+ if (p[0] < 0.0)
+ xl++;
+ else if (p[0] > _width)
+ xu++;
+ if (p[1] < 0.0)
+ yl++;
+ else if (p[1] > _height)
+ yu++;
+ }
+ return !(xl == 3 || xu == 3 || yl == 3 || yu == 3);
+}
+
+// Check the visibility of faces and strip segments.
+void BlenderStrokeRenderer::test_strip_visibility(Strip::vertex_container& strip_vertices,
+ int *visible_faces, int *visible_segments) const
+{
+ const int strip_vertex_count = strip_vertices.size();
+ Strip::vertex_container::iterator v[3];
+ StrokeVertexRep *svRep[3];
+ bool visible;
+
+ // iterate over all vertices and count visible faces and strip segments
+ // (note: a strip segment is a series of visible faces, while two strip
+ // segments are separated by one or more invisible faces)
+ v[0] = strip_vertices.begin();
+ v[1] = v[0] + 1;
+ v[2] = v[0] + 2;
+ *visible_faces = *visible_segments = 0;
+ visible = false;
+ for (int n = 2; n < strip_vertex_count; n++, v[0]++, v[1]++, v[2]++) {
+ svRep[0] = *(v[0]);
+ svRep[1] = *(v[1]);
+ svRep[2] = *(v[2]);
+ if (test_triangle_visibility(svRep)) {
+ (*visible_faces)++;
+ if (!visible)
+ (*visible_segments)++;
+ visible = true;
+ }
+ else {
+ visible = false;
+ }
+ }
+}
+// Build a mesh object representing a stroke
+void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
+{
vector<Strip*>& strips = iStrokeRep->getStrips();
+ const bool hasTex = iStrokeRep->getMTex(0) != NULL;
Strip::vertex_container::iterator v[3];
StrokeVertexRep *svRep[3];
- /* Vec3r color[3]; */ /* UNUSED */
unsigned int vertex_index, edge_index, loop_index;
Vec2r p;
+ int totvert = 0, totedge = 0, totpoly = 0, totloop = 0;
+ int visible_faces, visible_segments;
+
+ bool visible;
for (vector<Strip*>::iterator s = strips.begin(), send = strips.end(); s != send; ++s) {
Strip::vertex_container& strip_vertices = (*s)->vertices();
- int strip_vertex_count = (*s)->sizeStrip();
- int xl, xu, yl, yu, n, visible_faces, visible_segments;
- bool visible;
- // iterate over all vertices and count visible faces and strip segments
- // (note: a strip segment is a series of visible faces, while two strip
- // segments are separated by one or more invisible faces)
- v[0] = strip_vertices.begin();
- v[1] = v[0] + 1;
- v[2] = v[0] + 2;
- visible_faces = visible_segments = 0;
- visible = false;
- for (n = 2; n < strip_vertex_count; n++, v[0]++, v[1]++, v[2]++) {
- svRep[0] = *(v[0]);
- svRep[1] = *(v[1]);
- svRep[2] = *(v[2]);
- xl = xu = yl = yu = 0;
- for (int j = 0; j < 3; j++) {
- p = svRep[j]->point2d();
- if (p[0] < 0.0)
- xl++;
- else if (p[0] > _width)
- xu++;
- if (p[1] < 0.0)
- yl++;
- else if (p[1] > _height)
- yu++;
- }
- if (xl == 3 || xu == 3 || yl == 3 || yu == 3) {
- visible = false;
- }
- else {
- visible_faces++;
- if (!visible)
- visible_segments++;
- visible = true;
- }
- }
+ // count visible faces and strip segments
+ test_strip_visibility(strip_vertices, &visible_faces, &visible_segments);
if (visible_faces == 0)
continue;
- //me = Mesh.New()
+ totvert += visible_faces + visible_segments * 2;
+ totedge += visible_faces * 2 + visible_segments;
+ totpoly += visible_faces;
+ totloop += visible_faces * 3;
+ }
+
#if 0
- Object *object_mesh = BKE_object_add(freestyle_bmain, freestyle_scene, OB_MESH);
+ Object *object_mesh = BKE_object_add(freestyle_bmain, freestyle_scene, OB_MESH);
#else
- Object *object_mesh = NewMesh();
+ Object *object_mesh = NewMesh();
#endif
- Mesh *mesh = (Mesh *)object_mesh->data;
- mesh->mat = (Material **)MEM_mallocN(1 * sizeof(Material *), "MaterialList");
- mesh->mat[0] = material;
- mesh->totcol = 1;
- test_object_materials(freestyle_bmain, (ID *)mesh);
+ Mesh *mesh = (Mesh *)object_mesh->data;
+ mesh->mat = (Material **)MEM_mallocN(1 * sizeof(Material *), "MaterialList");
+ mesh->mat[0] = iStrokeRep->getMaterial();
+ mesh->totcol = 1;
+ test_object_materials(freestyle_bmain, (ID *)mesh);
- // vertices allocation
- mesh->totvert = visible_faces + visible_segments * 2;
- mesh->mvert = (MVert *)CustomData_add_layer(&mesh->vdata, CD_MVERT, CD_CALLOC, NULL, mesh->totvert);
+ // vertices allocation
+ mesh->totvert = totvert; // visible_faces + visible_segments * 2;
+ mesh->mvert = (MVert *)CustomData_add_layer(&mesh->vdata, CD_MVERT, CD_CALLOC, NULL, mesh->totvert);
- // edges allocation
- mesh->totedge = visible_faces * 2 + visible_segments;
- mesh->medge = (MEdge *)CustomData_add_layer(&mesh->edata, CD_MEDGE, CD_CALLOC, NULL, mesh->totedge);
+ // edges allocation
+ mesh->totedge = totedge; // visible_faces * 2 + visible_segments;
+ mesh->medge = (MEdge *)CustomData_add_layer(&mesh->edata, CD_MEDGE, CD_CALLOC, NULL, mesh->totedge);
- // faces allocation
- mesh->totpoly = visible_faces;
- mesh->mpoly = (MPoly *)CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_CALLOC, NULL, mesh->totpoly);
+ // faces allocation
+ mesh->totpoly = totpoly; // visible_faces;
+ mesh->mpoly = (MPoly *)CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_CALLOC, NULL, mesh->totpoly);
- // loops allocation
- mesh->totloop = visible_faces * 3;
- mesh->mloop = (MLoop *)CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_CALLOC, NULL, mesh->totloop);
+ // loops allocation
+ mesh->totloop = totloop; // visible_faces * 3;
+ mesh->mloop = (MLoop *)CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_CALLOC, NULL, mesh->totloop);
- // colors allocation
- mesh->mloopcol = (MLoopCol *)CustomData_add_layer(&mesh->ldata, CD_MLOOPCOL, CD_CALLOC, NULL, mesh->totloop);
+ // colors allocation
+ mesh->mloopcol = (MLoopCol *)CustomData_add_layer(&mesh->ldata, CD_MLOOPCOL, CD_CALLOC, NULL, mesh->totloop);
- ////////////////////
- // Data copy
- ////////////////////
+ ////////////////////
+ // Data copy
+ ////////////////////
+
+ MVert *vertices = mesh->mvert;
+ MEdge *edges = mesh->medge;
+ MPoly *polys = mesh->mpoly;
+ MLoop *loops = mesh->mloop;
+ MLoopCol *colors = mesh->mloopcol;
+ MLoopUV *loopsuv[2] = {NULL};
+
+ if (hasTex) {
+ // First UV layer
+ CustomData_add_layer_named(&mesh->pdata, CD_MTEXPOLY, CD_CALLOC, NULL, mesh->totpoly, "along_stroke");
+ CustomData_add_layer_named(&mesh->ldata, CD_MLOOPUV, CD_CALLOC, NULL, mesh->totloop, "along_stroke");
+ CustomData_set_layer_active(&mesh->pdata, CD_MTEXPOLY, 0);
+ CustomData_set_layer_active(&mesh->ldata, CD_MLOOPUV, 0);
+ BKE_mesh_update_customdata_pointers(mesh, true);
+
+ loopsuv[0] = mesh->mloopuv;
+
+ // Second UV layer
+ CustomData_add_layer_named(&mesh->pdata, CD_MTEXPOLY, CD_CALLOC, NULL, mesh->totpoly, "along_stroke_tips");
+ CustomData_add_layer_named(&mesh->ldata, CD_MLOOPUV, CD_CALLOC, NULL, mesh->totloop, "along_stroke_tips");
+ CustomData_set_layer_active(&mesh->pdata, CD_MTEXPOLY, 1);
+ CustomData_set_layer_active(&mesh->ldata, CD_MLOOPUV, 1);
+ BKE_mesh_update_customdata_pointers(mesh, true);
+
+ loopsuv[1] = mesh->mloopuv;
+ }
+
+ vertex_index = edge_index = loop_index = 0;
+
+ for (vector<Strip*>::iterator s = strips.begin(), send = strips.end(); s != send; ++s) {
+ Strip::vertex_container& strip_vertices = (*s)->vertices();
+ int strip_vertex_count = strip_vertices.size();
- MVert *vertices = mesh->mvert;
- MEdge *edges = mesh->medge;
- MPoly *polys = mesh->mpoly;
- MLoop *loops = mesh->mloop;
- MLoopCol *colors = mesh->mloopcol;
+ // count visible faces and strip segments
+ test_strip_visibility(strip_vertices, &visible_faces, &visible_segments);
+ if (visible_faces == 0)
+ continue;
v[0] = strip_vertices.begin();
v[1] = v[0] + 1;
v[2] = v[0] + 2;
- vertex_index = edge_index = loop_index = 0;
visible = false;
// Note: Mesh generation in the following loop assumes stroke strips
// to be triangle strips.
- for (n = 2; n < strip_vertex_count; n++, v[0]++, v[1]++, v[2]++) {
+ for (int n = 2; n < strip_vertex_count; n++, v[0]++, v[1]++, v[2]++) {
svRep[0] = *(v[0]);
svRep[1] = *(v[1]);
svRep[2] = *(v[2]);
- xl = xu = yl = yu = 0;
- for (int j = 0; j < 3; j++) {
- p = svRep[j]->point2d();
- if (p[0] < 0.0)
- xl++;
- else if (p[0] > _width)
- xu++;
- if (p[1] < 0.0)
- yl++;
- else if (p[1] > _height)
- yu++;
- }
- if (xl == 3 || xu == 3 || yl == 3 || yu == 3) {
+ if (!test_triangle_visibility(svRep)) {
visible = false;
}
else {
@@ -342,6 +435,9 @@ void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
vertices->co[0] = svRep[0]->point2d()[0];
vertices->co[1] = svRep[0]->point2d()[1];
vertices->co[2] = get_stroke_vertex_z();
+ vertices->no[0] = 0;
+ vertices->no[1] = 0;
+ vertices->no[2] = SHRT_MAX;
++vertices;
++vertex_index;
@@ -349,6 +445,9 @@ void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
vertices->co[0] = svRep[1]->point2d()[0];
vertices->co[1] = svRep[1]->point2d()[1];
vertices->co[2] = get_stroke_vertex_z();
+ vertices->no[0] = 0;
+ vertices->no[1] = 0;
+ vertices->no[2] = SHRT_MAX;
++vertices;
++vertex_index;
@@ -364,6 +463,9 @@ void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
vertices->co[0] = svRep[2]->point2d()[0];
vertices->co[1] = svRep[2]->point2d()[1];
vertices->co[2] = get_stroke_vertex_z();
+ vertices->no[0] = 0;
+ vertices->no[1] = 0;
+ vertices->no[2] = SHRT_MAX;
++vertices;
++vertex_index;
@@ -383,48 +485,67 @@ void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
polys->totloop = 3;
++polys;
+ // Even and odd loops connect triangles vertices differently
+ bool is_odd = n % 2;
// loops
- if (n % 2 == 0) {
+ if (is_odd) {
loops[0].v = vertex_index - 1;
- loops[0].e = edge_index - 1;
+ loops[0].e = edge_index - 2;
- loops[1].v = vertex_index - 2;
+ loops[1].v = vertex_index - 3;
loops[1].e = edge_index - 3;
- loops[2].v = vertex_index - 3;
- loops[2].e = edge_index - 2;
+ loops[2].v = vertex_index - 2;
+ loops[2].e = edge_index - 1;
}
else {
loops[0].v = vertex_index - 1;
- loops[0].e = edge_index - 2;
+ loops[0].e = edge_index - 1;
- loops[1].v = vertex_index - 3;
+ loops[1].v = vertex_index - 2;
loops[1].e = edge_index - 3;
- loops[2].v = vertex_index - 2;
- loops[2].e = edge_index - 1;
+ loops[2].v = vertex_index - 3;
+ loops[2].e = edge_index - 2;
}
loops += 3;
loop_index += 3;
- // colors
- if (n % 2 == 0) {
- colors[0].r = (short)(255.0f * svRep[2]->color()[0]);
- colors[0].g = (short)(255.0f * svRep[2]->color()[1]);
- colors[0].b = (short)(255.0f * svRep[2]->color()[2]);
- colors[0].a = (short)(255.0f * svRep[2]->alpha());
-
- colors[1].r = (short)(255.0f * svRep[1]->color()[0]);
- colors[1].g = (short)(255.0f * svRep[1]->color()[1]);
- colors[1].b = (short)(255.0f * svRep[1]->color()[2]);
- colors[1].a = (short)(255.0f * svRep[1]->alpha());
-
- colors[2].r = (short)(255.0f * svRep[0]->color()[0]);
- colors[2].g = (short)(255.0f * svRep[0]->color()[1]);
- colors[2].b = (short)(255.0f * svRep[0]->color()[2]);
- colors[2].a = (short)(255.0f * svRep[0]->alpha());
+ // UV
+ if (hasTex) {
+ // First UV layer (loopsuv[0]) has no tips (texCoord(0)).
+ // Second UV layer (loopsuv[1]) has tips: (texCoord(1)).
+ for (int L = 0; L < 2; L++) {
+ if (is_odd) {
+ loopsuv[L][0].uv[0] = svRep[2]->texCoord(L).x();
+ loopsuv[L][0].uv[1] = svRep[2]->texCoord(L).y();
+
+ loopsuv[L][1].uv[0] = svRep[0]->texCoord(L).x();
+ loopsuv[L][1].uv[1] = svRep[0]->texCoord(L).y();
+
+ loopsuv[L][2].uv[0] = svRep[1]->texCoord(L).x();
+ loopsuv[L][2].uv[1] = svRep[1]->texCoord(L).y();
+ }
+ else {
+ loopsuv[L][0].uv[0] = svRep[2]->texCoord(L).x();
+ loopsuv[L][0].uv[1] = svRep[2]->texCoord(L).y();
+
+ loopsuv[L][1].uv[0] = svRep[1]->texCoord(L).x();
+ loopsuv[L][1].uv[1] = svRep[1]->texCoord(L).y();
+
+ loopsuv[L][2].uv[0] = svRep[0]->texCoord(L).x();
+ loopsuv[L][2].uv[1] = svRep[0]->texCoord(L).y();
+ }
+ /* freestyle tex-origin is upside-down */
+ for (int i = 0; i < 3; i++) {
+ loopsuv[L][i].uv[1] *= -1;
+ }
+ loopsuv[L] += 3;
+ }
}
- else {
+
+ // colors
+ if (is_odd) {
colors[0].r = (short)(255.0f * svRep[2]->color()[0]);
colors[0].g = (short)(255.0f * svRep[2]->color()[1]);
colors[0].b = (short)(255.0f * svRep[2]->color()[2]);
@@ -439,14 +560,33 @@ void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
colors[2].g = (short)(255.0f * svRep[1]->color()[1]);
colors[2].b = (short)(255.0f * svRep[1]->color()[2]);
colors[2].a = (short)(255.0f * svRep[1]->alpha());
+ }
+ else {
+ colors[0].r = (short)(255.0f * svRep[2]->color()[0]);
+ colors[0].g = (short)(255.0f * svRep[2]->color()[1]);
+ colors[0].b = (short)(255.0f * svRep[2]->color()[2]);
+ colors[0].a = (short)(255.0f * svRep[2]->alpha());
+
+ colors[1].r = (short)(255.0f * svRep[1]->color()[0]);
+ colors[1].g = (short)(255.0f * svRep[1]->color()[1]);
+ colors[1].b = (short)(255.0f * svRep[1]->color()[2]);
+ colors[1].a = (short)(255.0f * svRep[1]->alpha());
+
+ colors[2].r = (short)(255.0f * svRep[0]->color()[0]);
+ colors[2].g = (short)(255.0f * svRep[0]->color()[1]);
+ colors[2].b = (short)(255.0f * svRep[0]->color()[2]);
+ colors[2].a = (short)(255.0f * svRep[0]->alpha());
}
colors += 3;
}
} // loop over strip vertices
+ } // loop over strips
#if 0
- BKE_mesh_validate(mesh, true);
+ BLI_assert(totvert == vertex_index);
+ BLI_assert(totedge == edge_index);
+ BLI_assert(totloop == loop_index);
+ BKE_mesh_validate(mesh, true);
#endif
- } // loop over strips
}
// A replacement of BKE_object_add() for better performance.
@@ -457,11 +597,9 @@ Object *BlenderStrokeRenderer::NewMesh() const
char name[MAX_ID_NAME];
unsigned int mesh_id = get_stroke_mesh_id();
- /* XXX this is for later review, for now we start names with 27 (DEL)
- to allow ignoring them in DAG_ids_check_recalc() */
- BLI_snprintf(name, MAX_ID_NAME, "%c0%08xOB", 27, mesh_id);
+ BLI_snprintf(name, MAX_ID_NAME, "0%08xOB", mesh_id);
ob = BKE_object_add_only_object(freestyle_bmain, OB_MESH, name);
- BLI_snprintf(name, MAX_ID_NAME, "%c0%08xME", 27, mesh_id);
+ BLI_snprintf(name, MAX_ID_NAME, "0%08xME", mesh_id);
ob->data = BKE_mesh_add(freestyle_bmain, name);
ob->lay = 1;
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h
index 96ce8c1be7e..0025d48e77f 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h
+++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h
@@ -39,7 +39,7 @@ extern "C" {
namespace Freestyle {
-class LIB_STROKE_EXPORT BlenderStrokeRenderer : public StrokeRenderer
+class BlenderStrokeRenderer : public StrokeRenderer
{
public:
BlenderStrokeRenderer(Render *re, int render_count);
@@ -57,13 +57,15 @@ protected:
Main *freestyle_bmain;
Scene *old_scene;
Scene *freestyle_scene;
- Material *material;
float _width, _height;
float _z, _z_delta;
unsigned int _mesh_id;
float get_stroke_vertex_z(void) const;
unsigned int get_stroke_mesh_id(void) const;
+ bool test_triangle_visibility(StrokeVertexRep *svRep[3]) const;
+ void test_strip_visibility(Strip::vertex_container& strip_vertices,
+ int *visible_faces, int *visible_segments) const;
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:BlenderStrokeRenderer")
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h b/source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h
index 8a16a2b5c2a..a1fb9fade58 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h
+++ b/source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h
@@ -32,6 +32,7 @@ extern "C" {
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_text.h"
+#include "BLI_utildefines.h"
}
namespace Freestyle {
@@ -52,7 +53,7 @@ protected:
virtual int interpret()
{
PythonInterpreter *py_inter = dynamic_cast<PythonInterpreter*>(_inter);
- assert(py_inter != 0);
+ BLI_assert(py_inter != 0);
return py_inter->interpretText(_text, getFileName());
}
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderTextureManager.cpp b/source/blender/freestyle/intern/blender_interface/BlenderTextureManager.cpp
deleted file mode 100644
index e58a219aede..00000000000
--- a/source/blender/freestyle/intern/blender_interface/BlenderTextureManager.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/freestyle/intern/blender_interface/BlenderTextureManager.cpp
- * \ingroup freestyle
- */
-
-#include "BlenderTextureManager.h"
-
-#include "BKE_global.h"
-
-namespace Freestyle {
-
-BlenderTextureManager::BlenderTextureManager()
-: TextureManager()
-{
- //_brushes_path = Config::getInstance()...
-}
-
-BlenderTextureManager::~BlenderTextureManager()
-{
-}
-
-void BlenderTextureManager::loadStandardBrushes()
-{
-#if 0
- getBrushTextureIndex(TEXTURES_DIR "/brushes/charcoalAlpha.bmp", Stroke::HUMID_MEDIUM);
- getBrushTextureIndex(TEXTURES_DIR "/brushes/washbrushAlpha.bmp", Stroke::HUMID_MEDIUM);
- getBrushTextureIndex(TEXTURES_DIR "/brushes/oil.bmp", Stroke::HUMID_MEDIUM);
- getBrushTextureIndex(TEXTURES_DIR "/brushes/oilnoblend.bmp", Stroke::HUMID_MEDIUM);
- getBrushTextureIndex(TEXTURES_DIR "/brushes/charcoalAlpha.bmp", Stroke::DRY_MEDIUM);
- getBrushTextureIndex(TEXTURES_DIR "/brushes/washbrushAlpha.bmp", Stroke::DRY_MEDIUM);
- getBrushTextureIndex(TEXTURES_DIR "/brushes/opaqueDryBrushAlpha.bmp", Stroke::OPAQUE_MEDIUM);
- getBrushTextureIndex(TEXTURES_DIR "/brushes/opaqueBrushAlpha.bmp", Stroke::OPAQUE_MEDIUM);
- _defaultTextureId = getBrushTextureIndex("smoothAlpha.bmp", Stroke::OPAQUE_MEDIUM);
-#endif
-}
-
-unsigned int BlenderTextureManager::loadBrush(string sname, Stroke::MediumType mediumType)
-{
-#if 0
- GLuint texId;
- glGenTextures(1, &texId);
- bool found = false;
- vector<string> pathnames;
- string path; //soc
- StringUtils::getPathName(TextureManager::Options::getBrushesPath(), sname, pathnames);
- for (vector<string>::const_iterator j = pathnames.begin(); j != pathnames.end(); j++) {
- path = j->c_str();
- //soc if (QFile::exists(path)) {
- if (BLI_exists( const_cast<char *>(path.c_str()))) {
- found = true;
- break;
- }
- }
- if (!found)
- return 0;
- // Brush texture
- if (G.debug & G_DEBUG_FREESTYLE) {
- cout << "Loading brush texture..." << endl;
- }
- switch (mediumType) {
- case Stroke::DRY_MEDIUM:
- //soc prepareTextureLuminance((const char*)path.toAscii(), texId);
- prepareTextureLuminance(path, texId);
- break;
- case Stroke::HUMID_MEDIUM:
- case Stroke::OPAQUE_MEDIUM:
- default:
- //soc prepareTextureAlpha((const char*)path.toAscii(), texId);
- prepareTextureAlpha(path, texId);
- break;
- }
- if (G.debug & G_DEBUG_FREESTYLE) {
- cout << "Done." << endl << endl;
- }
-
- return texId;
-#else
- return 0;
-#endif
-}
-
-} /* namespace Freestyle */
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderTextureManager.h b/source/blender/freestyle/intern/blender_interface/BlenderTextureManager.h
deleted file mode 100644
index b6cb303942a..00000000000
--- a/source/blender/freestyle/intern/blender_interface/BlenderTextureManager.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#ifndef __BLENDERTEXTUREMANAGER_H__
-#define __BLENDERTEXTUREMANAGER_H__
-
-/** \file blender/freestyle/intern/blender_interface/BlenderTextureManager.h
- * \ingroup freestyle
- */
-
-# include "../stroke/StrokeRenderer.h"
-# include "../stroke/StrokeRep.h"
-# include "../system/FreestyleConfig.h"
-
-namespace Freestyle {
-
-/*! Class to load textures */
-class LIB_RENDERING_EXPORT BlenderTextureManager : public TextureManager
-{
-public:
- BlenderTextureManager();
- virtual ~BlenderTextureManager();
-
-protected:
- virtual unsigned int loadBrush(string fileName, Stroke::MediumType=Stroke::OPAQUE_MEDIUM);
-
-protected:
- virtual void loadStandardBrushes();
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:BlenderTextureManager")
-#endif
-
-};
-
-} /* namespace Freestyle */
-
-#endif // __BLENDERTEXTUREMANAGER_H__
diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
index b592c1152b1..49c3fdce251 100644
--- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
+++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
@@ -711,15 +711,7 @@ void FRS_delete_active_lineset(FreestyleConfig *config)
FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(config);
if (lineset) {
- if (lineset->group) {
- lineset->group->id.us--;
- }
- if (lineset->linestyle) {
- lineset->linestyle->id.us--;
- }
- BLI_remlink(&config->linesets, lineset);
- MEM_freeN(lineset);
- BKE_freestyle_lineset_set_active_index(config, 0);
+ BKE_freestyle_lineset_delete(config, lineset);
}
}
diff --git a/source/blender/freestyle/intern/geometry/Bezier.h b/source/blender/freestyle/intern/geometry/Bezier.h
index 34af31d0ba8..ed26803c2a2 100644
--- a/source/blender/freestyle/intern/geometry/Bezier.h
+++ b/source/blender/freestyle/intern/geometry/Bezier.h
@@ -42,7 +42,7 @@ namespace Freestyle {
using namespace Geometry;
-class LIB_GEOMETRY_EXPORT BezierCurveSegment
+class BezierCurveSegment
{
private:
std::vector<Vec2d> _ControlPolygon;
@@ -70,7 +70,7 @@ public:
#endif
};
-class LIB_GEOMETRY_EXPORT BezierCurve
+class BezierCurve
{
private:
std::vector<Vec2d> _ControlPolygon;
diff --git a/source/blender/freestyle/intern/geometry/FastGrid.cpp b/source/blender/freestyle/intern/geometry/FastGrid.cpp
index 438cac3c209..2ce424483ea 100644
--- a/source/blender/freestyle/intern/geometry/FastGrid.cpp
+++ b/source/blender/freestyle/intern/geometry/FastGrid.cpp
@@ -25,9 +25,12 @@
* \date 30/07/2002
*/
+#include <cstdlib>
+
#include "FastGrid.h"
#include "BKE_global.h"
+#include "BLI_utildefines.h"
namespace Freestyle {
@@ -63,21 +66,21 @@ Cell *FastGrid::getCell(const Vec3u& p)
<< " " << _cells_size << endl;
}
#endif
- assert(_cells || ("_cells is a null pointer"));
- assert((_cells_nb[0] * (p[2] * _cells_nb[1] + p[1]) + p[0]) < _cells_size);
- assert(p[0] < _cells_nb[0]);
- assert(p[1] < _cells_nb[1]);
- assert(p[2] < _cells_nb[2]);
+ BLI_assert(_cells || ("_cells is a null pointer"));
+ BLI_assert((_cells_nb[0] * (p[2] * _cells_nb[1] + p[1]) + p[0]) < _cells_size);
+ BLI_assert(p[0] < _cells_nb[0]);
+ BLI_assert(p[1] < _cells_nb[1]);
+ BLI_assert(p[2] < _cells_nb[2]);
return _cells[_cells_nb[0] * (p[2] * _cells_nb[1] + p[1]) + p[0]];
}
void FastGrid::fillCell(const Vec3u& p, Cell& cell)
{
- assert(_cells || ("_cells is a null pointer"));
- assert((_cells_nb[0] * (p[2] * _cells_nb[1] + p[1]) + p[0]) < _cells_size);
- assert(p[0] < _cells_nb[0]);
- assert(p[1] < _cells_nb[1]);
- assert(p[2] < _cells_nb[2]);
+ BLI_assert(_cells || ("_cells is a null pointer"));
+ BLI_assert((_cells_nb[0] * (p[2] * _cells_nb[1] + p[1]) + p[0]) < _cells_size);
+ BLI_assert(p[0] < _cells_nb[0]);
+ BLI_assert(p[1] < _cells_nb[1]);
+ BLI_assert(p[2] < _cells_nb[2]);
_cells[_cells_nb[0] * (p[2] * _cells_nb[1] + p[1]) + p[0]] = &cell;
}
diff --git a/source/blender/freestyle/intern/geometry/FastGrid.h b/source/blender/freestyle/intern/geometry/FastGrid.h
index e292589b7cf..355a6e53399 100644
--- a/source/blender/freestyle/intern/geometry/FastGrid.h
+++ b/source/blender/freestyle/intern/geometry/FastGrid.h
@@ -28,8 +28,6 @@
* \date 30/07/2002
*/
-#include <cassert>
-
#include "Grid.h"
namespace Freestyle {
@@ -38,7 +36,7 @@ namespace Freestyle {
* We don't use a hashtable here. The grid is explicitly stored for faster computations.
* However, this might result in significant increase in memory usage (compared to the regular grid)
*/
-class LIB_GEOMETRY_EXPORT FastGrid : public Grid
+class FastGrid : public Grid
{
public:
FastGrid() : Grid()
diff --git a/source/blender/freestyle/intern/geometry/FitCurve.h b/source/blender/freestyle/intern/geometry/FitCurve.h
index 809ef875c0a..2268f6be1b7 100644
--- a/source/blender/freestyle/intern/geometry/FitCurve.h
+++ b/source/blender/freestyle/intern/geometry/FitCurve.h
@@ -74,7 +74,7 @@ typedef struct Point2Struct
typedef Point2 Vector2;
-class LIB_GEOMETRY_EXPORT FitCurveWrapper
+class FitCurveWrapper
{
private:
std::vector<Vector2> _vertices;
diff --git a/source/blender/freestyle/intern/geometry/GeomCleaner.h b/source/blender/freestyle/intern/geometry/GeomCleaner.h
index 0b97614f6ea..d516c5623b9 100644
--- a/source/blender/freestyle/intern/geometry/GeomCleaner.h
+++ b/source/blender/freestyle/intern/geometry/GeomCleaner.h
@@ -40,7 +40,7 @@ namespace Freestyle {
using namespace Geometry;
-class LIB_GEOMETRY_EXPORT GeomCleaner
+class GeomCleaner
{
public:
inline GeomCleaner() {}
diff --git a/source/blender/freestyle/intern/geometry/GeomUtils.h b/source/blender/freestyle/intern/geometry/GeomUtils.h
index dbb7a5d4e75..64aa6379e80 100644
--- a/source/blender/freestyle/intern/geometry/GeomUtils.h
+++ b/source/blender/freestyle/intern/geometry/GeomUtils.h
@@ -83,17 +83,14 @@ typedef enum {
COINCIDENT,
} intersection_test;
-LIB_GEOMETRY_EXPORT
intersection_test intersect2dSeg2dSeg(const Vec2r& p1, const Vec2r& p2, // first segment
const Vec2r& p3, const Vec2r& p4, // second segment
Vec2r& res); // found intersection point
-LIB_GEOMETRY_EXPORT
intersection_test intersect2dLine2dLine(const Vec2r& p1, const Vec2r& p2, // first segment
const Vec2r& p3, const Vec2r& p4, // second segment
Vec2r& res); // found intersection point
-LIB_GEOMETRY_EXPORT
intersection_test intersect2dSeg2dSegParametric(const Vec2r& p1, const Vec2r& p2, // first segment
const Vec2r& p3, const Vec2r& p4, // second segment
real& t, // I = P1 + t * P1P2)
@@ -101,26 +98,21 @@ intersection_test intersect2dSeg2dSegParametric(const Vec2r& p1, const Vec2r& p2
real epsilon = M_EPSILON);
/*! check whether a 2D segment intersect a 2D region or not */
-LIB_GEOMETRY_EXPORT
bool intersect2dSeg2dArea(const Vec2r& min, const Vec2r& max, const Vec2r& A, const Vec2r& B);
/*! check whether a 2D segment is included in a 2D region or not */
-LIB_GEOMETRY_EXPORT
bool include2dSeg2dArea(const Vec2r& min, const Vec2r& max, const Vec2r& A, const Vec2r& B);
/*! Box-triangle overlap test, adapted from Tomas Akenine-Möller code */
-LIB_GEOMETRY_EXPORT
bool overlapTriangleBox(Vec3r& boxcenter, Vec3r& boxhalfsize, Vec3r triverts[3]);
/*! Fast, Minimum Storage Ray-Triangle Intersection, adapted from Tomas Möller and Ben Trumbore code. */
-LIB_GEOMETRY_EXPORT
bool intersectRayTriangle(const Vec3r& orig, const Vec3r& dir, const Vec3r& v0, const Vec3r& v1, const Vec3r& v2,
real& t, // I = orig + t * dir
real& u, real& v, // I = (1 - u - v) * v0 + u * v1 + v * v2
const real epsilon = M_EPSILON); // the epsilon to use
/*! Intersection between plane and ray adapted from Graphics Gems, Didier Badouel */
-LIB_GEOMETRY_EXPORT
intersection_test intersectRayPlane(const Vec3r& orig, const Vec3r& dir, // ray origin and direction
// plane's normal and offset (plane = { P / P.N + d = 0 })
const Vec3r& norm, const real d,
@@ -130,7 +122,6 @@ intersection_test intersectRayPlane(const Vec3r& orig, const Vec3r& dir, // ray
/*! Intersection Ray-Bounding box (axis aligned).
* Adapted from Williams et al, "An Efficient Robust Ray-Box Intersection Algorithm", JGT 10:1 (2005), pp. 49-54.
*/
-LIB_GEOMETRY_EXPORT
bool intersectRayBBox(const Vec3r& orig, const Vec3r& dir, // ray origin and direction
const Vec3r& boxMin, const Vec3r& boxMax, // the bbox
// the interval in which at least on of the intersections must happen
@@ -140,16 +131,12 @@ bool intersectRayBBox(const Vec3r& orig, const Vec3r& dir, // ray origin an
real epsilon = M_EPSILON); // the epsilon to use
/*! Checks whether 3D point P lies inside or outside of the triangle ABC */
-LIB_GEOMETRY_EXPORT
bool includePointTriangle(const Vec3r& P, const Vec3r& A, const Vec3r& B, const Vec3r& C);
-LIB_GEOMETRY_EXPORT
void transformVertex(const Vec3r& vert, const Matrix44r& matrix, Vec3r& res);
-LIB_GEOMETRY_EXPORT
void transformVertices(const vector<Vec3r>& vertices, const Matrix44r& trans, vector<Vec3r>& res);
-LIB_GEOMETRY_EXPORT
Vec3r rotateVector(const Matrix44r& mat, const Vec3r& v);
//
@@ -171,7 +158,6 @@ Vec3r rotateVector(const Matrix44r& mat, const Vec3r& v);
* viewport
* The viewport: x,y coordinates followed by width and height (OpenGL like viewport)
*/
-LIB_GEOMETRY_EXPORT
void fromWorldToImage(const Vec3r& p, Vec3r& q, const real model_view_matrix[4][4], const real projection_matrix[4][4],
const int viewport[4]);
@@ -186,7 +172,6 @@ void fromWorldToImage(const Vec3r& p, Vec3r& q, const real model_view_matrix[4][
* viewport
* The viewport: x,y coordinates followed by width and height (OpenGL like viewport)
*/
-LIB_GEOMETRY_EXPORT
void fromWorldToImage(const Vec3r& p, Vec3r& q, const real transform[4][4], const int viewport[4]);
/*! Projects from world coordinates to camera coordinates
@@ -200,7 +185,6 @@ void fromWorldToImage(const Vec3r& p, Vec3r& q, const real transform[4][4], cons
* The model view matrix expressed in line major order (OpenGL
* matrices are column major ordered)
*/
-LIB_GEOMETRY_EXPORT
void fromWorldToCamera(const Vec3r& p, Vec3r& q, const real model_view_matrix[4][4]);
/*! Projects from World Coordinates to retina coordinates
@@ -213,7 +197,6 @@ void fromWorldToCamera(const Vec3r& p, Vec3r& q, const real model_view_matrix[4]
* The projection matrix expressed in line major order (OpenGL
* matrices are column major ordered)
*/
-LIB_GEOMETRY_EXPORT
void fromCameraToRetina(const Vec3r& p, Vec3r& q, const real projection_matrix[4][4]);
/*! From retina to image.
@@ -225,7 +208,6 @@ void fromCameraToRetina(const Vec3r& p, Vec3r& q, const real projection_matrix[4
* viewport
* The viewport: x,y coordinates followed by width and height (OpenGL like viewport).
*/
-LIB_GEOMETRY_EXPORT
void fromRetinaToImage(const Vec3r& p, Vec3r& q, const int viewport[4]);
/*! From image to retina
@@ -236,7 +218,6 @@ void fromRetinaToImage(const Vec3r& p, Vec3r& q, const int viewport[4]);
* viewport
* The viewport: x,y coordinates followed by width and height (OpenGL like viewport).
*/
-LIB_GEOMETRY_EXPORT
void fromImageToRetina(const Vec3r& p, Vec3r& q, const int viewport[4]);
/*! computes the coordinates of q in the camera coordinates system,
@@ -251,7 +232,6 @@ void fromImageToRetina(const Vec3r& p, Vec3r& q, const int viewport[4]);
* The projection matrix expressed in line major order (OpenGL
* matrices are column major ordered)
*/
-LIB_GEOMETRY_EXPORT
void fromRetinaToCamera(const Vec3r& p, Vec3r& q, real z, const real projection_matrix[4][4]);
/*! Projects from camera coordinates to world coordinates
@@ -265,7 +245,6 @@ void fromRetinaToCamera(const Vec3r& p, Vec3r& q, real z, const real projection_
* The model view matrix expressed in line major order (OpenGL
* matrices are column major ordered)
*/
-LIB_GEOMETRY_EXPORT
void fromCameraToWorld(const Vec3r& p, Vec3r& q, const real model_view_matrix[4][4]);
} // end of namespace GeomUtils
diff --git a/source/blender/freestyle/intern/geometry/Grid.cpp b/source/blender/freestyle/intern/geometry/Grid.cpp
index 49e115b4333..371c63318de 100644
--- a/source/blender/freestyle/intern/geometry/Grid.cpp
+++ b/source/blender/freestyle/intern/geometry/Grid.cpp
@@ -25,12 +25,13 @@
* \date 30/07/2002
*/
-#include <cassert>
#include <stdexcept>
#include "BBox.h"
#include "Grid.h"
+#include "BLI_utildefines.h"
+
namespace Freestyle {
// Grid Visitors
@@ -366,7 +367,7 @@ bool Grid::initInfiniteRay (const Vec3r &orig, const Vec3r& dir, unsigned timest
// is the ray intersecting the box?
real tmin(-1.0), tmax(-1.0);
if (GeomUtils::intersectRayBBox(orig, _ray_dir, boxMin, boxMax, 0, _t_end, tmin, tmax)) {
- assert(tmin != -1.0);
+ BLI_assert(tmin != -1.0);
Vec3r newOrig = orig + tmin * _ray_dir;
for (unsigned int i = 0; i < 3; i++) {
_current_cell[i] = (unsigned)floor((newOrig[i] - _orig[i]) / _cell_size[i]);
diff --git a/source/blender/freestyle/intern/geometry/Grid.h b/source/blender/freestyle/intern/geometry/Grid.h
index 25988b3b0f8..c0cab2a05db 100644
--- a/source/blender/freestyle/intern/geometry/Grid.h
+++ b/source/blender/freestyle/intern/geometry/Grid.h
@@ -62,7 +62,7 @@ typedef vector<Polygon3r*> OccludersSet;
//
///////////////////////////////////////////////////////////////////////////////
-class LIB_GEOMETRY_EXPORT Cell
+class Cell
{
public:
Cell(Vec3r& orig) {
@@ -175,7 +175,7 @@ public:
//
///////////////////////////////////////////////////////////////////////////////
-class LIB_GEOMETRY_EXPORT Grid
+class Grid
{
public:
/*! Builds a Grid. Must be followed by a call to configure() */
diff --git a/source/blender/freestyle/intern/geometry/GridHelpers.cpp b/source/blender/freestyle/intern/geometry/GridHelpers.cpp
index 2b809608edf..a0543e56a36 100644
--- a/source/blender/freestyle/intern/geometry/GridHelpers.cpp
+++ b/source/blender/freestyle/intern/geometry/GridHelpers.cpp
@@ -25,8 +25,6 @@
* \date 2010-12-21
*/
-#include <math.h>
-
#include "GridHelpers.h"
namespace Freestyle {
diff --git a/source/blender/freestyle/intern/geometry/HashGrid.h b/source/blender/freestyle/intern/geometry/HashGrid.h
index 7013a969eb5..4ea7c7146a4 100644
--- a/source/blender/freestyle/intern/geometry/HashGrid.h
+++ b/source/blender/freestyle/intern/geometry/HashGrid.h
@@ -60,7 +60,7 @@ struct GridHasher
};
/*! Class to define a regular grid used for ray casting computations */
-class LIB_GEOMETRY_EXPORT HashGrid : public Grid
+class HashGrid : public Grid
{
public:
typedef map<Vec3u, Cell*> GridHashTable;
diff --git a/source/blender/freestyle/intern/geometry/Noise.h b/source/blender/freestyle/intern/geometry/Noise.h
index 8798bc45a93..88994fac0d1 100644
--- a/source/blender/freestyle/intern/geometry/Noise.h
+++ b/source/blender/freestyle/intern/geometry/Noise.h
@@ -45,7 +45,7 @@ namespace Freestyle {
using namespace Geometry;
/*! Class to provide Perlin Noise functionalities */
-class LIB_GEOMETRY_EXPORT Noise
+class Noise
{
public:
/*! Builds a Noise object */
diff --git a/source/blender/freestyle/intern/geometry/matrix_util.cpp b/source/blender/freestyle/intern/geometry/matrix_util.cpp
index 7905dda5843..5e585497516 100644
--- a/source/blender/freestyle/intern/geometry/matrix_util.cpp
+++ b/source/blender/freestyle/intern/geometry/matrix_util.cpp
@@ -36,10 +36,10 @@
* \author Bruno Levy
*/
-#include <math.h>
-
#include "matrix_util.h"
+#include "BLI_math.h"
+
namespace Freestyle {
namespace OGF {
diff --git a/source/blender/freestyle/intern/geometry/matrix_util.h b/source/blender/freestyle/intern/geometry/matrix_util.h
index 162e2f85d3c..d65b0ea803b 100644
--- a/source/blender/freestyle/intern/geometry/matrix_util.h
+++ b/source/blender/freestyle/intern/geometry/matrix_util.h
@@ -61,7 +61,6 @@ namespace MatrixUtil {
* @param eigen_values (return) are in decreasing order
* size = n, must be allocated by caller
*/
- LIB_GEOMETRY_EXPORT
void semi_definite_symmetric_eigen(const double *mat, int n, double *eigen_vec, double *eigen_val);
} // MatrixUtil namespace
diff --git a/source/blender/freestyle/intern/geometry/normal_cycle.h b/source/blender/freestyle/intern/geometry/normal_cycle.h
index 7a63acdf52a..53bc23c6eb3 100644
--- a/source/blender/freestyle/intern/geometry/normal_cycle.h
+++ b/source/blender/freestyle/intern/geometry/normal_cycle.h
@@ -70,7 +70,7 @@ template <class T> inline void ogf_swap(T& x, T& y)
* D. Cohen-Steiner and J.M. Morvan,
* SOCG 2003
*/
-class LIB_GEOMETRY_EXPORT NormalCycle {
+class NormalCycle {
public:
NormalCycle();
void begin();
diff --git a/source/blender/freestyle/intern/image/GaussianFilter.h b/source/blender/freestyle/intern/image/GaussianFilter.h
index d3175e86382..7abd1bc18bc 100644
--- a/source/blender/freestyle/intern/image/GaussianFilter.h
+++ b/source/blender/freestyle/intern/image/GaussianFilter.h
@@ -43,7 +43,7 @@ extern "C" {
namespace Freestyle {
-class LIB_IMAGE_EXPORT GaussianFilter
+class GaussianFilter
{
protected:
/* The mask is a symetrical 2d array (with respect to the middle point).
diff --git a/source/blender/freestyle/intern/image/ImagePyramid.h b/source/blender/freestyle/intern/image/ImagePyramid.h
index 5ce937ed9f8..9a24ac6e1c8 100644
--- a/source/blender/freestyle/intern/image/ImagePyramid.h
+++ b/source/blender/freestyle/intern/image/ImagePyramid.h
@@ -40,7 +40,7 @@ namespace Freestyle {
class GrayImage;
-class LIB_IMAGE_EXPORT ImagePyramid
+class ImagePyramid
{
protected:
std::vector<GrayImage*> _levels;
@@ -88,7 +88,7 @@ public:
#endif
};
-class LIB_IMAGE_EXPORT GaussianPyramid : public ImagePyramid
+class GaussianPyramid : public ImagePyramid
{
protected:
float _sigma;
diff --git a/source/blender/freestyle/intern/python/BPy_BBox.h b/source/blender/freestyle/intern/python/BPy_BBox.h
index 6f8a3d21c50..089c2167c69 100644
--- a/source/blender/freestyle/intern/python/BPy_BBox.h
+++ b/source/blender/freestyle/intern/python/BPy_BBox.h
@@ -25,7 +25,9 @@
#ifndef __FREESTYLE_PYTHON_BBOX_H__
#define __FREESTYLE_PYTHON_BBOX_H__
+extern "C" {
#include <Python.h>
+}
#include "../geometry/BBox.h"
#include "../geometry/Geom.h"
diff --git a/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.h b/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.h
index 9622ca1eb98..a9a22970e4b 100644
--- a/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.h
+++ b/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.h
@@ -25,7 +25,9 @@
#ifndef __FREESTYLE_PYTHON_BINARYPREDICATE0D_H__
#define __FREESTYLE_PYTHON_BINARYPREDICATE0D_H__
+extern "C" {
#include <Python.h>
+}
#include "../stroke/Predicates0D.h"
diff --git a/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.h b/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.h
index 07a3d2986ce..43511edc09c 100644
--- a/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.h
+++ b/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.h
@@ -25,7 +25,9 @@
#ifndef __FREESTYLE_PYTHON_BINARYPREDICATE1D_H__
#define __FREESTYLE_PYTHON_BINARYPREDICATE1D_H__
+extern "C" {
#include <Python.h>
+}
#include "../stroke/Predicates1D.h"
diff --git a/source/blender/freestyle/intern/python/BPy_ContextFunctions.h b/source/blender/freestyle/intern/python/BPy_ContextFunctions.h
index 16e63be02f4..40652777c44 100644
--- a/source/blender/freestyle/intern/python/BPy_ContextFunctions.h
+++ b/source/blender/freestyle/intern/python/BPy_ContextFunctions.h
@@ -25,7 +25,9 @@
#ifndef __FREESTYLE_PYTHON_CONTEXTFUNCTIONS_H__
#define __FREESTYLE_PYTHON_CONTEXTFUNCTIONS_H__
+extern "C" {
#include <Python.h>
+}
#ifdef __cplusplus
extern "C" {
diff --git a/source/blender/freestyle/intern/python/BPy_Convert.h b/source/blender/freestyle/intern/python/BPy_Convert.h
index 45fc05a0921..cf55ba335cd 100644
--- a/source/blender/freestyle/intern/python/BPy_Convert.h
+++ b/source/blender/freestyle/intern/python/BPy_Convert.h
@@ -25,7 +25,10 @@
#ifndef __FREESTYLE_PYTHON_CONVERT_H__
#define __FREESTYLE_PYTHON_CONVERT_H__
+extern "C" {
#include <Python.h>
+}
+
#include <typeinfo>
#include "../geometry/Geom.h"
diff --git a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp
index dee058e6844..f390e937aac 100644
--- a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp
@@ -301,6 +301,7 @@ static char module_docstring[] =
"\n"
" - :class:`BackboneStretcherShader`\n"
" - :class:`BezierCurveShader`\n"
+" - :class:`BlenderTextureShader`\n"
" - :class:`CalligraphicShader`\n"
" - :class:`ColorNoiseShader`\n"
" - :class:`ColorVariationPatternShader`\n"
@@ -315,6 +316,7 @@ static char module_docstring[] =
" - :class:`SmoothingShader`\n"
" - :class:`SpatialNoiseShader`\n"
" - :class:`StrokeTextureShader`\n"
+" - :class:`StrokeTextureStepShader`\n"
" - :class:`TextureAssignerShader`\n"
" - :class:`ThicknessNoiseShader`\n"
" - :class:`ThicknessVariationPatternShader`\n"
@@ -485,6 +487,23 @@ PyObject *Freestyle_Init(void)
if (!module)
return NULL;
PyDict_SetItemString(PySys_GetObject("modules"), module_definition.m_name, module);
+
+ // update 'sys.path' for Freestyle Python API modules
+ const char * const path = BLI_get_folder(BLENDER_SYSTEM_SCRIPTS, "freestyle");
+ if (path) {
+ char modpath[FILE_MAX];
+ BLI_join_dirfile(modpath, sizeof(modpath), path, "modules");
+ PyObject *sys_path = PySys_GetObject("path"); /* borrow */
+ PyObject *py_modpath = PyUnicode_FromString(modpath);
+ PyList_Append(sys_path, py_modpath);
+ Py_DECREF(py_modpath);
+#if 0
+ printf("Adding Python path: %s\n", modpath);
+#endif
+ }
+ else {
+ printf("Freestyle: couldn't find 'scripts/freestyle/modules', Freestyle won't work properly.\n");
+ }
// attach its classes (adding the object types to the module)
diff --git a/source/blender/freestyle/intern/python/BPy_Freestyle.h b/source/blender/freestyle/intern/python/BPy_Freestyle.h
index c253a8181dd..0ed2e00d183 100644
--- a/source/blender/freestyle/intern/python/BPy_Freestyle.h
+++ b/source/blender/freestyle/intern/python/BPy_Freestyle.h
@@ -25,12 +25,12 @@
#ifndef __FREESTYLE_PYTHON_FREESTYLE_H__
#define __FREESTYLE_PYTHON_FREESTYLE_H__
-#include <Python.h>
-
#ifdef __cplusplus
extern "C" {
#endif
+#include <Python.h>
+
///////////////////////////////////////////////////////////////////////////////////////////
/*---------------------------Python BPy_Freestyle visible prototypes-----------*/
diff --git a/source/blender/freestyle/intern/python/BPy_FrsMaterial.h b/source/blender/freestyle/intern/python/BPy_FrsMaterial.h
index 62a9f2c9a78..7cbf5351745 100644
--- a/source/blender/freestyle/intern/python/BPy_FrsMaterial.h
+++ b/source/blender/freestyle/intern/python/BPy_FrsMaterial.h
@@ -25,7 +25,9 @@
#ifndef __FREESTYLE_PYTHON_FRSMATERIAL_H__
#define __FREESTYLE_PYTHON_FRSMATERIAL_H__
+extern "C" {
#include <Python.h>
+}
#include "../scene_graph/FrsMaterial.h"
diff --git a/source/blender/freestyle/intern/python/BPy_FrsNoise.h b/source/blender/freestyle/intern/python/BPy_FrsNoise.h
index 14d8696d0cb..19788e30a43 100644
--- a/source/blender/freestyle/intern/python/BPy_FrsNoise.h
+++ b/source/blender/freestyle/intern/python/BPy_FrsNoise.h
@@ -25,7 +25,9 @@
#ifndef __FREESTYLE_PYTHON_FRSNOISE_H__
#define __FREESTYLE_PYTHON_FRSNOISE_H__
+extern "C" {
#include <Python.h>
+}
#include "../geometry/Noise.h"
diff --git a/source/blender/freestyle/intern/python/BPy_Id.h b/source/blender/freestyle/intern/python/BPy_Id.h
index d4b635a4ea5..62e480628e3 100644
--- a/source/blender/freestyle/intern/python/BPy_Id.h
+++ b/source/blender/freestyle/intern/python/BPy_Id.h
@@ -25,7 +25,10 @@
#ifndef __FREESTYLE_PYTHON_ID_H__
#define __FREESTYLE_PYTHON_ID_H__
+extern "C" {
#include <Python.h>
+}
+
#include <iostream>
using namespace std;
diff --git a/source/blender/freestyle/intern/python/BPy_IntegrationType.h b/source/blender/freestyle/intern/python/BPy_IntegrationType.h
index 36b925f1ee7..feabe307d56 100644
--- a/source/blender/freestyle/intern/python/BPy_IntegrationType.h
+++ b/source/blender/freestyle/intern/python/BPy_IntegrationType.h
@@ -25,7 +25,9 @@
#ifndef __FREESTYLE_PYTHON_INTEGRATIONTYPE_H__
#define __FREESTYLE_PYTHON_INTEGRATIONTYPE_H__
+extern "C" {
#include <Python.h>
+}
#include "../view_map/Interface1D.h"
diff --git a/source/blender/freestyle/intern/python/BPy_Interface0D.h b/source/blender/freestyle/intern/python/BPy_Interface0D.h
index 02929bcdbc7..b8a4a6b21bd 100644
--- a/source/blender/freestyle/intern/python/BPy_Interface0D.h
+++ b/source/blender/freestyle/intern/python/BPy_Interface0D.h
@@ -25,7 +25,9 @@
#ifndef __FREESTYLE_PYTHON_INTERFACE0D_H__
#define __FREESTYLE_PYTHON_INTERFACE0D_H__
+extern "C" {
#include <Python.h>
+}
#include "../view_map/Interface0D.h"
diff --git a/source/blender/freestyle/intern/python/BPy_Interface1D.h b/source/blender/freestyle/intern/python/BPy_Interface1D.h
index 9bc447725e9..17c0752b2e8 100644
--- a/source/blender/freestyle/intern/python/BPy_Interface1D.h
+++ b/source/blender/freestyle/intern/python/BPy_Interface1D.h
@@ -25,7 +25,9 @@
#ifndef __FREESTYLE_PYTHON_INTERFACE1D_H__
#define __FREESTYLE_PYTHON_INTERFACE1D_H__
+extern "C" {
#include <Python.h>
+}
#include "../view_map/Interface1D.h"
diff --git a/source/blender/freestyle/intern/python/BPy_Iterator.h b/source/blender/freestyle/intern/python/BPy_Iterator.h
index a739787aa85..dcb8191948e 100644
--- a/source/blender/freestyle/intern/python/BPy_Iterator.h
+++ b/source/blender/freestyle/intern/python/BPy_Iterator.h
@@ -25,7 +25,9 @@
#ifndef __FREESTYLE_PYTHON_ITERATOR_H__
#define __FREESTYLE_PYTHON_ITERATOR_H__
+extern "C" {
#include <Python.h>
+}
#include "../system/Iterator.h"
diff --git a/source/blender/freestyle/intern/python/BPy_MediumType.h b/source/blender/freestyle/intern/python/BPy_MediumType.h
index 120829e0b40..d99fb537bb3 100644
--- a/source/blender/freestyle/intern/python/BPy_MediumType.h
+++ b/source/blender/freestyle/intern/python/BPy_MediumType.h
@@ -25,7 +25,9 @@
#ifndef __FREESTYLE_PYTHON_MEDIUMTYPE_H__
#define __FREESTYLE_PYTHON_MEDIUMTYPE_H__
+extern "C" {
#include <Python.h>
+}
#include "../stroke/Stroke.h"
diff --git a/source/blender/freestyle/intern/python/BPy_Nature.h b/source/blender/freestyle/intern/python/BPy_Nature.h
index 0b9901bbe06..ad6bc0fdbdd 100644
--- a/source/blender/freestyle/intern/python/BPy_Nature.h
+++ b/source/blender/freestyle/intern/python/BPy_Nature.h
@@ -25,7 +25,9 @@
#ifndef __FREESTYLE_PYTHON_NATURE_H__
#define __FREESTYLE_PYTHON_NATURE_H__
+extern "C" {
#include <Python.h>
+}
#include "../winged_edge/Nature.h"
diff --git a/source/blender/freestyle/intern/python/BPy_Operators.h b/source/blender/freestyle/intern/python/BPy_Operators.h
index be9514f46d8..86d23c4917f 100644
--- a/source/blender/freestyle/intern/python/BPy_Operators.h
+++ b/source/blender/freestyle/intern/python/BPy_Operators.h
@@ -25,7 +25,9 @@
#ifndef __FREESTYLE_PYTHON_OPERATORS_H__
#define __FREESTYLE_PYTHON_OPERATORS_H__
+extern "C" {
#include <Python.h>
+}
#include "../stroke/Operators.h"
diff --git a/source/blender/freestyle/intern/python/BPy_SShape.h b/source/blender/freestyle/intern/python/BPy_SShape.h
index 8e7d3b63582..4919a34bf6d 100644
--- a/source/blender/freestyle/intern/python/BPy_SShape.h
+++ b/source/blender/freestyle/intern/python/BPy_SShape.h
@@ -25,7 +25,9 @@
#ifndef __FREESTYLE_PYTHON_SSHAPE_H__
#define __FREESTYLE_PYTHON_SSHAPE_H__
+extern "C" {
#include <Python.h>
+}
#include "../view_map/Silhouette.h"
diff --git a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.h b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.h
index 6d30b6b1421..ce2384ea7d6 100644
--- a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.h
+++ b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.h
@@ -25,7 +25,9 @@
#ifndef __FREESTYLE_PYTHON_STROKEATTRIBUTE_H__
#define __FREESTYLE_PYTHON_STROKEATTRIBUTE_H__
+extern "C" {
#include <Python.h>
+}
#include "../stroke/Stroke.h"
diff --git a/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp b/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp
index e1d620cee1c..a6c7a40e780 100644
--- a/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp
+++ b/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp
@@ -29,6 +29,7 @@
#include "StrokeShader/BPy_BackboneStretcherShader.h"
#include "StrokeShader/BPy_BezierCurveShader.h"
+#include "StrokeShader/BPy_BlenderTextureShader.h"
#include "StrokeShader/BPy_CalligraphicShader.h"
#include "StrokeShader/BPy_ColorNoiseShader.h"
#include "StrokeShader/BPy_ColorVariationPatternShader.h"
@@ -45,6 +46,7 @@
#include "StrokeShader/BPy_SpatialNoiseShader.h"
#include "StrokeShader/BPy_streamShader.h"
#include "StrokeShader/BPy_StrokeTextureShader.h"
+#include "StrokeShader/BPy_StrokeTextureStepShader.h"
#include "StrokeShader/BPy_TextureAssignerShader.h"
#include "StrokeShader/BPy_ThicknessNoiseShader.h"
#include "StrokeShader/BPy_ThicknessVariationPatternShader.h"
@@ -77,6 +79,11 @@ int StrokeShader_Init(PyObject *module)
Py_INCREF(&BezierCurveShader_Type);
PyModule_AddObject(module, "BezierCurveShader", (PyObject *)&BezierCurveShader_Type);
+ if (PyType_Ready(&BlenderTextureShader_Type) < 0)
+ return -1;
+ Py_INCREF(&BlenderTextureShader_Type);
+ PyModule_AddObject(module, "BlenderTextureShader", (PyObject *)&BlenderTextureShader_Type);
+
if (PyType_Ready(&CalligraphicShader_Type) < 0)
return -1;
Py_INCREF(&CalligraphicShader_Type);
@@ -158,6 +165,11 @@ int StrokeShader_Init(PyObject *module)
Py_INCREF(&StrokeTextureShader_Type);
PyModule_AddObject(module, "StrokeTextureShader", (PyObject *)&StrokeTextureShader_Type);
+ if (PyType_Ready(&StrokeTextureStepShader_Type) < 0)
+ return -1;
+ Py_INCREF(&StrokeTextureStepShader_Type);
+ PyModule_AddObject(module, "StrokeTextureStepShader", (PyObject *)&StrokeTextureStepShader_Type);
+
if (PyType_Ready(&TextureAssignerShader_Type) < 0)
return -1;
Py_INCREF(&TextureAssignerShader_Type);
diff --git a/source/blender/freestyle/intern/python/BPy_StrokeShader.h b/source/blender/freestyle/intern/python/BPy_StrokeShader.h
index 19af6006c10..91498581695 100644
--- a/source/blender/freestyle/intern/python/BPy_StrokeShader.h
+++ b/source/blender/freestyle/intern/python/BPy_StrokeShader.h
@@ -25,7 +25,9 @@
#ifndef __FREESTYLE_PYTHON_STROKESHADER_H__
#define __FREESTYLE_PYTHON_STROKESHADER_H__
+extern "C" {
#include <Python.h>
+}
#include "../system/FreestyleConfig.h"
diff --git a/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.h b/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.h
index 3b6a2ab79e6..58126d5291a 100644
--- a/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.h
+++ b/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.h
@@ -25,7 +25,9 @@
#ifndef __FREESTYLE_PYTHON_UNARYFUNCTION0D_H__
#define __FREESTYLE_PYTHON_UNARYFUNCTION0D_H__
+extern "C" {
#include <Python.h>
+}
#include "../view_map/Functions0D.h"
diff --git a/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.h b/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.h
index 87c4430fd14..0b38b3d47ac 100644
--- a/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.h
+++ b/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.h
@@ -25,7 +25,9 @@
#ifndef __FREESTYLE_PYTHON_UNARYFUNCTION1D_H__
#define __FREESTYLE_PYTHON_UNARYFUNCTION1D_H__
+extern "C" {
#include <Python.h>
+}
#include "../view_map/Functions1D.h"
diff --git a/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.h b/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.h
index 0101a5f508a..a40d4648444 100644
--- a/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.h
+++ b/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.h
@@ -25,7 +25,9 @@
#ifndef __FREESTYLE_PYTHON_UNARYPREDICATE0D_H__
#define __FREESTYLE_PYTHON_UNARYPREDICATE0D_H__
+extern "C" {
#include <Python.h>
+}
#include "../stroke/Predicates0D.h"
diff --git a/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.h b/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.h
index fd37e1dc13a..bbbec57b2b3 100644
--- a/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.h
+++ b/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.h
@@ -25,7 +25,9 @@
#ifndef __FREESTYLE_PYTHON_UNARYPREDICATE1D_H__
#define __FREESTYLE_PYTHON_UNARYPREDICATE1D_H__
+extern "C" {
#include <Python.h>
+}
#include "../stroke/Predicates1D.h"
diff --git a/source/blender/freestyle/intern/python/BPy_ViewMap.h b/source/blender/freestyle/intern/python/BPy_ViewMap.h
index 5150c6fbebd..cd42e9453ae 100644
--- a/source/blender/freestyle/intern/python/BPy_ViewMap.h
+++ b/source/blender/freestyle/intern/python/BPy_ViewMap.h
@@ -25,7 +25,9 @@
#ifndef __FREESTYLE_PYTHON_VIEWMAP_H__
#define __FREESTYLE_PYTHON_VIEWMAP_H__
+extern "C" {
#include <Python.h>
+}
#include "../view_map/ViewMap.h"
diff --git a/source/blender/freestyle/intern/python/BPy_ViewShape.h b/source/blender/freestyle/intern/python/BPy_ViewShape.h
index 7727b131e1b..3151ebe8cbd 100644
--- a/source/blender/freestyle/intern/python/BPy_ViewShape.h
+++ b/source/blender/freestyle/intern/python/BPy_ViewShape.h
@@ -25,7 +25,9 @@
#ifndef __FREESTYLE_PYTHON_VIEWSHAPE_H__
#define __FREESTYLE_PYTHON_VIEWSHAPE_H__
+extern "C" {
#include <Python.h>
+}
#include "../view_map/ViewMap.h"
diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.h b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.h
index 214660b5a7c..add2a68214f 100644
--- a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.h
+++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject FalseBP1D_Type;
#define BPy_FalseBP1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&FalseBP1D_Type))
diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.h b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.h
index e4b02fc97d5..e79e8118c5a 100644
--- a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.h
+++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject Length2DBP1D_Type;
#define BPy_Length2DBP1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&Length2DBP1D_Type))
diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.h b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.h
index 097d68c4ce7..c78aab609a4 100644
--- a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.h
+++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject SameShapeIdBP1D_Type;
#define BPy_SameShapeIdBP1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&SameShapeIdBP1D_Type))
diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.h b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.h
index 772de1ae3df..29cf57a2215 100644
--- a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.h
+++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject TrueBP1D_Type;
#define BPy_TrueBP1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&TrueBP1D_Type))
diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.h b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.h
index 01bad10c71e..27182b852d1 100644
--- a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.h
+++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject ViewMapGradientNormBP1D_Type;
#define BPy_ViewMapGradientNormBP1D_Check(v) \
diff --git a/source/blender/freestyle/intern/python/Director.cpp b/source/blender/freestyle/intern/python/Director.cpp
index ed98bfee63f..f03aa0bcc97 100644
--- a/source/blender/freestyle/intern/python/Director.cpp
+++ b/source/blender/freestyle/intern/python/Director.cpp
@@ -74,7 +74,7 @@ int Director_BPy_BinaryPredicate0D___call__(BinaryPredicate0D *bp0D, Interface0D
Py_XDECREF(arg2);
return -1;
}
- PyObject *result = PyObject_CallMethod(bp0D->py_bp0D, (char *)"__call__", (char *)"OO", arg1, arg2);
+ PyObject *result = PyObject_CallMethod((PyObject *)bp0D->py_bp0D, (char *)"__call__", (char *)"OO", arg1, arg2);
Py_DECREF(arg1);
Py_DECREF(arg2);
if (!result)
@@ -101,7 +101,7 @@ int Director_BPy_BinaryPredicate1D___call__(BinaryPredicate1D *bp1D, Interface1D
Py_XDECREF(arg2);
return -1;
}
- PyObject *result = PyObject_CallMethod(bp1D->py_bp1D, (char *)"__call__", (char *)"OO", arg1, arg2);
+ PyObject *result = PyObject_CallMethod((PyObject *)bp1D->py_bp1D, (char *)"__call__", (char *)"OO", arg1, arg2);
Py_DECREF(arg1);
Py_DECREF(arg2);
if (!result)
@@ -124,7 +124,7 @@ int Director_BPy_UnaryPredicate0D___call__(UnaryPredicate0D *up0D, Interface0DIt
PyObject *arg = BPy_Interface0DIterator_from_Interface0DIterator(if0D_it, 0);
if (!arg)
return -1;
- PyObject *result = PyObject_CallMethod(up0D->py_up0D, (char *)"__call__", (char *)"O", arg);
+ PyObject *result = PyObject_CallMethod((PyObject *)up0D->py_up0D, (char *)"__call__", (char *)"O", arg);
Py_DECREF(arg);
if (!result)
return -1;
@@ -146,7 +146,7 @@ int Director_BPy_UnaryPredicate1D___call__(UnaryPredicate1D *up1D, Interface1D&
PyObject *arg = Any_BPy_Interface1D_from_Interface1D(if1D);
if (!arg)
return -1;
- PyObject *result = PyObject_CallMethod(up1D->py_up1D, (char *)"__call__", (char *)"O", arg);
+ PyObject *result = PyObject_CallMethod((PyObject *)up1D->py_up1D, (char *)"__call__", (char *)"O", arg);
Py_DECREF(arg);
if (!result)
return -1;
@@ -168,7 +168,7 @@ int Director_BPy_StrokeShader_shade(StrokeShader *ss, Stroke& s)
PyObject *arg = BPy_Stroke_from_Stroke(s);
if (!arg)
return -1;
- PyObject *result = PyObject_CallMethod(ss->py_ss, (char *)"shade", (char *)"O", arg);
+ PyObject *result = PyObject_CallMethod((PyObject *)ss->py_ss, (char *)"shade", (char *)"O", arg);
Py_DECREF(arg);
if (!result)
return -1;
@@ -183,7 +183,7 @@ int Director_BPy_ChainingIterator_init(ChainingIterator *c_it)
PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_c_it) not initialized");
return -1;
}
- PyObject *result = PyObject_CallMethod(c_it->py_c_it, (char *)"init", NULL);
+ PyObject *result = PyObject_CallMethod((PyObject *)c_it->py_c_it, (char *)"init", NULL);
if (!result)
return -1;
Py_DECREF(result);
@@ -199,7 +199,7 @@ int Director_BPy_ChainingIterator_traverse(ChainingIterator *c_it, AdjacencyIter
PyObject *arg = BPy_AdjacencyIterator_from_AdjacencyIterator(a_it);
if (!arg)
return -1;
- PyObject *result = PyObject_CallMethod(c_it->py_c_it, (char *)"traverse", (char *)"O", arg);
+ PyObject *result = PyObject_CallMethod((PyObject *)c_it->py_c_it, (char *)"traverse", (char *)"O", arg);
Py_DECREF(arg);
if (!result)
return -1;
@@ -219,12 +219,13 @@ int Director_BPy_ChainingIterator_traverse(ChainingIterator *c_it, AdjacencyIter
}
// BPy_UnaryFunction{0D,1D}: __call__
-int Director_BPy_UnaryFunction0D___call__(void *uf0D, PyObject *obj, Interface0DIterator& if0D_it)
+int Director_BPy_UnaryFunction0D___call__(void *uf0D, void *py_uf0D, Interface0DIterator& if0D_it)
{
- if (!obj) { // internal error
+ if (!py_uf0D) { // internal error
PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_uf0D) not initialized");
return -1;
}
+ PyObject *obj = (PyObject *)py_uf0D;
PyObject *arg = BPy_Interface0DIterator_from_Interface0DIterator(if0D_it, 0);
if (!arg)
return -1;
@@ -277,12 +278,13 @@ int Director_BPy_UnaryFunction0D___call__(void *uf0D, PyObject *obj, Interface0D
return 0;
}
-int Director_BPy_UnaryFunction1D___call__(void *uf1D, PyObject *obj, Interface1D& if1D)
+int Director_BPy_UnaryFunction1D___call__(void *uf1D, void *py_uf1D, Interface1D& if1D)
{
- if (!obj) { // internal error
+ if (!py_uf1D) { // internal error
PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_uf1D) not initialized");
return -1;
}
+ PyObject *obj = (PyObject *)py_uf1D;
PyObject *arg = Any_BPy_Interface1D_from_Interface1D(if1D);
if (!arg)
return -1;
diff --git a/source/blender/freestyle/intern/python/Director.h b/source/blender/freestyle/intern/python/Director.h
index d58a51b65b2..40576c0ec2c 100644
--- a/source/blender/freestyle/intern/python/Director.h
+++ b/source/blender/freestyle/intern/python/Director.h
@@ -41,16 +41,6 @@ class StrokeShader;
using namespace Freestyle;
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <Python.h>
-
-#ifdef __cplusplus
-}
-#endif
-
// BinaryPredicate0D: __call__
int Director_BPy_BinaryPredicate0D___call__(BinaryPredicate0D *bp0D, Interface0D& i1, Interface0D& i2);
@@ -58,8 +48,8 @@ int Director_BPy_BinaryPredicate0D___call__(BinaryPredicate0D *bp0D, Interface0D
int Director_BPy_BinaryPredicate1D___call__(BinaryPredicate1D *bp1D, Interface1D& i1, Interface1D& i2);
// UnaryFunction{0D,1D}: __call__
-int Director_BPy_UnaryFunction0D___call__(void *uf0D, PyObject *obj, Interface0DIterator& if0D_it);
-int Director_BPy_UnaryFunction1D___call__(void *uf1D, PyObject *obj, Interface1D& if1D);
+int Director_BPy_UnaryFunction0D___call__(void *uf0D, void *py_uf0D, Interface0DIterator& if0D_it);
+int Director_BPy_UnaryFunction1D___call__(void *uf1D, void *py_uf1D, Interface1D& if1D);
// UnaryPredicate0D: __call__
int Director_BPy_UnaryPredicate0D___call__(UnaryPredicate0D *up0D, Interface0DIterator& if0D_it);
diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.h b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.h
index 9ab5bea9e8c..5d651ef1a56 100644
--- a/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.h
+++ b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.h
@@ -26,6 +26,7 @@
#define __FREESTYLE_PYTHON_CURVEPOINT_H__
#include "../BPy_Interface0D.h"
+
#include "../../stroke/Curve.h"
#ifdef __cplusplus
@@ -34,8 +35,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject CurvePoint_Type;
#define BPy_CurvePoint_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&CurvePoint_Type))
diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.h b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.h
index 84866fb5a4e..a154ac4e48e 100644
--- a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.h
+++ b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.h
@@ -25,9 +25,9 @@
#ifndef __FREESTYLE_PYTHON_SVERTEX_H__
#define __FREESTYLE_PYTHON_SVERTEX_H__
-#include "../../view_map/Silhouette.h"
#include "../BPy_Interface0D.h"
+#include "../../view_map/Silhouette.h"
#ifdef __cplusplus
extern "C" {
@@ -35,8 +35,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject SVertex_Type;
#define BPy_SVertex_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&SVertex_Type))
diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.h b/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.h
index 9589b939e57..21b45c987f2 100644
--- a/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.h
+++ b/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.h
@@ -25,17 +25,16 @@
#ifndef __FREESTYLE_PYTHON_VIEWVERTEX_H__
#define __FREESTYLE_PYTHON_VIEWVERTEX_H__
-#include "../../view_map/ViewMap.h"
#include "../BPy_Interface0D.h"
+#include "../../view_map/ViewMap.h"
+
#ifdef __cplusplus
extern "C" {
#endif
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject ViewVertex_Type;
#define BPy_ViewVertex_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&ViewVertex_Type))
diff --git a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.h b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.h
index b4c52d6968e..8519fe98443 100644
--- a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.h
+++ b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.h
@@ -26,6 +26,7 @@
#define __FREESTYLE_PYTHON_STROKEVERTEX_H__
#include "../BPy_CurvePoint.h"
+
#include "../../../stroke/Stroke.h"
#ifdef __cplusplus
@@ -34,8 +35,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject StrokeVertex_Type;
#define BPy_StrokeVertex_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&StrokeVertex_Type))
diff --git a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.h b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.h
index 7d5ffd2d410..7f8d5c175c7 100644
--- a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.h
+++ b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.h
@@ -26,6 +26,7 @@
#define __FREESTYLE_PYTHON_NONTVERTEX_H__
#include "../BPy_ViewVertex.h"
+
#include "../../../view_map/ViewMap.h"
#ifdef __cplusplus
@@ -34,8 +35,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject NonTVertex_Type;
#define BPy_NonTVertex_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&NonTVertex_Type))
diff --git a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.h b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.h
index a3f8d0a57b0..4f14b5afdc0 100644
--- a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.h
+++ b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.h
@@ -26,6 +26,7 @@
#define __FREESTYLE_PYTHON_TVERTEX_H__
#include "../BPy_ViewVertex.h"
+
#include "../../../view_map/ViewMap.h"
#ifdef __cplusplus
@@ -34,8 +35,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject TVertex_Type;
#define BPy_TVertex_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&TVertex_Type))
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
index 3a0be48e4bf..7365ee8ac36 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
@@ -46,7 +46,7 @@ PyDoc_STRVAR(FEdge_doc,
"silhouettes, the FEdge is oriented so that the visible face lies on\n"
"the left of the edge. For borders, the FEdge is oriented so that the\n"
"face lies on the left of the edge. An FEdge can represent an initial\n"
-"edge of the mesh or runs accross a face of the initial mesh depending\n"
+"edge of the mesh or runs across a face of the initial mesh depending\n"
"on the smoothness or sharpness of the mesh. This class is specialized\n"
"into a smooth and a sharp version since their properties slightly vary\n"
"from one to the other.\n"
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.h b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.h
index 7e27e3e93ab..69e7fddd770 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.h
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.h
@@ -26,6 +26,7 @@
#define __FREESTYLE_PYTHON_FEDGE_H__
#include "../BPy_Interface1D.h"
+
#include "../../view_map/Silhouette.h"
#ifdef __cplusplus
@@ -34,8 +35,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject FEdge_Type;
#define BPy_FEdge_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&FEdge_Type))
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.h b/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.h
index e119fef5758..990d8fb5b24 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.h
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.h
@@ -26,6 +26,7 @@
#define __FREESTYLE_PYTHON_FRSCURVE_H__
#include "../BPy_Interface1D.h"
+
#include "../../stroke/Curve.h"
#ifdef __cplusplus
@@ -34,8 +35,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject FrsCurve_Type;
#define BPy_FrsCurve_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&FrsCurve_Type))
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.h b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.h
index 0ceaf3ec9f5..a22e5c2d006 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.h
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.h
@@ -26,6 +26,7 @@
#define __FREESTYLE_PYTHON_STROKE_H__
#include "../BPy_Interface1D.h"
+
#include "../../stroke/Stroke.h"
#ifdef __cplusplus
@@ -34,8 +35,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject Stroke_Type;
#define BPy_Stroke_Check(v) (((PyObject *)v)->ob_type == &Stroke_Type)
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.h b/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.h
index d47fed0fdc2..51af401f33b 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.h
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.h
@@ -25,18 +25,16 @@
#ifndef __FREESTYLE_PYTHON_VIEWEDGE_H__
#define __FREESTYLE_PYTHON_VIEWEDGE_H__
-#include "../../view_map/ViewMap.h"
-
#include "../BPy_Interface1D.h"
+#include "../../view_map/ViewMap.h"
+
#ifdef __cplusplus
extern "C" {
#endif
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject ViewEdge_Type;
#define BPy_ViewEdge_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&ViewEdge_Type))
diff --git a/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.h b/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.h
index 867b9b0387d..172dffff49b 100644
--- a/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.h
+++ b/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.h
@@ -26,6 +26,7 @@
#define __FREESTYLE_PYTHON_CHAIN_H__
#include "../BPy_FrsCurve.h"
+
#include "../../../stroke/Chain.h"
#ifdef __cplusplus
@@ -34,8 +35,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject Chain_Type;
#define BPy_Chain_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&Chain_Type))
diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.h b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.h
index 37f678ddd93..1c82453432b 100644
--- a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.h
+++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.h
@@ -26,6 +26,7 @@
#define __FREESTYLE_PYTHON_FEDGESHARP_H__
#include "../BPy_FEdge.h"
+
#include "../../../view_map/Silhouette.h"
#ifdef __cplusplus
@@ -34,8 +35,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject FEdgeSharp_Type;
#define BPy_FEdgeSharp_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&FEdgeSharp_Type))
diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.h b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.h
index a88afc24557..f3dfd796418 100644
--- a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.h
+++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.h
@@ -26,6 +26,7 @@
#define __FREESTYLE_PYTHON_FEDGESMOOTH_H__
#include "../BPy_FEdge.h"
+
#include "../../../view_map/Silhouette.h"
#ifdef __cplusplus
@@ -34,8 +35,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject FEdgeSmooth_Type;
#define BPy_FEdgeSmooth_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&FEdgeSmooth_Type))
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.h
index 20deea25c10..51fb3e5ebdc 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.h
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.h
@@ -25,9 +25,9 @@
#ifndef __FREESTYLE_PYTHON_ADJACENCYITERATOR_H__
#define __FREESTYLE_PYTHON_ADJACENCYITERATOR_H__
-#include "../../stroke/ChainingIterators.h"
#include "../BPy_Iterator.h"
+#include "../../stroke/ChainingIterators.h"
#ifdef __cplusplus
extern "C" {
@@ -35,8 +35,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject AdjacencyIterator_Type;
#define BPy_AdjacencyIterator_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&AdjacencyIterator_Type))
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.h
index 0a7d97813b5..733a16e3974 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.h
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.h
@@ -25,19 +25,16 @@
#ifndef __FREESTYLE_PYTHON_CHAINPREDICATEITERATOR_H__
#define __FREESTYLE_PYTHON_CHAINPREDICATEITERATOR_H__
+#include "BPy_ChainingIterator.h"
#include "../../stroke/ChainingIterators.h"
-#include "BPy_ChainingIterator.h"
-
#ifdef __cplusplus
extern "C" {
#endif
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject ChainPredicateIterator_Type;
#define BPy_ChainPredicateIterator_Check(v) \
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.h
index d58c3ffd294..e76c04a6640 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.h
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.h
@@ -25,19 +25,16 @@
#ifndef __FREESTYLE_PYTHON_CHAINSILHOUETTEITERATOR_H__
#define __FREESTYLE_PYTHON_CHAINSILHOUETTEITERATOR_H__
+#include "BPy_ChainingIterator.h"
#include "../../stroke/ChainingIterators.h"
-#include "BPy_ChainingIterator.h"
-
#ifdef __cplusplus
extern "C" {
#endif
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject ChainSilhouetteIterator_Type;
#define BPy_ChainSilhouetteIterator_Check(v) \
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.h
index 93526921ae3..72015e6a0d9 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.h
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.h
@@ -25,19 +25,16 @@
#ifndef __FREESTYLE_PYTHON_CHAININGITERATOR_H__
#define __FREESTYLE_PYTHON_CHAININGITERATOR_H__
+#include "BPy_ViewEdgeIterator.h"
#include "../../stroke/ChainingIterators.h"
-#include "BPy_ViewEdgeIterator.h"
-
#ifdef __cplusplus
extern "C" {
#endif
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject ChainingIterator_Type;
#define BPy_ChainingIterator_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&ChainingIterator_Type))
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.h
index 104c8557754..8c93ac2c014 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.h
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.h
@@ -25,18 +25,16 @@
#ifndef __FREESTYLE_PYTHON_CURVEPOINTITERATOR_H__
#define __FREESTYLE_PYTHON_CURVEPOINTITERATOR_H__
-#include "../../stroke/CurveIterators.h"
-
#include "../BPy_Iterator.h"
+#include "../../stroke/CurveIterators.h"
+
#ifdef __cplusplus
extern "C" {
#endif
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject CurvePointIterator_Type;
#define BPy_CurvePointIterator_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&CurvePointIterator_Type))
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.h
index 224fe13c576..5b1b70f19e8 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.h
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.h
@@ -25,9 +25,9 @@
#ifndef __FREESTYLE_PYTHON_INTERFACE0DITERATOR_H__
#define __FREESTYLE_PYTHON_INTERFACE0DITERATOR_H__
-#include "../../view_map/Interface0D.h"
#include "../BPy_Iterator.h"
+#include "../../view_map/Interface0D.h"
#ifdef __cplusplus
extern "C" {
@@ -35,8 +35,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject Interface0DIterator_Type;
#define BPy_Interface0DIterator_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&Interface0DIterator_Type))
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.h
index 858609efe47..a430e4e7876 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.h
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.h
@@ -25,10 +25,9 @@
#ifndef __FREESTYLE_PYTHON_SVERTEXITERATOR_H__
#define __FREESTYLE_PYTHON_SVERTEXITERATOR_H__
-#include "../../view_map/ViewMapIterators.h"
-
#include "../BPy_Iterator.h"
+#include "../../view_map/ViewMapIterators.h"
#ifdef __cplusplus
extern "C" {
@@ -36,8 +35,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject SVertexIterator_Type;
#define BPy_SVertexIterator_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&SVertexIterator_Type))
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.h
index 4ce11191b1c..18bad65b00a 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.h
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.h
@@ -25,18 +25,16 @@
#ifndef __FREESTYLE_PYTHON_STROKEVERTEXITERATOR_H__
#define __FREESTYLE_PYTHON_STROKEVERTEXITERATOR_H__
-#include "../../stroke/StrokeIterators.h"
-
#include "../BPy_Iterator.h"
+#include "../../stroke/StrokeIterators.h"
+
#ifdef __cplusplus
extern "C" {
#endif
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject StrokeVertexIterator_Type;
#define BPy_StrokeVertexIterator_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&StrokeVertexIterator_Type))
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.h
index eb11dd6cdea..47244dcb5f2 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.h
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.h
@@ -25,19 +25,16 @@
#ifndef __FREESTYLE_PYTHON_VIEWEDGEITERATOR_H__
#define __FREESTYLE_PYTHON_VIEWEDGEITERATOR_H__
+#include "../BPy_Iterator.h"
#include "../../view_map/ViewMapIterators.h"
-#include "../BPy_Iterator.h"
-
#ifdef __cplusplus
extern "C" {
#endif
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject ViewEdgeIterator_Type;
#define BPy_ViewEdgeIterator_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&ViewEdgeIterator_Type))
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.h
index 999e0ecad5d..bb1207aa46b 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.h
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.h
@@ -25,19 +25,16 @@
#ifndef __FREESTYLE_PYTHON_ORIENTEDVIEWEDGEITERATOR_H__
#define __FREESTYLE_PYTHON_ORIENTEDVIEWEDGEITERATOR_H__
-#include "../../stroke/Stroke.h"
-#include "../../view_map/ViewMapIterators.h"
-
#include "../BPy_Iterator.h"
+#include "../../view_map/ViewMapIterators.h"
+
#ifdef __cplusplus
extern "C" {
#endif
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject orientedViewEdgeIterator_Type;
#define BPy_orientedViewEdgeIterator_Check(v) \
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.h
index c9059eb96f2..82d39a853bd 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject BackboneStretcherShader_Type;
#define BPy_BackboneStretcherShader_Check(v) \
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.h
index ad967a76fd3..6982661366f 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject BezierCurveShader_Type;
#define BPy_BezierCurveShader_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&BezierCurveShader_Type))
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.cpp
new file mode 100644
index 00000000000..c8b9d7098e4
--- /dev/null
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.cpp
@@ -0,0 +1,125 @@
+/*
+ * ***** 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 *****
+ */
+
+/** \file source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.cpp
+ * \ingroup freestyle
+ */
+
+#include "BPy_BlenderTextureShader.h"
+
+#include "../../stroke/BasicStrokeShaders.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "../../../../python/generic/py_capi_utils.h"
+
+///////////////////////////////////////////////////////////////////////////////////////////
+
+//------------------------INSTANCE METHODS ----------------------------------
+
+static char BlenderTextureShader___doc__[] =
+"Class hierarchy: :class:`StrokeShader` > :class:`BlenderTextureShader`\n"
+"\n"
+"[Texture shader]\n"
+"\n"
+".. method:: __init__(LineStyleTextureSlot)\n"
+"\n"
+" Builds a BlenderTextureShader object.\n"
+"\n"
+" :arg mtex: texture slot to add to stroke shading.\n"
+" :type mtex: LineStyleTextureSlot\n"
+
+"\n"
+".. method:: shade(stroke)\n"
+"\n"
+" Assigns a blender texture slot to the stroke shading\n"
+" in order to simulate marks.\n"
+"\n"
+" :arg stroke: A Stroke object.\n"
+" :type stroke: :class:`Stroke`\n";
+
+static int BlenderTextureShader___init__(BPy_BlenderTextureShader *self, PyObject *args, PyObject *kwds)
+{
+ static const char *kwlist[] = {"LineStyleTextureSlot", NULL};
+ PyObject *py_mtex;
+ MTex *_mtex;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", (char **)kwlist, &py_mtex))
+ return -1;
+
+ _mtex = (MTex*)PyC_RNA_AsPointer(py_mtex, "LineStyleTextureSlot");
+
+ if (_mtex) {
+ self->py_ss.ss = new StrokeShaders::BlenderTextureShader(_mtex);
+ }
+
+ return 0;
+}
+
+/*-----------------------BPy_BlenderTextureShader type definition ------------------------------*/
+
+PyTypeObject BlenderTextureShader_Type = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "BlenderTextureShader", /* tp_name */
+ sizeof(BPy_BlenderTextureShader), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ 0, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_reserved */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ BlenderTextureShader___doc__, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ &StrokeShader_Type, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)BlenderTextureShader___init__, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+};
+
+///////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.h
new file mode 100644
index 00000000000..46294c07b66
--- /dev/null
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.h
@@ -0,0 +1,57 @@
+/*
+ * ***** 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 *****
+ */
+
+/** \file source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.h
+ * \ingroup freestyle
+ */
+
+#ifndef __FREESTYLE_PYTHON_BLENDERTEXTURESHADER_H__
+#define __FREESTYLE_PYTHON_BLENDERTEXTURESHADER_H__
+
+#include "../BPy_StrokeShader.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct MTex;
+
+///////////////////////////////////////////////////////////////////////////////////////////
+
+#include <Python.h>
+
+extern PyTypeObject BlenderTextureShader_Type;
+
+#define BPy_BlenderTextureShader_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&BlenderTextureShader_Type))
+
+/*---------------------------Python BPy_BlenderTextureShader structure definition-----------*/
+typedef struct {
+ BPy_StrokeShader py_ss;
+} BPy_BlenderTextureShader;
+
+
+///////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __FREESTYLE_PYTHON_BLENDERTEXTURESHADER_H__ */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.h
index bc94ad95442..6212a8f1d44 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject CalligraphicShader_Type;
#define BPy_CalligraphicShader_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&CalligraphicShader_Type)
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.h
index 8be7f8b7b2d..5bce58f9f10 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject ColorNoiseShader_Type;
#define BPy_ColorNoiseShader_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&ColorNoiseShader_Type))
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorVariationPatternShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorVariationPatternShader.h
index 4ec22d3e9f3..af5cf17caff 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorVariationPatternShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorVariationPatternShader.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject ColorVariationPatternShader_Type;
#define BPy_ColorVariationPatternShader_Check(v) \
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.h
index 5de697e62d8..a34db21a873 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject ConstantColorShader_Type;
#define BPy_ConstantColorShader_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&ConstantColorShader_Type))
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.h
index 6334283aff4..237b550b557 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject ConstantThicknessShader_Type;
#define BPy_ConstantThicknessShader_Check(v) \
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.h
index ccaf0708a74..124ce33aa8b 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject ConstrainedIncreasingThicknessShader_Type;
#define BPy_ConstrainedIncreasingThicknessShader_Check(v) \
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.h
index 1d08aa5578e..0fc4ce822c3 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject GuidingLinesShader_Type;
#define BPy_GuidingLinesShader_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&GuidingLinesShader_Type))
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.h
index 729aef5e772..db51fac1bd6 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject IncreasingColorShader_Type;
#define BPy_IncreasingColorShader_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&IncreasingColorShader_Type))
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.h
index 8f44deb354f..809921ffe93 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject IncreasingThicknessShader_Type;
#define BPy_IncreasingThicknessShader_Check(v) \
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.h
index 503e66d4b4c..023c8ff9fad 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject PolygonalizationShader_Type;
#define BPy_PolygonalizationShader_Check(v) \
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.h
index 26e73b2721a..ece206a5be4 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject SamplingShader_Type;
#define BPy_SamplingShader_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&SamplingShader_Type))
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp
index c4ca83743a6..ca69561d8e0 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp
@@ -68,7 +68,7 @@ static char SmoothingShader___doc__[] =
" Smoothes the stroke by moving the vertices to make the stroke\n"
" smoother. Uses curvature flow to converge towards a curve of\n"
" constant curvature. The diffusion method we use is anisotropic to\n"
-" prevent the diffusion accross corners.\n"
+" prevent the diffusion across corners.\n"
"\n"
" :arg stroke: A Stroke object.\n"
" :type stroke: :class:`Stroke`\n";
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.h
index fa7e924509b..5f45397c06a 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject SmoothingShader_Type;
#define BPy_SmoothingShader_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&SmoothingShader_Type))
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.h
index 03fc5727246..d7dfe6a6644 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject SpatialNoiseShader_Type;
#define BPy_SpatialNoiseShader_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&SpatialNoiseShader_Type))
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureShader.h
index 9d106cac065..d025e8b7c2d 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureShader.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject StrokeTextureShader_Type;
#define BPy_StrokeTextureShader_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&StrokeTextureShader_Type))
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.cpp
new file mode 100644
index 00000000000..5a7657f2dad
--- /dev/null
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.cpp
@@ -0,0 +1,114 @@
+/*
+ * ***** 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 *****
+ */
+
+/** \file source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.cpp
+ * \ingroup freestyle
+ */
+
+#include "BPy_StrokeTextureStepShader.h"
+
+#include "../../stroke/BasicStrokeShaders.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////
+
+//------------------------INSTANCE METHODS ----------------------------------
+
+static char StrokeTextureStepShader___doc__[] =
+"Class hierarchy: :class:`StrokeShader` > :class:`StrokeTextureStepShader`\n"
+"\n"
+"[Texture shader]\n"
+"\n"
+".. method:: __init__(step)\n"
+"\n"
+" Builds a StrokeTextureStepShader object.\n"
+"\n"
+" :arg step: The spacing along the stroke.\n"
+" :type step: float\n"
+"\n"
+".. method:: shade(stroke)\n"
+"\n"
+" Assigns a spacing factor to the texture coordinates of the Stroke.\n"
+"\n"
+" :arg stroke: A Stroke object.\n"
+" :type stroke: :class:`Stroke`\n";
+
+static int StrokeTextureStepShader___init__(BPy_StrokeTextureStepShader *self, PyObject *args, PyObject *kwds)
+{
+ static const char *kwlist[] = {"step", NULL};
+ float step = 0.1;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "f", (char **)kwlist, &step))
+ return -1;
+ self->py_ss.ss = new StrokeShaders::StrokeTextureStepShader(step);
+ return 0;
+}
+
+/*-----------------------BPy_StrokeTextureStepShader type definition ------------------------------*/
+
+PyTypeObject StrokeTextureStepShader_Type = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "StrokeTextureStepShader", /* tp_name */
+ sizeof(BPy_StrokeTextureStepShader), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ 0, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_reserved */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ StrokeTextureStepShader___doc__, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ &StrokeShader_Type, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)StrokeTextureStepShader___init__, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+};
+
+///////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.h
new file mode 100644
index 00000000000..038d0022dec
--- /dev/null
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.h
@@ -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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.h
+ * \ingroup freestyle
+ */
+
+#ifndef __FREESTYLE_PYTHON_STROKETEXTURESTEPSHADER_H__
+#define __FREESTYLE_PYTHON_STROKETEXTURESTEPSHADER_H__
+
+#include "../BPy_StrokeShader.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////
+
+#include <Python.h>
+
+extern PyTypeObject StrokeTextureStepShader_Type;
+
+#define BPy_StrokeTextureStepShader_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&StrokeTextureStepShader_Type))
+
+/*---------------------------Python BPy_StrokeTextureStepShader structure definition----------*/
+typedef struct {
+ BPy_StrokeShader py_ss;
+} BPy_StrokeTextureStepShader;
+
+
+///////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __FREESTYLE_PYTHON_STROKETEXTURESTEPSHADER_H__ */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_TextureAssignerShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_TextureAssignerShader.h
index c3302a617b7..046f785dc57 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_TextureAssignerShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_TextureAssignerShader.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject TextureAssignerShader_Type;
#define BPy_TextureAssignerShader_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&TextureAssignerShader_Type))
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.h
index 6dc6d0df90f..3dd77c750f7 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject ThicknessNoiseShader_Type;
#define BPy_ThicknessNoiseShader_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&ThicknessNoiseShader_Type))
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessVariationPatternShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessVariationPatternShader.h
index 160fba19983..604e875f815 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessVariationPatternShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessVariationPatternShader.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject ThicknessVariationPatternShader_Type;
#define BPy_ThicknessVariationPatternShader_Check(v) \
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.h
index f8ef5aed6a3..c0c5b024153 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject TipRemoverShader_Type;
#define BPy_TipRemoverShader_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&TipRemoverShader_Type))
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_fstreamShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_fstreamShader.h
index 65d77860352..9f2371a3756 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_fstreamShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_fstreamShader.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject fstreamShader_Type;
#define BPy_fstreamShader_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&fstreamShader_Type))
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_streamShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_streamShader.h
index 281dab51f4a..047ff4b58b5 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_streamShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_streamShader.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject streamShader_Type;
#define BPy_streamShader_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&streamShader_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp
index be2be0a9c5c..06ba12145c0 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp
@@ -38,8 +38,6 @@
#include "UnaryFunction0D_double/BPy_LocalAverageDepthF0D.h"
#include "UnaryFunction0D_double/BPy_ZDiscontinuityF0D.h"
-#include "../Director.h"
-
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.h
index a8cd84312e6..bcf201e3b25 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject UnaryFunction0DDouble_Type;
#define BPy_UnaryFunction0DDouble_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&UnaryFunction0DDouble_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.h
index 1fa50a1f0ca..ce335f8ad0f 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.h
@@ -35,8 +35,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject UnaryFunction0DEdgeNature_Type;
#define BPy_UnaryFunction0DEdgeNature_Check(v) \
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.h
index 093ebcee71a..ea0903701ec 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject UnaryFunction0DFloat_Type;
#define BPy_UnaryFunction0DFloat_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&UnaryFunction0DFloat_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.h
index 6ba38a8fcbd..e736cbaf1f9 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.h
@@ -35,8 +35,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject UnaryFunction0DId_Type;
#define BPy_UnaryFunction0DId_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&UnaryFunction0DId_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.h
index 697d226635a..8be2041158c 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.h
@@ -35,8 +35,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject UnaryFunction0DMaterial_Type;
#define BPy_UnaryFunction0DMaterial_Check(v) \
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.h
index 065deeef6ce..a0c9209da31 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject UnaryFunction0DUnsigned_Type;
#define BPy_UnaryFunction0DUnsigned_Check(v) \
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.h
index fc6dd3c6612..33b069e3bc3 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.h
@@ -36,8 +36,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject UnaryFunction0DVec2f_Type;
#define BPy_UnaryFunction0DVec2f_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&UnaryFunction0DVec2f_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.h
index 88863eae6df..da5f27ffb8c 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.h
@@ -36,8 +36,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject UnaryFunction0DVec3f_Type;
#define BPy_UnaryFunction0DVec3f_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&UnaryFunction0DVec3f_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.h
index 4069db9b27f..c51942c78ac 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.h
@@ -36,8 +36,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject UnaryFunction0DVectorViewShape_Type;
#define BPy_UnaryFunction0DVectorViewShape_Check(v) \
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.h
index 1a6a633c7ff..b7c67749d78 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.h
@@ -35,8 +35,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject UnaryFunction0DViewShape_Type;
#define BPy_UnaryFunction0DViewShape_Check(v) \
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.h
index 8188fabfbe5..3c2a0112ca4 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject ShapeIdF0D_Type;
#define BPy_ShapeIdF0D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&ShapeIdF0D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.h
index 3b70ae85374..d080976d7db 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject MaterialF0D_Type;
#define BPy_MaterialF0D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&MaterialF0D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.h
index fe296a20ff7..7a79c89f468 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject CurveNatureF0D_Type;
#define BPy_CurveNatureF0D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&CurveNatureF0D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.h
index dc1c667a0a2..60f9fa87f47 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject Normal2DF0D_Type;
#define BPy_Normal2DF0D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&Normal2DF0D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.h
index 9aaafeec904..20014038704 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject VertexOrientation2DF0D_Type;
#define BPy_VertexOrientation2DF0D_Check(v) \
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.h
index eed6b93d481..e3a3a696ff5 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject VertexOrientation3DF0D_Type;
#define BPy_VertexOrientation3DF0D_Check(v) \
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetOccludeeF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetOccludeeF0D.h
index 56e3d416d30..02b6ee44e4e 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetOccludeeF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetOccludeeF0D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject GetOccludeeF0D_Type;
#define BPy_GetOccludeeF0D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&GetOccludeeF0D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetShapeF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetShapeF0D.h
index 12e93b71870..fa25061dd08 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetShapeF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetShapeF0D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject GetShapeF0D_Type;
#define BPy_GetShapeF0D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&GetShapeF0D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_Curvature2DAngleF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_Curvature2DAngleF0D.h
index cd2d653af81..e9602363461 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_Curvature2DAngleF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_Curvature2DAngleF0D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject Curvature2DAngleF0D_Type;
#define BPy_Curvature2DAngleF0D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&Curvature2DAngleF0D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_DensityF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_DensityF0D.h
index 458facca8c8..7f29affd131 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_DensityF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_DensityF0D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject DensityF0D_Type;
#define BPy_DensityF0D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&DensityF0D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedXF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedXF0D.h
index 5cfedc93c6b..ff01bc0a296 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedXF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedXF0D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject GetProjectedXF0D_Type;
#define BPy_GetProjectedXF0D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&GetProjectedXF0D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedYF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedYF0D.h
index cea48b0703a..d2b8798e237 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedYF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedYF0D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject GetProjectedYF0D_Type;
#define BPy_GetProjectedYF0D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&GetProjectedYF0D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedZF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedZF0D.h
index c901e078b78..fa8a8c39d20 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedZF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedZF0D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject GetProjectedZF0D_Type;
#define BPy_GetProjectedZF0D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&GetProjectedZF0D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetXF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetXF0D.h
index 31385434b77..27e1d17d007 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetXF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetXF0D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject GetXF0D_Type;
#define BPy_GetXF0D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&GetXF0D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetYF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetYF0D.h
index 39c1b658324..91a24935472 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetYF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetYF0D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject GetYF0D_Type;
#define BPy_GetYF0D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&GetYF0D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetZF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetZF0D.h
index 34f0ccdc02a..2c1cea52d91 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetZF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetZF0D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject GetZF0D_Type;
#define BPy_GetZF0D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&GetZF0D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_LocalAverageDepthF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_LocalAverageDepthF0D.h
index dd5d4363cca..308aa0f381a 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_LocalAverageDepthF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_LocalAverageDepthF0D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject LocalAverageDepthF0D_Type;
#define BPy_LocalAverageDepthF0D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&LocalAverageDepthF0D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_ZDiscontinuityF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_ZDiscontinuityF0D.h
index 7f83636f586..1cf202cbed9 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_ZDiscontinuityF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_ZDiscontinuityF0D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject ZDiscontinuityF0D_Type;
#define BPy_ZDiscontinuityF0D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&ZDiscontinuityF0D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.h
index 309b23972b0..83defbd21ca 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject GetCurvilinearAbscissaF0D_Type;
#define BPy_GetCurvilinearAbscissaF0D_Check(v) \
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetParameterF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetParameterF0D.h
index c03eea65332..24fe5cdb6e8 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetParameterF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetParameterF0D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject GetParameterF0D_Type;
#define BPy_GetParameterF0D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&GetParameterF0D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.h
index 2999f94ab7b..200bbb67c52 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject GetViewMapGradientNormF0D_Type;
#define BPy_GetViewMapGradientNormF0D_Check(v) \
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.h
index 6686cc80170..e4e1707c5f7 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject ReadCompleteViewMapPixelF0D_Type;
#define BPy_ReadCompleteViewMapPixelF0D_Check(v) \
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadMapPixelF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadMapPixelF0D.h
index 949fd66d2a9..c73a258b717 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadMapPixelF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadMapPixelF0D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject ReadMapPixelF0D_Type;
#define BPy_ReadMapPixelF0D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&ReadMapPixelF0D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.h
index c71ea3401a4..d2ba4990eb7 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject ReadSteerableViewMapPixelF0D_Type;
#define BPy_ReadSteerableViewMapPixelF0D_Check(v) \
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.h
index b5e19968617..142c5b7c04e 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject QuantitativeInvisibilityF0D_Type;
#define BPy_QuantitativeInvisibilityF0D_Check(v) \
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.h
index e4ee0584860..d87ef720786 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject GetOccludersF0D_Type;
#define BPy_GetOccludersF0D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&GetOccludersF0D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.h b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.h
index 8f274cd80b7..5b56525f973 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject UnaryFunction1DDouble_Type;
#define BPy_UnaryFunction1DDouble_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&UnaryFunction1DDouble_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.h b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.h
index ae4c5a864c1..6f38e774107 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.h
@@ -35,8 +35,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject UnaryFunction1DEdgeNature_Type;
#define BPy_UnaryFunction1DEdgeNature_Check(v) \
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.h b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.h
index f386a00c9ac..6d8a4d32ab8 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject UnaryFunction1DFloat_Type;
#define BPy_UnaryFunction1DFloat_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&UnaryFunction1DFloat_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.h b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.h
index 36324fae6de..8a1f5ca4dff 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject UnaryFunction1DUnsigned_Type;
#define BPy_UnaryFunction1DUnsigned_Check(v) \
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.h b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.h
index 59e0983028c..eb7c2bb5cae 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.h
@@ -36,8 +36,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject UnaryFunction1DVec2f_Type;
#define BPy_UnaryFunction1DVec2f_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&UnaryFunction1DVec2f_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.h b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.h
index ccf323d97cd..4780c54da9d 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.h
@@ -36,8 +36,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject UnaryFunction1DVec3f_Type;
#define BPy_UnaryFunction1DVec3f_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&UnaryFunction1DVec3f_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.h b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.h
index 7cf4fd50d11..974070198ab 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.h
@@ -36,8 +36,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject UnaryFunction1DVectorViewShape_Type;
#define BPy_UnaryFunction1DVectorViewShape_Check(v) \
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.h b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.h
index ae4a3b61520..03f8446fd45 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject UnaryFunction1DVoid_Type;
#define BPy_UnaryFunction1DVoid_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&UnaryFunction1DVoid_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.h
index 194941e6e70..c911155526b 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject CurveNatureF1D_Type;
#define BPy_CurveNatureF1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&CurveNatureF1D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.h
index 6f653e629db..ac4efabc179 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject Normal2DF1D_Type;
#define BPy_Normal2DF1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&Normal2DF1D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.h
index 14813b18d25..159e98e2fec 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject Orientation2DF1D_Type;
#define BPy_Orientation2DF1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&Orientation2DF1D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.h
index 855f7363fa7..50d5427600f 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject Orientation3DF1D_Type;
#define BPy_Orientation3DF1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&Orientation3DF1D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.h
index 8f7dbfdbf57..457154e02c6 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject Curvature2DAngleF1D_Type;
#define BPy_Curvature2DAngleF1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&Curvature2DAngleF1D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.h
index 3e4db290803..c1f0685a967 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject DensityF1D_Type;
#define BPy_DensityF1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&DensityF1D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.h
index 4eabf52e986..b9706c2c7a9 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject GetCompleteViewMapDensityF1D_Type;
#define BPy_GetCompleteViewMapDensityF1D_Check(v) \
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.h
index f6df23d9a2d..3168a72af5f 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject GetDirectionalViewMapDensityF1D_Type;
#define BPy_GetDirectionalViewMapDensityF1D_Check(v) \
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.h
index 2c34b8720aa..556aedaaba7 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject GetProjectedXF1D_Type;
#define BPy_GetProjectedXF1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&GetProjectedXF1D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.h
index 2f4431eadbd..cd786bf0fa1 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject GetProjectedYF1D_Type;
#define BPy_GetProjectedYF1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&GetProjectedYF1D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.h
index fc59bb40805..fda8df45b2c 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject GetProjectedZF1D_Type;
#define BPy_GetProjectedZF1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&GetProjectedZF1D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.h
index dbfd9594302..60707ebf078 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject GetSteerableViewMapDensityF1D_Type;
#define BPy_GetSteerableViewMapDensityF1D_Check(v) \
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.h
index 129fb54b507..69dd7994bb5 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject GetViewMapGradientNormF1D_Type;
#define BPy_GetViewMapGradientNormF1D_Check(v) \
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.h
index b43d867c38b..24d209b5439 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject GetXF1D_Type;
#define BPy_GetXF1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&GetXF1D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.h
index 658be22817a..421ec0e393a 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject GetYF1D_Type;
#define BPy_GetYF1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&GetYF1D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.h
index e36de7c1125..844e18e1cab 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject GetZF1D_Type;
#define BPy_GetZF1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&GetZF1D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.h
index d354076c984..f743dcb53cd 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject LocalAverageDepthF1D_Type;
#define BPy_LocalAverageDepthF1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&LocalAverageDepthF1D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.h
index 6fe6ce5d0d7..31b0edf309b 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject ZDiscontinuityF1D_Type;
#define BPy_ZDiscontinuityF1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&ZDiscontinuityF1D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.h
index 8115c17aa1f..30439a35817 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject QuantitativeInvisibilityF1D_Type;
#define BPy_QuantitativeInvisibilityF1D_Check(v) \
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.h
index 4d2ab924f0d..0c7aed2eb46 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject GetOccludeeF1D_Type;
#define BPy_GetOccludeeF1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&GetOccludeeF1D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.h
index 24c07e2a64c..1d0a8a79f2b 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject GetOccludersF1D_Type;
#define BPy_GetOccludersF1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&GetOccludersF1D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.h
index 0c498a5a9ba..72ce1dde537 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject GetShapeF1D_Type;
#define BPy_GetShapeF1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&GetShapeF1D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.h
index 3c89e9b9ac0..968ab25da3b 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject ChainingTimeStampF1D_Type;
#define BPy_ChainingTimeStampF1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&ChainingTimeStampF1D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.h
index 92b990ac21c..e55e189d140 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject IncrementChainingTimeStampF1D_Type;
#define BPy_IncrementChainingTimeStampF1D_Check(v) \
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.h
index 60becf26f48..0117231c4f1 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject TimeStampF1D_Type;
#define BPy_TimeStampF1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&TimeStampF1D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.h b/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.h
index 19d38a1fb59..e083ba935cb 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.h
+++ b/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject FalseUP0D_Type;
#define BPy_FalseUP0D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&FalseUP0D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.h b/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.h
index dff2bdb269b..d13e8473d52 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.h
+++ b/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject TrueUP0D_Type;
#define BPy_TrueUP0D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&TrueUP0D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.h
index aba39fb6557..154a268538c 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.h
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject ContourUP1D_Type;
#define BPy_ContourUP1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&ContourUP1D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.h
index 618d7f701f2..beed0ce0ed9 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.h
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject DensityLowerThanUP1D_Type;
#define BPy_DensityLowerThanUP1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&DensityLowerThanUP1D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.h
index ef4e2ba6320..f4ca8a82a20 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.h
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject EqualToChainingTimeStampUP1D_Type;
#define BPy_EqualToChainingTimeStampUP1D_Check(v) \
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.h
index 58266057911..8bd222c7430 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.h
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject EqualToTimeStampUP1D_Type;
#define BPy_EqualToTimeStampUP1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&EqualToTimeStampUP1D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.h
index 6e789960bc9..cc346a8c814 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.h
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject ExternalContourUP1D_Type;
#define BPy_ExternalContourUP1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&ExternalContourUP1D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.h
index 34eb70fa193..adce6ad68c9 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.h
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject FalseUP1D_Type;
#define BPy_FalseUP1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&FalseUP1D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.h
index f605e452ec2..8450e383277 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.h
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject QuantitativeInvisibilityUP1D_Type;
#define BPy_QuantitativeInvisibilityUP1D_Check(v) \
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.h
index 9e018d606d3..2cea311ce20 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.h
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject ShapeUP1D_Type;
#define BPy_ShapeUP1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&ShapeUP1D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.h
index 26c32da3db6..69467ee1733 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.h
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject TrueUP1D_Type;
#define BPy_TrueUP1D_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&TrueUP1D_Type))
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_WithinImageBoundaryUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_WithinImageBoundaryUP1D.h
index 430864c3966..696f5d3063c 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_WithinImageBoundaryUP1D.h
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_WithinImageBoundaryUP1D.h
@@ -33,8 +33,6 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-#include <Python.h>
-
extern PyTypeObject WithinImageBoundaryUP1D_Type;
#define BPy_WithinImageBoundaryUP1D_Check(v) \
diff --git a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h
index 1ffddc9b24d..d3a10aab4dd 100644
--- a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h
+++ b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h
@@ -38,7 +38,7 @@
namespace Freestyle {
-class LIB_SCENE_GRAPH_EXPORT IndexedFaceSet : public Rep
+class IndexedFaceSet : public Rep
{
public:
/*! Triangles description style:*/
diff --git a/source/blender/freestyle/intern/scene_graph/LineRep.h b/source/blender/freestyle/intern/scene_graph/LineRep.h
index 6452e1260ad..6d1ac2825c0 100644
--- a/source/blender/freestyle/intern/scene_graph/LineRep.h
+++ b/source/blender/freestyle/intern/scene_graph/LineRep.h
@@ -40,7 +40,7 @@ using namespace std;
namespace Freestyle {
/*! Base class for all lines objects */
-class LIB_SCENE_GRAPH_EXPORT LineRep : public Rep
+class LineRep : public Rep
{
public:
/*! Line description style */
diff --git a/source/blender/freestyle/intern/scene_graph/Node.h b/source/blender/freestyle/intern/scene_graph/Node.h
index ba8549f5128..546458bad48 100644
--- a/source/blender/freestyle/intern/scene_graph/Node.h
+++ b/source/blender/freestyle/intern/scene_graph/Node.h
@@ -43,7 +43,7 @@ namespace Freestyle {
using namespace Geometry;
-class LIB_SCENE_GRAPH_EXPORT Node : public BaseObject
+class Node : public BaseObject
{
public:
inline Node() : BaseObject() {}
diff --git a/source/blender/freestyle/intern/scene_graph/NodeCamera.h b/source/blender/freestyle/intern/scene_graph/NodeCamera.h
index ee630e91884..5d84a624830 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeCamera.h
+++ b/source/blender/freestyle/intern/scene_graph/NodeCamera.h
@@ -42,7 +42,7 @@ class NodeOrthographicCamera;
class NodePerspectiveCamera;
-class LIB_SCENE_GRAPH_EXPORT NodeCamera : public Node
+class NodeCamera : public Node
{
public:
typedef enum {
@@ -90,7 +90,7 @@ protected:
};
-class LIB_SCENE_GRAPH_EXPORT NodeOrthographicCamera : public NodeCamera
+class NodeOrthographicCamera : public NodeCamera
{
public:
NodeOrthographicCamera();
@@ -157,7 +157,7 @@ private:
};
-class LIB_SCENE_GRAPH_EXPORT NodePerspectiveCamera : public NodeCamera
+class NodePerspectiveCamera : public NodeCamera
{
public:
NodePerspectiveCamera();
diff --git a/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h b/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h
index d3329693a06..d053d67c6ba 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h
+++ b/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h
@@ -35,7 +35,7 @@
namespace Freestyle {
-class LIB_SCENE_GRAPH_EXPORT NodeDrawingStyle : public NodeGroup
+class NodeDrawingStyle : public NodeGroup
{
public:
inline NodeDrawingStyle() : NodeGroup() {}
diff --git a/source/blender/freestyle/intern/scene_graph/NodeGroup.h b/source/blender/freestyle/intern/scene_graph/NodeGroup.h
index 8123639e01f..69c8a2c8f3b 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeGroup.h
+++ b/source/blender/freestyle/intern/scene_graph/NodeGroup.h
@@ -39,7 +39,7 @@ using namespace std;
namespace Freestyle {
-class LIB_SCENE_GRAPH_EXPORT NodeGroup : public Node
+class NodeGroup : public Node
{
public:
inline NodeGroup(): Node() {}
diff --git a/source/blender/freestyle/intern/scene_graph/NodeLight.h b/source/blender/freestyle/intern/scene_graph/NodeLight.h
index 25e13a768ec..c633a6bc7b8 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeLight.h
+++ b/source/blender/freestyle/intern/scene_graph/NodeLight.h
@@ -38,7 +38,7 @@ namespace Freestyle {
using namespace Geometry;
-class LIB_SCENE_GRAPH_EXPORT NodeLight : public Node
+class NodeLight : public Node
{
public:
NodeLight();
diff --git a/source/blender/freestyle/intern/scene_graph/NodeShape.h b/source/blender/freestyle/intern/scene_graph/NodeShape.h
index 3b4491f8b6d..351ccb8f743 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeShape.h
+++ b/source/blender/freestyle/intern/scene_graph/NodeShape.h
@@ -45,7 +45,7 @@ namespace Freestyle {
using namespace Geometry;
-class LIB_SCENE_GRAPH_EXPORT NodeShape : public Node
+class NodeShape : public Node
{
public:
inline NodeShape() : Node() {}
diff --git a/source/blender/freestyle/intern/scene_graph/NodeTransform.cpp b/source/blender/freestyle/intern/scene_graph/NodeTransform.cpp
index 5d26e85195f..8a25fe142d1 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeTransform.cpp
+++ b/source/blender/freestyle/intern/scene_graph/NodeTransform.cpp
@@ -28,7 +28,7 @@
#include "NodeTransform.h"
-#include "../system/FreestyleConfig.h"
+#include "BLI_math.h"
namespace Freestyle {
diff --git a/source/blender/freestyle/intern/scene_graph/NodeTransform.h b/source/blender/freestyle/intern/scene_graph/NodeTransform.h
index 544075998a4..c4de08ac4a7 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeTransform.h
+++ b/source/blender/freestyle/intern/scene_graph/NodeTransform.h
@@ -39,7 +39,7 @@ namespace Freestyle {
using namespace Geometry;
-class LIB_SCENE_GRAPH_EXPORT NodeTransform : public NodeGroup
+class NodeTransform : public NodeGroup
{
public:
inline NodeTransform() : NodeGroup()
diff --git a/source/blender/freestyle/intern/scene_graph/OrientedLineRep.h b/source/blender/freestyle/intern/scene_graph/OrientedLineRep.h
index 7272d47892a..8fafe72ac51 100644
--- a/source/blender/freestyle/intern/scene_graph/OrientedLineRep.h
+++ b/source/blender/freestyle/intern/scene_graph/OrientedLineRep.h
@@ -34,7 +34,7 @@
namespace Freestyle {
-class LIB_SCENE_GRAPH_EXPORT OrientedLineRep : public LineRep
+class OrientedLineRep : public LineRep
{
public:
OrientedLineRep() : LineRep() {}
diff --git a/source/blender/freestyle/intern/scene_graph/Rep.h b/source/blender/freestyle/intern/scene_graph/Rep.h
index 92624199c40..88ee0d2a801 100644
--- a/source/blender/freestyle/intern/scene_graph/Rep.h
+++ b/source/blender/freestyle/intern/scene_graph/Rep.h
@@ -42,7 +42,7 @@ namespace Freestyle {
using namespace Geometry;
-class LIB_SCENE_GRAPH_EXPORT Rep : public BaseObject
+class Rep : public BaseObject
{
public:
inline Rep() : BaseObject()
diff --git a/source/blender/freestyle/intern/scene_graph/SceneVisitor.h b/source/blender/freestyle/intern/scene_graph/SceneVisitor.h
index d3870fe835d..c00f5124a31 100644
--- a/source/blender/freestyle/intern/scene_graph/SceneVisitor.h
+++ b/source/blender/freestyle/intern/scene_graph/SceneVisitor.h
@@ -66,7 +66,7 @@ class IndexedFaceSet;
class DrawingStyle;
class FrsMaterial;
-class LIB_SCENE_GRAPH_EXPORT SceneVisitor
+class SceneVisitor
{
public:
SceneVisitor() {}
diff --git a/source/blender/freestyle/intern/scene_graph/TriangleRep.h b/source/blender/freestyle/intern/scene_graph/TriangleRep.h
index d204d128de4..d101cfd7988 100644
--- a/source/blender/freestyle/intern/scene_graph/TriangleRep.h
+++ b/source/blender/freestyle/intern/scene_graph/TriangleRep.h
@@ -34,7 +34,7 @@
namespace Freestyle {
/*! Base class for all lines objects */
-class LIB_SCENE_GRAPH_EXPORT TriangleRep : public Rep
+class TriangleRep : public Rep
{
public:
/*! Line description style */
diff --git a/source/blender/freestyle/intern/scene_graph/VertexRep.h b/source/blender/freestyle/intern/scene_graph/VertexRep.h
index 1f1284fe163..87420429e00 100644
--- a/source/blender/freestyle/intern/scene_graph/VertexRep.h
+++ b/source/blender/freestyle/intern/scene_graph/VertexRep.h
@@ -32,7 +32,7 @@
namespace Freestyle {
-class LIB_SCENE_GRAPH_EXPORT VertexRep : public Rep
+class VertexRep : public Rep
{
public:
inline VertexRep() : Rep()
diff --git a/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.h b/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.h
index f8204fb2c1c..48d5cd4803e 100644
--- a/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.h
+++ b/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.h
@@ -48,7 +48,7 @@ namespace Functions0D {
* This density is evaluated using a pixels square window around the evaluation point and integrating
* these values using a gaussian.
*/
-class LIB_STROKE_EXPORT DensityF0D : public UnaryFunction0D<double>
+class DensityF0D : public UnaryFunction0D<double>
{
public:
/*! Builds the functor from the gaussian sigma value.
@@ -78,7 +78,7 @@ private:
/*! Returns the average depth around a point.
* The result is obtained by querying the depth buffer on a window around that point.
*/
-class LIB_STROKE_EXPORT LocalAverageDepthF0D : public UnaryFunction0D<double>
+class LocalAverageDepthF0D : public UnaryFunction0D<double>
{
private:
GaussianFilter _filter;
@@ -102,7 +102,7 @@ public:
// ReadMapPixel
/*! Reads a pixel in a map. */
-class LIB_STROKE_EXPORT ReadMapPixelF0D : public UnaryFunction0D<float>
+class ReadMapPixelF0D : public UnaryFunction0D<float>
{
private:
const char * _mapName;
@@ -134,7 +134,7 @@ public:
// ReadSteerableViewMapPixel
/*! Reads a pixel in one of the level of one of the steerable viewmaps. */
-class LIB_STROKE_EXPORT ReadSteerableViewMapPixelF0D : public UnaryFunction0D<float>
+class ReadSteerableViewMapPixelF0D : public UnaryFunction0D<float>
{
private:
unsigned _orientation;
@@ -165,7 +165,7 @@ public:
// ReadCompleteViewMapPixel
/*! Reads a pixel in one of the level of the complete viewmap. */
-class LIB_STROKE_EXPORT ReadCompleteViewMapPixelF0D : public UnaryFunction0D<float>
+class ReadCompleteViewMapPixelF0D : public UnaryFunction0D<float>
{
private:
int _level;
@@ -192,7 +192,7 @@ public:
// GetViewMapGradientNormF0D
/*! Returns the norm of the gradient of the global viewmap density image. */
-class LIB_STROKE_EXPORT GetViewMapGradientNormF0D: public UnaryFunction0D< float>
+class GetViewMapGradientNormF0D: public UnaryFunction0D< float>
{
private:
int _level;
diff --git a/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.h b/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.h
index f58acf02d48..cbdff4ed96c 100644
--- a/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.h
+++ b/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.h
@@ -130,7 +130,7 @@ private:
* The density is evaluated for a set of points along the Interface1D (using the ReadCompleteViewMapPixelF0D functor)
* and then integrated into a single value using a user-defined integration method.
*/
-class LIB_STROKE_EXPORT GetCompleteViewMapDensityF1D : public UnaryFunction1D<double>
+class GetCompleteViewMapDensityF1D : public UnaryFunction1D<double>
{
public:
/*! Builds the functor.
@@ -172,7 +172,7 @@ private:
* The density is evaluated for a set of points along the Interface1D (using the ReadSteerableViewMapPixelF0D functor)
* and then integrated into a single value using a user-defined integration method.
*/
-class LIB_STROKE_EXPORT GetDirectionalViewMapDensityF1D : public UnaryFunction1D<double>
+class GetDirectionalViewMapDensityF1D : public UnaryFunction1D<double>
{
public:
/*! Builds the functor.
@@ -212,7 +212,7 @@ private:
/*! Returns the density of the viewmap for a given Interface1D. The density of each FEdge is evaluated
* in the proper steerable ViewMap depending on its oorientation.
*/
-class LIB_STROKE_EXPORT GetSteerableViewMapDensityF1D : public UnaryFunction1D<double>
+class GetSteerableViewMapDensityF1D : public UnaryFunction1D<double>
{
private:
int _level;
@@ -253,7 +253,7 @@ public:
/*! Returns the density of the viewmap for a given Interface1D. The density of each FEdge is evaluated in
* the proper steerable ViewMap depending on its oorientation.
*/
-class LIB_STROKE_EXPORT GetViewMapGradientNormF1D : public UnaryFunction1D<double>
+class GetViewMapGradientNormF1D : public UnaryFunction1D<double>
{
private:
int _level;
diff --git a/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp b/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp
index d30a75d9e14..274e36a4c9b 100644
--- a/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp
+++ b/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp
@@ -301,7 +301,7 @@ void Smoother::computeCurvature()
_curvature[i] = normalCurvature * _normal[i];
if (lba + lbc > M_EPSILON)
- _curvature[i] /= (0.5 * lba + lbc);
+ _curvature[i] /= (0.5 * lba + lbc);
}
_curvature[0] = _curvature[1];
_curvature[_nbVertices - 1] = _curvature[_nbVertices - 2];
@@ -325,7 +325,7 @@ void Smoother::computeCurvature()
_curvature[i] = normalCurvature * _normal[i];
if (lba + lbc > M_EPSILON)
- _curvature[i] /= (0.5 * lba + lbc);
+ _curvature[i] /= (0.5 * lba + lbc);
_normal[_nbVertices - 1] = _normal[0];
_curvature[_nbVertices - 1] = _curvature[0];
diff --git a/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h b/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h
index 18472ff2c2a..a9ef49aa802 100644
--- a/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h
+++ b/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h
@@ -37,7 +37,7 @@ namespace Freestyle {
* i.e. The stroke will be the thickest in a main direction, the thinest in the direction perpendicular to this one,
* and an interpolation inbetween.
*/
-class LIB_STROKE_EXPORT CalligraphicShader : public StrokeShader
+class CalligraphicShader : public StrokeShader
{
public:
/*! Builds the shader.
@@ -70,7 +70,7 @@ protected:
* Moves the vertices to make the stroke more noisy.
* @see \htmlonly <a href=noise/noise.html>noise/noise.html</a> \endhtmlonly
*/
-class LIB_STROKE_EXPORT SpatialNoiseShader : public StrokeShader
+class SpatialNoiseShader : public StrokeShader
{
public:
/*! Builds the shader.
@@ -108,7 +108,7 @@ protected:
* to prevent the diffusion accross corners.
* @see \htmlonly <a href=/smoothing/smoothing.html>smoothing/smoothing.html</a> \endhtmlonly
*/
-class LIB_STROKE_EXPORT SmoothingShader : public StrokeShader
+class SmoothingShader : public StrokeShader
{
public:
/*! Builds the shader.
@@ -149,7 +149,7 @@ protected:
real _carricatureFactor;
};
-class LIB_STROKE_EXPORT Smoother
+class Smoother
{
public:
Smoother(Stroke &ioStroke);
@@ -184,7 +184,7 @@ protected:
bool _safeTest;
};
-class LIB_STROKE_EXPORT Omitter : public Smoother
+class Omitter : public Smoother
{
public:
Omitter(Stroke &ioStroke);
@@ -203,7 +203,7 @@ protected:
};
/*! Omission shader */
-class LIB_STROKE_EXPORT OmissionShader : public StrokeShader
+class OmissionShader : public StrokeShader
{
public:
OmissionShader(real sizeWindow, real thrVari, real thrFlat, real lFlat);
diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
index af3b7f09c31..e92913d097e 100644
--- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
+++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
@@ -449,90 +449,27 @@ int ColorNoiseShader::shade(Stroke& stroke) const
//
///////////////////////////////////////////////////////////////////////////////
-int TextureAssignerShader::shade(Stroke& stroke) const
+int BlenderTextureShader::shade(Stroke& stroke) const
{
-#if 0
- getBrushTextureIndex(TEXTURES_DIR "/brushes/charcoalAlpha.bmp", Stroke::HUMID_MEDIUM);
- getBrushTextureIndex(TEXTURES_DIR "/brushes/washbrushAlpha.bmp", Stroke::HUMID_MEDIUM);
- getBrushTextureIndex(TEXTURES_DIR "/brushes/oil.bmp", Stroke::HUMID_MEDIUM);
- getBrushTextureIndex(TEXTURES_DIR "/brushes/oilnoblend.bmp", Stroke::HUMID_MEDIUM);
- getBrushTextureIndex(TEXTURES_DIR "/brushes/charcoalAlpha.bmp", Stroke::DRY_MEDIUM);
- getBrushTextureIndex(TEXTURES_DIR "/brushes/washbrushAlpha.bmp", Stroke::DRY_MEDIUM);
- getBrushTextureIndex(TEXTURES_DIR "/brushes/opaqueDryBrushAlpha.bmp", Stroke::OPAQUE_MEDIUM);
- getBrushTextureIndex(TEXTURES_DIR "/brushes/opaqueBrushAlpha.bmp", Stroke::OPAQUE_MEDIUM);
-#endif
+ return stroke.setMTex(_mtex);
+}
- TextureManager *instance = TextureManager::getInstance();
- if (!instance)
- return 0;
- string pathname;
- Stroke::MediumType mediumType;
- bool hasTips = false;
- switch (_textureId) {
- case 0:
- //pathname = TextureManager::Options::getBrushesPath() + "/charcoalAlpha.bmp";
- pathname = "/charcoalAlpha.bmp";
- mediumType = Stroke::HUMID_MEDIUM;
- hasTips = false;
- break;
- case 1:
- pathname = "/washbrushAlpha.bmp";
- mediumType = Stroke::HUMID_MEDIUM;
- hasTips = true;
- break;
- case 2:
- pathname = "/oil.bmp";
- mediumType = Stroke::HUMID_MEDIUM;
- hasTips = true;
- break;
- case 3:
- pathname = "/oilnoblend.bmp";
- mediumType = Stroke::HUMID_MEDIUM;
- hasTips = true;
- break;
- case 4:
- pathname = "/charcoalAlpha.bmp";
- mediumType = Stroke::DRY_MEDIUM;
- hasTips = false;
- break;
- case 5:
- mediumType = Stroke::DRY_MEDIUM;
- hasTips = true;
- break;
- case 6:
- pathname = "/opaqueDryBrushAlpha.bmp";
- mediumType = Stroke::OPAQUE_MEDIUM;
- hasTips = true;
- break;
- case 7:
- pathname = "/opaqueBrushAlpha.bmp";
- mediumType = Stroke::OPAQUE_MEDIUM;
- hasTips = true;
- break;
- default:
- pathname = "/smoothAlpha.bmp";
- mediumType = Stroke::OPAQUE_MEDIUM;
- hasTips = false;
- break;
- }
- unsigned int texId = instance->getBrushTextureIndex(pathname, mediumType);
- stroke.setMediumType(mediumType);
- stroke.setTips(hasTips);
- stroke.setTextureId(texId);
+int StrokeTextureStepShader::shade(Stroke& stroke) const
+{
+ stroke.setTextureStep(_step);
+ return 0;
+}
+
+// Legacy shaders from freestyle standalone texture system
+int TextureAssignerShader::shade(Stroke& stroke) const
+{
+ cout << "TextureAssignerShader is not supported in blender, please use the BlenderTextureShader" << endl;
return 0;
}
-// FIXME
int StrokeTextureShader::shade(Stroke& stroke) const
{
- TextureManager *instance = TextureManager::getInstance();
- if (!instance)
- return 0;
- string pathname = TextureManager::Options::getBrushesPath() + "/" + _texturePath;
- unsigned int texId = instance->getBrushTextureIndex(pathname, _mediumType);
- stroke.setMediumType(_mediumType);
- stroke.setTips(_tips);
- stroke.setTextureId(texId);
+ cout << "StrokeTextureShader is not supported in blender, please use the BlenderTextureShader" << endl;
return 0;
}
@@ -841,7 +778,7 @@ int BezierCurveShader::shade(Stroke& stroke) const
if (it.isEnd()) {
// XXX Shocking! :P Shouldn't we break in this case???
if (G.debug & G_DEBUG_FREESTYLE) {
- cout << "fucked up" << endl;
+ cout << "messed up!" << endl;
}
}
}
diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
index d55a689def4..9186d164e9b 100644
--- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
+++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
@@ -36,6 +36,8 @@
#include "../geometry/Bezier.h"
#include "../geometry/Geom.h"
+struct MTex;
+
using namespace std;
namespace Freestyle {
@@ -52,7 +54,7 @@ namespace StrokeShaders {
/*! [ Thickness Shader ].
* Assigns an absolute constant thickness to every vertices of the Stroke.
*/
-class LIB_STROKE_EXPORT ConstantThicknessShader : public StrokeShader
+class ConstantThicknessShader : public StrokeShader
{
public:
/*! Builds the shader.
@@ -85,7 +87,7 @@ private:
* is its thickness from the point to the strip border in the direction pointing outside the object the
* Stroke delimitates.
*/
-class LIB_STROKE_EXPORT ConstantExternThicknessShader : public StrokeShader
+class ConstantExternThicknessShader : public StrokeShader
{
public:
ConstantExternThicknessShader(float thickness) : StrokeShader()
@@ -112,7 +114,7 @@ private:
* and the last vertex.
* The thickness is linearly interpolated from A to B.
*/
-class LIB_STROKE_EXPORT IncreasingThicknessShader : public StrokeShader
+class IncreasingThicknessShader : public StrokeShader
{
public:
/*! Builds the shader.
@@ -147,7 +149,7 @@ private:
* Same as previous but here we allow the user to control the ratio thickness/length so that we don't get
* fat short lines
*/
-class LIB_STROKE_EXPORT ConstrainedIncreasingThicknessShader : public StrokeShader
+class ConstrainedIncreasingThicknessShader : public StrokeShader
{
private:
float _ThicknessMin;
@@ -185,7 +187,7 @@ public:
/* [ Thickness Shader ].
* Modifys the thickness in a relative way depending on its length.
*/
-class LIB_STROKE_EXPORT LengthDependingThicknessShader : public StrokeShader
+class LengthDependingThicknessShader : public StrokeShader
{
private:
float _minThickness;
@@ -218,7 +220,7 @@ public:
* The new thicknesses are the result of the multiplication
* of the pattern and the original thickness
*/
-class LIB_STROKE_EXPORT ThicknessVariationPatternShader : public StrokeShader
+class ThicknessVariationPatternShader : public StrokeShader
{
public:
/*! Builds the shader.
@@ -263,7 +265,7 @@ private:
* Adds some noise to the stroke thickness.
* \see \htmlonly <a href=noise/noise.html>noise/noise.html</a>\endhtmlonly
*/
-class LIB_STROKE_EXPORT ThicknessNoiseShader : public StrokeShader
+class ThicknessNoiseShader : public StrokeShader
{
private:
float _amplitude;
@@ -297,7 +299,7 @@ public:
/*! [ Color Shader ].
* Assigns a constant color to every vertices of the Stroke.
*/
-class LIB_STROKE_EXPORT ConstantColorShader : public StrokeShader
+class ConstantColorShader : public StrokeShader
{
public:
/*! Builds the shader from a user-specified color.
@@ -335,7 +337,7 @@ private:
* The user specifies 2 colors A and B. The stroke color will change linearly from A to B between the
* first and the last vertex.
*/
-class LIB_STROKE_EXPORT IncreasingColorShader : public StrokeShader
+class IncreasingColorShader : public StrokeShader
{
private:
float _colorMin[4];
@@ -388,7 +390,7 @@ public:
* Applys a pattern to vary original color.
* The new color is the result of the multiplication of the pattern and the original color
*/
-class LIB_STROKE_EXPORT ColorVariationPatternShader : public StrokeShader
+class ColorVariationPatternShader : public StrokeShader
{
public:
/*! Builds the shader from the pattern texture file name.
@@ -425,7 +427,7 @@ private:
/* [ Color Shader ].
* Assigns a color to the stroke depending on the material of the shape to which ot belongs to. (Disney shader)
*/
-class LIB_STROKE_EXPORT MaterialColorShader : public StrokeShader
+class MaterialColorShader : public StrokeShader
{
private:
float _coefficient;
@@ -444,7 +446,7 @@ public:
virtual int shade(Stroke& stroke) const;
};
-class LIB_STROKE_EXPORT CalligraphicColorShader : public StrokeShader
+class CalligraphicColorShader : public StrokeShader
{
private:
/* UNUSED */
@@ -469,7 +471,7 @@ public:
/*! [ Color Shader ].
* Shader to add noise to the stroke colors.
*/
-class LIB_STROKE_EXPORT ColorNoiseShader : public StrokeShader
+class ColorNoiseShader : public StrokeShader
{
private:
float _amplitude;
@@ -516,7 +518,7 @@ public:
* Any other value will lead to the following preset:
* default) -> /brushes/smoothAlpha.bmp, OPAQUE_MEDIUM.
*/
-class LIB_STROKE_EXPORT TextureAssignerShader : public StrokeShader // FIXME
+class TextureAssignerShader : public StrokeShader // FIXME
{
private:
int _textureId;
@@ -544,7 +546,7 @@ public:
* Assigns a texture and a blending mode to the stroke
* in order to simulate its marks system.
*/
-class LIB_STROKE_EXPORT StrokeTextureShader : public StrokeShader
+class StrokeTextureShader : public StrokeShader
{
private:
string _texturePath;
@@ -601,7 +603,7 @@ public:
/*! [ Geometry Shader ].
* Stretches the stroke at its two extremities and following the respective directions: v(1)v(0) and v(n-1)v(n).
*/
-class LIB_STROKE_EXPORT BackboneStretcherShader : public StrokeShader
+class BackboneStretcherShader : public StrokeShader
{
private:
float _amount;
@@ -629,7 +631,7 @@ public:
* Resamples the stroke.
* @see Stroke::Resample(float).
*/
-class LIB_STROKE_EXPORT SamplingShader: public StrokeShader
+class SamplingShader: public StrokeShader
{
private:
float _sampling;
@@ -654,7 +656,7 @@ public:
};
-class LIB_STROKE_EXPORT ExternalContourStretcherShader : public StrokeShader
+class ExternalContourStretcherShader : public StrokeShader
{
private:
float _amount;
@@ -674,7 +676,7 @@ public:
};
// B-Spline stroke shader
-class LIB_STROKE_EXPORT BSplineShader: public StrokeShader
+class BSplineShader: public StrokeShader
{
public:
BSplineShader() : StrokeShader() {}
@@ -694,7 +696,7 @@ public:
* original backbone geometry.
* @see \htmlonly <a href=bezier/bezier.html>bezier/bezier.html</a> \endhtmlonly
*/
-class LIB_STROKE_EXPORT BezierCurveShader : public StrokeShader
+class BezierCurveShader : public StrokeShader
{
private:
float _error;
@@ -723,7 +725,7 @@ public:
* The displacement value is proportional to the 2d curvature at the considered point (the higher the curvature,
* the smaller the displacement) and to a value specified by the user.
*/
-class LIB_STROKE_EXPORT InflateShader : public StrokeShader
+class InflateShader : public StrokeShader
{
private:
float _amount;
@@ -756,7 +758,7 @@ public:
* The basic idea is to start from the minimal stroke approximation consisting in a line joining the first vertex
* to the last one and to subdivide using the original stroke vertices until a certain error is reached.
*/
-class LIB_STROKE_EXPORT PolygonalizationShader : public StrokeShader
+class PolygonalizationShader : public StrokeShader
{
private:
float _error;
@@ -789,7 +791,7 @@ public:
* Indeed, the precision of the approximation will depend on the size of the stroke's pieces.
* The bigger the pieces, the rougher the approximation.
*/
-class LIB_STROKE_EXPORT GuidingLinesShader : public StrokeShader
+class GuidingLinesShader : public StrokeShader
{
private:
float _offset;
@@ -817,7 +819,7 @@ public:
/*! [ Geometry Shader ].
* Removes the stroke's extremities.
*/
-class LIB_STROKE_EXPORT TipRemoverShader : public StrokeShader
+class TipRemoverShader : public StrokeShader
{
public:
/*! Builds the shader.
@@ -844,7 +846,7 @@ protected:
/*! [ output Shader ].
* streams the Stroke
*/
-class LIB_STROKE_EXPORT streamShader : public StrokeShader
+class streamShader : public StrokeShader
{
public:
/*! Destructor. */
@@ -863,7 +865,7 @@ public:
/*! [ output Shader ].
* streams the Stroke in a file
*/
-class LIB_STROKE_EXPORT fstreamShader : public StrokeShader
+class fstreamShader : public StrokeShader
{
protected:
mutable ofstream _stream;
@@ -894,6 +896,62 @@ public:
virtual int shade(Stroke& stroke) const;
};
+/*! [ Texture Shader ].
+ * Shader to assign texture to the Stroke material.
+ */
+
+class BlenderTextureShader : public StrokeShader
+{
+private:
+ MTex *_mtex;
+
+public:
+ /*! Builds the shader.
+ * \param mtex
+ * The blender texture to use.
+ */
+ BlenderTextureShader(MTex *mtex) : StrokeShader()
+ {
+ _mtex = mtex;
+ }
+
+ virtual string getName() const
+ {
+ return "BlenderTextureShader";
+ }
+
+ /*! The shading method */
+ virtual int shade(Stroke& stroke) const;
+};
+
+/*! [ Texture Shader ].
+ * Shader to assign texture to the Stroke material.
+ */
+
+class StrokeTextureStepShader : public StrokeShader
+{
+private:
+ float _step;
+
+public:
+ /*! Builds the shader.
+ * \param id
+ * The number of the preset to use.
+ */
+ StrokeTextureStepShader(float step) : StrokeShader()
+ {
+ _step = step;
+ }
+
+ virtual string getName() const
+ {
+ return "StrokeTextureStepShader";
+ }
+
+ /*! The shading method */
+ virtual int shade(Stroke& stroke) const;
+};
+
} // end of namespace StrokeShaders
} /* namespace Freestyle */
diff --git a/source/blender/freestyle/intern/stroke/Canvas.cpp b/source/blender/freestyle/intern/stroke/Canvas.cpp
index 09c8d9ed74e..69d37f61df9 100644
--- a/source/blender/freestyle/intern/stroke/Canvas.cpp
+++ b/source/blender/freestyle/intern/stroke/Canvas.cpp
@@ -56,10 +56,8 @@ using namespace std;
namespace Freestyle {
-LIB_STROKE_EXPORT
Canvas *Canvas::_pInstance = 0;
-LIB_STROKE_EXPORT
const char *Canvas::_MapsPath = 0;
Canvas::Canvas()
diff --git a/source/blender/freestyle/intern/stroke/Canvas.h b/source/blender/freestyle/intern/stroke/Canvas.h
index 038b4b3af0f..b56b5f92c14 100644
--- a/source/blender/freestyle/intern/stroke/Canvas.h
+++ b/source/blender/freestyle/intern/stroke/Canvas.h
@@ -71,7 +71,7 @@ class StyleModule;
/*! Class to define the canvas on which strokes are drawn.
* It's used to store state information about the drawing.
*/
-class LIB_STROKE_EXPORT Canvas
+class Canvas
{
public:
/*! Returns a pointer on the Canvas instance */
diff --git a/source/blender/freestyle/intern/stroke/Chain.cpp b/source/blender/freestyle/intern/stroke/Chain.cpp
index c09ccbd393a..7fd756472b0 100644
--- a/source/blender/freestyle/intern/stroke/Chain.cpp
+++ b/source/blender/freestyle/intern/stroke/Chain.cpp
@@ -27,8 +27,8 @@
#include "Chain.h"
-#include "../view_map/ViewMapAdvancedIterators.h"
#include "../view_map/ViewMapIterators.h"
+#include "../view_map/ViewMapAdvancedIterators.h"
namespace Freestyle {
diff --git a/source/blender/freestyle/intern/stroke/ChainingIterators.cpp b/source/blender/freestyle/intern/stroke/ChainingIterators.cpp
index 66575fd8fc2..84d770a96cd 100644
--- a/source/blender/freestyle/intern/stroke/ChainingIterators.cpp
+++ b/source/blender/freestyle/intern/stroke/ChainingIterators.cpp
@@ -25,6 +25,8 @@
* \date 01/07/2003
*/
+#include "../python/Director.h"
+
#include "ChainingIterators.h"
#include "../system/TimeStamp.h"
@@ -62,6 +64,16 @@ bool AdjacencyIterator::isValid(ViewEdge *edge)
return true;
}
+int ChainingIterator::init()
+{
+ return Director_BPy_ChainingIterator_init(this);
+}
+
+int ChainingIterator::traverse(const AdjacencyIterator &it)
+{
+ return Director_BPy_ChainingIterator_traverse(this, const_cast<AdjacencyIterator &>(it));
+}
+
int ChainingIterator::increment()
{
_increment = true;
@@ -152,7 +164,7 @@ int ChainSilhouetteIterator::traverse(const AdjacencyIterator& ait)
Nature::RIDGE
};
int numNatures = sizeof(natures) / sizeof(Nature::EdgeNature);
- for (unsigned int i = 0; i < numNatures; ++i) {
+ for (int i = 0; i < numNatures; ++i) {
if (getCurrentEdge()->getNature() & natures[i]) {
int n = 0;
while (!it.isEnd()) {
diff --git a/source/blender/freestyle/intern/stroke/ChainingIterators.h b/source/blender/freestyle/intern/stroke/ChainingIterators.h
index 8d01cea84e7..5d05ed2776d 100644
--- a/source/blender/freestyle/intern/stroke/ChainingIterators.h
+++ b/source/blender/freestyle/intern/stroke/ChainingIterators.h
@@ -32,9 +32,7 @@
#include "Predicates1D.h"
-#include "../python/Director.h"
-
-#include "../system/Iterator.h" //soc
+#include "../system/Iterator.h"
#include "../view_map/ViewMap.h"
#include "../view_map/ViewMapIterators.h"
@@ -48,7 +46,7 @@ namespace Freestyle {
// Adjacency iterator used in the chaining process
//
///////////////////////////////////////////////////////////
-class LIB_STROKE_EXPORT AdjacencyIterator : public Iterator
+class AdjacencyIterator : public Iterator
{
protected:
ViewVertexInternal::orientedViewEdgeIterator _internalIterator;
@@ -152,7 +150,7 @@ protected:
* If you specify restriction rules (such as "Chain only ViewEdges of the selection"), they will be included
* in the adjacency iterator. (i.e, the adjacent iterator will only stop on "valid" edges).
*/
-class LIB_STROKE_EXPORT ChainingIterator : public ViewEdgeInternal::ViewEdgeIterator
+class ChainingIterator : public ViewEdgeInternal::ViewEdgeIterator
{
protected:
bool _restrictToSelection;
@@ -161,7 +159,7 @@ protected:
public:
ViewEdge *result;
- PyObject *py_c_it;
+ void *py_c_it;
/*! Builds a Chaining Iterator from the first ViewEdge used for iteration and its orientation.
* \param iRestrictToSelection
@@ -203,10 +201,7 @@ public:
* This method is called each time a new chain is started.
* It can be used to reset some history information that you might want to keep.
*/
- virtual int init()
- {
- return Director_BPy_ChainingIterator_init(this);
- }
+ virtual int init();
/*! This method iterates over the potential next ViewEdges and returns the one that will be followed next.
* returns the next ViewEdge to follow or 0 when the end of the chain is reached.
@@ -214,10 +209,7 @@ public:
* The iterator over the ViewEdges adjacent to the end vertex of the current ViewEdge.
* The Adjacency iterator reflects the restriction rules by only iterating over the valid ViewEdges.
*/
- virtual int traverse(const AdjacencyIterator &it)
- {
- return Director_BPy_ChainingIterator_traverse(this, const_cast<AdjacencyIterator &>(it));
- }
+ virtual int traverse(const AdjacencyIterator &it);
/* accessors */
/*! Returns true if the orientation of the current ViewEdge corresponds to its natural orientation */
@@ -266,7 +258,7 @@ public:
* In the case of an iteration over a set of ViewEdge that are both Silhouette and Crease, there will be a precedence
* of the silhouette over the crease criterion.
*/
-class LIB_STROKE_EXPORT ChainSilhouetteIterator : public ChainingIterator
+class ChainSilhouetteIterator : public ChainingIterator
{
public:
/*! Builds a ChainSilhouetteIterator from the first ViewEdge used for iteration and its orientation.
@@ -317,7 +309,7 @@ public:
* selection. The first ViewEdge respecting both the unary predicate and the binary predicate is kept as the next one.
* If none of the potential next ViewEdge respects these 2 predicates, 0 is returned.
*/
-class LIB_STROKE_EXPORT ChainPredicateIterator : public ChainingIterator
+class ChainPredicateIterator : public ChainingIterator
{
protected:
BinaryPredicate1D *_binary_predicate; // the caller is responsible for the deletion of this object
diff --git a/source/blender/freestyle/intern/stroke/ContextFunctions.h b/source/blender/freestyle/intern/stroke/ContextFunctions.h
index 28ce918e919..d8b780e77a0 100644
--- a/source/blender/freestyle/intern/stroke/ContextFunctions.h
+++ b/source/blender/freestyle/intern/stroke/ContextFunctions.h
@@ -45,27 +45,22 @@ namespace ContextFunctions {
// GetTimeStamp
/*! Returns the system time stamp */
-LIB_STROKE_EXPORT
unsigned GetTimeStampCF();
// GetCanvasWidth
/*! Returns the canvas width */
-LIB_STROKE_EXPORT
unsigned GetCanvasWidthCF();
// GetCanvasHeight
/*! Returns the canvas height */
-LIB_STROKE_EXPORT
unsigned GetCanvasHeightCF();
// GetBorder
/*! Returns the border */
-LIB_STROKE_EXPORT
BBox<Vec2i> GetBorderCF();
// Load map
/*! Loads an image map for further reading */
-LIB_STROKE_EXPORT
void LoadMapCF(const char *iFileName, const char *iMapName, unsigned iNbLevels = 4, float iSigma = 1.0f);
// ReadMapPixel
@@ -80,7 +75,6 @@ void LoadMapCF(const char *iFileName, const char *iMapName, unsigned iNbLevels =
* \param y
* The y-coordinate of the pixel we wish to read. The origin is in the lower-left corner.
*/
-LIB_STROKE_EXPORT
float ReadMapPixelCF(const char *iMapName, int level, unsigned x, unsigned y);
// ReadCompleteViewMapPixel
@@ -93,7 +87,6 @@ float ReadMapPixelCF(const char *iMapName, int level, unsigned x, unsigned y);
* \param y
* The y-coordinate of the pixel we wish to read. The origin is in the lower-left corner.
*/
-LIB_STROKE_EXPORT
float ReadCompleteViewMapPixelCF(int level, unsigned x, unsigned y);
// ReadOrientedViewMapPixel
@@ -108,11 +101,9 @@ float ReadCompleteViewMapPixelCF(int level, unsigned x, unsigned y);
* \param y
* The y-coordinate of the pixel we wish to read. The origin is in the lower-left corner.
*/
-LIB_STROKE_EXPORT
float ReadDirectionalViewMapPixelCF(int iOrientation, int level, unsigned x, unsigned y);
// DEBUG
-LIB_STROKE_EXPORT
FEdge *GetSelectedFEdgeCF();
} // end of namespace ContextFunctions
diff --git a/source/blender/freestyle/intern/stroke/Curve.cpp b/source/blender/freestyle/intern/stroke/Curve.cpp
index e5dc27a0c57..32cfac016d6 100644
--- a/source/blender/freestyle/intern/stroke/Curve.cpp
+++ b/source/blender/freestyle/intern/stroke/Curve.cpp
@@ -26,10 +26,11 @@
*/
#include "Curve.h"
-#include "CurveAdvancedIterators.h"
#include "CurveIterators.h"
+#include "CurveAdvancedIterators.h"
#include "BKE_global.h"
+#include "BLI_utildefines.h"
namespace Freestyle {
@@ -158,7 +159,7 @@ iA_B_eq_iB_A:
}
cerr << "Fatal error in CurvePoint::CurvePoint(CurvePoint *iA, CurvePoint *iB, float t3)" << endl;
}
- assert(__A != 0 && __B != 0);
+ BLI_assert(__A != 0 && __B != 0);
#if 0
_Point2d = __A->point2d() + _t2d * (__B->point2d() - __A->point2d());
diff --git a/source/blender/freestyle/intern/stroke/Curve.h b/source/blender/freestyle/intern/stroke/Curve.h
index fd4150c6c13..17b9a5c0a1f 100644
--- a/source/blender/freestyle/intern/stroke/Curve.h
+++ b/source/blender/freestyle/intern/stroke/Curve.h
@@ -66,7 +66,7 @@ using namespace Geometry;
* Thus, a CurvePoint is built by lineraly interpolating two SVertex.
* CurvePoint can be used as virtual points while querying 0D information along a curve at a given resolution.
*/
-class LIB_STROKE_EXPORT CurvePoint : public Interface0D
+class CurvePoint : public Interface0D
{
public: // Implementation of Interface0D
/*! Returns the string "CurvePoint"*/
@@ -365,7 +365,7 @@ class CurvePointIterator;
* SVertex is the type of the initial curve vertices.
* A Chain is a specialization of a Curve.
*/
-class LIB_STROKE_EXPORT Curve : public Interface1D
+class Curve : public Interface1D
{
public:
typedef CurvePoint Vertex;
diff --git a/source/blender/freestyle/intern/stroke/CurveIterators.h b/source/blender/freestyle/intern/stroke/CurveIterators.h
index f2272f2f9a9..ff7b2d04385 100644
--- a/source/blender/freestyle/intern/stroke/CurveIterators.h
+++ b/source/blender/freestyle/intern/stroke/CurveIterators.h
@@ -43,15 +43,15 @@ namespace CurveInternal {
class CurvePointIterator : public Interface0DIteratorNested
{
public:
- friend class ::Curve;
+ friend class Freestyle::Curve;
public:
float _CurvilinearLength;
float _step;
- ::Curve::vertex_container::iterator __A;
- ::Curve::vertex_container::iterator __B;
- ::Curve::vertex_container::iterator _begin;
- ::Curve::vertex_container::iterator _end;
+ Curve::vertex_container::iterator __A;
+ Curve::vertex_container::iterator __B;
+ Curve::vertex_container::iterator _begin;
+ Curve::vertex_container::iterator _end;
int _n;
int _currentn;
float _t;
@@ -104,8 +104,8 @@ public:
virtual ~CurvePointIterator() {}
protected:
- inline CurvePointIterator(::Curve::vertex_container::iterator iA, ::Curve::vertex_container::iterator iB,
- ::Curve::vertex_container::iterator ibegin, ::Curve::vertex_container::iterator iend,
+ inline CurvePointIterator(Curve::vertex_container::iterator iA, Curve::vertex_container::iterator iB,
+ Curve::vertex_container::iterator ibegin, Curve::vertex_container::iterator iend,
int currentn, int n, float iCurveLength, float step, float t = 0.0f,
float iCurvilinearLength = 0.0f)
: Interface0DIteratorNested()
diff --git a/source/blender/freestyle/intern/stroke/Operators.cpp b/source/blender/freestyle/intern/stroke/Operators.cpp
index eed3c913057..2e68aa0c1fa 100644
--- a/source/blender/freestyle/intern/stroke/Operators.cpp
+++ b/source/blender/freestyle/intern/stroke/Operators.cpp
@@ -38,10 +38,10 @@
namespace Freestyle {
-LIB_STROKE_EXPORT Operators::I1DContainer Operators::_current_view_edges_set;
-LIB_STROKE_EXPORT Operators::I1DContainer Operators::_current_chains_set;
-LIB_STROKE_EXPORT Operators::I1DContainer *Operators::_current_set = NULL;
-LIB_STROKE_EXPORT Operators::StrokesContainer Operators::_current_strokes_set;
+Operators::I1DContainer Operators::_current_view_edges_set;
+Operators::I1DContainer Operators::_current_chains_set;
+Operators::I1DContainer *Operators::_current_set = NULL;
+Operators::StrokesContainer Operators::_current_strokes_set;
int Operators::select(UnaryPredicate1D& pred)
{
diff --git a/source/blender/freestyle/intern/stroke/Operators.h b/source/blender/freestyle/intern/stroke/Operators.h
index dcd61b8ce84..59ebec57246 100644
--- a/source/blender/freestyle/intern/stroke/Operators.h
+++ b/source/blender/freestyle/intern/stroke/Operators.h
@@ -53,7 +53,7 @@ namespace Freestyle {
* There are 4 classes of operators: Selection, Chaining, Splitting and Creating. All these operators are
* user controlled in the scripting language through Functors, Predicates and Shaders that are taken as arguments.
*/
-class LIB_STROKE_EXPORT Operators {
+class Operators {
public:
typedef vector<Interface1D*> I1DContainer;
diff --git a/source/blender/freestyle/intern/stroke/PSStrokeRenderer.h b/source/blender/freestyle/intern/stroke/PSStrokeRenderer.h
index 7958fbb311b..c802bf4291a 100644
--- a/source/blender/freestyle/intern/stroke/PSStrokeRenderer.h
+++ b/source/blender/freestyle/intern/stroke/PSStrokeRenderer.h
@@ -44,7 +44,7 @@ namespace Freestyle {
/* */
/**********************************/
-class LIB_STROKE_EXPORT PSStrokeRenderer : public StrokeRenderer
+class PSStrokeRenderer : public StrokeRenderer
{
public:
PSStrokeRenderer(const char *iFileName = NULL);
diff --git a/source/blender/compositor/nodes/COM_SeparateYCCANode.h b/source/blender/freestyle/intern/stroke/Predicates0D.cpp
index 542e1693932..f189b2e38ea 100644
--- a/source/blender/compositor/nodes/COM_SeparateYCCANode.h
+++ b/source/blender/freestyle/intern/stroke/Predicates0D.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011, Blender Foundation.
+ * ***** 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
@@ -15,24 +15,27 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Dalai Felinto
+ * ***** END GPL LICENSE BLOCK *****
*/
-#ifndef _COM_SeparateYCCANode_h_
-#define _COM_SeparateYCCANode_h_
+/** \file blender/freestyle/intern/stroke/Predicates0D.cpp
+ * \ingroup freestyle
+ */
-#include "COM_Node.h"
-#include "DNA_node_types.h"
-#include "COM_SeparateRGBANode.h"
+#include "Predicates0D.h"
-/**
- * @brief SeparateYCCANode
- * @ingroup Node
- */
-class SeparateYCCANode : public SeparateRGBANode {
-public:
- SeparateYCCANode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
-};
-#endif
+#include "../python/Director.h"
+
+namespace Freestyle {
+
+int UnaryPredicate0D::operator()(Interface0DIterator& it)
+{
+ return Director_BPy_UnaryPredicate0D___call__(this, it);
+}
+
+int BinaryPredicate0D::operator()(Interface0D& inter1, Interface0D& inter2)
+{
+ return Director_BPy_BinaryPredicate0D___call__(this, inter1, inter2);
+}
+
+} /* namespace Freestyle */
diff --git a/source/blender/freestyle/intern/stroke/Predicates0D.h b/source/blender/freestyle/intern/stroke/Predicates0D.h
index a6e7cbee042..6ce77649c31 100644
--- a/source/blender/freestyle/intern/stroke/Predicates0D.h
+++ b/source/blender/freestyle/intern/stroke/Predicates0D.h
@@ -29,8 +29,6 @@
* \date 01/07/2003
*/
-#include "../python/Director.h"
-
#include "../view_map/Functions0D.h"
#ifdef WITH_CXX_GUARDEDALLOC
@@ -54,7 +52,7 @@ class UnaryPredicate0D
{
public:
bool result;
- PyObject *py_up0D;
+ void *py_up0D;
/*! Default constructor. */
UnaryPredicate0D()
@@ -76,10 +74,7 @@ public:
* The Interface0DIterator pointing onto the Interface0D at which we wish to evaluate the predicate.
* \return true if the condition is satisfied, false otherwise.
*/
- virtual int operator()(Interface0DIterator& it)
- {
- return Director_BPy_UnaryPredicate0D___call__(this, it);
- }
+ virtual int operator()(Interface0DIterator& it);
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:UnaryPredicate0D")
@@ -101,7 +96,7 @@ class BinaryPredicate0D
{
public:
bool result;
- PyObject *py_bp0D;
+ void *py_bp0D;
/*! Default constructor. */
BinaryPredicate0D()
@@ -126,10 +121,7 @@ public:
* The second Interface0D.
* \return true or false.
*/
- virtual int operator()(Interface0D& inter1, Interface0D& inter2)
- {
- return Director_BPy_BinaryPredicate0D___call__(this, inter1, inter2);
- }
+ virtual int operator()(Interface0D& inter1, Interface0D& inter2);
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:BinaryPredicate0D")
diff --git a/source/blender/compositor/nodes/COM_SeparateHSVANode.h b/source/blender/freestyle/intern/stroke/Predicates1D.cpp
index 6199237ebda..7c5d777e57c 100644
--- a/source/blender/compositor/nodes/COM_SeparateHSVANode.h
+++ b/source/blender/freestyle/intern/stroke/Predicates1D.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011, Blender Foundation.
+ * ***** 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
@@ -15,25 +15,27 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
- * Monique Dewanchand
+ * ***** END GPL LICENSE BLOCK *****
*/
-#ifndef _COM_SeparateHSVANode_h_
-#define _COM_SeparateHSVANode_h_
+/** \file blender/freestyle/intern/stroke/Predicates1D.cpp
+ * \ingroup freestyle
+ */
-#include "COM_Node.h"
-#include "DNA_node_types.h"
-#include "COM_SeparateRGBANode.h"
+#include "Predicates1D.h"
-/**
- * @brief SeparateHSVANode
- * @ingroup Node
- */
-class SeparateHSVANode : public SeparateRGBANode {
-public:
- SeparateHSVANode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
-};
-#endif
+#include "../python/Director.h"
+
+namespace Freestyle {
+
+int UnaryPredicate1D::operator()(Interface1D& inter)
+{
+ return Director_BPy_UnaryPredicate1D___call__(this, inter);
+}
+
+int BinaryPredicate1D::operator()(Interface1D& inter1, Interface1D& inter2)
+{
+ return Director_BPy_BinaryPredicate1D___call__(this, inter1, inter2);
+}
+
+} /* namespace Freestyle */
diff --git a/source/blender/freestyle/intern/stroke/Predicates1D.h b/source/blender/freestyle/intern/stroke/Predicates1D.h
index 257f938bf30..46efeae9f12 100644
--- a/source/blender/freestyle/intern/stroke/Predicates1D.h
+++ b/source/blender/freestyle/intern/stroke/Predicates1D.h
@@ -33,8 +33,6 @@
#include "AdvancedFunctions1D.h"
-#include "../python/Director.h"
-
#include "../system/TimeStamp.h"
#include "../view_map/Interface1D.h"
@@ -61,7 +59,7 @@ class UnaryPredicate1D
{
public:
bool result;
- PyObject *py_up1D;
+ void *py_up1D;
/*! Default constructor. */
UnaryPredicate1D()
@@ -83,10 +81,7 @@ public:
* The Interface1D on which we wish to evaluate the predicate.
* \return true if the condition is satisfied, false otherwise.
*/
- virtual int operator()(Interface1D& inter)
- {
- return Director_BPy_UnaryPredicate1D___call__(this, inter);
- }
+ virtual int operator()(Interface1D& inter);
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:UnaryPredicate1D")
@@ -108,7 +103,7 @@ class BinaryPredicate1D
{
public:
bool result;
- PyObject *py_bp1D;
+ void *py_bp1D;
/*! Default constructor. */
BinaryPredicate1D()
@@ -133,10 +128,7 @@ public:
* The second Interface1D.
* \return true or false.
*/
- virtual int operator()(Interface1D& inter1, Interface1D& inter2)
- {
- return Director_BPy_BinaryPredicate1D___call__(this, inter1, inter2);
- }
+ virtual int operator()(Interface1D& inter1, Interface1D& inter2);
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:BinaryPredicate1D")
diff --git a/source/blender/freestyle/intern/stroke/Stroke.cpp b/source/blender/freestyle/intern/stroke/Stroke.cpp
index 159e4a39849..6629de0fa04 100644
--- a/source/blender/freestyle/intern/stroke/Stroke.cpp
+++ b/source/blender/freestyle/intern/stroke/Stroke.cpp
@@ -26,8 +26,8 @@
*/
#include "Stroke.h"
-#include "StrokeAdvancedIterators.h"
#include "StrokeIterators.h"
+#include "StrokeAdvancedIterators.h"
#include "StrokeRenderer.h"
#include "BKE_global.h"
@@ -106,7 +106,7 @@ StrokeAttribute::StrokeAttribute(const StrokeAttribute& a1, const StrokeAttribut
for (int i = 0; i < 3; ++i)
_color[i] = (1 - t) * a1._color[i] + t * a2._color[i];
- _visible = true;
+ _visible = a1.isVisible();
// FIXME: to be checked (and enhanced)
if ((a1._userAttributesReal) && (a2._userAttributesReal)) {
@@ -393,6 +393,10 @@ Stroke::Stroke()
//_mediumType = DEFAULT_STROKE;
_mediumType = OPAQUE_MEDIUM;
_textureId = 0;
+ _textureStep = 1.0;
+ for (int a = 0; a < MAX_MTEX; a++) {
+ _mtex[a] = NULL;
+ }
_tips = false;
_rep = NULL;
}
@@ -411,6 +415,15 @@ Stroke::Stroke(const Stroke& iBrother)
_sampling = iBrother._sampling;
_mediumType = iBrother._mediumType;
_textureId = iBrother._textureId;
+ _textureStep = iBrother._textureStep;
+ for (int a = 0; a < MAX_MTEX; a++) {
+ if (iBrother._mtex) {
+ _mtex[a] = iBrother._mtex[a];
+ }
+ else {
+ _mtex[a] = NULL;
+ }
+ }
_tips = iBrother._tips;
if (iBrother._rep)
_rep = new StrokeRep(*(iBrother._rep));
diff --git a/source/blender/freestyle/intern/stroke/Stroke.h b/source/blender/freestyle/intern/stroke/Stroke.h
index d116edc6ace..f6451d8e487 100644
--- a/source/blender/freestyle/intern/stroke/Stroke.h
+++ b/source/blender/freestyle/intern/stroke/Stroke.h
@@ -43,6 +43,14 @@
#include "MEM_guardedalloc.h"
#endif
+extern "C" {
+#include "DNA_material_types.h"
+}
+
+#ifndef MAX_MTEX
+#define MAX_MTEX 18
+#endif
+
namespace Freestyle {
//
@@ -53,7 +61,7 @@ namespace Freestyle {
/*! Class to define an attribute associated to a Stroke Vertex.
* This attribute stores the color, alpha and thickness values for a Stroke Vertex.
*/
-class LIB_STROKE_EXPORT StrokeAttribute
+class StrokeAttribute
{
public:
/*! default constructor */
@@ -314,7 +322,7 @@ private:
////////////////////////////////////////////////////////
/*! Class to define a stroke vertex. */
-class LIB_STROKE_EXPORT StrokeVertex : public CurvePoint
+class StrokeVertex : public CurvePoint
{
public: // Implementation of Interface0D
/*! Returns the string "StrokeVertex" */
@@ -489,7 +497,7 @@ class StrokeVertexIterator;
* This set of vertices defines the stroke's backbone geometry.
* Each of these stroke vertices defines the stroke's shape and appearance at this vertex position.
*/
-class LIB_STROKE_EXPORT Stroke : public Interface1D
+class Stroke : public Interface1D
{
public: // Implementation of Interface1D
/*! Returns the string "Stroke" */
@@ -528,9 +536,11 @@ private:
float _Length; // The stroke length
viewedge_container _ViewEdges;
float _sampling;
+ float _textureStep;
// StrokeRenderer *_renderer; // mark implementation OpenGL renderer
MediumType _mediumType;
unsigned int _textureId;
+ MTex *_mtex[MAX_MTEX];
bool _tips;
Vec2r _extremityOrientations[2]; // the orientations of the first and last extermity
StrokeRep *_rep;
@@ -635,6 +645,20 @@ public:
/*! Returns the id of the texture used to simulate th marks system for this Stroke */
inline unsigned int getTextureId() {return _textureId;}
+ /*! Returns the spacing of texture coordinates along the stroke lenght */
+ inline float getTextureStep() {return _textureStep;}
+
+ /*! Returns the texture used at given index to simulate the marks system for this Stroke */
+ inline MTex *getMTex(int idx) {
+ return _mtex[idx];
+ }
+
+ /*! Returns true if this Stroke has textures assigned, false otherwise. */
+ inline bool hasTex() const
+ {
+ return _mtex[0] != NULL;
+ }
+
/*! Returns true if this Stroke uses a texture with tips, false otherwise. */
inline bool hasTips() const
{
@@ -725,6 +749,24 @@ public:
_textureId = id;
}
+ /*! sets the spacing of texture coordinates along the stroke lenght. */
+ inline void setTextureStep(float step)
+ {
+ _textureStep = step;
+ }
+
+ /*! assigns a blender texture to the first available slot. */
+ inline int setMTex(MTex *mtex)
+ {
+ for (int a = 0; a < MAX_MTEX; a++) {
+ if (!_mtex[a]) {
+ _mtex[a] = mtex;
+ return 0;
+ }
+ }
+ return -1; /* no free slots */
+ }
+
/*! sets the flag telling whether this stroke is using a texture with tips or not. */
inline void setTips(bool iTips)
{
diff --git a/source/blender/freestyle/intern/stroke/StrokeIO.h b/source/blender/freestyle/intern/stroke/StrokeIO.h
index daaf6239987..f3833e04143 100644
--- a/source/blender/freestyle/intern/stroke/StrokeIO.h
+++ b/source/blender/freestyle/intern/stroke/StrokeIO.h
@@ -36,13 +36,10 @@
namespace Freestyle {
-LIB_STROKE_EXPORT
ostream& operator<<(ostream& out, const StrokeAttribute& iStrokeAttribute);
-LIB_STROKE_EXPORT
ostream& operator<<(ostream& out, const StrokeVertex& iStrokeVertex);
-LIB_STROKE_EXPORT
ostream& operator<<(ostream& out, const Stroke& iStroke);
} /* namespace Freestyle */
diff --git a/source/blender/freestyle/intern/stroke/StrokeIterators.h b/source/blender/freestyle/intern/stroke/StrokeIterators.h
index 1082adfbf41..a8ec529fbfa 100644
--- a/source/blender/freestyle/intern/stroke/StrokeIterators.h
+++ b/source/blender/freestyle/intern/stroke/StrokeIterators.h
@@ -66,9 +66,9 @@ public:
_end = vi._end;
}
- StrokeVertexIterator(const ::Stroke::vertex_container::iterator& it,
- const ::Stroke::vertex_container::iterator& begin,
- const ::Stroke::vertex_container::iterator& end)
+ StrokeVertexIterator(const Stroke::vertex_container::iterator& it,
+ const Stroke::vertex_container::iterator& begin,
+ const Stroke::vertex_container::iterator& end)
{
_it = it;
_begin = begin;
@@ -208,15 +208,15 @@ public:
// Not exported in Python
//
//////////////////////////////////////////////////
- const ::Stroke::vertex_container::iterator& getIt()
+ const Stroke::vertex_container::iterator& getIt()
{
return _it;
}
private:
- ::Stroke::vertex_container::iterator _it;
- ::Stroke::vertex_container::iterator _begin;
- ::Stroke::vertex_container::iterator _end;
+ Stroke::vertex_container::iterator _it;
+ Stroke::vertex_container::iterator _begin;
+ Stroke::vertex_container::iterator _end;
};
} // end of namespace StrokeInternal
diff --git a/source/blender/freestyle/intern/stroke/StrokeRenderer.cpp b/source/blender/freestyle/intern/stroke/StrokeRenderer.cpp
index f9d7413e2f9..d7b37d65a6d 100644
--- a/source/blender/freestyle/intern/stroke/StrokeRenderer.cpp
+++ b/source/blender/freestyle/intern/stroke/StrokeRenderer.cpp
@@ -41,7 +41,6 @@ namespace Freestyle {
/* */
/**********************************/
-LIB_STROKE_EXPORT
TextureManager *StrokeRenderer::_textureManager = 0;
StrokeRenderer::StrokeRenderer() {}
@@ -64,13 +63,10 @@ bool StrokeRenderer::loadTextures()
/**********************************/
-LIB_STROKE_EXPORT
TextureManager *TextureManager::_pInstance = 0;
-LIB_STROKE_EXPORT
string TextureManager::_patterns_path;
-LIB_STROKE_EXPORT
string TextureManager::_brushes_path;
TextureManager::TextureManager()
diff --git a/source/blender/freestyle/intern/stroke/StrokeRenderer.h b/source/blender/freestyle/intern/stroke/StrokeRenderer.h
index 90f41a0d0ac..868f61224de 100644
--- a/source/blender/freestyle/intern/stroke/StrokeRenderer.h
+++ b/source/blender/freestyle/intern/stroke/StrokeRenderer.h
@@ -55,7 +55,7 @@ namespace Freestyle {
/*! Class to load textures */
-class LIB_STROKE_EXPORT TextureManager
+class TextureManager
{
public:
TextureManager ();
@@ -79,7 +79,7 @@ public:
return _defaultTextureId;
}
- struct LIB_STROKE_EXPORT Options
+ struct Options
{
static void setPatternsPath(const string& path);
static string getPatternsPath();
@@ -128,7 +128,7 @@ protected:
/**********************************/
/*! Class to render a stroke. Creates a triangle strip and stores it strip is lazily created at the first rendering */
-class LIB_STROKE_EXPORT StrokeRenderer
+class StrokeRenderer
{
public:
StrokeRenderer();
diff --git a/source/blender/freestyle/intern/stroke/StrokeRep.cpp b/source/blender/freestyle/intern/stroke/StrokeRep.cpp
index fb6da853e02..8e84228f37f 100644
--- a/source/blender/freestyle/intern/stroke/StrokeRep.cpp
+++ b/source/blender/freestyle/intern/stroke/StrokeRep.cpp
@@ -26,8 +26,8 @@
*/
#include "Stroke.h"
-#include "StrokeAdvancedIterators.h"
#include "StrokeIterators.h"
+#include "StrokeAdvancedIterators.h"
#include "StrokeRenderer.h"
#include "StrokeRep.h"
@@ -45,6 +45,7 @@ StrokeVertexRep::StrokeVertexRep(const StrokeVertexRep& iBrother)
{
_point2d = iBrother._point2d;
_texCoord = iBrother._texCoord;
+ _texCoord_w_tips = iBrother._texCoord_w_tips;
_color = iBrother._color;
_alpha = iBrother._alpha;
}
@@ -53,13 +54,17 @@ StrokeVertexRep::StrokeVertexRep(const StrokeVertexRep& iBrother)
// STRIP
/////////////////////////////////////
-Strip::Strip(const vector<StrokeVertex*>& iStrokeVertices, bool hasTips, bool beginTip, bool endTip)
+Strip::Strip(const vector<StrokeVertex*>& iStrokeVertices, bool hasTex, bool beginTip, bool endTip, float texStep)
{
createStrip(iStrokeVertices);
- if (!hasTips)
- computeTexCoord (iStrokeVertices);
- else
- computeTexCoordWithTips (iStrokeVertices, beginTip, endTip);
+
+ setVertexColor(iStrokeVertices);
+
+ if (hasTex) {
+ // We compute both kinds of coordinates to use different kinds of textures
+ computeTexCoord(iStrokeVertices, texStep);
+ computeTexCoordWithTips(iStrokeVertices, beginTip, endTip, texStep);
+ }
}
Strip::Strip(const Strip& iBrother)
@@ -482,24 +487,20 @@ void Strip::cleanUpSingularities (const vector<StrokeVertex*>& iStrokeVertices)
}
-// Texture coordinates
+// Vertex color (RGBA)
////////////////////////////////
-void Strip::computeTexCoord (const vector<StrokeVertex *>& iStrokeVertices)
+void Strip::setVertexColor (const vector<StrokeVertex *>& iStrokeVertices)
{
vector<StrokeVertex *>::const_iterator v, vend;
StrokeVertex *sv;
int i = 0;
for (v = iStrokeVertices.begin(), vend = iStrokeVertices.end(); v != vend; v++) {
sv = (*v);
- _vertices[i]->setTexCoord(Vec2r((real)(sv->curvilinearAbscissa() / _averageThickness), 0));
- _vertices[i]->setColor(Vec3r(sv->attribute().getColor()[0], sv->attribute().getColor()[1],
- sv->attribute().getColor()[2]));
+ _vertices[i]->setColor(Vec3r(sv->attribute().getColorRGB()));
_vertices[i]->setAlpha(sv->attribute().getAlpha());
i++;
- _vertices[i]->setTexCoord(Vec2r((real)(sv->curvilinearAbscissa() / _averageThickness), 1));
- _vertices[i]->setColor(Vec3r(sv->attribute().getColor()[0], sv->attribute().getColor()[1],
- sv->attribute().getColor()[2]));
+ _vertices[i]->setColor(Vec3r(sv->attribute().getColorRGB()));
_vertices[i]->setAlpha(sv->attribute().getAlpha());
i++;
#if 0
@@ -509,23 +510,41 @@ void Strip::computeTexCoord (const vector<StrokeVertex *>& iStrokeVertices)
}
}
-void Strip::computeTexCoordWithTips (const vector<StrokeVertex*>& iStrokeVertices, bool tipBegin, bool tipEnd)
+
+// Texture coordinates
+////////////////////////////////
+
+void Strip::computeTexCoord (const vector<StrokeVertex *>& iStrokeVertices, float texStep)
+{
+ vector<StrokeVertex *>::const_iterator v, vend;
+ StrokeVertex *sv;
+ int i = 0;
+ for (v = iStrokeVertices.begin(), vend = iStrokeVertices.end(); v != vend; v++) {
+ sv = (*v);
+ _vertices[i]->setTexCoord(Vec2r((real)(sv->curvilinearAbscissa() / (_averageThickness * texStep)), 0));
+ i++;
+ _vertices[i]->setTexCoord(Vec2r((real)(sv->curvilinearAbscissa() / (_averageThickness * texStep)), 1));
+ i++;
+ }
+}
+
+void Strip::computeTexCoordWithTips (const vector<StrokeVertex*>& iStrokeVertices, bool tipBegin, bool tipEnd, float texStep)
{
- //soc unused - unsigned int sizeStrip = _vertices.size() + 8; //for the transition between the tip and the body
vector<StrokeVertex*>::const_iterator v, vend;
StrokeVertex *sv = NULL;
+ StrokeVertexRep *tvRep[2] = {NULL};
+
+ float l, fact, t;
+ float u = 0, uPrev = 0;
+ int tiles;
+ int i = 0;
+ float spacedThickness = _averageThickness * texStep;
v = iStrokeVertices.begin();
vend = iStrokeVertices.end();
- float l = (*v)->strokeLength() / _averageThickness;
- int tiles = int(l);
- float fact = (float(tiles) + 0.5) / l;
- //soc unused - float uTip2 = float(tiles) + 0.25;
- float u = 0;
- float uPrev = 0;
- int i = 0;
- float t;
- StrokeVertexRep *tvRep1, *tvRep2;
+ l = (*v)->strokeLength() / spacedThickness;
+ tiles = int(l + 0.5); // round to the nearest
+ fact = (float(tiles) + 0.5) / l;
#if 0
cerr << "l=" << l << " tiles=" << tiles << " _averageThicnkess="
@@ -538,166 +557,122 @@ void Strip::computeTexCoordWithTips (const vector<StrokeVertex*>& iStrokeVertice
for (; v != vend; v++) {
sv = (*v);
svRep = *currentSV;
- u = sv->curvilinearAbscissa() / _averageThickness * fact;
+ u = sv->curvilinearAbscissa() / spacedThickness * fact;
if (u > 0.25)
break;
- svRep->setTexCoord(Vec2r((real)u, 0.5));
- svRep->setColor(Vec3r(sv->attribute().getColor()[0], sv->attribute().getColor()[1],
- sv->attribute().getColor()[2]));
- svRep->setAlpha(sv->attribute().getAlpha());
+ svRep->setTexCoord(Vec2r((real)u, 0.5), true);
i++;
++currentSV;
svRep = *currentSV;
- svRep->setTexCoord(Vec2r((real)u, 1));
- svRep->setColor(Vec3r(sv->attribute().getColor()[0], sv->attribute().getColor()[1],
- sv->attribute().getColor()[2]));
- svRep->setAlpha(sv->attribute().getAlpha());
+ svRep->setTexCoord(Vec2r((real)u, 1), true);
i++;
++currentSV;
uPrev = u;
}
- //first transition vertex
-
- if (fabs(u - uPrev) > ZERO)
- t = (0.25 - uPrev) / (u - uPrev);
- else
- t = 0;
-#if 0
- if (!tiles)
- t = 0.5;
-#endif
- tvRep1 = new StrokeVertexRep(Vec2r((1 - t) * _vertices[i - 2]->point2d() + t * _vertices[i]->point2d()));
- tvRep1->setTexCoord(Vec2r(0.25, 0.5));
- tvRep1->setColor(Vec3r((1 - t) * _vertices[i - 2]->color() +
- t * Vec3r(sv->attribute().getColor()[0], sv->attribute().getColor()[1],
- sv->attribute().getColor()[2])));
- tvRep1->setAlpha((1 - t) * _vertices[i - 2]->alpha() + t * sv->attribute().getAlpha());
- i++;
- tvRep2 = new StrokeVertexRep(Vec2r((1 - t) * _vertices[i - 2]->point2d() + t *_vertices[i]->point2d()));
- tvRep2->setTexCoord(Vec2r(0.25, 1));
- tvRep2->setColor(Vec3r((1 - t) * _vertices[i - 2]->color() +
- t * Vec3r(sv->attribute().getColor()[0], sv->attribute().getColor()[1],
- sv->attribute().getColor()[2])));
- tvRep2->setAlpha((1 - t) * _vertices[i - 2]->alpha() + t * sv->attribute().getAlpha());
- i++;
-
- currentSV = _vertices.insert(currentSV, tvRep1);
- ++currentSV;
- currentSV = _vertices.insert(currentSV, tvRep2);
- ++currentSV;
-
- // copy the vertices with different texture coordinates
- tvRep1 = new StrokeVertexRep(_vertices[i - 2]->point2d());
- tvRep1->setTexCoord(Vec2r(0.25, 0));
- tvRep1->setColor(_vertices[i - 2]->color());
- tvRep1->setAlpha(_vertices[i - 2]->alpha());
- i++;
-
- tvRep2 = new StrokeVertexRep(_vertices[i - 2]->point2d());
- tvRep2->setTexCoord(Vec2r(0.25, 0.5));
- tvRep2->setColor(_vertices[i - 2]->color());
- tvRep2->setAlpha(_vertices[i - 2]->alpha());
- i++;
+ if (v != vend && i >= 2) {
+ // first transition vertex
+ if (fabs(u - uPrev) > ZERO)
+ t = (0.25 - uPrev) / (u - uPrev);
+ else
+ t = 0;
+ for (int k = 0; k < 2; k++) {
+ tvRep[k] = new StrokeVertexRep((1 - t) * _vertices[i - 2]->point2d() + t * _vertices[i]->point2d());
+ tvRep[k]->setTexCoord((1 - t) * _vertices[i - 2]->texCoord() + t * _vertices[i]->texCoord());
+ // v coord is 0.5 for tvRep[0], 1.0 for tvRep[1]
+ tvRep[k]->setTexCoord(Vec2r(0.25, 0.5 * (k + 1)), true);
+ tvRep[k]->setColor((1 - t) * _vertices[i - 2]->color() + t * Vec3r(sv->attribute().getColorRGB()));
+ tvRep[k]->setAlpha((1 - t) * _vertices[i - 2]->alpha() + t * sv->attribute().getAlpha());
+ i++;
+ }
+ for (int k = 0; k < 2; k++) {
+ currentSV = _vertices.insert(currentSV, tvRep[k]);
+ ++currentSV;
+ }
- currentSV = _vertices.insert(currentSV, tvRep1);
- ++currentSV;
- currentSV = _vertices.insert(currentSV, tvRep2);
- ++currentSV;
+ // copy the vertices with different texture coordinates
+ for (int k = 0; k < 2; k++) {
+ tvRep[k] = new StrokeVertexRep(*(_vertices[i - 2]));
+ // v coord is 0.0 for tvRep[0], 0.5 for tvRep[1]
+ tvRep[k]->setTexCoord(Vec2r(0.0, 0.5 * k), true); // FIXED u coord
+ i++;
+ }
+ for (int k = 0; k < 2; k++) {
+ currentSV = _vertices.insert(currentSV, tvRep[k]);
+ ++currentSV;
+ }
+ }
}
uPrev = 0;
- //body of the stroke
+ // body of the stroke
for (; v != vend; v++) {
sv = (*v);
svRep = *currentSV;
- u = sv->curvilinearAbscissa() / _averageThickness * fact - 0.25;
+ u = sv->curvilinearAbscissa() / spacedThickness * fact - 0.25;
if (u > tiles)
break;
- svRep->setTexCoord(Vec2r((real)u, 0));
- svRep->setColor(Vec3r(sv->attribute().getColor()[0], sv->attribute().getColor()[1],
- sv->attribute().getColor()[2]));
- svRep->setAlpha(sv->attribute().getAlpha());
+ svRep->setTexCoord(Vec2r((real)u, 0), true);
i++;
++currentSV;
svRep = *currentSV;
- svRep->setTexCoord(Vec2r((real)u, 0.5));
- svRep->setColor(Vec3r(sv->attribute().getColor()[0], sv->attribute().getColor()[1],
- sv->attribute().getColor()[2]));
- svRep->setAlpha(sv->attribute().getAlpha());
+ svRep->setTexCoord(Vec2r((real)u, 0.5), true);
i++;
++currentSV;
uPrev = u;
}
- if (tipEnd) {
- //second transition vertex
- if ((fabs(u - uPrev) > ZERO))
- t = (float(tiles) - uPrev) / (u - uPrev);
- else
- t = 0;
-
- tvRep1 = new StrokeVertexRep(Vec2r((1 - t) * _vertices[i - 2]->point2d() + t * _vertices[i]->point2d()));
- tvRep1->setTexCoord(Vec2r((real)tiles, 0));
- tvRep1->setColor(Vec3r((1 - t) * _vertices[i - 2]->color() +
- t * Vec3r(sv->attribute().getColor()[0], sv->attribute().getColor()[1],
- sv->attribute().getColor()[2])));
- tvRep1->setAlpha((1 - t) * _vertices[i - 2]->alpha() + t * sv->attribute().getAlpha());
- i++;
- tvRep2 = new StrokeVertexRep(Vec2r((1 - t) * _vertices[i - 2]->point2d() + t * _vertices[i]->point2d()));
- tvRep2->setTexCoord(Vec2r((real)tiles, 0.5));
- tvRep2->setColor(Vec3r((1 - t) * _vertices[i - 2]->color() +
- t * Vec3r(sv->attribute().getColor()[0], sv->attribute().getColor()[1],
- sv->attribute().getColor()[2])));
- tvRep2->setAlpha((1 - t) * _vertices[i - 2]->alpha() + t * sv->attribute().getAlpha());
- i++;
-
- currentSV = _vertices.insert(currentSV, tvRep1);
- ++currentSV;
- currentSV = _vertices.insert(currentSV, tvRep2);
- ++currentSV;
-
- //copy the vertices with different texture coordinates
- tvRep1 = new StrokeVertexRep(_vertices[i - 2]->point2d());
- tvRep1->setTexCoord(Vec2r(0.75, 0.5));
- tvRep1->setColor(_vertices[i - 2]->color());
- tvRep1->setAlpha(_vertices[i - 2]->alpha());
- i++;
-
- tvRep2 = new StrokeVertexRep(_vertices[i - 2]->point2d());
- tvRep2->setTexCoord(Vec2r(0.75, 1));
- tvRep2->setColor(_vertices[i - 2]->color());
- tvRep2->setAlpha(_vertices[i - 2]->alpha());
- i++;
+ if (tipEnd) {
+ if (v != vend && i >= 2) {
+ // second transition vertex
+ if (fabs(u - uPrev) > ZERO)
+ t = (float(tiles) - uPrev) / (u - uPrev);
+ else
+ t = 0;
+ for (int k = 0; k < 2; k++) {
+ tvRep[k] = new StrokeVertexRep((1 - t) * _vertices[i - 2]->point2d() + t * _vertices[i]->point2d());
+ tvRep[k]->setTexCoord((1 - t) * _vertices[i - 2]->texCoord() + t * _vertices[i]->texCoord());
+ // v coord is 0.0 for tvRep[0], 0.5 for tvRep[1]
+ tvRep[k]->setTexCoord(Vec2r((real)tiles, 0.5 * k), true); // FIXED u coord
+ tvRep[k]->setColor((1 - t) * _vertices[i - 2]->color() + t * Vec3r(sv->attribute().getColorRGB()));
+ tvRep[k]->setAlpha((1 - t) * _vertices[i - 2]->alpha() + t * sv->attribute().getAlpha());
+ i++;
+ }
+ for (int k = 0; k < 2; k++) {
+ currentSV = _vertices.insert(currentSV, tvRep[k]);
+ ++currentSV;
+ }
- currentSV = _vertices.insert(currentSV, tvRep1);
- ++currentSV;
- currentSV = _vertices.insert(currentSV, tvRep2);
- ++currentSV;
+ // copy the vertices with different texture coordinates
+ for (int k = 0; k < 2; k++) {
+ tvRep[k] = new StrokeVertexRep(*(_vertices[i - 2]));
+ // v coord is 0.5 for tvRep[0], 1.0 for tvRep[1]
+ tvRep[k]->setTexCoord(Vec2r(0.75, 0.5 * (k + 1)), true);
+ i++;
+ }
+ for (int k = 0; k < 2; k++) {
+ currentSV = _vertices.insert(currentSV, tvRep[k]);
+ ++currentSV;
+ }
+ }
- //end tip
+ // end tip
for (; v != vend; v++) {
- sv = (*v);
+ sv = (*v);
svRep = *currentSV;
- u = 0.75 + sv->curvilinearAbscissa() / _averageThickness * fact - float(tiles) - 0.25;
+ u = 0.75 + sv->curvilinearAbscissa() / spacedThickness * fact - float(tiles) - 0.25;
- svRep->setTexCoord(Vec2r((real)u, 0.5));
- svRep->setColor(Vec3r(sv->attribute().getColor()[0], sv->attribute().getColor()[1],
- sv->attribute().getColor()[2]));
- svRep->setAlpha(sv->attribute().getAlpha());
+ svRep->setTexCoord(Vec2r((real)u, 0.5), true);
i++;
++currentSV;
svRep = *currentSV;
- svRep->setTexCoord(Vec2r((real)u, 1));
- svRep->setColor(Vec3r(sv->attribute().getColor()[0], sv->attribute().getColor()[1],
- sv->attribute().getColor()[2]));
- svRep->setAlpha(sv->attribute().getAlpha());
+ svRep->setTexCoord(Vec2r((real)u, 1), true);
i++;
++currentSV;
}
@@ -729,6 +704,10 @@ StrokeRep::StrokeRep()
{
_stroke = 0;
_strokeType = Stroke::OPAQUE_MEDIUM;
+ _textureStep = 1.0;
+ for (int a = 0; a < MAX_MTEX; a++) {
+ _mtex[a] = NULL;
+ }
TextureManager *ptm = TextureManager::getInstance();
if (ptm)
_textureId = ptm->getDefaultTextureId();
@@ -746,6 +725,15 @@ StrokeRep::StrokeRep(Stroke *iStroke)
_stroke = iStroke;
_strokeType = iStroke->getMediumType();
_textureId = iStroke->getTextureId();
+ _textureStep = iStroke->getTextureStep();
+ for (int a = 0; a < MAX_MTEX; a++) {
+ if (iStroke->getMTex(a)) {
+ _mtex[a] = iStroke->getMTex(a);
+ }
+ else {
+ _mtex[a] = NULL;
+ }
+ }
if (_textureId == 0) {
TextureManager *ptm = TextureManager::getInstance();
if (ptm)
@@ -768,6 +756,15 @@ StrokeRep::StrokeRep(const StrokeRep& iBrother)
_stroke = iBrother._stroke;
_strokeType = iBrother._strokeType;
_textureId = iBrother._textureId;
+ _textureStep = iBrother._textureStep;
+ for (int a = 0; a < MAX_MTEX; a++) {
+ if (iBrother._mtex[a]) {
+ _mtex[a] = iBrother._mtex[a];
+ }
+ else {
+ _mtex[a] = NULL;
+ }
+ }
for (vector<Strip*>::const_iterator s = iBrother._strips.begin(), send = iBrother._strips.end();
s != send;
++s)
@@ -811,7 +808,7 @@ void StrokeRep::create()
end = true;
}
if ((!strip.empty()) && (strip.size() > 1)) {
- _strips.push_back(new Strip(strip, _stroke->hasTips(), first, end));
+ _strips.push_back(new Strip(strip, _stroke->hasTex(), first, end, _textureStep));
strip.clear();
}
first = false;
diff --git a/source/blender/freestyle/intern/stroke/StrokeRep.h b/source/blender/freestyle/intern/stroke/StrokeRep.h
index d01b27215fe..61a456cdf42 100644
--- a/source/blender/freestyle/intern/stroke/StrokeRep.h
+++ b/source/blender/freestyle/intern/stroke/StrokeRep.h
@@ -36,6 +36,10 @@
#include "MEM_guardedalloc.h"
#endif
+extern "C" {
+#include "DNA_material_types.h"
+}
+
namespace Freestyle {
using namespace Geometry;
@@ -78,9 +82,13 @@ public:
return _point2d;
}
- inline Vec2r& texCoord()
+ inline Vec2r& texCoord(bool tips=false)
{
- return _texCoord;
+ if (tips) {
+ return _texCoord_w_tips;
+ }
+ else
+ return _texCoord;
}
inline Vec3r& color()
@@ -98,9 +106,14 @@ public:
_point2d = p;
}
- inline void setTexCoord(const Vec2r& p)
+ inline void setTexCoord(const Vec2r& p, bool tips=false)
{
- _texCoord = p;
+ if (tips) {
+ _texCoord_w_tips = p;
+ }
+ else {
+ _texCoord = p;
+ }
}
inline void setColor(const Vec3r& p)
@@ -116,6 +129,7 @@ public:
protected:
Vec2r _point2d;
Vec2r _texCoord;
+ Vec2r _texCoord_w_tips;
Vec3r _color;
float _alpha;
@@ -134,16 +148,17 @@ protected:
float _averageThickness;
public:
- Strip(const std::vector<StrokeVertex*>& iStrokeVertices, bool hasTips = false,
- bool tipBegin = false, bool tipEnd = false);
+ Strip(const std::vector<StrokeVertex*>& iStrokeVertices, bool hasTex = false,
+ bool tipBegin = false, bool tipEnd = false, float texStep = 1.0);
Strip(const Strip& iBrother);
virtual ~Strip();
protected:
void createStrip(const std::vector<StrokeVertex*>& iStrokeVertices);
void cleanUpSingularities(const std::vector<StrokeVertex*>& iStrokeVertices);
- void computeTexCoord (const std::vector<StrokeVertex*>& iStrokeVertices);
- void computeTexCoordWithTips (const std::vector<StrokeVertex*>& iStrokeVertices, bool tipBegin, bool tipEnd);
+ void setVertexColor (const std::vector<StrokeVertex*>& iStrokeVertices);
+ void computeTexCoord (const std::vector<StrokeVertex*>& iStrokeVertices, float texStep);
+ void computeTexCoordWithTips (const std::vector<StrokeVertex*>& iStrokeVertices, bool tipBegin, bool tipEnd, float texStep);
public:
inline int sizeStrip() const
@@ -168,6 +183,9 @@ protected:
vector<Strip*> _strips;
Stroke::MediumType _strokeType;
unsigned int _textureId;
+ float _textureStep;
+ MTex *_mtex[MAX_MTEX];
+ Material *_material;
// float _averageTextureAlpha;
@@ -194,6 +212,16 @@ public:
return _textureId;
}
+ inline MTex *getMTex(int idx) const
+ {
+ return _mtex[idx];
+ }
+
+ inline Material *getMaterial() const
+ {
+ return _material;
+ }
+
inline vector<Strip*>& getStrips()
{
return _strips;
@@ -220,6 +248,16 @@ public:
_textureId = textureId;
}
+ inline void setMaterial(Material *mat)
+ {
+ _material = mat;
+ }
+ /*
+ inline void setMTex(int idx, MTex *mtex_ptr)
+ {
+ _mtex[idx] = mtex_ptr;
+ }*/
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:StrokeRep")
#endif
diff --git a/source/blender/compositor/nodes/COM_SeparateRGBANode.h b/source/blender/freestyle/intern/stroke/StrokeShader.cpp
index 35321304d99..4b21910a894 100644
--- a/source/blender/compositor/nodes/COM_SeparateRGBANode.h
+++ b/source/blender/freestyle/intern/stroke/StrokeShader.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011, Blender Foundation.
+ * ***** 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
@@ -15,23 +15,22 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
- * Monique Dewanchand
+ * ***** END GPL LICENSE BLOCK *****
*/
-#ifndef _COM_SeparateRGBANode_h_
-#define _COM_SeparateRGBANode_h_
-
-#include "COM_Node.h"
-#include "DNA_node_types.h"
-/**
- * @brief SeparateRGBANode
- * @ingroup Node
+/** \file blender/freestyle/intern/stroke/StrokeShader.cpp
+ * \ingroup freestyle
*/
-class SeparateRGBANode : public Node {
-public:
- SeparateRGBANode(bNode *editorNode);
- void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
-};
-#endif
+
+#include "StrokeShader.h"
+
+#include "../python/Director.h"
+
+namespace Freestyle {
+
+int StrokeShader::shade(Stroke& ioStroke) const
+{
+ return Director_BPy_StrokeShader_shade( const_cast<StrokeShader *>(this), ioStroke);
+}
+
+} /* namespace Freestyle */
diff --git a/source/blender/freestyle/intern/stroke/StrokeShader.h b/source/blender/freestyle/intern/stroke/StrokeShader.h
index 4657e98be61..e655b80d397 100644
--- a/source/blender/freestyle/intern/stroke/StrokeShader.h
+++ b/source/blender/freestyle/intern/stroke/StrokeShader.h
@@ -32,12 +32,12 @@
#include <iostream>
#include <vector>
-#include "../python/Director.h"
-
#ifdef WITH_CXX_GUARDEDALLOC
#include "MEM_guardedalloc.h"
#endif
+using namespace std;
+
namespace Freestyle {
//
@@ -72,10 +72,10 @@ class Stroke;
* }
* \endcode
*/
-class LIB_STROKE_EXPORT StrokeShader
+class StrokeShader
{
public:
- PyObject *py_ss;
+ void *py_ss;
/*! Default constructor. */
StrokeShader()
@@ -97,10 +97,7 @@ public:
* The stroke we wish to shade. this Stroke is modified by the Shader (which typically
* modifies the Stroke's attribute's values such as Color, Thickness, Geometry...)
*/
- virtual int shade(Stroke& ioStroke) const
- {
- return Director_BPy_StrokeShader_shade( const_cast<StrokeShader *>(this), ioStroke);
- }
+ virtual int shade(Stroke& ioStroke) const;
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:StrokeShader")
diff --git a/source/blender/freestyle/intern/stroke/StrokeTesselator.cpp b/source/blender/freestyle/intern/stroke/StrokeTesselator.cpp
index 443e14bd0f3..fb221735fb1 100644
--- a/source/blender/freestyle/intern/stroke/StrokeTesselator.cpp
+++ b/source/blender/freestyle/intern/stroke/StrokeTesselator.cpp
@@ -56,7 +56,7 @@ LineRep *StrokeTesselator::Tesselate(Stroke *iStroke)
}
else {
if (_overloadFrsMaterial)
- line->setFrsMaterial(_FrsMaterial);
+ line->setFrsMaterial(_FrsMaterial);
line->setStyle(LineRep::LINE_STRIP);
diff --git a/source/blender/freestyle/intern/stroke/TextStrokeRenderer.h b/source/blender/freestyle/intern/stroke/TextStrokeRenderer.h
index 8e89847ca3d..02f7177b95c 100644
--- a/source/blender/freestyle/intern/stroke/TextStrokeRenderer.h
+++ b/source/blender/freestyle/intern/stroke/TextStrokeRenderer.h
@@ -52,7 +52,7 @@ namespace Freestyle {
/* */
/**********************************/
-class LIB_STROKE_EXPORT TextStrokeRenderer : public StrokeRenderer
+class TextStrokeRenderer : public StrokeRenderer
{
public:
TextStrokeRenderer(const char *iFileName = NULL);
diff --git a/source/blender/freestyle/intern/system/BaseObject.h b/source/blender/freestyle/intern/system/BaseObject.h
index 56f52a5fb80..8cabd9130b4 100644
--- a/source/blender/freestyle/intern/system/BaseObject.h
+++ b/source/blender/freestyle/intern/system/BaseObject.h
@@ -29,15 +29,13 @@
* \date 06/02/2002
*/
-#include "FreestyleConfig.h"
-
#ifdef WITH_CXX_GUARDEDALLOC
#include "MEM_guardedalloc.h"
#endif
namespace Freestyle {
-class LIB_SYSTEM_EXPORT BaseObject
+class BaseObject
{
public:
inline BaseObject()
diff --git a/source/blender/freestyle/intern/system/Exception.h b/source/blender/freestyle/intern/system/Exception.h
index dedc4152ae9..f605735ec40 100644
--- a/source/blender/freestyle/intern/system/Exception.h
+++ b/source/blender/freestyle/intern/system/Exception.h
@@ -28,15 +28,13 @@
* \date 10/01/2003
*/
-#include "FreestyleConfig.h"
-
#ifdef WITH_CXX_GUARDEDALLOC
#include "MEM_guardedalloc.h"
#endif
namespace Freestyle {
-class LIB_SYSTEM_EXPORT Exception
+class Exception
{
public:
typedef enum {
diff --git a/source/blender/freestyle/intern/system/FreestyleConfig.h b/source/blender/freestyle/intern/system/FreestyleConfig.h
index 42f9833836d..752940d83a5 100644
--- a/source/blender/freestyle/intern/system/FreestyleConfig.h
+++ b/source/blender/freestyle/intern/system/FreestyleConfig.h
@@ -30,8 +30,6 @@
#include <string>
-#include "BLI_math.h"
-
using namespace std;
namespace Freestyle {
@@ -48,44 +46,6 @@ namespace Config {
static const string PATH_SEP(":");
#endif // WIN32
-// DLL import/export macros for Win32
-
-#ifndef LIB_SYSTEM_EXPORT
-# define LIB_SYSTEM_EXPORT
-#endif // LIB_SYSTEM_EXPORT
-
-#ifndef LIB_IMAGE_EXPORT
-# define LIB_IMAGE_EXPORT
-#endif // LIB_IMAGE_EXPORT
-
-#ifndef LIB_GEOMETRY_EXPORT
-# define LIB_GEOMETRY_EXPORT
-#endif // LIB_GEOMETRY_EXPORT
-
-#ifndef LIB_SCENE_GRAPH_EXPORT
-# define LIB_SCENE_GRAPH_EXPORT
-#endif // LIB_SCENE_GRAPH_EXPORT
-
-#ifndef LIB_WINGED_EDGE_EXPORT
-# define LIB_WINGED_EDGE_EXPORT
-#endif // LIB_WINGED_EDGE_EXPORT
-
-#ifndef LIB_VIEW_MAP_EXPORT
-# define LIB_VIEW_MAP_EXPORT
-#endif // LIB_VIEW_MAP_EXPORT
-
-#ifndef LIB_STROKE_EXPORT
-# define LIB_STROKE_EXPORT
-#endif // LIB_STROKE_EXPORT
-
-#ifndef LIB_RENDERING_EXPORT
-# define LIB_RENDERING_EXPORT
-#endif // LIB_RENDERING_EXPORT
-
-#ifndef LIB_WRAPPER_EXPORT
-# define LIB_WRAPPER_EXPORT
-#endif // LIB_WRAPPER_EXPORT
-
} // end of namespace Config
} /* namespace Freestyle */
diff --git a/source/blender/freestyle/intern/system/Interpreter.h b/source/blender/freestyle/intern/system/Interpreter.h
index e1269f40468..74af9f82b12 100644
--- a/source/blender/freestyle/intern/system/Interpreter.h
+++ b/source/blender/freestyle/intern/system/Interpreter.h
@@ -38,7 +38,7 @@ using namespace std;
namespace Freestyle {
-class LIB_SYSTEM_EXPORT Interpreter
+class Interpreter
{
public:
Interpreter()
@@ -46,7 +46,7 @@ public:
_language = "Unknown";
}
- virtual ~Interpreter() {}; //soc
+ virtual ~Interpreter() {}
virtual int interpretFile(const string& filename) = 0;
diff --git a/source/blender/freestyle/intern/system/PseudoNoise.cpp b/source/blender/freestyle/intern/system/PseudoNoise.cpp
index 6083a46d609..4949cb8c430 100644
--- a/source/blender/freestyle/intern/system/PseudoNoise.cpp
+++ b/source/blender/freestyle/intern/system/PseudoNoise.cpp
@@ -26,6 +26,7 @@
*/
#include "BLI_math.h"
+#include "BLI_utildefines.h"
#include "PseudoNoise.h"
#include "RandGen.h"
diff --git a/source/blender/freestyle/intern/system/PseudoNoise.h b/source/blender/freestyle/intern/system/PseudoNoise.h
index e53d8ed7a7a..602ad5293f0 100644
--- a/source/blender/freestyle/intern/system/PseudoNoise.h
+++ b/source/blender/freestyle/intern/system/PseudoNoise.h
@@ -28,7 +28,6 @@
* \date 16/06/2003
*/
-#include "FreestyleConfig.h"
#include "Precision.h"
#ifdef WITH_CXX_GUARDEDALLOC
@@ -37,7 +36,7 @@
namespace Freestyle {
-class LIB_SYSTEM_EXPORT PseudoNoise
+class PseudoNoise
{
public:
PseudoNoise();
diff --git a/source/blender/freestyle/intern/system/PythonInterpreter.cpp b/source/blender/freestyle/intern/system/PythonInterpreter.cpp
index 9e7ef39a0e4..852030e365b 100644
--- a/source/blender/freestyle/intern/system/PythonInterpreter.cpp
+++ b/source/blender/freestyle/intern/system/PythonInterpreter.cpp
@@ -26,10 +26,3 @@
*/
#include "PythonInterpreter.h"
-
-namespace Freestyle {
-
-string PythonInterpreter::_path = "";
-bool PythonInterpreter::_initialized = false;
-
-} /* namespace Freestyle */
diff --git a/source/blender/freestyle/intern/system/PythonInterpreter.h b/source/blender/freestyle/intern/system/PythonInterpreter.h
index 30ee6d30163..60193590944 100644
--- a/source/blender/freestyle/intern/system/PythonInterpreter.h
+++ b/source/blender/freestyle/intern/system/PythonInterpreter.h
@@ -29,7 +29,10 @@
*/
#include <iostream>
+
+extern "C" {
#include <Python.h>
+}
#include "StringUtils.h"
#include "Interpreter.h"
@@ -52,7 +55,7 @@ extern "C" {
namespace Freestyle {
-class LIB_SYSTEM_EXPORT PythonInterpreter : public Interpreter
+class PythonInterpreter : public Interpreter
{
public:
PythonInterpreter()
@@ -60,12 +63,6 @@ public:
_language = "Python";
_context = 0;
memset(&_freestyle_bmain, 0, sizeof(Main));
- //Py_Initialize();
- }
-
- virtual ~PythonInterpreter()
- {
- //Py_Finalize();
}
void setContext(bContext *C)
@@ -75,8 +72,6 @@ public:
int interpretFile(const string& filename)
{
- initPath();
-
ReportList *reports = CTX_wm_reports(_context);
BKE_reports_clear(reports);
char *fn = const_cast<char*>(filename.c_str());
@@ -112,8 +107,6 @@ public:
int interpretText(struct Text *text, const string& name)
{
- initPath();
-
ReportList *reports = CTX_wm_reports(_context);
BKE_reports_clear(reports);
@@ -131,63 +124,14 @@ public:
return 0;
}
- struct Options
- {
- static void setPythonPath(const string& path)
- {
- _path = path;
- }
-
- static string getPythonPath()
- {
- return _path;
- }
- };
-
void reset()
{
- Py_Finalize();
- Py_Initialize();
- _initialized = false;
+ // nothing to do
}
private:
bContext *_context;
Main _freestyle_bmain;
-
- void initPath()
- {
- if (_initialized)
- return;
-
- vector<string> pathnames;
- StringUtils::getPathName(_path, "", pathnames);
-
- struct Text *text = BKE_text_add(&_freestyle_bmain, "tmp_freestyle_initpath.txt");
- string cmd = "import sys\n";
- txt_insert_buf(text, const_cast<char*>(cmd.c_str()));
-
- for (vector<string>::const_iterator it = pathnames.begin(); it != pathnames.end(); ++it) {
- if (!it->empty()) {
- if (G.debug & G_DEBUG_FREESTYLE) {
- cout << "Adding Python path: " << *it << endl;
- }
- cmd = "sys.path.append(r\"" + *it + "\")\n";
- txt_insert_buf(text, const_cast<char *>(cmd.c_str()));
- }
- }
-
- BPY_text_exec(_context, text, NULL, false);
-
- // cleaning up
- BKE_text_unlink(&_freestyle_bmain, text);
- BKE_libblock_free(&_freestyle_bmain, text);
-
- _initialized = true;
- }
-
- static bool _initialized;
- static string _path;
};
} /* namespace Freestyle */
diff --git a/source/blender/freestyle/intern/system/RandGen.h b/source/blender/freestyle/intern/system/RandGen.h
index 3c8724bcbee..d39b4f95bbf 100644
--- a/source/blender/freestyle/intern/system/RandGen.h
+++ b/source/blender/freestyle/intern/system/RandGen.h
@@ -30,8 +30,6 @@
// TODO Check whether we could replace this with BLI rand stuff...
-#include "FreestyleConfig.h"
-
#include "../system/Precision.h"
#ifdef WITH_CXX_GUARDEDALLOC
@@ -40,7 +38,7 @@
namespace Freestyle {
-class LIB_SYSTEM_EXPORT RandGen
+class RandGen
{
public:
static real drand48();
diff --git a/source/blender/freestyle/intern/system/StringUtils.h b/source/blender/freestyle/intern/system/StringUtils.h
index 92600eddc42..77b543c7886 100644
--- a/source/blender/freestyle/intern/system/StringUtils.h
+++ b/source/blender/freestyle/intern/system/StringUtils.h
@@ -34,15 +34,9 @@
#include <string>
#include <vector>
-#include "FreestyleConfig.h"
-
-//soc
extern "C" {
-
#include "BKE_utildefines.h"
-
#include "BLI_blenlib.h"
-
}
using namespace std;
@@ -51,7 +45,6 @@ namespace Freestyle {
namespace StringUtils {
-LIB_SYSTEM_EXPORT
void getPathName(const string& path, const string& base, vector<string>& pathnames);
// STL related
diff --git a/source/blender/freestyle/intern/system/TimeStamp.cpp b/source/blender/freestyle/intern/system/TimeStamp.cpp
index 7c02095ad51..0e387a5cc54 100644
--- a/source/blender/freestyle/intern/system/TimeStamp.cpp
+++ b/source/blender/freestyle/intern/system/TimeStamp.cpp
@@ -29,7 +29,6 @@
namespace Freestyle {
-LIB_SYSTEM_EXPORT
TimeStamp TimeStamp::_instance;
} /* namespace Freestyle */
diff --git a/source/blender/freestyle/intern/system/TimeStamp.h b/source/blender/freestyle/intern/system/TimeStamp.h
index e809aa71575..ccf370ad228 100644
--- a/source/blender/freestyle/intern/system/TimeStamp.h
+++ b/source/blender/freestyle/intern/system/TimeStamp.h
@@ -28,15 +28,13 @@
* \date 12/12/2002
*/
-#include "FreestyleConfig.h"
-
#ifdef WITH_CXX_GUARDEDALLOC
#include "MEM_guardedalloc.h"
#endif
namespace Freestyle {
-class LIB_SYSTEM_EXPORT TimeStamp
+class TimeStamp
{
public:
static inline TimeStamp *instance()
diff --git a/source/blender/freestyle/intern/system/TimeUtils.h b/source/blender/freestyle/intern/system/TimeUtils.h
index 6fe8b0e7431..2d14adc5912 100644
--- a/source/blender/freestyle/intern/system/TimeUtils.h
+++ b/source/blender/freestyle/intern/system/TimeUtils.h
@@ -30,8 +30,6 @@
#include <time.h>
-#include "FreestyleConfig.h"
-
#ifdef WITH_CXX_GUARDEDALLOC
#include "MEM_guardedalloc.h"
#endif
diff --git a/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp b/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp
index 2a1388c939b..d98a3238a25 100644
--- a/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp
+++ b/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp
@@ -27,8 +27,6 @@
#include "CulledOccluderSource.h"
-#include "FRS_freestyle.h"
-
#include "../geometry/GridHelpers.h"
#include "BKE_global.h"
diff --git a/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp b/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp
index 2da82f175ed..9c9cd88f188 100644
--- a/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp
+++ b/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp
@@ -26,7 +26,6 @@
*/
#include <float.h>
-#include <math.h>
#include "FEdgeXDetector.h"
diff --git a/source/blender/freestyle/intern/view_map/FEdgeXDetector.h b/source/blender/freestyle/intern/view_map/FEdgeXDetector.h
index 2bc0cd13e88..8adf685a6eb 100644
--- a/source/blender/freestyle/intern/view_map/FEdgeXDetector.h
+++ b/source/blender/freestyle/intern/view_map/FEdgeXDetector.h
@@ -39,6 +39,8 @@
#include "../winged_edge/Curvature.h"
#include "../winged_edge/WXEdge.h"
+#include "BLI_math.h"
+
#ifdef WITH_CXX_GUARDEDALLOC
#include "MEM_guardedalloc.h"
#endif
@@ -48,7 +50,7 @@ namespace Freestyle {
using namespace Geometry;
/*! This class takes as input a WXEdge structure and fills it */
-class LIB_VIEW_MAP_EXPORT FEdgeXDetector
+class FEdgeXDetector
{
public:
FEdgeXDetector()
diff --git a/source/blender/freestyle/intern/view_map/Functions0D.cpp b/source/blender/freestyle/intern/view_map/Functions0D.cpp
index f95690e6ff6..f47e5ff16d5 100644
--- a/source/blender/freestyle/intern/view_map/Functions0D.cpp
+++ b/source/blender/freestyle/intern/view_map/Functions0D.cpp
@@ -182,9 +182,9 @@ int VertexOrientation3DF0D::operator()(Interface0DIterator& iter)
A = Vec3r(iter->getX(), iter->getY(), iter->getZ());
}
else {
- Interface0DIterator previous = iter;
- --previous ;
- A = Vec3r(previous->getX(), previous->getY(), previous->getZ());
+ Interface0DIterator previous = iter;
+ --previous ;
+ A = Vec3r(previous->getX(), previous->getY(), previous->getZ());
}
Interface0DIterator next = iter;
++next ;
diff --git a/source/blender/freestyle/intern/view_map/Functions0D.h b/source/blender/freestyle/intern/view_map/Functions0D.h
index 7b90eacc218..045ad317db2 100644
--- a/source/blender/freestyle/intern/view_map/Functions0D.h
+++ b/source/blender/freestyle/intern/view_map/Functions0D.h
@@ -74,11 +74,11 @@ using namespace Geometry;
* - UnaryFunction0DVec3f
*/
template <class T>
-class /*LIB_VIEW_MAP_EXPORT*/ UnaryFunction0D
+class UnaryFunction0D
{
public:
T result;
- PyObject *py_uf0D;
+ void *py_uf0D;
/*! The type of the value returned by the functor. */
typedef T ReturnedValueType;
@@ -103,6 +103,7 @@ public:
* An Interface0DIterator pointing onto the point at which we wish to evaluate the function.
* \return the result of the function of type T.
*/
+ /* FIXME move the implementation to Functions0D.cpp */
virtual int operator()(Interface0DIterator& iter)
{
return Director_BPy_UnaryFunction0D___call__(this, py_uf0D, iter);
@@ -143,7 +144,7 @@ namespace Functions0D {
// GetXF0D
/*! Returns the X 3D coordinate of an Interface0D. */
-class LIB_VIEW_MAP_EXPORT GetXF0D : public UnaryFunction0D<double>
+class GetXF0D : public UnaryFunction0D<double>
{
public:
/*! Returns the string "GetXF0D" */
@@ -162,7 +163,7 @@ public:
// GetYF0D
/*! Returns the Y 3D coordinate of an Interface0D. */
-class LIB_VIEW_MAP_EXPORT GetYF0D : public UnaryFunction0D<double>
+class GetYF0D : public UnaryFunction0D<double>
{
public:
/*! Returns the string "GetYF0D" */
@@ -181,7 +182,7 @@ public:
// GetZF0D
/*! Returns the Z 3D coordinate of an Interface0D. */
-class LIB_VIEW_MAP_EXPORT GetZF0D : public UnaryFunction0D<double>
+class GetZF0D : public UnaryFunction0D<double>
{
public:
/*! Returns the string "GetZF0D" */
@@ -200,7 +201,7 @@ public:
// GetProjectedXF0D
/*! Returns the X 3D projected coordinate of an Interface0D. */
-class LIB_VIEW_MAP_EXPORT GetProjectedXF0D : public UnaryFunction0D<double>
+class GetProjectedXF0D : public UnaryFunction0D<double>
{
public:
/*! Returns the string "GetProjectedXF0D" */
@@ -219,7 +220,7 @@ public:
// GetProjectedYF0D
/*! Returns the Y projected 3D coordinate of an Interface0D. */
-class LIB_VIEW_MAP_EXPORT GetProjectedYF0D : public UnaryFunction0D<double>
+class GetProjectedYF0D : public UnaryFunction0D<double>
{
public:
/*! Returns the string "GetProjectedYF0D" */
@@ -238,7 +239,7 @@ public:
// GetProjectedZF0D
/*! Returns the Z projected 3D coordinate of an Interface0D. */
-class LIB_VIEW_MAP_EXPORT GetProjectedZF0D : public UnaryFunction0D<double>
+class GetProjectedZF0D : public UnaryFunction0D<double>
{
public:
/*! Returns the string "GetProjectedZF0D" */
@@ -257,7 +258,7 @@ public:
// GetCurvilinearAbscissaF0D
/*! Returns the curvilinear abscissa of an Interface0D in the context of its 1D element. */
-class LIB_VIEW_MAP_EXPORT GetCurvilinearAbscissaF0D : public UnaryFunction0D<float>
+class GetCurvilinearAbscissaF0D : public UnaryFunction0D<float>
{
public:
/*! Returns the string "GetCurvilinearAbscissaF0D" */
@@ -276,7 +277,7 @@ public:
// GetParameterF0D
/*! Returns the parameter of an Interface0D in the context of its 1D element. */
-class LIB_VIEW_MAP_EXPORT GetParameterF0D : public UnaryFunction0D<float>
+class GetParameterF0D : public UnaryFunction0D<float>
{
public:
/*! Returns the string "GetCurvilinearAbscissaF0D" */
@@ -297,7 +298,7 @@ public:
/*! Returns a Vec2r giving the 2D oriented tangent to the 1D element to which the Interface0DIterator& belongs to and
* evaluated at the Interface0D pointed by this Interface0DIterator&.
*/
-class LIB_VIEW_MAP_EXPORT VertexOrientation2DF0D : public UnaryFunction0D<Vec2f>
+class VertexOrientation2DF0D : public UnaryFunction0D<Vec2f>
{
public:
/*! Returns the string "VertexOrientation2DF0D" */
@@ -314,7 +315,7 @@ public:
/*! Returns a Vec3r giving the 3D oriented tangent to the 1D element to which the Interface0DIterator& belongs to and
* evaluated at the Interface0D pointed by this Interface0DIterator&.
*/
-class LIB_VIEW_MAP_EXPORT VertexOrientation3DF0D : public UnaryFunction0D<Vec3f>
+class VertexOrientation3DF0D : public UnaryFunction0D<Vec3f>
{
public:
/*! Returns the string "VertexOrientation3DF0D" */
@@ -331,7 +332,7 @@ public:
/*! Returns a real giving the 2D curvature (as an angle) of the 1D element to which the Interface0DIterator&
* belongs to and evaluated at the Interface0D pointed by this Interface0DIterator&.
*/
-class LIB_VIEW_MAP_EXPORT Curvature2DAngleF0D : public UnaryFunction0D<double>
+class Curvature2DAngleF0D : public UnaryFunction0D<double>
{
public:
/*! Returns the string "Curvature2DAngleF0D" */
@@ -349,7 +350,7 @@ public:
* This distance is evaluated in the camera space and normalized between 0 and 1. Therefore, if no object is occluded
* by the shape to which the Interface0D belongs to, 1 is returned.
*/
-class LIB_VIEW_MAP_EXPORT ZDiscontinuityF0D : public UnaryFunction0D<double>
+class ZDiscontinuityF0D : public UnaryFunction0D<double>
{
public:
/*! Returns the string "ZDiscontinuityF0D" */
@@ -366,7 +367,7 @@ public:
/*! Returns a Vec2f giving the normalized 2D normal to the 1D element to which the Interface0DIterator& belongs to and
* evaluated at the Interface0D pointed by this Interface0DIterator&.
*/
-class LIB_VIEW_MAP_EXPORT Normal2DF0D : public UnaryFunction0D<Vec2f>
+class Normal2DF0D : public UnaryFunction0D<Vec2f>
{
public:
/*! Returns the string "Normal2DF0D" */
@@ -388,7 +389,7 @@ public:
* However, there still can be problematic cases, and the user willing to deal with this cases in a specific way
* should implement its own getMaterial functor.
*/
-class LIB_VIEW_MAP_EXPORT MaterialF0D : public UnaryFunction0D<FrsMaterial>
+class MaterialF0D : public UnaryFunction0D<FrsMaterial>
{
public:
/*! Returns the string "MaterialF0D" */
@@ -409,7 +410,7 @@ public:
* However, there still can be problematic cases, and the user willing to deal with this cases in a specific way
* should implement its own getShapeIdF0D functor.
*/
-class LIB_VIEW_MAP_EXPORT ShapeIdF0D : public UnaryFunction0D<Id>
+class ShapeIdF0D : public UnaryFunction0D<Id>
{
public:
/*! Returns the string "ShapeIdF0D" */
@@ -430,7 +431,7 @@ public:
* However, there still can be problematic cases, and the user willing to deal with this cases in a specific way
* should implement its own getQIF0D functor.
*/
-class LIB_VIEW_MAP_EXPORT QuantitativeInvisibilityF0D : public UnaryFunction0D<unsigned int>
+class QuantitativeInvisibilityF0D : public UnaryFunction0D<unsigned int>
{
public:
/*! Returns the string "QuantitativeInvisibilityF0D" */
@@ -445,7 +446,7 @@ public:
// CurveNatureF0D
/*! Returns the Nature::EdgeNature of the 1D element the Interface0DIterator& belongs to. */
-class LIB_VIEW_MAP_EXPORT CurveNatureF0D : public UnaryFunction0D<Nature::EdgeNature>
+class CurveNatureF0D : public UnaryFunction0D<Nature::EdgeNature>
{
public:
/*! Returns the string "QuantitativeInvisibilityF0D" */
@@ -460,7 +461,7 @@ public:
// GetShapeF0D
/*! Returns the ViewShape* containing the Interface0D */
-class LIB_VIEW_MAP_EXPORT GetShapeF0D : public UnaryFunction0D< ViewShape*>
+class GetShapeF0D : public UnaryFunction0D< ViewShape*>
{
public:
/*! Returns the string "GetShapeF0D" */
@@ -475,7 +476,7 @@ public:
// GetOccludersF0D
/*! Returns a vector containing the ViewShape* occluding the Interface0D */
-class LIB_VIEW_MAP_EXPORT GetOccludersF0D : public UnaryFunction0D< std::vector<ViewShape*> >
+class GetOccludersF0D : public UnaryFunction0D< std::vector<ViewShape*> >
{
public:
/*! Returns the string "GetOccludersF0D" */
@@ -490,7 +491,7 @@ public:
// GetOccludeeF0D
/*! Returns the ViewShape* "occluded" by the Interface0D */
-class LIB_VIEW_MAP_EXPORT GetOccludeeF0D: public UnaryFunction0D< ViewShape*>
+class GetOccludeeF0D: public UnaryFunction0D< ViewShape*>
{
public:
/*! Returns the string "GetOccludeeF0D" */
@@ -507,27 +508,21 @@ public:
/////////////////////////// Internal ////////////////////////////
// getFEdge
-LIB_VIEW_MAP_EXPORT
FEdge *getFEdge(Interface0D& it1, Interface0D& it2);
// getFEdges
-LIB_VIEW_MAP_EXPORT
void getFEdges(Interface0DIterator& it, FEdge *&fe1, FEdge *&fe2);
// getViewEdges
-LIB_VIEW_MAP_EXPORT
void getViewEdges(Interface0DIterator& it, ViewEdge *&ve1, ViewEdge *&ve2);
// getShapeF0D
-LIB_VIEW_MAP_EXPORT
ViewShape *getShapeF0D(Interface0DIterator& it);
// getOccludersF0D
-LIB_VIEW_MAP_EXPORT
void getOccludersF0D(Interface0DIterator& it, std::set<ViewShape*>& oOccluders);
// getOccludeeF0D
-LIB_VIEW_MAP_EXPORT
ViewShape *getOccludeeF0D(Interface0DIterator& it);
} // end of namespace Functions0D
diff --git a/source/blender/freestyle/intern/view_map/Functions1D.cpp b/source/blender/freestyle/intern/view_map/Functions1D.cpp
index c66d8b8bfe7..f29da6680bf 100644
--- a/source/blender/freestyle/intern/view_map/Functions1D.cpp
+++ b/source/blender/freestyle/intern/view_map/Functions1D.cpp
@@ -26,7 +26,7 @@
* \date 01/07/2003
*/
-# include "Functions1D.h"
+#include "Functions1D.h"
using namespace std;
diff --git a/source/blender/freestyle/intern/view_map/Functions1D.h b/source/blender/freestyle/intern/view_map/Functions1D.h
index ff109903e9b..0821475ca9c 100644
--- a/source/blender/freestyle/intern/view_map/Functions1D.h
+++ b/source/blender/freestyle/intern/view_map/Functions1D.h
@@ -64,11 +64,11 @@ namespace Freestyle {
* - UnaryFunction1DVec3f
*/
template <class T>
-class /*LIB_VIEW_MAP_EXPORT*/ UnaryFunction1D
+class UnaryFunction1D
{
public:
T result;
- PyObject *py_uf1D;
+ void *py_uf1D;
/*! The type of the value returned by the functor. */
typedef T ReturnedValueType;
@@ -104,6 +104,7 @@ public:
* The Interface1D on which we wish to evaluate the function.
* \return the result of the function of type T.
*/
+ /* FIXME move the implementation to Functions1D.cpp */
virtual int operator()(Interface1D& inter)
{
return Director_BPy_UnaryFunction1D___call__(this, py_uf1D, inter);
@@ -133,7 +134,7 @@ protected:
class UnaryFunction1D_void
{
public:
- PyObject *py_uf1D;
+ void *py_uf1D;
UnaryFunction1D_void()
{
@@ -152,6 +153,7 @@ public:
return "UnaryFunction1D_void";
}
+ /* FIXME move the implementation to Functions1D.cpp */
int operator()(Interface1D& inter)
{
return Director_BPy_UnaryFunction1D___call__(this, py_uf1D, inter);
@@ -185,7 +187,7 @@ namespace Functions1D {
// GetXF1D
/*! Returns the X 3D coordinate of an Interface1D. */
-class LIB_VIEW_MAP_EXPORT GetXF1D : public UnaryFunction1D<double>
+class GetXF1D : public UnaryFunction1D<double>
{
private:
Functions0D::GetXF0D _func;
@@ -209,7 +211,7 @@ public:
// GetYF1D
/*! Returns the Y 3D coordinate of an Interface1D. */
-class LIB_VIEW_MAP_EXPORT GetYF1D : public UnaryFunction1D<double>
+class GetYF1D : public UnaryFunction1D<double>
{
private:
Functions0D::GetYF0D _func;
@@ -233,7 +235,7 @@ public:
// GetZF1D
/*! Returns the Z 3D coordinate of an Interface1D. */
-class LIB_VIEW_MAP_EXPORT GetZF1D : public UnaryFunction1D<double>
+class GetZF1D : public UnaryFunction1D<double>
{
private:
Functions0D::GetZF0D _func;
@@ -257,7 +259,7 @@ public:
// GetProjectedXF1D
/*! Returns the projected X 3D coordinate of an Interface1D. */
-class LIB_VIEW_MAP_EXPORT GetProjectedXF1D : public UnaryFunction1D<double>
+class GetProjectedXF1D : public UnaryFunction1D<double>
{
private:
Functions0D::GetProjectedXF0D _func;
@@ -281,7 +283,7 @@ public:
// GetProjectedYF1D
/*! Returns the projected Y 3D coordinate of an Interface1D. */
-class LIB_VIEW_MAP_EXPORT GetProjectedYF1D : public UnaryFunction1D<double>
+class GetProjectedYF1D : public UnaryFunction1D<double>
{
private:
Functions0D::GetProjectedYF0D _func;
@@ -305,7 +307,7 @@ public:
// GetProjectedZF1D
/*! Returns the projected Z 3D coordinate of an Interface1D. */
-class LIB_VIEW_MAP_EXPORT GetProjectedZF1D : public UnaryFunction1D<double>
+class GetProjectedZF1D : public UnaryFunction1D<double>
{
private:
Functions0D::GetProjectedZF0D _func;
@@ -329,7 +331,7 @@ public:
// Orientation2DF1D
/*! Returns the 2D orientation as a Vec2f*/
-class LIB_VIEW_MAP_EXPORT Orientation2DF1D : public UnaryFunction1D<Vec2f>
+class Orientation2DF1D : public UnaryFunction1D<Vec2f>
{
private:
Functions0D::VertexOrientation2DF0D _func;
@@ -353,7 +355,7 @@ public:
// Orientation3DF1D
/*! Returns the 3D orientation as a Vec3f. */
-class LIB_VIEW_MAP_EXPORT Orientation3DF1D : public UnaryFunction1D<Vec3f>
+class Orientation3DF1D : public UnaryFunction1D<Vec3f>
{
private:
Functions0D::VertexOrientation3DF0D _func;
@@ -380,7 +382,7 @@ public:
* This distance is evaluated in the camera space and normalized between 0 and 1. Therefore, if no object is occluded
* by the shape to which the Interface1D belongs to, 1 is returned.
*/
-class LIB_VIEW_MAP_EXPORT ZDiscontinuityF1D : public UnaryFunction1D<double>
+class ZDiscontinuityF1D : public UnaryFunction1D<double>
{
private:
Functions0D::ZDiscontinuityF0D _func;
@@ -408,7 +410,7 @@ public:
* results of a chaining (chain, stroke), then it might be made of several 1D elements of different
* Quantitative Invisibilities.
*/
-class LIB_VIEW_MAP_EXPORT QuantitativeInvisibilityF1D : public UnaryFunction1D<unsigned>
+class QuantitativeInvisibilityF1D : public UnaryFunction1D<unsigned>
{
private:
Functions0D::QuantitativeInvisibilityF0D _func;
@@ -436,7 +438,7 @@ public:
* Indeed, the Interface1D might result from the gathering of several 1D elements, each one being of a different
* nature. An integration method, such as the MEAN, might give, in this case, irrelevant results.
*/
-class LIB_VIEW_MAP_EXPORT CurveNatureF1D : public UnaryFunction1D<Nature::EdgeNature>
+class CurveNatureF1D : public UnaryFunction1D<Nature::EdgeNature>
{
private:
Functions0D::CurveNatureF0D _func;
@@ -460,7 +462,7 @@ public:
// TimeStampF1D
/*! Returns the time stamp of the Interface1D. */
-class LIB_VIEW_MAP_EXPORT TimeStampF1D : public UnaryFunction1D_void
+class TimeStampF1D : public UnaryFunction1D_void
{
public:
/*! Returns the string "TimeStampF1D" */
@@ -475,7 +477,7 @@ public:
// IncrementChainingTimeStampF1D
/*! Increments the chaining time stamp of the Interface1D. */
-class LIB_VIEW_MAP_EXPORT IncrementChainingTimeStampF1D : public UnaryFunction1D_void
+class IncrementChainingTimeStampF1D : public UnaryFunction1D_void
{
public:
/*! Returns the string "IncrementChainingTimeStampF1D" */
@@ -490,7 +492,7 @@ public:
// ChainingTimeStampF1D
/*! Sets the chaining time stamp of the Interface1D. */
-class LIB_VIEW_MAP_EXPORT ChainingTimeStampF1D : public UnaryFunction1D_void
+class ChainingTimeStampF1D : public UnaryFunction1D_void
{
public:
/*! Returns the string "ChainingTimeStampF1D" */
@@ -506,7 +508,7 @@ public:
// Curvature2DAngleF1D
/*! Returns the 2D curvature as an angle for an Interface1D. */
-class LIB_VIEW_MAP_EXPORT Curvature2DAngleF1D : public UnaryFunction1D<double>
+class Curvature2DAngleF1D : public UnaryFunction1D<double>
{
public:
/*! Builds the functor.
@@ -534,7 +536,7 @@ private:
// Normal2DF1D
/*! Returns the 2D normal for an interface 1D. */
-class LIB_VIEW_MAP_EXPORT Normal2DF1D : public UnaryFunction1D<Vec2f>
+class Normal2DF1D : public UnaryFunction1D<Vec2f>
{
public:
/*! Builds the functor.
@@ -562,7 +564,7 @@ private:
// GetShapeF1D
/*! Returns list of shapes covered by this Interface1D. */
-class LIB_VIEW_MAP_EXPORT GetShapeF1D : public UnaryFunction1D<std::vector<ViewShape*> >
+class GetShapeF1D : public UnaryFunction1D<std::vector<ViewShape*> >
{
public:
/*! Builds the functor. */
@@ -580,7 +582,7 @@ public:
// GetOccludersF1D
/*! Returns list of occluding shapes covered by this Interface1D. */
-class LIB_VIEW_MAP_EXPORT GetOccludersF1D : public UnaryFunction1D<std::vector<ViewShape*> >
+class GetOccludersF1D : public UnaryFunction1D<std::vector<ViewShape*> >
{
public:
/*! Builds the functor. */
@@ -598,7 +600,7 @@ public:
// GetOccludeeF1D
/*! Returns list of occluded shapes covered by this Interface1D. */
-class LIB_VIEW_MAP_EXPORT GetOccludeeF1D : public UnaryFunction1D<std::vector<ViewShape*> >
+class GetOccludeeF1D : public UnaryFunction1D<std::vector<ViewShape*> >
{
public:
/*! Builds the functor. */
@@ -618,15 +620,12 @@ public:
////////////
// getOccludeeF1D
-LIB_VIEW_MAP_EXPORT
void getOccludeeF1D(Interface1D& inter, set<ViewShape*>& oShapes);
// getOccludersF1D
-LIB_VIEW_MAP_EXPORT
void getOccludersF1D(Interface1D& inter, set<ViewShape*>& oShapes);
// getShapeF1D
-LIB_VIEW_MAP_EXPORT
void getShapeF1D(Interface1D& inter, set<ViewShape*>& oShapes);
} // end of namespace Functions1D
diff --git a/source/blender/freestyle/intern/view_map/Interface0D.cpp b/source/blender/freestyle/intern/view_map/Interface0D.cpp
new file mode 100644
index 00000000000..135a935d2fe
--- /dev/null
+++ b/source/blender/freestyle/intern/view_map/Interface0D.cpp
@@ -0,0 +1,123 @@
+/*
+ * ***** 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 *****
+ */
+
+/** \file blender/freestyle/intern/view_map/Interface0D.cpp
+ * \ingroup freestyle
+ */
+
+extern "C" {
+#include <Python.h>
+}
+
+#include "Interface0D.h"
+
+namespace Freestyle {
+
+real Interface0D::getX() const
+{
+ PyErr_SetString(PyExc_TypeError, "method getX() not properly overridden");
+ return 0;
+}
+
+real Interface0D::getY() const
+{
+ PyErr_SetString(PyExc_TypeError, "method getY() not properly overridden");
+ return 0;
+}
+
+real Interface0D::getZ() const
+{
+ PyErr_SetString(PyExc_TypeError, "method getZ() not properly overridden");
+ return 0;
+}
+
+Geometry::Vec3f Interface0D::getPoint3D() const
+{
+ PyErr_SetString(PyExc_TypeError, "method getPoint3D() not properly overridden");
+ return 0;
+}
+
+real Interface0D::getProjectedX() const
+{
+ PyErr_SetString(PyExc_TypeError, "method getProjectedX() not properly overridden");
+ return 0;
+}
+
+real Interface0D::getProjectedY() const
+{
+ PyErr_SetString(PyExc_TypeError, "method getProjectedY() not properly overridden");
+ return 0;
+}
+
+real Interface0D::getProjectedZ() const
+{
+ PyErr_SetString(PyExc_TypeError, "method getProjectedZ() not properly overridden");
+ return 0;
+}
+
+Geometry::Vec2f Interface0D::getPoint2D() const
+{
+ PyErr_SetString(PyExc_TypeError, "method getPoint2D() not properly overridden");
+ return 0;
+}
+
+FEdge * Interface0D::getFEdge(Interface0D&)
+{
+ PyErr_SetString(PyExc_TypeError, "method getFEdge() not properly overridden");
+ return 0;
+}
+
+Id Interface0D::getId() const
+{
+ PyErr_SetString(PyExc_TypeError, "method getId() not properly overridden");
+ return 0;
+}
+
+Nature::VertexNature Interface0D::getNature() const
+{
+ PyErr_SetString(PyExc_TypeError, "method getNature() not properly overridden");
+ return Nature::POINT;
+}
+
+SVertex * Interface0D::castToSVertex()
+{
+ PyErr_SetString(PyExc_TypeError, "method castToSVertex() not properly overridden");
+ return 0;
+}
+
+ViewVertex * Interface0D::castToViewVertex()
+{
+ PyErr_SetString(PyExc_TypeError, "method castToViewVertex() not properly overridden");
+ return 0;
+}
+
+NonTVertex * Interface0D::castToNonTVertex()
+{
+ PyErr_SetString(PyExc_TypeError, "method castToNonTVertex() not properly overridden");
+ return 0;
+}
+
+TVertex * Interface0D::castToTVertex()
+{
+ PyErr_SetString(PyExc_TypeError, "method castToTVertex() not properly overridden");
+ return 0;
+}
+
+} /* namespace Freestyle */
diff --git a/source/blender/freestyle/intern/view_map/Interface0D.h b/source/blender/freestyle/intern/view_map/Interface0D.h
index c9776bb77fa..e59ed4c96c8 100644
--- a/source/blender/freestyle/intern/view_map/Interface0D.h
+++ b/source/blender/freestyle/intern/view_map/Interface0D.h
@@ -29,13 +29,12 @@
*/
#include <iostream>
-#include <Python.h>
#include <string>
#include "../geometry/Geom.h"
#include "../system/Id.h"
-#include "../system/Iterator.h" //soc
+#include "../system/Iterator.h"
#include "../system/Precision.h"
#include "../winged_edge/Nature.h"
@@ -65,7 +64,9 @@ class Interface0D
public:
/*! Default constructor */
Interface0D() {}
- virtual ~Interface0D() {}; //soc
+
+ /*! Destructor */
+ virtual ~Interface0D() {};
/*! Returns the string "Interface0D". */
virtual string getExactTypeName() const
@@ -76,110 +77,49 @@ public:
// Data access methods
/*! Returns the 3D x coordinate of the point. */
- virtual real getX() const
- {
- PyErr_SetString(PyExc_TypeError, "method getX() not properly overridden");
- return 0;
- }
+ virtual real getX() const;
/*! Returns the 3D y coordinate of the point. */
- virtual real getY() const
- {
- PyErr_SetString(PyExc_TypeError, "method getY() not properly overridden");
- return 0;
- }
+ virtual real getY() const;
- /*! Returns the 3D z coordinate of the point. */
- virtual real getZ() const
- {
- PyErr_SetString(PyExc_TypeError, "method getZ() not properly overridden");
- return 0;
- }
+ /*! Returns the 3D z coordinate of the point. */
+ virtual real getZ() const;
- /*! Returns the 3D point. */
- virtual Geometry::Vec3f getPoint3D() const
- {
- PyErr_SetString(PyExc_TypeError, "method getPoint3D() not properly overridden");
- return 0;
- }
+ /*! Returns the 3D point. */
+ virtual Geometry::Vec3f getPoint3D() const;
/*! Returns the 2D x coordinate of the point. */
- virtual real getProjectedX() const
- {
- PyErr_SetString(PyExc_TypeError, "method getProjectedX() not properly overridden");
- return 0;
- }
+ virtual real getProjectedX() const;
/*! Returns the 2D y coordinate of the point. */
- virtual real getProjectedY() const
- {
- PyErr_SetString(PyExc_TypeError, "method getProjectedY() not properly overridden");
- return 0;
- }
+ virtual real getProjectedY() const;
/*! Returns the 2D z coordinate of the point. */
- virtual real getProjectedZ() const
- {
- PyErr_SetString(PyExc_TypeError, "method getProjectedZ() not properly overridden");
- return 0;
- }
+ virtual real getProjectedZ() const;
- /*! Returns the 2D point. */
- virtual Geometry::Vec2f getPoint2D() const
- {
- PyErr_SetString(PyExc_TypeError, "method getPoint2D() not properly overridden");
- return 0;
- }
+ /*! Returns the 2D point. */
+ virtual Geometry::Vec2f getPoint2D() const;
/*! Returns the FEdge that lies between this Interface0D and the Interface0D given as argument. */
- virtual FEdge *getFEdge(Interface0D&)
- {
- PyErr_SetString(PyExc_TypeError, "method getFEdge() not properly overridden");
- return 0;
- }
+ virtual FEdge *getFEdge(Interface0D&);
/*! Returns the Id of the point. */
- virtual Id getId() const
- {
- PyErr_SetString(PyExc_TypeError, "method getId() not properly overridden");
- return 0;
- }
+ virtual Id getId() const;
/*! Returns the nature of the point. */
- virtual Nature::VertexNature getNature() const
- {
- PyErr_SetString(PyExc_TypeError, "method getNature() not properly overridden");
- return Nature::POINT;
- }
-
+ virtual Nature::VertexNature getNature() const;
/*! Cast the Interface0D in SVertex if it can be. */
- virtual SVertex *castToSVertex()
- {
- PyErr_SetString(PyExc_TypeError, "method castToSVertex() not properly overridden");
- return 0;
- }
+ virtual SVertex *castToSVertex();
/*! Cast the Interface0D in ViewVertex if it can be. */
- virtual ViewVertex *castToViewVertex()
- {
- PyErr_SetString(PyExc_TypeError, "method castToViewVertex() not properly overridden");
- return 0;
- }
+ virtual ViewVertex *castToViewVertex();
/*! Cast the Interface0D in NonTVertex if it can be. */
- virtual NonTVertex *castToNonTVertex()
- {
- PyErr_SetString(PyExc_TypeError, "method castToNonTVertex() not properly overridden");
- return 0;
- }
+ virtual NonTVertex *castToNonTVertex();
/*! Cast the Interface0D in TVertex if it can be. */
- virtual TVertex *castToTVertex()
- {
- PyErr_SetString(PyExc_TypeError, "method castToTVertex() not properly overridden");
- return 0;
- }
+ virtual TVertex *castToTVertex();
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:Interface0D")
diff --git a/source/blender/freestyle/intern/view_map/Interface1D.cpp b/source/blender/freestyle/intern/view_map/Interface1D.cpp
new file mode 100644
index 00000000000..985310e52b5
--- /dev/null
+++ b/source/blender/freestyle/intern/view_map/Interface1D.cpp
@@ -0,0 +1,75 @@
+/*
+ * ***** 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 *****
+ */
+
+/** \file blender/freestyle/intern/view_map/Interface1D.cpp
+ * \ingroup freestyle
+ */
+
+extern "C" {
+#include <Python.h>
+}
+
+#include "Interface1D.h"
+
+namespace Freestyle {
+
+Interface0DIterator Interface1D::verticesBegin()
+{
+ PyErr_SetString(PyExc_TypeError, "method verticesBegin() not properly overridden");
+ return Interface0DIterator();
+}
+
+Interface0DIterator Interface1D::verticesEnd()
+{
+ PyErr_SetString(PyExc_TypeError, "method verticesEnd() not properly overridden");
+ return Interface0DIterator();
+}
+
+Interface0DIterator Interface1D::pointsBegin(float t)
+{
+ PyErr_SetString(PyExc_TypeError, "method pointsBegin() not properly overridden");
+ return Interface0DIterator();
+}
+
+Interface0DIterator Interface1D::pointsEnd(float t)
+{
+ PyErr_SetString(PyExc_TypeError, "method pointsEnd() not properly overridden");
+ return Interface0DIterator();
+}
+
+real Interface1D::getLength2D() const
+{
+ PyErr_SetString(PyExc_TypeError, "method getLength2D() not properly overridden");
+ return 0;
+}
+
+Id Interface1D::getId() const
+{
+ PyErr_SetString(PyExc_TypeError, "method getId() not properly overridden");
+ return Id(0, 0);
+}
+
+Nature::EdgeNature Interface1D::getNature() const
+{
+ PyErr_SetString(PyExc_TypeError, "method getNature() not properly overridden");
+ return Nature::NO_FEATURE;
+}
+
+} /* namespace Freestyle */
diff --git a/source/blender/freestyle/intern/view_map/Interface1D.h b/source/blender/freestyle/intern/view_map/Interface1D.h
index c7beafaf14d..7afa61ff496 100644
--- a/source/blender/freestyle/intern/view_map/Interface1D.h
+++ b/source/blender/freestyle/intern/view_map/Interface1D.h
@@ -30,7 +30,6 @@
#include <float.h>
#include <iostream>
-#include <Python.h>
#include <string>
#include "Functions0D.h"
@@ -137,7 +136,8 @@ public:
_timeStamp = 0;
}
- virtual ~Interface1D() {}; //soc
+ /*! Destructor */
+ virtual ~Interface1D() {};
/*! Returns the string "Interface1D". */
virtual string getExactTypeName() const
@@ -148,18 +148,10 @@ public:
// Iterator access
/*! Returns an iterator over the Interface1D vertices, pointing to the first vertex. */
- virtual Interface0DIterator verticesBegin()
- {
- PyErr_SetString(PyExc_TypeError, "method verticesBegin() not properly overridden");
- return Interface0DIterator();
- }
+ virtual Interface0DIterator verticesBegin();
/*! Returns an iterator over the Interface1D vertices, pointing after the last vertex. */
- virtual Interface0DIterator verticesEnd()
- {
- PyErr_SetString(PyExc_TypeError, "method verticesEnd() not properly overridden");
- return Interface0DIterator();
- }
+ virtual Interface0DIterator verticesEnd();
/*! Returns an iterator over the Interface1D points, pointing to the first point. The difference with
* verticesBegin() is that here we can iterate over points of the 1D element at a any given sampling.
@@ -167,11 +159,7 @@ public:
* \param t
* The sampling with which we want to iterate over points of this 1D element.
*/
- virtual Interface0DIterator pointsBegin(float t = 0.0f)
- {
- PyErr_SetString(PyExc_TypeError, "method pointsBegin() not properly overridden");
- return Interface0DIterator();
- }
+ virtual Interface0DIterator pointsBegin(float t = 0.0f);
/*! Returns an iterator over the Interface1D points, pointing after the last point. The difference with
* verticesEnd() is that here we can iterate over points of the 1D element at a any given sampling.
@@ -179,36 +167,19 @@ public:
* \param t
* The sampling with which we want to iterate over points of this 1D element.
*/
- virtual Interface0DIterator pointsEnd(float t = 0.0f)
- {
- PyErr_SetString(PyExc_TypeError, "method pointsEnd() not properly overridden");
- return Interface0DIterator();
- }
+ virtual Interface0DIterator pointsEnd(float t = 0.0f);
// Data access methods
/*! Returns the 2D length of the 1D element. */
- virtual real getLength2D() const
- {
- PyErr_SetString(PyExc_TypeError, "method getLength2D() not properly overridden");
- return 0;
- }
+ virtual real getLength2D() const;
/*! Returns the Id of the 1D element. */
- virtual Id getId() const
- {
- PyErr_SetString(PyExc_TypeError, "method getId() not properly overridden");
- return Id(0, 0);
- }
-
+ virtual Id getId() const;
// FIXME: ce truc n'a rien a faire la...(c une requete complexe qui doit etre ds les Function1D)
/*! Returns the nature of the 1D element. */
- virtual Nature::EdgeNature getNature() const
- {
- PyErr_SetString(PyExc_TypeError, "method getNature() not properly overridden");
- return Nature::NO_FEATURE;
- }
+ virtual Nature::EdgeNature getNature() const;
/*! Returns the time stamp of the 1D element. Mainly used for selection. */
virtual unsigned getTimeStamp() const
diff --git a/source/blender/freestyle/intern/view_map/Silhouette.h b/source/blender/freestyle/intern/view_map/Silhouette.h
index 88a07127837..e747f9c3e68 100644
--- a/source/blender/freestyle/intern/view_map/Silhouette.h
+++ b/source/blender/freestyle/intern/view_map/Silhouette.h
@@ -74,7 +74,7 @@ class ViewVertex;
class SShape;
/*! Class to define a vertex of the embedding. */
-class LIB_VIEW_MAP_EXPORT SVertex : public Interface0D
+class SVertex : public Interface0D
{
public: // Implementation of Interface0D
/*! Returns the string "SVertex" .*/
@@ -462,7 +462,7 @@ class ViewEdge;
* This class is specialized into a smooth and a sharp version since their properties slightly vary from
* one to the other.
*/
-class LIB_VIEW_MAP_EXPORT FEdge : public Interface1D
+class FEdge : public Interface1D
{
public: // Implementation of Interface0D
/*! Returns the string "FEdge". */
@@ -1103,7 +1103,7 @@ Interface0DIterator FEdge::pointsEnd(float t)
* by two faces of the mesh. Face a lies on its right whereas Face b lies on its left.
* If it is a border edge, then it doesn't have any face on its right, and thus Face a = 0.
*/
-class LIB_VIEW_MAP_EXPORT FEdgeSharp : public FEdge
+class FEdgeSharp : public FEdge
{
protected:
Vec3r _aNormal; // When following the edge, normal of the right face
@@ -1246,7 +1246,7 @@ public:
/*! Class defining a smooth edge. This kind of edge typically runs across a face of the input mesh. It can be
* a silhouette, a ridge or valley, a suggestive contour.
*/
-class LIB_VIEW_MAP_EXPORT FEdgeSmooth : public FEdge
+class FEdgeSmooth : public FEdge
{
protected:
Vec3r _Normal;
@@ -1366,7 +1366,7 @@ public:
/*! Class to define a feature shape. It is the gathering of feature elements from an identified input shape */
-class LIB_VIEW_MAP_EXPORT SShape
+class SShape
{
private:
vector<FEdge*> _chains; // list of fedges that are chains starting points.
diff --git a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp
index 8b8f42f3922..ee885f29211 100644
--- a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp
+++ b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp
@@ -26,6 +26,9 @@
* \date 03/09/2002
*/
+#include <cstring>
+#include <cstdio>
+
#include "Silhouette.h"
#include "SilhouetteGeomEngine.h"
@@ -295,11 +298,11 @@ iter:
}
#if 0
if (G.debug & G_DEBUG_FREESTYLE) {
- printf("SilhouetteGeomEngine::ImageToWorldParameter(): #iters = %d, dist = %e\n", i, dist);
+ cout << "SilhouetteGeomEngine::ImageToWorldParameter(): #iters = " << i << ", dist = " << dist << "\n";
}
#endif
if (i == max_iters && G.debug & G_DEBUG_FREESTYLE) {
- printf("SilhouetteGeomEngine::ImageToWorldParameter(): reached to max_iters (dist = %e)\n", dist);
+ cout << "SilhouetteGeomEngine::ImageToWorldParameter(): reached to max_iters (dist = " << dist << ")\n";
}
}
diff --git a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h
index 4002385a823..1234c028ca1 100644
--- a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h
+++ b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h
@@ -46,7 +46,7 @@ using namespace Geometry;
class SVertex;
class FEdge;
-class LIB_VIEW_MAP_EXPORT SilhouetteGeomEngine
+class SilhouetteGeomEngine
{
private:
// The viewpoint under which the silhouette has to be computed
diff --git a/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp b/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp
index c777db6249f..fe6f3f1892d 100644
--- a/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp
+++ b/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp
@@ -25,9 +25,6 @@
* \date 01/07/2003
*/
-#include <math.h>
-//soc #include <qimage.h>
-//soc #include <qstring.h>
#include <sstream>
#include "Silhouette.h"
@@ -39,6 +36,7 @@
#include "../image/Image.h"
#include "BKE_global.h"
+#include "BLI_math.h"
extern "C" {
#include "IMB_imbuf.h"
diff --git a/source/blender/freestyle/intern/view_map/SteerableViewMap.h b/source/blender/freestyle/intern/view_map/SteerableViewMap.h
index d6af7384fb8..0cd5d222621 100644
--- a/source/blender/freestyle/intern/view_map/SteerableViewMap.h
+++ b/source/blender/freestyle/intern/view_map/SteerableViewMap.h
@@ -51,7 +51,7 @@ class GrayImage;
/*! This class checks for every FEdge in which steerable it belongs and stores the mapping allowing to retrieve
* this information from the FEdge Id.
*/
-class LIB_VIEW_MAP_EXPORT SteerableViewMap
+class SteerableViewMap
{
protected:
// for each vector the list of nbOrientations weigths corresponding to its contributions
diff --git a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h
index 6efc81efbaf..7f214919114 100644
--- a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h
+++ b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h
@@ -183,7 +183,7 @@ class ViewVertex;
class ViewEdge;
class ViewShape;
-class LIB_VIEW_MAP_EXPORT ViewEdgeXBuilder
+class ViewEdgeXBuilder
{
protected:
int _currentViewId; // Id for view edges
diff --git a/source/blender/freestyle/intern/view_map/ViewMap.cpp b/source/blender/freestyle/intern/view_map/ViewMap.cpp
index 246c4caef82..fd5ebb99f72 100644
--- a/source/blender/freestyle/intern/view_map/ViewMap.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewMap.cpp
@@ -28,8 +28,8 @@
#include <float.h>
#include "ViewMap.h"
-#include "ViewMapAdvancedIterators.h"
#include "ViewMapIterators.h"
+#include "ViewMapAdvancedIterators.h"
#include "../geometry/GeomUtils.h"
diff --git a/source/blender/freestyle/intern/view_map/ViewMap.h b/source/blender/freestyle/intern/view_map/ViewMap.h
index 2c9672be53b..eeaeada5dc6 100644
--- a/source/blender/freestyle/intern/view_map/ViewMap.h
+++ b/source/blender/freestyle/intern/view_map/ViewMap.h
@@ -65,7 +65,7 @@ class ViewShape;
class TVertex;
/*! Class defining the ViewMap.*/
-class LIB_VIEW_MAP_EXPORT ViewMap
+class ViewMap
{
public:
typedef vector<ViewEdge*> viewedges_container;
@@ -268,7 +268,7 @@ class orientedViewEdgeIterator;
* NonTVertex when it corresponds to a vertex of the initial input mesh (it is the case for vertices such as corners
* for example). Thus, this class can be specialized into two classes, the TVertex class and the NonTVertex class.
*/
-class LIB_VIEW_MAP_EXPORT ViewVertex : public Interface0D
+class ViewVertex : public Interface0D
{
public: // Implementation of Interface0D
/*! Returns the string "ViewVertex". */
@@ -386,7 +386,7 @@ public:
* Basically the front edge hides part of the back edge.
* So, among the back edges, 1 is of invisibility n and the other of visibility n+1
*/
-class LIB_VIEW_MAP_EXPORT TVertex : public ViewVertex
+class TVertex : public ViewVertex
{
public:
typedef vector<directedViewEdge*> edge_pointers_container;
@@ -660,7 +660,7 @@ public:
* Associated to a single SVertex.
* Can be associated to 2 or several view edges
*/
-class LIB_VIEW_MAP_EXPORT NonTVertex : public ViewVertex
+class NonTVertex : public ViewVertex
{
public:
typedef vector<directedViewEdge> edges_container;
@@ -891,7 +891,7 @@ template<class Traits> class vertex_iterator_base;
/*! Class defining a ViewEdge. A ViewEdge in an edge of the image graph. it connects two ViewVertex.
* It is made by connecting a set of FEdges.
*/
-class LIB_VIEW_MAP_EXPORT ViewEdge : public Interface1D
+class ViewEdge : public Interface1D
{
public: // Implementation of Interface0D
/*! Returns the string "ViewEdge". */
@@ -1392,7 +1392,7 @@ public:
/**********************************/
/*! Class gathering the elements of the ViewMap (ViewVertex, ViewEdge) that are issued from the same input shape. */
-class LIB_VIEW_MAP_EXPORT ViewShape
+class ViewShape
{
private:
vector<ViewVertex*> _Vertices;
diff --git a/source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h b/source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h
index a8c046c4dc1..8e98cabd75b 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h
+++ b/source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h
@@ -53,21 +53,21 @@ namespace Freestyle {
namespace ViewVertexInternal {
-class edge_const_traits : public Const_traits< ::ViewVertex::directedViewEdge>
+class edge_const_traits : public Const_traits<ViewVertex::directedViewEdge>
{
public:
- typedef vector< ::ViewVertex::directedViewEdge> edges_container;
+ typedef vector<ViewVertex::directedViewEdge> edges_container;
typedef edges_container::const_iterator edges_container_iterator;
- typedef vector< ::ViewVertex::directedViewEdge*> edge_pointers_container;
+ typedef vector<ViewVertex::directedViewEdge*> edge_pointers_container;
typedef edge_pointers_container::const_iterator edge_pointers_container_iterator;
};
-class edge_nonconst_traits : public Nonconst_traits< ::ViewVertex::directedViewEdge>
+class edge_nonconst_traits : public Nonconst_traits<ViewVertex::directedViewEdge>
{
public:
- typedef vector< ::ViewVertex::directedViewEdge> edges_container;
+ typedef vector<ViewVertex::directedViewEdge> edges_container;
typedef edges_container::iterator edges_container_iterator;
- typedef vector< ::ViewVertex::directedViewEdge*> edge_pointers_container;
+ typedef vector<ViewVertex::directedViewEdge*> edge_pointers_container;
typedef edge_pointers_container::iterator edge_pointers_container_iterator;
};
@@ -377,14 +377,14 @@ public:
_first = 0;
}
- inline edge_iterator_base(const edge_iterator_base<Nonconst_traits< ::ViewEdge*> >& iBrother) : parent_class()
+ inline edge_iterator_base(const edge_iterator_base<Nonconst_traits<ViewEdge*> >& iBrother) : parent_class()
{
_ViewEdge = iBrother._ViewEdge;
_first = iBrother._first;
_orientation = iBrother._orientation;
}
- inline edge_iterator_base(const edge_iterator_base<Const_traits< ::ViewEdge*> >& iBrother) : parent_class()
+ inline edge_iterator_base(const edge_iterator_base<Const_traits<ViewEdge*> >& iBrother) : parent_class()
{
_ViewEdge = iBrother._ViewEdge;
_first = iBrother._first;
@@ -521,7 +521,7 @@ public:
value_type _FEdgeB; // last fedge of the view edge
public:
- friend class ::ViewEdge;
+ friend class ViewEdge;
friend class fedge_iterator;
inline fedge_iterator_base() : parent_class() {}
diff --git a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
index 6f4f1df4b47..a0a1282219c 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
@@ -138,28 +138,28 @@ static void findOccludee(FEdge *fe, G& grid, I& occluders, real epsilon, WFace *
if (p->rayIntersect(A, v, t, t_u, t_v)) {
#if LOGGING
- if (_global.debug & G_DEBUG_FREESTYLE) {
- cout << "\t\tRay " << A << " * " << v << " intersects at time " << t << endl;
- cout << "\t\t(v * normal) == " << (v * p->getNormal()) << " for normal " << p->getNormal() << endl;
- }
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\t\tRay " << A << " * " << v << " intersects at time " << t << endl;
+ cout << "\t\t(v * normal) == " << (v * p->getNormal()) << " for normal " << p->getNormal() << endl;
+ }
#endif
- if (fabs(v * p->getNormal()) > 0.0001) {
- if ((t > 0.0)) { // && (t<1.0))
- if (t < mint) {
- *oaWFace = oface;
- mint = t;
- noIntersection = false;
- fe->setOccludeeIntersection(Vec3r(A + t * v));
+ if (fabs(v * p->getNormal()) > 0.0001) {
+ if ((t > 0.0)) { // && (t<1.0))
+ if (t < mint) {
+ *oaWFace = oface;
+ mint = t;
+ noIntersection = false;
+ fe->setOccludeeIntersection(Vec3r(A + t * v));
#if LOGGING
- if (_global.debug & G_DEBUG_FREESTYLE) {
- cout << "\t\tIs occludee" << endl;
- }
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\t\tIs occludee" << endl;
+ }
#endif
+ }
}
}
- }
- occluders.reportDepth(A, v, t);
+ occluders.reportDepth(A, v, t);
}
}
@@ -246,146 +246,146 @@ static int computeVisibility(ViewMap *viewMap, FEdge *fe, G& grid, real epsilon,
I occluders(grid, center, epsilon);
for (occluders.initBeforeTarget(); occluders.validBeforeTarget(); occluders.nextOccluder()) {
- // If we're dealing with an exact silhouette, check whether we must take care of this occluder of not.
- // (Indeed, we don't consider the occluders that share at least one vertex with the face containing this edge).
- //-----------
- oface = occluders.getWFace();
- Polygon3r *p = occluders.getCameraSpacePolygon();
- real t, t_u, t_v;
-#if LOGGING
- if (_global.debug & G_DEBUG_FREESTYLE) {
- cout << "\t\tEvaluating intersection for occluder " << (p->getVertices())[0] << (p->getVertices())[1] <<
- (p->getVertices())[2] << endl << "\t\t\tand ray " << vp << " * " << u << " (center " << center <<
- ")" << endl;
- }
-#endif
-
+ // If we're dealing with an exact silhouette, check whether we must take care of this occluder of not.
+ // (Indeed, we don't consider the occluders that share at least one vertex with the face containing this edge).
+ //-----------
+ oface = occluders.getWFace();
+ Polygon3r *p = occluders.getCameraSpacePolygon();
+ real t, t_u, t_v;
#if LOGGING
- Vec3r v(vp - center);
- real rl = v.norm();
- v.normalize();
- vector<Vec3r> points;
- // Iterate over vertices, storing projections in points
- for (vector<WOEdge*>::const_iterator woe = oface->getEdgeList().begin(), woend = oface->getEdgeList().end();
- woe != woend;
- woe++)
- {
- points.push_back(Vec3r((*woe)->GetaVertex()->GetVertex()));
- }
- Polygon3r p1(points, oface->GetNormal());
- Vec3r v1((p1.getVertices())[0]);
- real d = -(v1 * p->getNormal());
- if (_global.debug & G_DEBUG_FREESTYLE) {
- cout << "\t\tp: " << (p->getVertices())[0] << (p->getVertices())[1] << (p->getVertices())[2] << ", norm: " <<
- p->getNormal() << endl;
- cout << "\t\tp1: " << (p1.getVertices())[0] << (p1.getVertices())[1] << (p1.getVertices())[2] << ", norm: " <<
- p1.getNormal() << endl;
- }
-#else
- real d = -((p->getVertices())[0] * p->getNormal());
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\t\tEvaluating intersection for occluder " << (p->getVertices())[0] << (p->getVertices())[1] <<
+ (p->getVertices())[2] << endl << "\t\t\tand ray " << vp << " * " << u << " (center " << center <<
+ ")" << endl;
+ }
#endif
- if (face) {
#if LOGGING
+ Vec3r v(vp - center);
+ real rl = v.norm();
+ v.normalize();
+ vector<Vec3r> points;
+ // Iterate over vertices, storing projections in points
+ for (vector<WOEdge*>::const_iterator woe = oface->getEdgeList().begin(), woend = oface->getEdgeList().end();
+ woe != woend;
+ woe++)
+ {
+ points.push_back(Vec3r((*woe)->GetaVertex()->GetVertex()));
+ }
+ Polygon3r p1(points, oface->GetNormal());
+ Vec3r v1((p1.getVertices())[0]);
+ real d = -(v1 * p->getNormal());
if (_global.debug & G_DEBUG_FREESTYLE) {
- cout << "\t\tDetermining face adjacency...";
+ cout << "\t\tp: " << (p->getVertices())[0] << (p->getVertices())[1] << (p->getVertices())[2] << ", norm: " <<
+ p->getNormal() << endl;
+ cout << "\t\tp1: " << (p1.getVertices())[0] << (p1.getVertices())[1] << (p1.getVertices())[2] << ", norm: " <<
+ p1.getNormal() << endl;
}
+#else
+ real d = -((p->getVertices())[0] * p->getNormal());
#endif
- skipFace = false;
- if (face == oface) {
+ if (face) {
#if LOGGING
if (_global.debug & G_DEBUG_FREESTYLE) {
- cout << " Rejecting occluder for face concurrency." << endl;
+ cout << "\t\tDetermining face adjacency...";
}
#endif
- continue;
- }
-
+ skipFace = false;
- for (vector<WVertex*>::iterator fv = faceVertices.begin(), fvend = faceVertices.end(); fv != fvend; ++fv) {
- if ((*fv)->isBoundary())
+ if (face == oface) {
+#if LOGGING
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << " Rejecting occluder for face concurrency." << endl;
+ }
+#endif
continue;
+ }
- WVertex::incoming_edge_iterator iebegin = (*fv)->incoming_edges_begin();
- WVertex::incoming_edge_iterator ieend = (*fv)->incoming_edges_end();
- for (ie = iebegin; ie != ieend; ++ie) {
- if ((*ie) == 0)
+
+ for (vector<WVertex*>::iterator fv = faceVertices.begin(), fvend = faceVertices.end(); fv != fvend; ++fv) {
+ if ((*fv)->isBoundary())
continue;
- WFace *sface = (*ie)->GetbFace();
- //WFace *sfacea = (*ie)->GetaFace();
- //if ((sface == oface) || (sfacea == oface))
- if (sface == oface) {
- skipFace = true;
- break;
+ WVertex::incoming_edge_iterator iebegin = (*fv)->incoming_edges_begin();
+ WVertex::incoming_edge_iterator ieend = (*fv)->incoming_edges_end();
+ for (ie = iebegin; ie != ieend; ++ie) {
+ if ((*ie) == 0)
+ continue;
+
+ WFace *sface = (*ie)->GetbFace();
+ //WFace *sfacea = (*ie)->GetaFace();
+ //if ((sface == oface) || (sfacea == oface))
+ if (sface == oface) {
+ skipFace = true;
+ break;
+ }
}
+ if (skipFace)
+ break;
}
- if (skipFace)
- break;
- }
- if (skipFace) {
+ if (skipFace) {
#if LOGGING
- if (_global.debug & G_DEBUG_FREESTYLE) {
- cout << " Rejecting occluder for face adjacency." << endl;
- }
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << " Rejecting occluder for face adjacency." << endl;
+ }
#endif
- continue;
+ continue;
+ }
}
- }
- else {
- // check whether the edge and the polygon plane are coincident:
- //-------------------------------------------------------------
- //first let us compute the plane equation.
- if (GeomUtils::COINCIDENT == GeomUtils::intersectRayPlane(origin, edge, p->getNormal(), d, t, epsilon)) {
+ else {
+ // check whether the edge and the polygon plane are coincident:
+ //-------------------------------------------------------------
+ //first let us compute the plane equation.
+ if (GeomUtils::COINCIDENT == GeomUtils::intersectRayPlane(origin, edge, p->getNormal(), d, t, epsilon)) {
#if LOGGING
- if (_global.debug & G_DEBUG_FREESTYLE) {
- cout << "\t\tRejecting occluder for target coincidence." << endl;
- }
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\t\tRejecting occluder for target coincidence." << endl;
+ }
#endif
- continue;
+ continue;
+ }
}
- }
#if LOGGING
- if (_global.debug & G_DEBUG_FREESTYLE) {
- real x;
- if (p1.rayIntersect(center, v, x, t_u, t_v)) {
- cout << "\t\tRay should intersect at time " << (rl - x) << ". Center: " << center << ", V: " << v <<
- ", RL: " << rl << ", T:" << x << endl;
- }
- else {
- cout << "\t\tRay should not intersect. Center: " << center << ", V: " << v << ", RL: " << rl << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ real x;
+ if (p1.rayIntersect(center, v, x, t_u, t_v)) {
+ cout << "\t\tRay should intersect at time " << (rl - x) << ". Center: " << center << ", V: " << v <<
+ ", RL: " << rl << ", T:" << x << endl;
+ }
+ else {
+ cout << "\t\tRay should not intersect. Center: " << center << ", V: " << v << ", RL: " << rl << endl;
+ }
}
- }
#endif
- if (p->rayIntersect(center, u, t, t_u, t_v)) {
+ if (p->rayIntersect(center, u, t, t_u, t_v)) {
#if LOGGING
- if (_global.debug & G_DEBUG_FREESTYLE) {
- cout << "\t\tRay " << center << " * " << u << " intersects at time " << t << " (raylength is " <<
- raylength << ")" << endl;
- cout << "\t\t(u * normal) == " << (u * p->getNormal()) << " for normal " << p->getNormal() << endl;
- }
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\t\tRay " << center << " * " << u << " intersects at time " << t << " (raylength is " <<
+ raylength << ")" << endl;
+ cout << "\t\t(u * normal) == " << (u * p->getNormal()) << " for normal " << p->getNormal() << endl;
+ }
#endif
- if (fabs(u * p->getNormal()) > 0.0001) {
- if ((t > 0.0) && (t < raylength)) {
+ if (fabs(u * p->getNormal()) > 0.0001) {
+ if ((t > 0.0) && (t < raylength)) {
#if LOGGING
- if (_global.debug & G_DEBUG_FREESTYLE) {
- cout << "\t\tIs occluder" << endl;
- }
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\t\tIs occluder" << endl;
+ }
#endif
- if ( foundOccluders != NULL ) {
- ViewShape *vshape = viewMap->viewShape(oface->GetVertex(0)->shape()->GetId());
- foundOccluders->insert(vshape);
- }
- ++qi;
+ if ( foundOccluders != NULL ) {
+ ViewShape *vshape = viewMap->viewShape(oface->GetVertex(0)->shape()->GetId());
+ foundOccluders->insert(vshape);
+ }
+ ++qi;
- if (! grid.enableQI())
- break;
- }
+ if (! grid.enableQI())
+ break;
+ }
- occluders.reportDepth(center, u, t);
+ occluders.reportDepth(center, u, t);
}
}
}
diff --git a/source/blender/freestyle/intern/view_map/ViewMapBuilder.h b/source/blender/freestyle/intern/view_map/ViewMapBuilder.h
index 29e393052a3..08b2fde8f31 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapBuilder.h
+++ b/source/blender/freestyle/intern/view_map/ViewMapBuilder.h
@@ -60,7 +60,7 @@ namespace Freestyle {
using namespace Geometry;
-class LIB_VIEW_MAP_EXPORT ViewMapBuilder
+class ViewMapBuilder
{
private:
ViewMap *_ViewMap; // result
diff --git a/source/blender/freestyle/intern/view_map/ViewMapIO.cpp b/source/blender/freestyle/intern/view_map/ViewMapIO.cpp
index e78fb894be0..71ae68c06bc 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapIO.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewMapIO.cpp
@@ -25,6 +25,8 @@
* \date 09/01/2003
*/
+#include <limits.h>
+
#include "ViewMapIO.h"
#ifdef IRIX
@@ -674,14 +676,16 @@ static int save(ostream& out, ViewShape *vs)
// ViewEdges (List)
tmp = vs->edges().size();
WRITE(tmp);
- for (vector<ViewEdge*>::const_iterator i4 = vs->edges().begin(); i4 != vs->edges().end(); i4++)
+ for (vector<ViewEdge*>::const_iterator i4 = vs->edges().begin(); i4 != vs->edges().end(); i4++) {
WRITE_IF_NON_NULL(*i4);
+ }
// ViewVertices (List)
tmp = vs->vertices().size();
WRITE(tmp);
- for (vector<ViewVertex*>::const_iterator i5 = vs->vertices().begin(); i5 != vs->vertices().end(); i5++)
+ for (vector<ViewVertex*>::const_iterator i5 = vs->vertices().begin(); i5 != vs->vertices().end(); i5++) {
WRITE_IF_NON_NULL(*i5);
+ }
return 0;
}
@@ -816,8 +820,9 @@ static int save(ostream& out, SVertex *sv)
// FEdges (List)
tmp = sv->fedges().size();
WRITE(tmp);
- for (vector<FEdge*>::const_iterator j = sv->fedges_begin(); j != sv->fedges_end(); j++)
+ for (vector<FEdge*>::const_iterator j = sv->fedges_begin(); j != sv->fedges_end(); j++) {
WRITE_IF_NON_NULL(*j);
+ }
return 0;
}
@@ -868,8 +873,9 @@ static int save(ostream& out, ViewEdge *ve)
if (!(Options::getFlags() & Options::NO_OCCLUDERS)) {
tmp = ve->occluders().size();
WRITE(tmp);
- for (vector<ViewShape*>::const_iterator i = ve->occluders().begin(); i != ve->occluders().end(); i++)
+ for (vector<ViewShape*>::const_iterator i = ve->occluders().begin(); i != ve->occluders().end(); i++) {
WRITE_IF_NON_NULL((*i));
+ }
}
return 0;
diff --git a/source/blender/freestyle/intern/view_map/ViewMapIO.h b/source/blender/freestyle/intern/view_map/ViewMapIO.h
index e2223cd5734..eb26e8adab0 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapIO.h
+++ b/source/blender/freestyle/intern/view_map/ViewMapIO.h
@@ -42,10 +42,8 @@ namespace ViewMapIO {
static const unsigned ZERO = UINT_MAX;
-LIB_VIEW_MAP_EXPORT
int load(istream& in, ViewMap *vm, ProgressBar *pb = NULL);
-LIB_VIEW_MAP_EXPORT
int save(ostream& out, ViewMap *vm, ProgressBar *pb = NULL);
namespace Options {
@@ -53,22 +51,16 @@ namespace Options {
static const unsigned char FLOAT_VECTORS = 1;
static const unsigned char NO_OCCLUDERS = 2;
-LIB_VIEW_MAP_EXPORT
void setFlags(const unsigned char flags);
-LIB_VIEW_MAP_EXPORT
void addFlags(const unsigned char flags);
-LIB_VIEW_MAP_EXPORT
void rmFlags(const unsigned char flags);
-LIB_VIEW_MAP_EXPORT
unsigned char getFlags();
-LIB_VIEW_MAP_EXPORT
void setModelsPath(const string& path);
-LIB_VIEW_MAP_EXPORT
string getModelsPath();
}; // End of namepace Options
diff --git a/source/blender/freestyle/intern/view_map/ViewMapIterators.h b/source/blender/freestyle/intern/view_map/ViewMapIterators.h
index 2794d9028d2..469c2c3b29c 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapIterators.h
+++ b/source/blender/freestyle/intern/view_map/ViewMapIterators.h
@@ -66,8 +66,8 @@ public:
friend class ViewEdge;
// FIXME
- typedef ::TVertex::edge_pointers_container edge_pointers_container;
- typedef ::NonTVertex::edges_container edges_container;
+ typedef TVertex::edge_pointers_container edge_pointers_container;
+ typedef NonTVertex::edges_container edges_container;
protected:
Nature::VertexNature _Nature; // the nature of the underlying vertex
@@ -184,7 +184,7 @@ public:
/*! Returns a reference to the pointed orientedViewEdge.
* In the scripting language, you must call "getObject()" instead.
*/
- virtual ::ViewVertex::directedViewEdge& operator*() const
+ virtual ViewVertex::directedViewEdge& operator*() const
{
if (_Nature & Nature::T_VERTEX)
//return _tvertex_iter;
@@ -195,7 +195,7 @@ public:
/*! Returns a pointer to the pointed orientedViewEdge.
* Can't be called in the scripting language.
*/
- virtual ::ViewVertex::directedViewEdge *operator->() const
+ virtual ViewVertex::directedViewEdge *operator->() const
{
return &(operator*());
}
@@ -205,11 +205,11 @@ public:
virtual inline int increment()
{
if (_Nature & Nature::T_VERTEX) {
- ::ViewVertex::directedViewEdge tmp = (**_tvertex_iter);
+ ViewVertex::directedViewEdge tmp = (**_tvertex_iter);
++_tvertex_iter;
if (_tvertex_iter != _tend) {
// FIXME : pquoi deja ?
- ::ViewVertex::directedViewEdge tmp2 = (**_tvertex_iter);
+ ViewVertex::directedViewEdge tmp2 = (**_tvertex_iter);
if (tmp2.first == tmp.first)
++_tvertex_iter;
}
diff --git a/source/blender/freestyle/intern/view_map/ViewMapTesselator.h b/source/blender/freestyle/intern/view_map/ViewMapTesselator.h
index 9c4d214d931..cb19875b6c7 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapTesselator.h
+++ b/source/blender/freestyle/intern/view_map/ViewMapTesselator.h
@@ -50,7 +50,7 @@ class NodeGroup;
class SShape;
class WShape;
-class LIB_VIEW_MAP_EXPORT ViewMapTesselator
+class ViewMapTesselator
{
public:
inline ViewMapTesselator()
diff --git a/source/blender/freestyle/intern/winged_edge/Curvature.cpp b/source/blender/freestyle/intern/winged_edge/Curvature.cpp
index 4493080c8fb..4a910099bff 100644
--- a/source/blender/freestyle/intern/winged_edge/Curvature.cpp
+++ b/source/blender/freestyle/intern/winged_edge/Curvature.cpp
@@ -45,7 +45,6 @@
#include <assert.h>
#include <cstdlib> // for malloc and free
-#include <math.h>
#include <set>
#include <stack>
@@ -54,7 +53,7 @@
#include "../geometry/normal_cycle.h"
-#include "../system/FreestyleConfig.h"
+#include "BLI_math.h"
namespace Freestyle {
diff --git a/source/blender/freestyle/intern/winged_edge/Curvature.h b/source/blender/freestyle/intern/winged_edge/Curvature.h
index 5977f12d870..dbcecf5bc4b 100644
--- a/source/blender/freestyle/intern/winged_edge/Curvature.h
+++ b/source/blender/freestyle/intern/winged_edge/Curvature.h
@@ -61,7 +61,7 @@ using namespace Geometry;
class WVertex;
-class LIB_WINGED_EDGE_EXPORT CurvatureInfo
+class CurvatureInfo
{
public:
CurvatureInfo()
@@ -133,21 +133,21 @@ public:
#endif
};
-bool LIB_WINGED_EDGE_EXPORT gts_vertex_mean_curvature_normal(WVertex *v, Vec3r &n);
+bool gts_vertex_mean_curvature_normal(WVertex *v, Vec3r &n);
-bool LIB_WINGED_EDGE_EXPORT gts_vertex_gaussian_curvature(WVertex *v, real *Kg);
+bool gts_vertex_gaussian_curvature(WVertex *v, real *Kg);
-void LIB_WINGED_EDGE_EXPORT gts_vertex_principal_curvatures(real Kh, real Kg, real *K1, real *K2);
+void gts_vertex_principal_curvatures(real Kh, real Kg, real *K1, real *K2);
-void LIB_WINGED_EDGE_EXPORT gts_vertex_principal_directions(WVertex *v, Vec3r Kh, real Kg, Vec3r &e1, Vec3r &e2);
+void gts_vertex_principal_directions(WVertex *v, Vec3r Kh, real Kg, Vec3r &e1, Vec3r &e2);
namespace OGF {
class NormalCycle ;
-void LIB_WINGED_EDGE_EXPORT compute_curvature_tensor( WVertex *start, double radius, NormalCycle& nc);
+void compute_curvature_tensor( WVertex *start, double radius, NormalCycle& nc);
-void LIB_WINGED_EDGE_EXPORT compute_curvature_tensor_one_ring(WVertex *start, NormalCycle& nc);
+void compute_curvature_tensor_one_ring(WVertex *start, NormalCycle& nc);
} // OGF namespace
diff --git a/source/blender/freestyle/intern/winged_edge/WEdge.cpp b/source/blender/freestyle/intern/winged_edge/WEdge.cpp
index 03d3cf65142..97248669822 100644
--- a/source/blender/freestyle/intern/winged_edge/WEdge.cpp
+++ b/source/blender/freestyle/intern/winged_edge/WEdge.cpp
@@ -470,7 +470,6 @@ WShape *WFace::getShape()
* *
**********************************/
-LIB_WINGED_EDGE_EXPORT
unsigned WShape::_SceneCurrentId = 0;
WShape *WShape::duplicate()
diff --git a/source/blender/freestyle/intern/winged_edge/WEdge.h b/source/blender/freestyle/intern/winged_edge/WEdge.h
index f0692aecd5b..5dda41ad279 100644
--- a/source/blender/freestyle/intern/winged_edge/WEdge.h
+++ b/source/blender/freestyle/intern/winged_edge/WEdge.h
@@ -29,7 +29,6 @@
*/
#include <iterator>
-#include <math.h>
#include <vector>
#include "../geometry/Geom.h"
@@ -38,6 +37,8 @@
#include "../system/FreestyleConfig.h"
+#include "BLI_math.h"
+
#ifdef WITH_CXX_GUARDEDALLOC
#include "MEM_guardedalloc.h"
#endif
@@ -63,7 +64,7 @@ class WEdge;
class WShape;
class WFace;
-class LIB_WINGED_EDGE_EXPORT WVertex
+class WVertex
{
protected:
int _Id; // an identificator
@@ -165,7 +166,7 @@ public:
#if defined(__GNUC__) && (__GNUC__ < 3)
class incoming_edge_iterator : public input_iterator<WOEdge *, ptrdiff_t>
#else
- class LIB_WINGED_EDGE_EXPORT incoming_edge_iterator
+ class incoming_edge_iterator
: public iterator<input_iterator_tag, WOEdge *, ptrdiff_t>
#endif
{
@@ -253,7 +254,7 @@ public:
#if defined(__GNUC__) && (__GNUC__ < 3)
class face_iterator : public input_iterator<WFace *, ptrdiff_t>
#else
- class LIB_WINGED_EDGE_EXPORT face_iterator : public iterator<input_iterator_tag, WFace *, ptrdiff_t>
+ class face_iterator : public iterator<input_iterator_tag, WFace *, ptrdiff_t>
#endif
{
private:
@@ -365,7 +366,7 @@ public:
class WFace;
class WEdge;
-class LIB_WINGED_EDGE_EXPORT WOEdge
+class WOEdge
{
protected:
#if 0
@@ -548,7 +549,7 @@ public:
* *
**********************************/
-class LIB_WINGED_EDGE_EXPORT WEdge
+class WEdge
{
protected:
WOEdge *_paOEdge; // first oriented edge
@@ -736,7 +737,7 @@ public:
**********************************/
-class LIB_WINGED_EDGE_EXPORT WFace
+class WFace
{
protected:
vector<WOEdge *> _OEdgeList; // list of oriented edges of bording the face
@@ -1019,7 +1020,7 @@ public:
**********************************/
-class LIB_WINGED_EDGE_EXPORT WShape
+class WShape
{
protected:
vector<WVertex *> _VertexList;
diff --git a/source/blender/freestyle/intern/winged_edge/WFillGrid.h b/source/blender/freestyle/intern/winged_edge/WFillGrid.h
index 819bb24ffc2..1b83b81274a 100644
--- a/source/blender/freestyle/intern/winged_edge/WFillGrid.h
+++ b/source/blender/freestyle/intern/winged_edge/WFillGrid.h
@@ -40,7 +40,7 @@
namespace Freestyle {
-class LIB_WINGED_EDGE_EXPORT WFillGrid
+class WFillGrid
{
public:
inline WFillGrid(Grid *grid = NULL, WingedEdge *winged_edge = NULL)
diff --git a/source/blender/freestyle/intern/winged_edge/WSFillGrid.h b/source/blender/freestyle/intern/winged_edge/WSFillGrid.h
index 5b33df906a6..247999bfcbf 100644
--- a/source/blender/freestyle/intern/winged_edge/WSFillGrid.h
+++ b/source/blender/freestyle/intern/winged_edge/WSFillGrid.h
@@ -35,7 +35,7 @@
namespace Freestyle {
-class LIB_WINGED_EDGE_EXPORT WSFillGrid
+class WSFillGrid
{
public:
inline WSFillGrid(Grid *grid = NULL, WingedEdge *winged_edge = NULL)
diff --git a/source/blender/freestyle/intern/winged_edge/WXEdge.cpp b/source/blender/freestyle/intern/winged_edge/WXEdge.cpp
index 88da9cf9f80..84dbd5fbef8 100644
--- a/source/blender/freestyle/intern/winged_edge/WXEdge.cpp
+++ b/source/blender/freestyle/intern/winged_edge/WXEdge.cpp
@@ -197,43 +197,43 @@ WXSmoothEdge *WXFaceLayer::BuildSmoothEdge()
WSFace *bface = (WSFace *)GetBordingFace(i);
if (bface) {
if ((front()) ^ (bface->front())) { // fA->front XOR fB->front (true if one is 0 and the other is 1)
- // that means that the edge i of the face is a silhouette edge
- // CHECK FIRST WHETHER THE EXACTSILHOUETTEEDGE HAS NOT YET BEEN BUILT ON THE OTHER FACE (1 is enough).
- if (((WSExactFace *)bface)->exactSilhouetteEdge()) {
- // that means that this silhouette edge has already been built
- return ((WSExactFace *)bface)->exactSilhouetteEdge();
- }
- // Else we must build it
- WOEdge *woea, *woeb;
- real ta, tb;
- if (!front()) { // is it in the right order ?
- // the order of the WOEdge index is wrong
- woea = _OEdgeList[(i + 1) % numberOfEdges()];
- if (0 == i)
- woeb = _OEdgeList[numberOfEdges() - 1];
- else
- woeb = _OEdgeList[(i - 1)];
- ta = 0;
- tb = 1;
- }
- else {
- // the order of the WOEdge index is good
- if (0 == i)
- woea = _OEdgeList[numberOfEdges() - 1];
- else
- woea = _OEdgeList[(i - 1)];
- woeb = _OEdgeList[(i + 1) % numberOfEdges()];
- ta = 1;
- tb = 0;
- }
+ // that means that the edge i of the face is a silhouette edge
+ // CHECK FIRST WHETHER THE EXACTSILHOUETTEEDGE HAS NOT YET BEEN BUILT ON THE OTHER FACE (1 is enough).
+ if (((WSExactFace *)bface)->exactSilhouetteEdge()) {
+ // that means that this silhouette edge has already been built
+ return ((WSExactFace *)bface)->exactSilhouetteEdge();
+ }
+ // Else we must build it
+ WOEdge *woea, *woeb;
+ real ta, tb;
+ if (!front()) { // is it in the right order ?
+ // the order of the WOEdge index is wrong
+ woea = _OEdgeList[(i + 1) % numberOfEdges()];
+ if (0 == i)
+ woeb = _OEdgeList[numberOfEdges() - 1];
+ else
+ woeb = _OEdgeList[(i - 1)];
+ ta = 0;
+ tb = 1;
+ }
+ else {
+ // the order of the WOEdge index is good
+ if (0 == i)
+ woea = _OEdgeList[numberOfEdges() - 1];
+ else
+ woea = _OEdgeList[(i - 1)];
+ woeb = _OEdgeList[(i + 1) % numberOfEdges()];
+ ta = 1;
+ tb = 0;
+ }
- _pSmoothEdge = new ExactSilhouetteEdge(ExactSilhouetteEdge::VERTEX_VERTEX);
- _pSmoothEdge->setWOeA(woea);
- _pSmoothEdge->setWOeA(woeb);
- _pSmoothEdge->setTa(ta);
- _pSmoothEdge->setTb(tb);
+ _pSmoothEdge = new ExactSilhouetteEdge(ExactSilhouetteEdge::VERTEX_VERTEX);
+ _pSmoothEdge->setWOeA(woea);
+ _pSmoothEdge->setWOeA(woeb);
+ _pSmoothEdge->setTa(ta);
+ _pSmoothEdge->setTb(tb);
- return _pSmoothEdge;
+ return _pSmoothEdge;
}
}
}
diff --git a/source/blender/freestyle/intern/winged_edge/WXEdge.h b/source/blender/freestyle/intern/winged_edge/WXEdge.h
index 364183bbc84..ce9749369fc 100644
--- a/source/blender/freestyle/intern/winged_edge/WXEdge.h
+++ b/source/blender/freestyle/intern/winged_edge/WXEdge.h
@@ -327,7 +327,7 @@ public:
*/
class WXFace;
-class LIB_WINGED_EDGE_EXPORT WXFaceLayer
+class WXFaceLayer
{
public:
void *userdata;
diff --git a/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.h b/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.h
index 5579989072a..143c2e33608 100644
--- a/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.h
+++ b/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.h
@@ -35,7 +35,7 @@
namespace Freestyle {
-class LIB_WINGED_EDGE_EXPORT WXEdgeBuilder : public WingedEdgeBuilder
+class WXEdgeBuilder : public WingedEdgeBuilder
{
public:
WXEdgeBuilder() : WingedEdgeBuilder() {}
diff --git a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h
index d68acaf29c1..7fd5cd8443a 100644
--- a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h
+++ b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h
@@ -40,7 +40,7 @@
namespace Freestyle {
-class LIB_WINGED_EDGE_EXPORT WingedEdgeBuilder : public SceneVisitor
+class WingedEdgeBuilder : public SceneVisitor
{
public:
inline WingedEdgeBuilder() : SceneVisitor()
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index 93c80c68f24..739deffa519 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -69,6 +69,10 @@ data_to_c_simple(shaders/gpu_shader_vertex.glsl SRC)
data_to_c_simple(shaders/gpu_shader_vsm_store_frag.glsl SRC)
data_to_c_simple(shaders/gpu_shader_vsm_store_vert.glsl SRC)
+if(WITH_GAMEENGINE)
+ add_definitions(-DWITH_GAMEENGINE)
+endif()
+
if(WITH_MOD_SMOKE)
add_definitions(-DWITH_SMOKE)
endif()
diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h
index f880bfbda6f..096b2080b2b 100644
--- a/source/blender/gpu/GPU_buffers.h
+++ b/source/blender/gpu/GPU_buffers.h
@@ -94,9 +94,13 @@ typedef struct GPUDrawObject {
/* for each original vertex, the list of related points */
struct GPUVertPointLink *vert_points;
+
+ /* see: USE_GPU_POINT_LINK define */
+#if 0
/* storage for the vert_points lists */
struct GPUVertPointLink *vert_points_mem;
int vert_points_usage;
+#endif
int colType;
@@ -112,7 +116,7 @@ typedef struct GPUDrawObject {
/* if there was a failure allocating some buffer, use old
* rendering code */
- int legacy;
+ bool legacy;
} GPUDrawObject;
/* used for GLSL materials */
@@ -157,27 +161,30 @@ void GPU_buffer_draw_elements(GPUBuffer *elements, unsigned int mode, int start,
void GPU_buffer_unbind(void);
/* used to check whether to use the old (without buffers) code */
-int GPU_buffer_legacy(struct DerivedMesh *dm);
+bool GPU_buffer_legacy(struct DerivedMesh *dm);
/* Buffers for non-DerivedMesh drawing */
typedef struct GPU_PBVH_Buffers GPU_PBVH_Buffers;
-GPU_PBVH_Buffers *GPU_build_pbvh_mesh_buffers(int (*face_vert_indices)[4],
+/* build */
+GPU_PBVH_Buffers *GPU_build_mesh_pbvh_buffers(int (*face_vert_indices)[4],
struct MFace *mface, struct MVert *mvert,
int *face_indices, int totface);
-void GPU_update_mesh_pbvh_buffers(GPU_PBVH_Buffers *buffers, MVert *mvert,
- int *vert_indices, int totvert, const float *vmask,
- int (*face_vert_indices)[4], bool show_diffuse_color);
-
GPU_PBVH_Buffers *GPU_build_grid_pbvh_buffers(int *grid_indices, int totgrid,
unsigned int **grid_hidden, int gridsize);
GPU_PBVH_Buffers *GPU_build_bmesh_pbvh_buffers(int smooth_shading);
+/* update */
+
+void GPU_update_mesh_pbvh_buffers(GPU_PBVH_Buffers *buffers, MVert *mvert,
+ int *vert_indices, int totvert, const float *vmask,
+ int (*face_vert_indices)[4], bool show_diffuse_color);
+
void GPU_update_bmesh_pbvh_buffers(GPU_PBVH_Buffers *buffers,
struct BMesh *bm,
- struct GHash *bm_faces,
+ struct GSet *bm_faces,
struct GSet *bm_unique_verts,
struct GSet *bm_other_verts,
bool show_diffuse_color);
@@ -187,10 +194,16 @@ void GPU_update_grid_pbvh_buffers(GPU_PBVH_Buffers *buffers, struct CCGElem **gr
int *grid_indices, int totgrid, const struct CCGKey *key,
bool show_diffuse_color);
+/* draw */
void GPU_draw_pbvh_buffers(GPU_PBVH_Buffers *buffers, DMSetMaterial setMaterial,
bool wireframe);
-bool GPU_pbvh_buffers_diffuse_changed(GPU_PBVH_Buffers *buffers, struct GHash *bm_faces, bool show_diffuse_color);
+/* debug PBVH draw*/
+void GPU_draw_pbvh_BB(float min[3], float max[3], bool leaf);
+void GPU_end_draw_pbvh_BB(void);
+void GPU_init_draw_pbvh_BB(void);
+
+bool GPU_pbvh_buffers_diffuse_changed(GPU_PBVH_Buffers *buffers, struct GSet *bm_faces, bool show_diffuse_color);
void GPU_free_pbvh_buffers(GPU_PBVH_Buffers *buffers);
diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h
index 101fd67af2c..1011ac80901 100644
--- a/source/blender/gpu/GPU_material.h
+++ b/source/blender/gpu/GPU_material.h
@@ -47,6 +47,7 @@ struct Image;
struct bNode;
struct LinkNode;
struct Scene;
+struct SceneRenderLayer;
struct GPUVertexAttribs;
struct GPUNode;
struct GPUNodeLink;
@@ -105,8 +106,8 @@ typedef struct GPUNodeStack {
const char *name;
float vec[4];
struct GPUNodeLink *link;
- short hasinput;
- short hasoutput;
+ bool hasinput;
+ bool hasoutput;
short sockettype;
} GPUNodeStack;
@@ -135,6 +136,7 @@ void GPU_material_free(struct Material *ma);
void GPU_materials_free(void);
+bool GPU_lamp_override_visible(GPULamp *lamp, struct SceneRenderLayer *srl, struct Material *ma);
void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time, int mipmap, float viewmat[4][4], float viewinv[4][4]);
void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[4][4], float obcol[4], float autobumpscale);
void GPU_material_unbind(GPUMaterial *material);
diff --git a/source/blender/gpu/SConscript b/source/blender/gpu/SConscript
index c1c3fa92cb1..e9320f08eff 100644
--- a/source/blender/gpu/SConscript
+++ b/source/blender/gpu/SConscript
@@ -49,6 +49,8 @@ incs = [
env['BF_OPENGL_INC'],
]
+if env['WITH_BF_GAMEENGINE']:
+ defs.append('WITH_GAMEENGINE')
if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'):
incs.append(env['BF_PTHREADS_INC'])
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index e01fa510dfb..f5256f18897 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -47,12 +47,11 @@
#include "BLI_threads.h"
#include "DNA_meshdata_types.h"
-#include "DNA_material_types.h"
#include "BKE_ccg.h"
#include "BKE_DerivedMesh.h"
#include "BKE_paint.h"
-#include "BKE_subsurf.h"
+#include "BKE_pbvh.h"
#include "DNA_userdef_types.h"
@@ -71,9 +70,6 @@ typedef enum {
#define MAX_GPU_ATTRIB_DATA 32
-/* material number is an 16-bit signed short and the range (assume material number is non-negative) */
-#define MAX_MATERIALS MAXMAT
-
/* -1 - undefined, 0 - vertex arrays, 1 - VBOs */
static int useVBOs = -1;
static GPUBufferState GLStates = 0;
@@ -118,10 +114,10 @@ static GPUBufferPool *gpu_buffer_pool_new(void)
pool->maxsize = MAX_FREE_GPU_BUFFERS;
pool->maxpbvhsize = MAX_FREE_GPU_BUFF_IDS;
- pool->buffers = MEM_callocN(sizeof(*pool->buffers) * pool->maxsize,
- "GPUBufferPool.buffers");
- pool->pbvhbufids = MEM_callocN(sizeof(*pool->pbvhbufids) * pool->maxpbvhsize,
- "GPUBufferPool.pbvhbuffers");
+ pool->buffers = MEM_mallocN(sizeof(*pool->buffers) * pool->maxsize,
+ "GPUBufferPool.buffers");
+ pool->pbvhbufids = MEM_mallocN(sizeof(*pool->pbvhbufids) * pool->maxpbvhsize,
+ "GPUBufferPool.pbvhbuffers");
return pool;
}
@@ -380,14 +376,22 @@ void GPU_buffer_free(GPUBuffer *buffer)
BLI_mutex_unlock(&buffer_mutex);
}
+/* currently unused */
+// #define USE_GPU_POINT_LINK
+
typedef struct GPUVertPointLink {
+#ifdef USE_GPU_POINT_LINK
struct GPUVertPointLink *next;
+#endif
/* -1 means uninitialized */
int point_index;
} GPUVertPointLink;
+
/* add a new point to the list of points related to a particular
* vertex */
+#ifdef USE_GPU_POINT_LINK
+
static void gpu_drawobject_add_vert_point(GPUDrawObject *gdo, int vert_index, int point_index)
{
GPUVertPointLink *lnk;
@@ -407,6 +411,19 @@ static void gpu_drawobject_add_vert_point(GPUDrawObject *gdo, int vert_index, in
lnk->point_index = point_index;
}
+#else
+
+static void gpu_drawobject_add_vert_point(GPUDrawObject *gdo, int vert_index, int point_index)
+{
+ GPUVertPointLink *lnk;
+ lnk = &gdo->vert_points[vert_index];
+ if (lnk->point_index == -1) {
+ lnk->point_index = point_index;
+ }
+}
+
+#endif /* USE_GPU_POINT_LINK */
+
/* update the vert_points and triangle_to_mface fields with a new
* triangle */
static void gpu_drawobject_add_triangle(GPUDrawObject *gdo,
@@ -422,17 +439,21 @@ static void gpu_drawobject_add_triangle(GPUDrawObject *gdo,
/* for each vertex, build a list of points related to it; these lists
* are stored in an array sized to the number of vertices */
-static void gpu_drawobject_init_vert_points(GPUDrawObject *gdo, MFace *f, int totface)
+static void gpu_drawobject_init_vert_points(GPUDrawObject *gdo, MFace *f, int totface, int totmat)
{
GPUBufferMaterial *mat;
- int i, mat_orig_to_new[MAX_MATERIALS];
+ int i, *mat_orig_to_new;
+ mat_orig_to_new = MEM_callocN(sizeof(*mat_orig_to_new) * totmat,
+ "GPUDrawObject.mat_orig_to_new");
/* allocate the array and space for links */
- gdo->vert_points = MEM_callocN(sizeof(GPUVertPointLink) * gdo->totvert,
+ gdo->vert_points = MEM_mallocN(sizeof(GPUVertPointLink) * gdo->totvert,
"GPUDrawObject.vert_points");
+#ifdef USE_GPU_POINT_LINK
gdo->vert_points_mem = MEM_callocN(sizeof(GPUVertPointLink) * gdo->tot_triangle_point,
"GPUDrawObject.vert_points_mem");
gdo->vert_points_usage = 0;
+#endif
/* build a map from the original material indices to the new
* GPUBufferMaterial indices */
@@ -440,8 +461,12 @@ static void gpu_drawobject_init_vert_points(GPUDrawObject *gdo, MFace *f, int to
mat_orig_to_new[gdo->materials[i].mat_nr] = i;
/* -1 indicates the link is not yet used */
- for (i = 0; i < gdo->totvert; i++)
+ for (i = 0; i < gdo->totvert; i++) {
+#ifdef USE_GPU_POINT_LINK
+ gdo->vert_points[i].link = NULL;
+#endif
gdo->vert_points[i].point_index = -1;
+ }
for (i = 0; i < totface; i++, f++) {
mat = &gdo->materials[mat_orig_to_new[f->mat_nr]];
@@ -466,6 +491,8 @@ static void gpu_drawobject_init_vert_points(GPUDrawObject *gdo, MFace *f, int to
gdo->tot_loose_point++;
}
}
+
+ MEM_freeN(mat_orig_to_new);
}
/* see GPUDrawObject's structure definition for a description of the
@@ -474,15 +501,19 @@ GPUDrawObject *GPU_drawobject_new(DerivedMesh *dm)
{
GPUDrawObject *gdo;
MFace *mface;
- int points_per_mat[MAX_MATERIALS];
+ int totmat = dm->totmat;
+ int *points_per_mat;
int i, curmat, curpoint, totface;
+ /* object contains at least one material (default included) so zero means uninitialized dm */
+ BLI_assert(totmat != 0);
+
mface = dm->getTessFaceArray(dm);
totface = dm->getNumTessFaces(dm);
/* get the number of points used by each material, treating
* each quad as two triangles */
- memset(points_per_mat, 0, sizeof(int) * MAX_MATERIALS);
+ points_per_mat = MEM_callocN(sizeof(*points_per_mat) * totmat, "GPU_drawobject_new.mat_orig_to_new");
for (i = 0; i < totface; i++)
points_per_mat[mface[i].mat_nr] += mface[i].v4 ? 6 : 3;
@@ -492,7 +523,7 @@ GPUDrawObject *GPU_drawobject_new(DerivedMesh *dm)
gdo->totedge = dm->getNumEdges(dm);
/* count the number of materials used by this DerivedMesh */
- for (i = 0; i < MAX_MATERIALS; i++) {
+ for (i = 0; i < totmat; i++) {
if (points_per_mat[i] > 0)
gdo->totmaterial++;
}
@@ -502,7 +533,7 @@ GPUDrawObject *GPU_drawobject_new(DerivedMesh *dm)
"GPUDrawObject.materials");
/* initialize the materials array */
- for (i = 0, curmat = 0, curpoint = 0; i < MAX_MATERIALS; i++) {
+ for (i = 0, curmat = 0, curpoint = 0; i < totmat; i++) {
if (points_per_mat[i] > 0) {
gdo->materials[curmat].start = curpoint;
gdo->materials[curmat].totpoint = 0;
@@ -519,7 +550,8 @@ GPUDrawObject *GPU_drawobject_new(DerivedMesh *dm)
gdo->triangle_to_mface = MEM_mallocN(sizeof(int) * (gdo->tot_triangle_point / 3),
"GPUDrawObject.triangle_to_mface");
- gpu_drawobject_init_vert_points(gdo, mface, totface);
+ gpu_drawobject_init_vert_points(gdo, mface, totface, totmat);
+ MEM_freeN(points_per_mat);
return gdo;
}
@@ -534,7 +566,9 @@ void GPU_drawobject_free(DerivedMesh *dm)
MEM_freeN(gdo->materials);
MEM_freeN(gdo->triangle_to_mface);
MEM_freeN(gdo->vert_points);
+#ifdef USE_GPU_POINT_LINK
MEM_freeN(gdo->vert_points_mem);
+#endif
GPU_buffer_free(gdo->points);
GPU_buffer_free(gdo->normals);
GPU_buffer_free(gdo->uv);
@@ -556,10 +590,10 @@ static GPUBuffer *gpu_buffer_setup(DerivedMesh *dm, GPUDrawObject *object,
GPUBufferPool *pool;
GPUBuffer *buffer;
float *varray;
- int mat_orig_to_new[MAX_MATERIALS];
+ int *mat_orig_to_new;
int *cur_index_per_mat;
int i;
- int success;
+ bool success;
GLboolean uploaded;
pool = gpu_get_global_buffer_pool();
@@ -576,6 +610,8 @@ static GPUBuffer *gpu_buffer_setup(DerivedMesh *dm, GPUDrawObject *object,
return NULL;
}
+ mat_orig_to_new = MEM_mallocN(sizeof(*mat_orig_to_new) * dm->totmat,
+ "GPU_buffer_setup.mat_orig_to_new");
cur_index_per_mat = MEM_mallocN(sizeof(int) * object->totmaterial,
"GPU_buffer_setup.cur_index_per_mat");
for (i = 0; i < object->totmaterial; i++) {
@@ -648,6 +684,7 @@ static GPUBuffer *gpu_buffer_setup(DerivedMesh *dm, GPUDrawObject *object,
}
MEM_freeN(cur_index_per_mat);
+ MEM_freeN(mat_orig_to_new);
BLI_mutex_unlock(&buffer_mutex);
@@ -698,7 +735,8 @@ static void GPU_buffer_copy_normal(DerivedMesh *dm, float *varray, int *index, i
int start;
float f_no[3];
- float *nors = dm->getTessFaceDataArray(dm, CD_NORMAL);
+ const float *nors = dm->getTessFaceDataArray(dm, CD_NORMAL);
+ short (*tlnors)[4][3] = dm->getTessFaceDataArray(dm, CD_TESSLOOPNORMAL);
MVert *mvert = dm->getVertArray(dm);
MFace *f = dm->getTessFaceArray(dm);
@@ -709,7 +747,20 @@ static void GPU_buffer_copy_normal(DerivedMesh *dm, float *varray, int *index, i
start = index[mat_orig_to_new[f->mat_nr]];
index[mat_orig_to_new[f->mat_nr]] += f->v4 ? 18 : 9;
- if (smoothnormal) {
+ if (tlnors) {
+ short (*tlnor)[3] = tlnors[i];
+ /* Copy loop normals */
+ normal_short_to_float_v3(&varray[start], tlnor[0]);
+ normal_short_to_float_v3(&varray[start + 3], tlnor[1]);
+ normal_short_to_float_v3(&varray[start + 6], tlnor[2]);
+
+ if (f->v4) {
+ normal_short_to_float_v3(&varray[start + 9], tlnor[2]);
+ normal_short_to_float_v3(&varray[start + 12], tlnor[3]);
+ normal_short_to_float_v3(&varray[start + 15], tlnor[0]);
+ }
+ }
+ else if (smoothnormal) {
/* copy vertex normal */
normal_short_to_float_v3(&varray[start], mvert[f->v1].no);
normal_short_to_float_v3(&varray[start + 3], mvert[f->v2].no);
@@ -1231,13 +1282,13 @@ void GPU_color_switch(int mode)
/* return 1 if drawing should be done using old immediate-mode
* code, 0 otherwise */
-int GPU_buffer_legacy(DerivedMesh *dm)
+bool GPU_buffer_legacy(DerivedMesh *dm)
{
int test = (U.gameflags & USER_DISABLE_VBO);
if (test)
return 1;
- if (dm->drawObject == 0)
+ if (dm->drawObject == NULL)
dm->drawObject = GPU_drawobject_new(dm);
return dm->drawObject->legacy;
}
@@ -1332,7 +1383,7 @@ struct GPU_PBVH_Buffers {
/* mesh pointers in case buffer allocation fails */
MFace *mface;
MVert *mvert;
- int *face_indices;
+ const int *face_indices;
int totface;
const float *vmask;
@@ -1341,7 +1392,7 @@ struct GPU_PBVH_Buffers {
CCGElem **grids;
const DMFlagMat *grid_flag_mats;
BLI_bitmap * const *grid_hidden;
- int *grid_indices;
+ const int *grid_indices;
int totgrid;
int has_hidden;
@@ -1429,7 +1480,7 @@ static void gpu_color_from_mask_quad_copy(const CCGKey *key,
static void gpu_color_from_mask_quad_set(const CCGKey *key,
CCGElem *a, CCGElem *b,
CCGElem *c, CCGElem *d,
- float diffuse_color[4])
+ const float diffuse_color[4])
{
float color = gpu_color_from_mask_quad(key, a, b, c, d);
glColor3f(diffuse_color[0] * color, diffuse_color[1] * color, diffuse_color[2] * color);
@@ -1573,7 +1624,7 @@ void GPU_update_mesh_pbvh_buffers(GPU_PBVH_Buffers *buffers, MVert *mvert,
buffers->mvert = mvert;
}
-GPU_PBVH_Buffers *GPU_build_pbvh_mesh_buffers(int (*face_vert_indices)[4],
+GPU_PBVH_Buffers *GPU_build_mesh_pbvh_buffers(int (*face_vert_indices)[4],
MFace *mface, MVert *mvert,
int *face_indices,
int totface)
@@ -1596,6 +1647,16 @@ GPU_PBVH_Buffers *GPU_build_pbvh_mesh_buffers(int (*face_vert_indices)[4],
tottri += f->v4 ? 2 : 1;
}
+ if (tottri == 0) {
+ buffers->tot_tri = 0;
+
+ buffers->mface = mface;
+ buffers->face_indices = face_indices;
+ buffers->totface = 0;
+
+ return buffers;
+ }
+
/* An element index buffer is used for smooth shading, but flat
* shading requires separate vertex normals so an index buffer is
* can't be used there. */
@@ -1767,36 +1828,6 @@ void GPU_update_grid_pbvh_buffers(GPU_PBVH_Buffers *buffers, CCGElem **grids,
//printf("node updated %p\n", buffers);
}
-/* Returns the number of visible quads in the nodes' grids. */
-static int gpu_count_grid_quads(BLI_bitmap **grid_hidden,
- int *grid_indices, int totgrid,
- int gridsize)
-{
- int gridarea = (gridsize - 1) * (gridsize - 1);
- int i, x, y, totquad;
-
- /* grid hidden layer is present, so have to check each grid for
- * visibility */
-
- for (i = 0, totquad = 0; i < totgrid; i++) {
- const BLI_bitmap *gh = grid_hidden[grid_indices[i]];
-
- if (gh) {
- /* grid hidden are present, have to check each element */
- for (y = 0; y < gridsize - 1; y++) {
- for (x = 0; x < gridsize - 1; x++) {
- if (!paint_is_grid_face_hidden(gh, gridsize, x, y))
- totquad++;
- }
- }
- }
- else
- totquad += gridarea;
- }
-
- return totquad;
-}
-
/* Build the element array buffer of grid indices using either
* unsigned shorts or unsigned ints. */
#define FILL_QUAD_BUFFER(type_, tot_quad_, buffer_) \
@@ -1856,7 +1887,7 @@ static GLuint gpu_get_grid_buffer(int gridsize, GLenum *index_type, unsigned *to
/* used in the FILL_QUAD_BUFFER macro */
BLI_bitmap * const *grid_hidden = NULL;
- int *grid_indices = NULL;
+ const int *grid_indices = NULL;
int totgrid = 1;
/* VBO is disabled; delete the previous buffer (if it exists) and
@@ -1900,7 +1931,7 @@ static GLuint gpu_get_grid_buffer(int gridsize, GLenum *index_type, unsigned *to
}
GPU_PBVH_Buffers *GPU_build_grid_pbvh_buffers(int *grid_indices, int totgrid,
- BLI_bitmap **grid_hidden, int gridsize)
+ BLI_bitmap **grid_hidden, int gridsize)
{
GPU_PBVH_Buffers *buffers;
int totquad;
@@ -1914,7 +1945,11 @@ GPU_PBVH_Buffers *GPU_build_grid_pbvh_buffers(int *grid_indices, int totgrid,
buffers->use_matcaps = false;
/* Count the number of quads */
- totquad = gpu_count_grid_quads(grid_hidden, grid_indices, totgrid, gridsize);
+ totquad = BKE_pbvh_count_grid_quads(grid_hidden, grid_indices, totgrid, gridsize);
+
+ /* totally hidden node, return here to avoid BufferData with zero below. */
+ if (totquad == 0)
+ return buffers;
if (totquad == fully_visible_totquad) {
buffers->index_buf = gpu_get_grid_buffer(gridsize, &buffers->index_type, &buffers->tot_quad);
@@ -2010,15 +2045,15 @@ static int gpu_bmesh_vert_visible_count(GSet *bm_unique_verts,
}
/* Return the total number of visible faces */
-static int gpu_bmesh_face_visible_count(GHash *bm_faces)
+static int gpu_bmesh_face_visible_count(GSet *bm_faces)
{
- GHashIterator gh_iter;
+ GSetIterator gh_iter;
int totface = 0;
- GHASH_ITER (gh_iter, bm_faces) {
- BMFace *f = BLI_ghashIterator_getKey(&gh_iter);
+ GSET_ITER (gh_iter, bm_faces) {
+ BMFace *f = BLI_gsetIterator_getKey(&gh_iter);
- if (!paint_is_bmesh_face_hidden(f))
+ if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN))
totface++;
}
@@ -2029,7 +2064,7 @@ static int gpu_bmesh_face_visible_count(GHash *bm_faces)
* shading, an element index buffer. */
void GPU_update_bmesh_pbvh_buffers(GPU_PBVH_Buffers *buffers,
BMesh *bm,
- GHash *bm_faces,
+ GSet *bm_faces,
GSet *bm_unique_verts,
GSet *bm_other_verts,
bool show_diffuse_color)
@@ -2058,15 +2093,7 @@ void GPU_update_bmesh_pbvh_buffers(GPU_PBVH_Buffers *buffers,
else
totvert = tottri * 3;
- /* some nodes may lose all their vertices/faces. Normally we should delete those but since we don't
- * support dynamic nodes yet, just return immediately to avoid opengl errors */
if (!tottri) {
- if (buffers->index_buf)
- glDeleteBuffersARB(1, &buffers->index_buf);
- if (buffers->vert_buf)
- glDeleteBuffersARB(1, &buffers->vert_buf);
- buffers->vert_buf = 0;
- buffers->index_buf = 0;
buffers->tot_tri = 0;
return;
}
@@ -2075,10 +2102,10 @@ void GPU_update_bmesh_pbvh_buffers(GPU_PBVH_Buffers *buffers,
diffuse_color[0] = diffuse_color[1] = diffuse_color[2] = 1.0;
else if (show_diffuse_color) {
/* due to dynamic nature of dyntopo, only get first material */
- GHashIterator gh_iter;
+ GSetIterator gs_iter;
BMFace *f;
- BLI_ghashIterator_init(&gh_iter, bm_faces);
- f = BLI_ghashIterator_getKey(&gh_iter);
+ BLI_gsetIterator_init(&gs_iter, bm_faces);
+ f = BLI_gsetIterator_getKey(&gs_iter);
GPU_material_diffuse_get(f->mat_nr + 1, diffuse_color);
}
@@ -2117,14 +2144,14 @@ void GPU_update_bmesh_pbvh_buffers(GPU_PBVH_Buffers *buffers,
maxvert = v_index;
}
else {
- GHashIterator gh_iter;
+ GSetIterator gs_iter;
- GHASH_ITER (gh_iter, bm_faces) {
- BMFace *f = BLI_ghashIterator_getKey(&gh_iter);
+ GSET_ITER (gs_iter, bm_faces) {
+ BMFace *f = BLI_gsetIterator_getKey(&gs_iter);
BLI_assert(f->len == 3);
- if (!paint_is_bmesh_face_hidden(f)) {
+ if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
BMVert *v[3];
float fmask = 0;
int i;
@@ -2175,12 +2202,12 @@ void GPU_update_bmesh_pbvh_buffers(GPU_PBVH_Buffers *buffers,
/* Fill triangle index buffer */
tri_data = glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
if (tri_data) {
- GHashIterator gh_iter;
+ GSetIterator gs_iter;
- GHASH_ITER (gh_iter, bm_faces) {
- BMFace *f = BLI_ghashIterator_getKey(&gh_iter);
+ GSET_ITER (gs_iter, bm_faces) {
+ BMFace *f = BLI_gsetIterator_getKey(&gs_iter);
- if (!paint_is_bmesh_face_hidden(f)) {
+ if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
BMLoop *l_iter;
BMLoop *l_first;
@@ -2476,7 +2503,7 @@ void GPU_draw_pbvh_buffers(GPU_PBVH_Buffers *buffers, DMSetMaterial setMaterial,
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
if (buffers->tot_quad) {
- char *offset = 0;
+ const char *offset = 0;
int i, last = buffers->has_hidden ? 1 : buffers->totgrid;
for (i = 0; i < last; i++) {
glVertexPointer(3, GL_FLOAT, sizeof(VertexBufferFormat),
@@ -2491,7 +2518,7 @@ void GPU_draw_pbvh_buffers(GPU_PBVH_Buffers *buffers, DMSetMaterial setMaterial,
offset += buffers->gridkey.grid_area * sizeof(VertexBufferFormat);
}
}
- else {
+ else if (buffers->tot_tri) {
int totelem = buffers->tot_tri * 3;
glVertexPointer(3, GL_FLOAT, sizeof(VertexBufferFormat),
@@ -2529,17 +2556,18 @@ void GPU_draw_pbvh_buffers(GPU_PBVH_Buffers *buffers, DMSetMaterial setMaterial,
}
}
-bool GPU_pbvh_buffers_diffuse_changed(GPU_PBVH_Buffers *buffers, GHash *bm_faces, bool show_diffuse_color)
+bool GPU_pbvh_buffers_diffuse_changed(GPU_PBVH_Buffers *buffers, GSet *bm_faces, bool show_diffuse_color)
{
float diffuse_color[4];
+ bool use_matcaps = GPU_material_use_matcaps_get();
if (buffers->show_diffuse_color != show_diffuse_color)
return true;
- if (buffers->use_matcaps != GPU_material_use_matcaps_get())
+ if (buffers->use_matcaps != use_matcaps)
return true;
- if (buffers->show_diffuse_color == false)
+ if ((buffers->show_diffuse_color == false) || use_matcaps)
return false;
if (buffers->mface) {
@@ -2549,10 +2577,10 @@ bool GPU_pbvh_buffers_diffuse_changed(GPU_PBVH_Buffers *buffers, GHash *bm_faces
}
else if (buffers->use_bmesh) {
/* due to dynamc nature of dyntopo, only get first material */
- GHashIterator gh_iter;
+ GSetIterator gs_iter;
BMFace *f;
- BLI_ghashIterator_init(&gh_iter, bm_faces);
- f = BLI_ghashIterator_getKey(&gh_iter);
+ BLI_gsetIterator_init(&gs_iter, bm_faces);
+ f = BLI_gsetIterator_getKey(&gs_iter);
GPU_material_diffuse_get(f->mat_nr + 1, diffuse_color);
}
else {
@@ -2614,3 +2642,65 @@ void GPU_free_pbvh_buffers(GPU_PBVH_Buffers *buffers)
MEM_freeN(buffers);
}
}
+
+
+/* debug function, draws the pbvh BB */
+void GPU_draw_pbvh_BB(float min[3], float max[3], bool leaf)
+{
+ float quads[4][4][3] = {
+ {
+ {min[0], min[1], min[2]},
+ {max[0], min[1], min[2]},
+ {max[0], min[1], max[2]},
+ {min[0], min[1], max[2]}
+ },
+
+ {
+ {min[0], min[1], min[2]},
+ {min[0], max[1], min[2]},
+ {min[0], max[1], max[2]},
+ {min[0], min[1], max[2]}
+ },
+
+ {
+ {max[0], max[1], min[2]},
+ {max[0], min[1], min[2]},
+ {max[0], min[1], max[2]},
+ {max[0], max[1], max[2]}
+ },
+
+ {
+ {max[0], max[1], min[2]},
+ {min[0], max[1], min[2]},
+ {min[0], max[1], max[2]},
+ {max[0], max[1], max[2]}
+ },
+ };
+
+ if (leaf)
+ glColor4f(0.0, 1.0, 0.0, 0.5);
+ else
+ glColor4f(1.0, 0.0, 0.0, 0.5);
+
+ glVertexPointer(3, GL_FLOAT, 0, &quads[0][0][0]);
+ glDrawArrays(GL_QUADS, 0, 16);
+}
+
+void GPU_init_draw_pbvh_BB(void)
+{
+ glPushAttrib(GL_ENABLE_BIT);
+ glDisable(GL_CULL_FACE);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glDisableClientState(GL_COLOR_ARRAY);
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+ glDisable(GL_LIGHTING);
+ glDisable(GL_COLOR_MATERIAL);
+ glEnable(GL_BLEND);
+ glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
+}
+
+void GPU_end_draw_pbvh_BB(void)
+{
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ glPopAttrib();
+}
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index 2687157d01b..b3155f0ad50 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -43,7 +43,6 @@
#include "BLI_utildefines.h"
#include "BLI_dynstr.h"
#include "BLI_ghash.h"
-#include "BLI_heap.h"
#include "GPU_material.h"
#include "GPU_extensions.h"
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 64ab701acba..1845de16780 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -85,7 +85,7 @@ extern Material defmaterial; /* from material.c */
static void gpu_mcol(unsigned int ucol)
{
/* mcol order is swapped */
- char *cp= (char *)&ucol;
+ const char *cp= (char *)&ucol;
glColor3ub(cp[3], cp[2], cp[1]);
}
@@ -261,7 +261,7 @@ void GPU_set_gpu_mipmapping(int gpu_mipmap)
static void gpu_generate_mipmap(GLenum target)
{
- int is_ati = GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY);
+ const bool is_ati = GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY);
int target_enabled = 0;
/* work around bug in ATI driver, need to have GL_TEXTURE_2D enabled
@@ -1040,7 +1040,7 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h)
/* if color correction is needed, we must update the part that needs updating. */
if (ibuf->rect_float) {
float *buffer = MEM_mallocN(w*h*sizeof(float)*4, "temp_texpaint_float_buf");
- int is_data = (ima->tpageflag & IMA_GLBIND_IS_DATA);
+ bool is_data = (ima->tpageflag & IMA_GLBIND_IS_DATA) != 0;
IMB_partial_rect_from_float(ibuf, buffer, x, y, w, h, is_data);
if (GPU_check_scaled_image(ibuf, ima, buffer, x, y, w, h)) {
@@ -1403,8 +1403,12 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O
const bool new_shading_nodes = BKE_scene_use_new_shading_nodes(scene);
const bool use_matcap = (v3d->flag2 & V3D_SHOW_SOLID_MATCAP) != 0; /* assumes v3d->defmaterial->preview is set */
- ob = BKE_object_lod_matob_get(ob, scene);
-
+#ifdef WITH_GAMEENGINE
+ if (rv3d->rflag & RV3D_IS_GAME_ENGINE) {
+ ob = BKE_object_lod_matob_get(ob, scene);
+ }
+#endif
+
/* initialize state */
memset(&GMS, 0, sizeof(GMS));
GMS.lastmatnr = -1;
@@ -1597,6 +1601,9 @@ int GPU_enable_material(int nr, void *attribs)
else
glDisable(GL_CULL_FACE);
}
+
+ if (GMS.use_matcaps)
+ glColor3f(1.0, 1.0, 1.0f);
}
else {
/* or do fixed function opengl material */
diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c
index 5c3bf6eb8e2..cd256a570d0 100644
--- a/source/blender/gpu/intern/gpu_extensions.c
+++ b/source/blender/gpu/intern/gpu_extensions.c
@@ -330,7 +330,7 @@ struct GPUTexture {
static unsigned char *GPU_texture_convert_pixels(int length, float *fpixels)
{
unsigned char *pixels, *p;
- float *fp;
+ const float *fp;
int a, len;
len = 4*length;
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index 0f05a7f0cda..4b070a4568a 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -58,6 +58,7 @@
#include "BKE_node.h"
#include "BKE_scene.h"
#include "BKE_texture.h"
+#include "BKE_group.h"
#include "IMB_imbuf_types.h"
@@ -259,18 +260,33 @@ void GPU_material_free(Material *ma)
BLI_freelistN(&ma->gpumaterial);
}
+bool GPU_lamp_override_visible(GPULamp *lamp, SceneRenderLayer *srl, Material *ma)
+{
+ if (srl && srl->light_override)
+ return BKE_group_object_exists(srl->light_override, lamp->ob);
+ else if (ma && ma->group)
+ return BKE_group_object_exists(ma->group, lamp->ob);
+ else
+ return true;
+}
+
void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time, int mipmap, float viewmat[4][4], float viewinv[4][4])
{
if (material->pass) {
LinkData *nlink;
GPULamp *lamp;
GPUShader *shader = GPU_pass_shader(material->pass);
+ SceneRenderLayer *srl = BLI_findlink(&material->scene->r.layers, material->scene->r.actlay);
+
+ if (srl)
+ viewlay &= srl->lay;
/* handle layer lamps */
for (nlink=material->lamps.first; nlink; nlink=nlink->next) {
lamp= nlink->data;
- if (!lamp->hide && (lamp->lay & viewlay) && (!(lamp->mode & LA_LAYER) || (lamp->lay & oblay))) {
+ if (!lamp->hide && (lamp->lay & viewlay) && (!(lamp->mode & LA_LAYER) || (lamp->lay & oblay))
+ && GPU_lamp_override_visible(lamp, srl, material->ma)) {
lamp->dynenergy = lamp->energy;
copy_v3_v3(lamp->dyncol, lamp->col);
}
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index cfe99625db3..a224f8e979a 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -299,6 +299,11 @@ void math_modulo(float val1, float val2, out float outval)
outval = mod(val1, val2);
}
+void math_abs(float val1, out float outval)
+{
+ outval = abs(val1);
+}
+
void squeeze(float val, float width, float center, out float outval)
{
outval = 1.0/(1.0 + pow(2.71828183, -((val-center)*width)));
@@ -944,12 +949,9 @@ void mtex_rgb_dark(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 in
fact *= facg;
facm = 1.0-fact;
- col= texcol.r + ((1.0 -texcol.r)*facm);
- if(col < outcol.r) incol.r = col; else incol.r = outcol.r;
- col= texcol.g + ((1.0 -texcol.g)*facm);
- if(col < outcol.g) incol.g = col; else incol.g = outcol.g;
- col= texcol.b + ((1.0 -texcol.b)*facm);
- if(col < outcol.b) incol.b = col; else incol.b = outcol.b;
+ incol.r = min(outcol.r, texcol.r) * fact + outcol.r * facm;
+ incol.g = min(outcol.g, texcol.g) * fact + outcol.g * facm;
+ incol.b = min(outcol.b, texcol.b) * fact + outcol.b * facm;
}
void mtex_rgb_light(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
@@ -1078,8 +1080,7 @@ void mtex_value_dark(float outcol, float texcol, float fact, float facg, out flo
float facm;
mtex_value_vars(fact, facg, facm);
- float col = fact*texcol;
- if(col < outcol) incol = col; else incol = outcol;
+ incol = facm*outcol + fact*min(outcol, texcol);
}
void mtex_value_light(float outcol, float texcol, float fact, float facg, out float incol)
@@ -2362,7 +2363,8 @@ void node_light_path(
out float is_reflection_ray,
out float is_transmission_ray,
out float ray_length,
- out float ray_depth)
+ out float ray_depth,
+ out float transparent_depth)
{
is_camera_ray = 1.0;
is_shadow_ray = 0.0;
@@ -2373,6 +2375,7 @@ void node_light_path(
is_transmission_ray = 0.0;
ray_length = 1.0;
ray_depth = 1.0;
+ transparent_depth = 1.0;
}
void node_light_falloff(float strength, float tsmooth, out float quadratic, out float linear, out float constant)
diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c
index c3b6df8ac85..80c508267f3 100644
--- a/source/blender/ikplugin/intern/iksolver_plugin.c
+++ b/source/blender/ikplugin/intern/iksolver_plugin.c
@@ -374,7 +374,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
/* 1.0=ctime, we pass on object for auto-ik (owner-type here is object, even though
* strictly speaking, it is a posechannel)
*/
- BKE_get_constraint_target_matrix(scene, target->con, 0, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0);
+ BKE_constraint_target_matrix_get(scene, target->con, 0, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0);
/* and set and transform goal */
mul_m4_m4m4(goal, goalinv, rootmat);
@@ -385,7 +385,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
/* same for pole vector target */
if (data->poletar) {
- BKE_get_constraint_target_matrix(scene, target->con, 1, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0);
+ BKE_constraint_target_matrix_get(scene, target->con, 1, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0);
if (data->flag & CONSTRAINT_IK_SETANGLE) {
/* don't solve IK when we are setting the pole angle */
diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp
index e1bc47b107f..dbc4100e287 100644
--- a/source/blender/ikplugin/intern/itasc_plugin.cpp
+++ b/source/blender/ikplugin/intern/itasc_plugin.cpp
@@ -551,7 +551,7 @@ static bool target_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Fram
bConstraint *constraint = (bConstraint *)target->blenderConstraint;
float tarmat[4][4];
- BKE_get_constraint_target_matrix(target->blscene, constraint, 0, CONSTRAINT_OBTYPE_OBJECT, target->owner, tarmat, 1.0);
+ BKE_constraint_target_matrix_get(target->blscene, constraint, 0, CONSTRAINT_OBTYPE_OBJECT, target->owner, tarmat, 1.0);
// rootmat contains the target pose in world coordinate
// if enforce is != 1.0, blend the target position with the end effector position
@@ -620,7 +620,7 @@ static bool base_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Frame&
IK_Channel &rootchan = ikscene->channels[0];
// get polar target matrix in world space
- BKE_get_constraint_target_matrix(ikscene->blscene, ikscene->polarConstraint, 1, CONSTRAINT_OBTYPE_OBJECT, ikscene->blArmature, mat, 1.0);
+ BKE_constraint_target_matrix_get(ikscene->blscene, ikscene->polarConstraint, 1, CONSTRAINT_OBTYPE_OBJECT, ikscene->blArmature, mat, 1.0);
// convert to armature space
mul_m4_m4m4(polemat, imat, mat);
// get the target in world space (was computed before as target object are defined before base object)
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index c941f1b065e..090e7a66d41 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -355,6 +355,7 @@ short IMB_saveiff(struct ImBuf *ibuf, const char *filepath, int flags);
* \attention Defined in util.c
*/
bool IMB_ispic(const char *name);
+int IMB_ispic_type(const char *name);
/**
*
@@ -379,7 +380,7 @@ void IMB_interlace(struct ImBuf *ibuf);
void IMB_rect_from_float(struct ImBuf *ibuf);
/* Create char buffer for part of the image, color corrected if necessary,
* Changed part will be stored in buffer. This is expected to be used for texture painting updates */
-void IMB_partial_rect_from_float(struct ImBuf *ibuf, float *buffer, int x, int y, int w, int h, int is_data);
+void IMB_partial_rect_from_float(struct ImBuf *ibuf, float *buffer, int x, int y, int w, int h, bool is_data);
void IMB_float_from_rect(struct ImBuf *ibuf);
void IMB_color_to_bw(struct ImBuf *ibuf);
void IMB_saturation(struct ImBuf *ibuf, float sat);
@@ -388,12 +389,17 @@ void IMB_saturation(struct ImBuf *ibuf, float sat);
void IMB_buffer_byte_from_float(unsigned char *rect_to, const float *rect_from,
int channels_from, float dither, int profile_to, int profile_from, bool predivide,
int width, int height, int stride_to, int stride_from);
+void IMB_buffer_byte_from_float_mask(unsigned char *rect_to, const float *rect_from,
+ int channels_from, float dither, bool predivide,
+ int width, int height, int stride_to, int stride_from, char *mask);
void IMB_buffer_float_from_byte(float *rect_to, const unsigned char *rect_from,
int profile_to, int profile_from, bool predivide,
int width, int height, int stride_to, int stride_from);
void IMB_buffer_float_from_float(float *rect_to, const float *rect_from,
int channels_from, int profile_to, int profile_from, bool predivide,
int width, int height, int stride_to, int stride_from);
+void IMB_buffer_float_from_float_mask(float *rect_to, const float *rect_from,
+ int channels_from, int width, int height, int stride_to, int stride_from, char *mask);
void IMB_buffer_byte_from_byte(unsigned char *rect_to, const unsigned char *rect_from,
int profile_to, int profile_from, bool predivide,
int width, int height, int stride_to, int stride_from);
diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c
index d0e81f2f383..612517775f4 100644
--- a/source/blender/imbuf/intern/allocimbuf.c
+++ b/source/blender/imbuf/intern/allocimbuf.c
@@ -46,10 +46,9 @@
#include "imbuf.h"
#include "MEM_guardedalloc.h"
-#include "MEM_CacheLimiterC-Api.h"
-#include "BLI_utildefines.h"
#include "BLI_threads.h"
+#include "BLI_utildefines.h"
static SpinLock refcounter_spin;
diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c
index 40fdf19ccc1..eef7964ef3f 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -67,14 +67,12 @@
#include "BLI_utildefines.h"
#include "BLI_string.h"
#include "BLI_path_util.h"
-#include "BLI_math_base.h"
#include "MEM_guardedalloc.h"
#include "DNA_userdef_types.h"
#include "BKE_global.h"
-#include "BKE_depsgraph.h"
#include "imbuf.h"
@@ -1048,7 +1046,7 @@ static ImBuf *ffmpeg_fetchibuf(struct anim *anim, int position,
av_log(anim->pFormatCtx, AV_LOG_DEBUG,
"TC INDEX seek pos = %lld\n", pos);
av_log(anim->pFormatCtx, AV_LOG_DEBUG,
- "TC INDEX seek dts = %lld\n", dts);
+ "TC INDEX seek dts = %llu\n", dts);
if (ffmpeg_seek_by_byte(anim->pFormatCtx)) {
av_log(anim->pFormatCtx, AV_LOG_DEBUG,
diff --git a/source/blender/imbuf/intern/cineon/cineonlib.c b/source/blender/imbuf/intern/cineon/cineonlib.c
index b80a381ebbb..e8cb550fc05 100644
--- a/source/blender/imbuf/intern/cineon/cineonlib.c
+++ b/source/blender/imbuf/intern/cineon/cineonlib.c
@@ -37,9 +37,12 @@
#include <string.h>
#include "BLI_fileops.h"
-#include "BLI_math_base.h"
#include "BLI_utildefines.h"
+#if defined(_MSC_VER) && (_MSC_VER <= 1500)
+#include "BLI_math_base.h"
+#endif
+
#include "MEM_guardedalloc.h"
/*
diff --git a/source/blender/imbuf/intern/cineon/dpxlib.c b/source/blender/imbuf/intern/cineon/dpxlib.c
index ff7d37893c7..84f80faeacc 100644
--- a/source/blender/imbuf/intern/cineon/dpxlib.c
+++ b/source/blender/imbuf/intern/cineon/dpxlib.c
@@ -37,9 +37,12 @@
#include <string.h>
#include "BLI_fileops.h"
-#include "BLI_math_base.h"
#include "BLI_utildefines.h"
+#if defined(_MSC_VER) && (_MSC_VER <= 1500)
+#include "BLI_math_base.h"
+#endif
+
#include "MEM_guardedalloc.h"
/*
diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c
index 8aa9615feac..590b21259c3 100644
--- a/source/blender/imbuf/intern/colormanagement.c
+++ b/source/blender/imbuf/intern/colormanagement.c
@@ -42,9 +42,7 @@
#include "DNA_image_types.h"
#include "DNA_movieclip_types.h"
#include "DNA_scene_types.h"
-#include "DNA_screen_types.h"
#include "DNA_space_types.h"
-#include "DNA_windowmanager_types.h"
#include "IMB_filter.h"
#include "IMB_imbuf.h"
@@ -66,7 +64,6 @@
#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BKE_image.h"
-#include "BKE_utildefines.h"
#include "BKE_main.h"
#include "RNA_define.h"
@@ -1237,7 +1234,7 @@ const char *IMB_colormanagement_get_rect_colorspace(ImBuf *ibuf)
typedef struct DisplayBufferThread {
ColormanageProcessor *cm_processor;
- float *buffer;
+ const float *buffer;
unsigned char *byte_buffer;
float *display_buffer;
@@ -1258,7 +1255,7 @@ typedef struct DisplayBufferThread {
typedef struct DisplayBufferInitData {
ImBuf *ibuf;
ColormanageProcessor *cm_processor;
- float *buffer;
+ const float *buffer;
unsigned char *byte_buffer;
float *display_buffer;
@@ -2779,21 +2776,27 @@ void IMB_partial_display_buffer_update(ImBuf *ibuf, const float *linear_buffer,
ColormanageProcessor *cm_processor = NULL;
bool skip_transform = false;
- /* byte buffer is assumed to be in imbuf's rect space, so if byte buffer
+ /* Byte buffer is assumed to be in imbuf's rect space, so if byte buffer
* is known we could skip display->linear->display conversion in case
- * display color space matches imbuf's rect space
+ * display color space matches imbuf's rect space.
+ *
+ * But if there's a float buffer it's likely operation was performed on
+ * it first and byte buffer is likely to be out of date here.
*/
- if (byte_buffer != NULL)
+ if (linear_buffer == NULL && byte_buffer != NULL) {
skip_transform = is_ibuf_rect_in_display_space(ibuf, view_settings, display_settings);
+ }
- if (!skip_transform)
+ if (!skip_transform) {
cm_processor = IMB_colormanagement_display_processor_new(view_settings, display_settings);
+ }
partial_buffer_update_rect(ibuf, display_buffer, linear_buffer, byte_buffer, buffer_width, stride,
offset_x, offset_y, cm_processor, xmin, ymin, xmax, ymax);
- if (cm_processor)
+ if (cm_processor) {
IMB_colormanagement_processor_free(cm_processor);
+ }
IMB_display_buffer_release(cache_handle);
}
diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
index f6606711cc3..028026527dc 100644
--- a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
+++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
@@ -1475,20 +1475,20 @@ void DirectDrawSurface::printInfo() const
if (header.pf.fourcc != 0) {
// Display fourcc code even when DDPF_FOURCC flag not set.
printf("\tFourCC: '%c%c%c%c' (0x%.8X)\n",
- ((header.pf.fourcc >> 0) & 0xFF),
- ((header.pf.fourcc >> 8) & 0xFF),
- ((header.pf.fourcc >> 16) & 0xFF),
- ((header.pf.fourcc >> 24) & 0xFF),
+ (int)((header.pf.fourcc >> 0) & 0xFF),
+ (int)((header.pf.fourcc >> 8) & 0xFF),
+ (int)((header.pf.fourcc >> 16) & 0xFF),
+ (int)((header.pf.fourcc >> 24) & 0xFF),
header.pf.fourcc);
}
if ((header.pf.flags & DDPF_FOURCC) && (header.pf.bitcount != 0))
{
printf("\tSwizzle: '%c%c%c%c' (0x%.8X)\n",
- (header.pf.bitcount >> 0) & 0xFF,
- (header.pf.bitcount >> 8) & 0xFF,
- (header.pf.bitcount >> 16) & 0xFF,
- (header.pf.bitcount >> 24) & 0xFF,
+ (int)(header.pf.bitcount >> 0) & 0xFF,
+ (int)(header.pf.bitcount >> 8) & 0xFF,
+ (int)(header.pf.bitcount >> 16) & 0xFF,
+ (int)(header.pf.bitcount >> 24) & 0xFF,
header.pf.bitcount);
}
else
diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c
index ef1bc9eaafa..9975c58bdd2 100644
--- a/source/blender/imbuf/intern/divers.c
+++ b/source/blender/imbuf/intern/divers.c
@@ -43,7 +43,6 @@
#include "IMB_colormanagement.h"
#include "IMB_colormanagement_intern.h"
-#include "BLI_threads.h"
#include "MEM_guardedalloc.h"
@@ -327,6 +326,84 @@ void IMB_buffer_byte_from_float(uchar *rect_to, const float *rect_from,
clear_dither_context(di);
}
+
+/* float to byte pixels, output 4-channel RGBA */
+void IMB_buffer_byte_from_float_mask(uchar *rect_to, const float *rect_from,
+ int channels_from, float dither, bool predivide,
+ int width, int height, int stride_to, int stride_from, char *mask)
+{
+ int x, y;
+ DitherContext *di = NULL;
+ float inv_width = 1.0f / width,
+ inv_height = 1.0f / height;
+
+ if (dither)
+ di = create_dither_context(dither);
+
+ for (y = 0; y < height; y++) {
+ float t = y * inv_height;
+
+ if (channels_from == 1) {
+ /* single channel input */
+ const float *from = rect_from + stride_from * y;
+ uchar *to = rect_to + stride_to * y * 4;
+
+ for (x = 0; x < width; x++, from++, to += 4)
+ if (*mask++ == FILTER_MASK_USED)
+ to[0] = to[1] = to[2] = to[3] = FTOCHAR(from[0]);
+ }
+ else if (channels_from == 3) {
+ /* RGB input */
+ const float *from = rect_from + stride_from * y * 3;
+ uchar *to = rect_to + stride_to * y * 4;
+
+ for (x = 0; x < width; x++, from += 3, to += 4) {
+ if (*mask++ == FILTER_MASK_USED) {
+ rgb_float_to_uchar(to, from);
+ to[3] = 255;
+ }
+ }
+ }
+ else if (channels_from == 4) {
+ /* RGBA input */
+ const float *from = rect_from + stride_from * y * 4;
+ uchar *to = rect_to + stride_to * y * 4;
+
+ float straight[4];
+
+ if (dither && predivide) {
+ for (x = 0; x < width; x++, from += 4, to += 4) {
+ if (*mask++ == FILTER_MASK_USED) {
+ premul_to_straight_v4_v4(straight, from);
+ float_to_byte_dither_v4(to, straight, di, (float) x * inv_width, t);
+ }
+ }
+ }
+ else if (dither) {
+ for (x = 0; x < width; x++, from += 4, to += 4)
+ if (*mask++ == FILTER_MASK_USED)
+ float_to_byte_dither_v4(to, from, di, (float) x * inv_width, t);
+ }
+ else if (predivide) {
+ for (x = 0; x < width; x++, from += 4, to += 4) {
+ if (*mask++ == FILTER_MASK_USED) {
+ premul_to_straight_v4_v4(straight, from);
+ rgba_float_to_uchar(to, straight);
+ }
+ }
+ }
+ else {
+ for (x = 0; x < width; x++, from += 4, to += 4)
+ if (*mask++ == FILTER_MASK_USED)
+ rgba_float_to_uchar(to, from);
+ }
+ }
+ }
+
+ if (dither)
+ clear_dither_context(di);
+}
+
/* byte to float pixels, input and output 4-channel RGBA */
void IMB_buffer_float_from_byte(float *rect_to, const uchar *rect_from,
int profile_to, int profile_from, bool predivide,
@@ -466,6 +543,50 @@ void IMB_buffer_float_from_float(float *rect_to, const float *rect_from,
}
}
+/* float to float pixels, output 4-channel RGBA */
+void IMB_buffer_float_from_float_mask(float *rect_to, const float *rect_from, int channels_from,
+ int width, int height, int stride_to, int stride_from, char *mask)
+{
+ int x, y;
+
+ if (channels_from == 1) {
+ /* single channel input */
+ for (y = 0; y < height; y++) {
+ const float *from = rect_from + stride_from * y;
+ float *to = rect_to + stride_to * y * 4;
+
+ for (x = 0; x < width; x++, from++, to += 4)
+ if (*mask++ == FILTER_MASK_USED)
+ to[0] = to[1] = to[2] = to[3] = from[0];
+ }
+ }
+ else if (channels_from == 3) {
+ /* RGB input */
+ for (y = 0; y < height; y++) {
+ const float *from = rect_from + stride_from * y * 3;
+ float *to = rect_to + stride_to * y * 4;
+
+ for (x = 0; x < width; x++, from += 3, to += 4) {
+ if (*mask++ == FILTER_MASK_USED) {
+ copy_v3_v3(to, from);
+ to[3] = 1.0f;
+ }
+ }
+ }
+ }
+ else if (channels_from == 4) {
+ /* RGBA input */
+ for (y = 0; y < height; y++) {
+ const float *from = rect_from + stride_from * y * 4;
+ float *to = rect_to + stride_to * y * 4;
+
+ for (x = 0; x < width; x++, from += 4, to += 4)
+ if (*mask++ == FILTER_MASK_USED)
+ copy_v4_v4(to, from);
+ }
+ }
+}
+
/* byte to byte pixels, input and output 4-channel RGBA */
void IMB_buffer_byte_from_byte(uchar *rect_to, const uchar *rect_from,
int profile_to, int profile_from, bool predivide,
@@ -565,9 +686,9 @@ void IMB_rect_from_float(ImBuf *ibuf)
}
/* converts from linear float to sRGB byte for part of the texture, buffer will hold the changed part */
-void IMB_partial_rect_from_float(ImBuf *ibuf, float *buffer, int x, int y, int w, int h, int is_data)
+void IMB_partial_rect_from_float(ImBuf *ibuf, float *buffer, int x, int y, int w, int h, bool is_data)
{
- float *rect_float;
+ const float *rect_float;
uchar *rect_byte;
int profile_from = IB_PROFILE_LINEAR_RGB;
diff --git a/source/blender/imbuf/intern/filter.c b/source/blender/imbuf/intern/filter.c
index d0d7fc2448b..352e230068b 100644
--- a/source/blender/imbuf/intern/filter.c
+++ b/source/blender/imbuf/intern/filter.c
@@ -263,7 +263,7 @@ void IMB_filter(struct ImBuf *ibuf)
void IMB_mask_filter_extend(char *mask, int width, int height)
{
- char *row1, *row2, *row3;
+ const char *row1, *row2, *row3;
int rowlen, x, y;
char *temprect;
@@ -333,7 +333,7 @@ static int filter_make_index(const int x, const int y, const int w, const int h)
else return y * w + x;
}
-static int check_pixel_assigned(const void *buffer, const char *mask, const int index, const int depth, const int is_float)
+static int check_pixel_assigned(const void *buffer, const char *mask, const int index, const int depth, const bool is_float)
{
int res = 0;
@@ -364,7 +364,7 @@ void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter)
const int depth = 4; /* always 4 channels */
const int chsize = ibuf->rect_float ? sizeof(float) : sizeof(unsigned char);
const int bsize = width * height * depth * chsize;
- const int is_float = ibuf->rect_float != NULL;
+ const bool is_float = (ibuf->rect_float != NULL);
void *dstbuf = (void *) MEM_dupallocN(ibuf->rect_float ? (void *) ibuf->rect_float : (void *) ibuf->rect);
char *dstmask = mask == NULL ? NULL : (char *) MEM_dupallocN(mask);
void *srcbuf = ibuf->rect_float ? (void *) ibuf->rect_float : (void *) ibuf->rect;
diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c
index e0a6e034f94..cf875bb247b 100644
--- a/source/blender/imbuf/intern/imageprocess.c
+++ b/source/blender/imbuf/intern/imageprocess.c
@@ -42,7 +42,6 @@
#include "BLI_utildefines.h"
#include "BLI_task.h"
-#include "BLI_listbase.h"
#include "BLI_math.h"
#include "IMB_imbuf_types.h"
@@ -221,7 +220,7 @@ void bilinear_interpolation(ImBuf *in, ImBuf *out, float u, float v, int xout, i
/* NEAREST INTERPOLATION */
void nearest_interpolation_color(struct ImBuf *in, unsigned char outI[4], float outF[4], float u, float v)
{
- float *dataF;
+ const float *dataF;
unsigned char *dataI;
int y1, x1;
diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c
index 841e13d3ff1..547a8df4438 100644
--- a/source/blender/imbuf/intern/indexer.c
+++ b/source/blender/imbuf/intern/indexer.c
@@ -35,14 +35,12 @@
#include "BLI_path_util.h"
#include "BLI_string.h"
#include "BLI_fileops.h"
-#include "BLI_math_base.h"
#include "IMB_indexer.h"
#include "IMB_anim.h"
#include "imbuf.h"
#include "MEM_guardedalloc.h"
-#include "DNA_userdef_types.h"
#include "BKE_global.h"
#ifdef WITH_AVI
diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c
index ac1bb246dce..8f98f240053 100644
--- a/source/blender/imbuf/intern/iris.c
+++ b/source/blender/imbuf/intern/iris.c
@@ -72,7 +72,7 @@ typedef struct {
unsigned int offset;
unsigned int rleend; /* for rle images */
unsigned int *rowstart; /* for rle images */
- int *rowsize; /* for rle images */
+ const int *rowsize; /* for rle images */
} IMAGE;
#define RINTLUM (79)
diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c
index f8a8beb72bc..f4b5f987869 100644
--- a/source/blender/imbuf/intern/jpeg.c
+++ b/source/blender/imbuf/intern/jpeg.c
@@ -37,7 +37,6 @@
#include "MEM_guardedalloc.h"
-#include "BLI_utildefines.h"
#include "BLI_string.h"
#include "BLI_fileops.h"
diff --git a/source/blender/imbuf/intern/moviecache.c b/source/blender/imbuf/intern/moviecache.c
index 87043a5581a..ea75673e5f0 100644
--- a/source/blender/imbuf/intern/moviecache.c
+++ b/source/blender/imbuf/intern/moviecache.c
@@ -306,9 +306,9 @@ MovieCache *IMB_moviecache_create(const char *name, int keysize, GHashHashFP has
BLI_strncpy(cache->name, name, sizeof(cache->name));
- cache->keys_pool = BLI_mempool_create(sizeof(MovieCacheKey), 64, 64, BLI_MEMPOOL_NOP);
- cache->items_pool = BLI_mempool_create(sizeof(MovieCacheItem), 64, 64, BLI_MEMPOOL_NOP);
- cache->userkeys_pool = BLI_mempool_create(keysize, 64, 64, 0);
+ cache->keys_pool = BLI_mempool_create(sizeof(MovieCacheKey), 0, 64, BLI_MEMPOOL_NOP);
+ cache->items_pool = BLI_mempool_create(sizeof(MovieCacheItem), 0, 64, BLI_MEMPOOL_NOP);
+ cache->userkeys_pool = BLI_mempool_create(keysize, 0, 64, BLI_MEMPOOL_NOP);
cache->hash = BLI_ghash_new(moviecache_hashhash, moviecache_hashcmp, "MovieClip ImBuf cache hash");
cache->keysize = keysize;
diff --git a/source/blender/imbuf/intern/oiio/openimageio_api.cpp b/source/blender/imbuf/intern/oiio/openimageio_api.cpp
index ec9c8fdbb4d..6e3f97a4902 100644
--- a/source/blender/imbuf/intern/oiio/openimageio_api.cpp
+++ b/source/blender/imbuf/intern/oiio/openimageio_api.cpp
@@ -100,9 +100,9 @@ static ImBuf *imb_oiio_load_image(ImageInput *in, int width, int height, int com
{
if (!in->read_image(TypeDesc::UINT8,
(uchar *)ibuf->rect + (height - 1) * scanlinesize,
- AutoStride,
- -scanlinesize,
- AutoStride))
+ AutoStride,
+ -scanlinesize,
+ AutoStride))
{
std::cerr << __func__ << ": ImageInput::read_image() failed:" << std::endl
<< in->geterror() << std::endl;
@@ -139,9 +139,9 @@ static ImBuf *imb_oiio_load_image_float(ImageInput *in, int width, int height, i
{
if (!in->read_image(TypeDesc::FLOAT,
(uchar *)ibuf->rect_float + (height - 1) * scanlinesize,
- AutoStride,
- -scanlinesize,
- AutoStride))
+ AutoStride,
+ -scanlinesize,
+ AutoStride))
{
std::cerr << __func__ << ": ImageInput::read_image() failed:" << std::endl
<< in->geterror() << std::endl;
@@ -185,7 +185,8 @@ int imb_is_a_photoshop(const char *filename)
int imb_save_photoshop(struct ImBuf *ibuf, const char *name, int flags)
{
if (flags & IB_mem) {
- printf("Photoshop PSD-save: Create PSD in memory CURRENTLY NOT SUPPORTED !\n");
+ std::cerr << __func__ << ": Photoshop PSD-save: Create PSD in memory"
+ << " currently not supported" << std::endl;
imb_addencodedbufferImBuf(ibuf);
ibuf->encodedsize = 0;
return(0);
@@ -202,6 +203,7 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac
bool is_float, is_alpha;
TypeDesc typedesc;
int basesize;
+ char file_colorspace[IM_MAX_SPACE];
/* load image from file through OIIO */
if (imb_is_a_photoshop(filename) == 0) return (NULL);
@@ -226,7 +228,15 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac
}
string ics = spec.get_string_attribute("oiio:ColorSpace");
- BLI_strncpy(colorspace, ics.c_str(), IM_MAX_SPACE);
+ BLI_strncpy(file_colorspace, ics.c_str(), IM_MAX_SPACE);
+
+ /* only use colorspaces exis */
+ if (colormanage_colorspace_get_named(file_colorspace))
+ strcpy(colorspace, file_colorspace);
+ else
+ std::cerr << __func__ << ": The embed colorspace (\"" << file_colorspace
+ << "\") not supported in existent OCIO configuration file. Fallback "
+ << "to system default colorspace (\"" << colorspace << "\")." << std::endl;
width = spec.width;
height = spec.height;
diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c
index d45438e2853..db268546480 100644
--- a/source/blender/imbuf/intern/radiance_hdr.c
+++ b/source/blender/imbuf/intern/radiance_hdr.c
@@ -43,7 +43,6 @@
#include "MEM_guardedalloc.h"
-#include "BLI_utildefines.h"
#include "BLI_fileops.h"
#include "imbuf.h"
diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c
index 6988687e4ed..f0bcfcea62d 100644
--- a/source/blender/imbuf/intern/readimage.c
+++ b/source/blender/imbuf/intern/readimage.c
@@ -37,9 +37,6 @@
# include <stddef.h>
# include <sys/types.h>
# include "mmap_win.h"
-# define open _open
-# define read _read
-# define close _close
#endif
#include <stdlib.h>
@@ -215,7 +212,8 @@ ImBuf *IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_S
imb_cache_filename(filepath_tx, filepath, flags);
file = BLI_open(filepath_tx, O_BINARY | O_RDONLY, 0);
- if (file < 0) return NULL;
+ if (file == -1)
+ return NULL;
ibuf = IMB_loadifffile(file, filepath, flags, colorspace, filepath_tx);
@@ -242,7 +240,8 @@ ImBuf *IMB_testiffname(const char *filepath, int flags)
imb_cache_filename(filepath_tx, filepath, flags);
file = BLI_open(filepath_tx, O_BINARY | O_RDONLY, 0);
- if (file < 0) return NULL;
+ if (file == -1)
+ return NULL;
ibuf = IMB_loadifffile(file, filepath, flags | IB_test | IB_multilayer, colorspace, filepath_tx);
@@ -285,7 +284,8 @@ void imb_loadtile(ImBuf *ibuf, int tx, int ty, unsigned int *rect)
int file;
file = BLI_open(ibuf->cachename, O_BINARY | O_RDONLY, 0);
- if (file < 0) return;
+ if (file == -1)
+ return;
imb_loadtilefile(ibuf, file, tx, ty, rect);
diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c
index d9cec1f3047..c98b39c826b 100644
--- a/source/blender/imbuf/intern/scaling.c
+++ b/source/blender/imbuf/intern/scaling.c
@@ -618,7 +618,7 @@ static void enlarge_picture_float(
y_src = 0;
for (y_dst = 0; y_dst < dst_height; y_dst++) {
float *line1 = src + ((int) y_src) * 4 * src_width;
- float *line2 = line1 + 4 * src_width;
+ const float *line2 = line1 + 4 * src_width;
const float weight1y = (float)(1.0 - (y_src - (int) y_src));
const float weight2y = 1.0f - weight1y;
@@ -674,7 +674,7 @@ struct scale_outpix_float {
};
static void shrink_picture_float(
- float *src, float *dst, int src_width,
+ const float *src, float *dst, int src_width,
int src_height, int dst_width, int dst_height)
{
double ratiox = (double) (dst_width) / (double) (src_width);
@@ -684,7 +684,7 @@ static void shrink_picture_float(
float dx_dst, x_dst;
float dy_dst, y_dst;
float y_counter;
- float *dst_begin = dst;
+ const float *dst_begin = dst;
struct scale_outpix_float *dst_line1;
struct scale_outpix_float *dst_line2;
@@ -702,7 +702,7 @@ static void shrink_picture_float(
y_dst = 0;
y_counter = 1.0;
for (y_src = 0; y_src < src_height; y_src++) {
- float *line = src + y_src * 4 * src_width;
+ const float *line = src + y_src * 4 * src_width;
uintptr_t weight1y = 1.0f - (y_dst - (int) y_dst);
uintptr_t weight2y = 1.0f - weight1y;
x_dst = 0;
diff --git a/source/blender/imbuf/intern/targa.c b/source/blender/imbuf/intern/targa.c
index 07c6bb6f84f..2dcb27a05d4 100644
--- a/source/blender/imbuf/intern/targa.c
+++ b/source/blender/imbuf/intern/targa.c
@@ -117,7 +117,7 @@ static int tga_out4(unsigned int data, FILE *file)
return ~EOF;
}
-static short makebody_tga(ImBuf *ibuf, FILE *file, int (*out)(unsigned int, FILE *))
+static bool makebody_tga(ImBuf *ibuf, FILE *file, int (*out)(unsigned int, FILE *))
{
register int last, this;
register int copy, bytes;
@@ -196,7 +196,7 @@ static short makebody_tga(ImBuf *ibuf, FILE *file, int (*out)(unsigned int, FILE
return 1;
}
-static int dumptarga(struct ImBuf *ibuf, FILE *file)
+static bool dumptarga(struct ImBuf *ibuf, FILE *file)
{
int size;
uchar *rect;
@@ -253,7 +253,7 @@ int imb_savetarga(struct ImBuf *ibuf, const char *name, int flags)
{
char buf[20] = {0};
FILE *fildes;
- short ok = 0;
+ bool ok = false;
(void)flags; /* unused */
diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c
index 843134a4289..b4c97a2aea1 100644
--- a/source/blender/imbuf/intern/thumbs.c
+++ b/source/blender/imbuf/intern/thumbs.c
@@ -29,11 +29,8 @@
* \ingroup imbuf
*/
-
#include <stdio.h>
-#include "MEM_guardedalloc.h"
-
#include "BLI_utildefines.h"
#include "BLI_string.h"
#include "BLI_path_util.h"
@@ -66,9 +63,22 @@
# include "utfconv.h"
#endif
+#if defined(WIN32) || defined(__APPLE__)
+ /* pass */
+#else
+# define USE_FREEDESKTOP
+#endif
+
+/* '$HOME/.cache/thumbnails' or '$HOME/.thumbnails' */
+#ifdef USE_FREEDESKTOP
+# define THUMBNAILS "thumbnails"
+#else
+# define THUMBNAILS ".thumbnails"
+#endif
+
#define URI_MAX (FILE_MAX * 3 + 8)
-static int get_thumb_dir(char *dir, ThumbSize size)
+static bool get_thumb_dir(char *dir, ThumbSize size)
{
char *s = dir;
const char *subdir;
@@ -79,19 +89,30 @@ static int get_thumb_dir(char *dir, ThumbSize size)
conv_utf_16_to_8(dir_16, dir, FILE_MAX);
s += strlen(dir);
#else
+#if defined(USE_FREEDESKTOP)
+ const char *home_cache = getenv("XDG_CACHE_HOME");
+ const char *home = home_cache ? home_cache : getenv("HOME");
+#else
const char *home = getenv("HOME");
+#endif
if (!home) return 0;
s += BLI_strncpy_rlen(s, home, FILE_MAX);
+
+#ifdef USE_FREEDESKTOP
+ if (!home_cache) {
+ s += BLI_strncpy_rlen(s, "/.cache", FILE_MAX - (s - dir));
+ }
+#endif
#endif
switch (size) {
case THB_NORMAL:
- subdir = "/.thumbnails/normal/";
+ subdir = "/" THUMBNAILS "/normal/";
break;
case THB_LARGE:
- subdir = "/.thumbnails/large/";
+ subdir = "/" THUMBNAILS "/large/";
break;
case THB_FAIL:
- subdir = "/.thumbnails/fail/blender/";
+ subdir = "/" THUMBNAILS "/fail/blender/";
break;
default:
return 0; /* unknown size */
@@ -103,6 +124,9 @@ static int get_thumb_dir(char *dir, ThumbSize size)
return 1;
}
+#undef THUMBNAILS
+
+
/** ----- begin of adapted code from glib ---
* The following code is adapted from function g_escape_uri_string from the gnome glib
* Source: http://svn.gnome.org/viewcvs/glib/trunk/glib/gconvert.c?view=markup
@@ -136,7 +160,7 @@ static const char hex[17] = "0123456789abcdef";
/* Note: This escape function works on file: URIs, but if you want to
* escape something else, please read RFC-2396 */
-static void escape_uri_string(const char *string, char *escaped_string, int len, UnsafeCharacterSet mask)
+static void escape_uri_string(const char *string, char *escaped_string, int escaped_string_size, UnsafeCharacterSet mask)
{
#define ACCEPTABLE(a) ((a) >= 32 && (a) < 128 && (acceptable[(a) - 32] & use_mask))
@@ -146,17 +170,27 @@ static void escape_uri_string(const char *string, char *escaped_string, int len,
UnsafeCharacterSet use_mask;
use_mask = mask;
- for (q = escaped_string, p = string; (*p != '\0') && len; p++) {
+ BLI_assert(escaped_string_size > 0);
+
+ /* space for \0 */
+ escaped_string_size -= 1;
+
+ for (q = escaped_string, p = string; (*p != '\0') && escaped_string_size; p++) {
c = (unsigned char) *p;
- len--;
if (!ACCEPTABLE(c)) {
+ if (escaped_string_size < 3) {
+ break;
+ }
+
*q++ = '%'; /* means hex coming */
*q++ = hex[c >> 4];
*q++ = hex[c & 15];
+ escaped_string_size -= 3;
}
else {
*q++ = *p;
+ escaped_string_size -= 1;
}
}
diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c
index a91990774fc..fbb28849ce6 100644
--- a/source/blender/imbuf/intern/util.c
+++ b/source/blender/imbuf/intern/util.c
@@ -34,9 +34,6 @@
#ifdef _WIN32
# include <io.h>
-# define open _open
-# define read _read
-# define close _close
#endif
#include <stdlib.h>
@@ -183,7 +180,7 @@ const char *imb_ext_audio[] = {
NULL
};
-bool IMB_ispic(const char *name)
+int IMB_ispic_type(const char *name)
{
/* increased from 32 to 64 because of the bitmaps header size */
#define HEADER_SIZE 64
@@ -200,7 +197,7 @@ bool IMB_ispic(const char *name)
if (((st.st_mode) & S_IFMT) != S_IFREG)
return false;
- if ((fp = BLI_open(name, O_BINARY | O_RDONLY, 0)) < 0)
+ if ((fp = BLI_open(name, O_BINARY | O_RDONLY, 0)) == -1)
return false;
memset(buf, 0, sizeof(buf));
@@ -228,11 +225,15 @@ bool IMB_ispic(const char *name)
}
}
- return false;
+ return 0;
#undef HEADER_SIZE
}
+bool IMB_ispic(const char *name)
+{
+ return (IMB_ispic_type(name) != 0);
+}
static int isavi(const char *name)
{
diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h
index 76aacb5bebc..dab825c856e 100644
--- a/source/blender/makesdna/DNA_action_types.h
+++ b/source/blender/makesdna/DNA_action_types.h
@@ -655,7 +655,11 @@ typedef enum eAnimEdit_AutoSnap {
/* snap to actual frames/seconds (nla-action time) */
SACTSNAP_FRAME = 2,
/* snap to nearest marker */
- SACTSNAP_MARKER = 3
+ SACTSNAP_MARKER = 3,
+ /* snap to actual seconds (nla-action time) */
+ SACTSNAP_SECOND = 4,
+ /* snap to 1.0 second increments */
+ SACTSNAP_TSTEP = 5
} eAnimEdit_AutoSnap;
diff --git a/source/blender/makesdna/DNA_actuator_types.h b/source/blender/makesdna/DNA_actuator_types.h
index f4e2ff43fc5..99f0c999a29 100644
--- a/source/blender/makesdna/DNA_actuator_types.h
+++ b/source/blender/makesdna/DNA_actuator_types.h
@@ -264,7 +264,7 @@ typedef struct bActuator {
* For ipo's and props: to find out which object the actuator
* belongs to */
struct Object *ob;
-
+
} bActuator;
/* objectactuator->flag */
@@ -322,6 +322,7 @@ typedef struct bActuator {
#define ACT_LINKED 8
#define ACT_VISIBLE 16
#define ACT_PIN 32
+#define ACT_DEACTIVATE 64
/* link codes */
#define LINK_SENSOR 0
diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h
index 8c04c41650d..390233a433d 100644
--- a/source/blender/makesdna/DNA_anim_types.h
+++ b/source/blender/makesdna/DNA_anim_types.h
@@ -791,7 +791,8 @@ typedef enum eInsertKeyFlags {
INSERTKEY_FAST = (1<<2), /* don't recalculate handles,etc. after adding key */
INSERTKEY_FASTR = (1<<3), /* don't realloc mem (or increase count, as array has already been set out) */
INSERTKEY_REPLACE = (1<<4), /* only replace an existing keyframe (this overrides INSERTKEY_NEEDED) */
- INSERTKEY_XYZ2RGB = (1<<5) /* transform F-Curves should have XYZ->RGB color mode */
+ INSERTKEY_XYZ2RGB = (1<<5), /* transform F-Curves should have XYZ->RGB color mode */
+ INSERTKEY_NO_USERPREF = (1 << 6), /* ignore user-prefs (needed for predictable API use) */
} eInsertKeyFlags;
/* ************************************************ */
diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h
index 29e49a970d8..e35e4673684 100644
--- a/source/blender/makesdna/DNA_constraint_types.h
+++ b/source/blender/makesdna/DNA_constraint_types.h
@@ -338,9 +338,18 @@ typedef struct bTransformConstraint {
float from_min[3]; /* from_min/max defines range of target transform */
float from_max[3]; /* to map on to to_min/max range. */
-
float to_min[3]; /* range of motion on owner caused by target */
float to_max[3];
+
+ float from_min_rot[3]; /* from_min/max defines range of target transform */
+ float from_max_rot[3]; /* to map on to to_min/max range. */
+ float to_min_rot[3]; /* range of motion on owner caused by target */
+ float to_max_rot[3];
+
+ float from_min_scale[3]; /* from_min/max defines range of target transform */
+ float from_max_scale[3]; /* to map on to to_min/max range. */
+ float to_min_scale[3]; /* range of motion on owner caused by target */
+ float to_max_scale[3];
} bTransformConstraint;
/* Pivot Constraint */
@@ -557,6 +566,13 @@ typedef enum eCopyScale_Flags {
SIZELIKE_OFFSET = (1<<3)
} eCopyScale_Flags;
+/* bTransformConstraint.to/from */
+typedef enum eTransform_ToFrom {
+ TRANS_LOCATION = 0,
+ TRANS_ROTATION = 1,
+ TRANS_SCALE = 2,
+} eTransform_ToFrom;
+
/* bSameVolumeConstraint.flag */
typedef enum eSameVolume_Modes {
SAMEVOL_X = 0,
diff --git a/source/blender/makesdna/DNA_controller_types.h b/source/blender/makesdna/DNA_controller_types.h
index 0c1aaf5fd20..154542d60c5 100644
--- a/source/blender/makesdna/DNA_controller_types.h
+++ b/source/blender/makesdna/DNA_controller_types.h
@@ -83,6 +83,7 @@ typedef struct bController {
#define CONT_NEW 4
#define CONT_MASK 8
#define CONT_PRIO 16
+#define CONT_DEACTIVATE 32
/* pyctrl->flag */
#define CONT_PY_DEBUG 1
diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h
index 82ec02e01e9..0321c1cad12 100644
--- a/source/blender/makesdna/DNA_curve_types.h
+++ b/source/blender/makesdna/DNA_curve_types.h
@@ -380,9 +380,11 @@ typedef enum eBezTriple_Interpolation {
/* easing modes (used only for Keyframes - BezTriple->easing) */
typedef enum eBezTriple_Easing {
- BEZT_IPO_EASE_IN = 0,
- BEZT_IPO_EASE_OUT = 1,
- BEZT_IPO_EASE_IN_OUT = 2
+ BEZT_IPO_EASE_AUTO = 0,
+
+ BEZT_IPO_EASE_IN = 1,
+ BEZT_IPO_EASE_OUT = 2,
+ BEZT_IPO_EASE_IN_OUT = 3
} eBezTriple_Easing;
/* types of keyframe (used only for BezTriple->hide when BezTriple is used in F-Curves) */
diff --git a/source/blender/makesdna/DNA_customdata_types.h b/source/blender/makesdna/DNA_customdata_types.h
index 325c2a8df54..70dc43676ac 100644
--- a/source/blender/makesdna/DNA_customdata_types.h
+++ b/source/blender/makesdna/DNA_customdata_types.h
@@ -63,13 +63,12 @@ typedef struct CustomDataExternal {
* layers, each with a data type (e.g. MTFace, MDeformVert, etc.). */
typedef struct CustomData {
CustomDataLayer *layers; /* CustomDataLayers, ordered by type */
- int typemap[40]; /* runtime only! - maps types to indices of first layer of that type,
+ int typemap[41]; /* runtime only! - maps types to indices of first layer of that type,
* MUST be >= CD_NUMTYPES, but we cant use a define here.
* Correct size is ensured in CustomData_update_typemap assert() */
- int pad[1];
int totlayer, maxlayer; /* number of layers, size of layers array */
int totsize; /* in editmode, total size of all data layers */
- void *pool; /* Bmesh: Memory pool for allocation of blocks */
+ struct BLI_mempool *pool; /* (BMesh Only): Memory pool for allocation of blocks */
CustomDataExternal *external; /* external file storing customdata layers */
} CustomData;
@@ -119,7 +118,9 @@ enum {
CD_FREESTYLE_EDGE = 37,
CD_FREESTYLE_FACE = 38,
CD_MLOOPTANGENT = 39,
- CD_NUMTYPES = 40,
+ CD_TESSLOOPNORMAL = 40,
+
+ CD_NUMTYPES = 41
};
/* Bits for CustomDataMask */
@@ -164,7 +165,8 @@ enum {
#define CD_MASK_MVERT_SKIN (1LL << CD_MVERT_SKIN)
#define CD_MASK_FREESTYLE_EDGE (1LL << CD_FREESTYLE_EDGE)
#define CD_MASK_FREESTYLE_FACE (1LL << CD_FREESTYLE_FACE)
-#define CD_MASK_MLOOPTANGENT (1LL << CD_MLOOPTANGENT)
+#define CD_MASK_MLOOPTANGENT (1LL << CD_MLOOPTANGENT)
+#define CD_MASK_TESSLOOPNORMAL (1LL << CD_TESSLOOPNORMAL)
/* CustomData.flag */
enum {
@@ -184,6 +186,8 @@ enum {
#define MAX_MTFACE 8
#define MAX_MCOL 8
+#define DYNTOPO_NODE_NONE -1
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/makesdna/DNA_linestyle_types.h b/source/blender/makesdna/DNA_linestyle_types.h
index 19c4e057a96..f7ba53c1f79 100644
--- a/source/blender/makesdna/DNA_linestyle_types.h
+++ b/source/blender/makesdna/DNA_linestyle_types.h
@@ -35,8 +35,16 @@
#include "DNA_listBase.h"
#include "DNA_ID.h"
+#ifndef MAX_MTEX
+#define MAX_MTEX 18
+#endif
+
+/* texco (also in DNA_material_types.h) */
+#define TEXCO_STROKE 16 /* actually it's UV */
+
struct ColorBand;
struct CurveMapping;
+struct MTex;
typedef struct LineStyleModifier {
struct LineStyleModifier *next, *prev;
@@ -354,7 +362,8 @@ typedef struct LineStyleThicknessModifier_Calligraphy {
#define LS_PANEL_ALPHA 3
#define LS_PANEL_THICKNESS 4
#define LS_PANEL_GEOMETRY 5
-#define LS_PANEL_MISC 6
+#define LS_PANEL_TEXTURE 6
+#define LS_PANEL_MISC 7
/* FreestyleLineStyle::flag */
#define LS_DS_EXPAND (1 << 0) /* for animation editors */
@@ -368,6 +377,9 @@ typedef struct LineStyleThicknessModifier_Calligraphy {
#define LS_MAX_2D_ANGLE (1 << 8)
#define LS_SPLIT_LENGTH (1 << 9)
#define LS_SPLIT_PATTERN (1 << 10)
+#define LS_NO_SORTING (1 << 11)
+#define LS_REVERSE_ORDER (1 << 12) /* for sorting */
+#define LS_TEXTURE (1 << 13)
/* FreestyleLineStyle::chaining */
#define LS_CHAINING_PLAIN 1
@@ -384,6 +396,17 @@ typedef struct LineStyleThicknessModifier_Calligraphy {
#define LS_THICKNESS_OUTSIDE 3
#define LS_THICKNESS_RELATIVE 4 /* thickness_ratio is used */
+/* FreestyleLineStyle::sort_key */
+#define LS_SORT_KEY_DISTANCE_FROM_CAMERA 1
+#define LS_SORT_KEY_2D_LENGTH 2
+
+/* FreestyleLineStyle::integration_type */
+#define LS_INTEGRATION_MEAN 1
+#define LS_INTEGRATION_MIN 2
+#define LS_INTEGRATION_MAX 3
+#define LS_INTEGRATION_FIRST 4
+#define LS_INTEGRATION_LAST 5
+
typedef struct FreestyleLineStyle {
ID id;
struct AnimData *adt;
@@ -401,10 +424,17 @@ typedef struct FreestyleLineStyle {
unsigned short split_dash1, split_gap1;
unsigned short split_dash2, split_gap2;
unsigned short split_dash3, split_gap3;
- int pad;
+ int sort_key, integration_type;
+ float texstep;
+ short texact, pr_texture;
+ short use_nodes, pad;
unsigned short dash1, gap1, dash2, gap2, dash3, gap3;
int panel; /* for UI */
+ struct MTex *mtex[18]; /* MAX_MTEX */
+ /* nodes */
+ struct bNodeTree *nodetree;
+
ListBase color_modifiers;
ListBase alpha_modifiers;
ListBase thickness_modifiers;
diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h
index a6478f2ae69..6bcbabc226d 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -117,6 +117,7 @@ typedef struct Material {
short shade_flag; /* like Cubic interpolation */
int mode, mode_l; /* mode_l is the or-ed result of all layer modes */
+ int mode2, mode2_l; /* additional mode flags */
short flarec, starc, linec, ringc;
float hasize, flaresize, subsize, flareboost;
float strand_sta, strand_end, strand_ease, strand_surfnor;
@@ -278,6 +279,13 @@ typedef struct Material {
#define MA_STR_SURFDIFF 0x80000000
#define MA_MODE_MASK 0x6fffffff /* all valid mode bits */
+#define MA_MODE_PIPELINE (MA_TRANSP | MA_ZTRANSP | MA_RAYTRANSP \
+ | MA_TRACEBLE | MA_FULL_OSA | MA_ENV | MA_ZINV \
+ | MA_ONLYCAST | MA_SHADBUF)
+
+/* mode2 (is int) */
+#define MA_CASTSHADOW (1 << 0)
+#define MA_MODE2_PIPELINE (MA_CASTSHADOW)
/* mapflag */
#define MA_MAPFLAG_UVPROJECT (1 << 0)
diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h
index b942197e52c..e535e6012b3 100644
--- a/source/blender/makesdna/DNA_mesh_types.h
+++ b/source/blender/makesdna/DNA_mesh_types.h
@@ -116,8 +116,9 @@ typedef struct Mesh {
float rot[3];
int drawflag;
- short texflag, pad2[3];
- short smoothresh, flag;
+ short texflag, flag;
+ float smoothresh;
+ int pad2;
/* customdata flag, for bevel-weight and crease, which are now optional */
char cd_flag, pad;
@@ -212,6 +213,9 @@ typedef struct TFace {
/* draw stats */
#define ME_DRAW_STATVIS (1 << 17)
+/* draw loop normals */
+#define ME_DRAW_LNORMALS (1 << 18)
+
/* Subsurf Type */
#define ME_CC_SUBSURF 0
#define ME_SIMPLE_SUBSURF 1
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 967ec8d8d06..e13d53934cb 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -112,7 +112,8 @@ typedef struct bNodeSocket {
short stack_index; /* local stack index */
/* XXX deprecated, kept for forward compatibility */
short stack_type DNA_DEPRECATED;
- int resizemode; /* compositor resize mode of the socket */
+ int pad;
+
void *cache; /* cached data from execution */
/* internal data to retrieve relations and groups
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 1f18b054d0e..811c33befca 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -176,8 +176,6 @@ typedef struct Object {
float imat_ren[4][4];
unsigned int lay; /* copy of Base's layer in the scene */
-
- float sf; /* sf is time-offset */
short flag; /* copy of Base */
short colbits DNA_DEPRECATED; /* deprecated, use 'matbits' */
@@ -192,6 +190,8 @@ typedef struct Object {
int dupon, dupoff, dupsta, dupend;
+ int pad;
+
/* during realtime */
/* note that inertia is only called inertia for historical reasons
@@ -208,11 +208,10 @@ typedef struct Object {
*/
float formfactor;
- float rdamping, sizefac;
+ float rdamping;
float margin;
float max_vel; /* clamp the maximum velocity 0.0 is disabled */
float min_vel; /* clamp the minimum velocity 0.0 is disabled */
- float m_contactProcessingThreshold;
float obstacleRad;
/* "Character" physics properties */
@@ -239,7 +238,8 @@ typedef struct Object {
ListBase controllers; /* game logic controllers */
ListBase actuators; /* game logic actuators */
- float bbsize[3] DNA_DEPRECATED;
+ float sf; /* sf is time-offset */
+
short index; /* custom index, for renderpasses */
unsigned short actdef; /* current deformation group, note: index starts at 1 */
float col[4]; /* object color */
@@ -270,8 +270,10 @@ typedef struct Object {
struct FluidsimSettings *fluidsimSettings; /* if fluidsim enabled, store additional settings */
+ /* Runtime valuated curve-specific data, not stored in the file */
+ struct CurveCache *curve_cache;
+
struct DerivedMesh *derivedDeform, *derivedFinal;
- int *pad;
uint64_t lastDataMask; /* the custom data layer mask that was last used to calculate derivedDeform and derivedFinal */
uint64_t customdata_mask; /* (extra) custom data layer mask to use for creating derivedmesh, set by depsgraph */
unsigned int state; /* bit masks of game controllers that are active */
@@ -289,9 +291,6 @@ typedef struct Object {
ListBase lodlevels; /* contains data for levels of detail */
LodLevel *currentlod;
-
- /* Runtime valuated curve-specific data, not stored in the file */
- struct CurveCache *curve_cache;
} Object;
/* Warning, this is not used anymore because hooks are now modifiers */
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 0c950ff9ff0..ceb938c3af2 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -60,6 +60,7 @@ struct Editing;
struct SceneStats;
struct bGPdata;
struct MovieClip;
+struct ColorSpace;
/* ************************************************************* */
/* Scene Data */
@@ -209,37 +210,39 @@ typedef struct SceneRenderLayer {
#define SCE_LAY_NEG_ZMASK 0x80000
/* srl->passflag */
-#define SCE_PASS_COMBINED (1<<0)
-#define SCE_PASS_Z (1<<1)
-#define SCE_PASS_RGBA (1<<2)
-#define SCE_PASS_DIFFUSE (1<<3)
-#define SCE_PASS_SPEC (1<<4)
-#define SCE_PASS_SHADOW (1<<5)
-#define SCE_PASS_AO (1<<6)
-#define SCE_PASS_REFLECT (1<<7)
-#define SCE_PASS_NORMAL (1<<8)
-#define SCE_PASS_VECTOR (1<<9)
-#define SCE_PASS_REFRACT (1<<10)
-#define SCE_PASS_INDEXOB (1<<11)
-#define SCE_PASS_UV (1<<12)
-#define SCE_PASS_INDIRECT (1<<13)
-#define SCE_PASS_MIST (1<<14)
-#define SCE_PASS_RAYHITS (1<<15)
-#define SCE_PASS_EMIT (1<<16)
-#define SCE_PASS_ENVIRONMENT (1<<17)
-#define SCE_PASS_INDEXMA (1<<18)
-#define SCE_PASS_DIFFUSE_DIRECT (1<<19)
-#define SCE_PASS_DIFFUSE_INDIRECT (1<<20)
-#define SCE_PASS_DIFFUSE_COLOR (1<<21)
-#define SCE_PASS_GLOSSY_DIRECT (1<<22)
-#define SCE_PASS_GLOSSY_INDIRECT (1<<23)
-#define SCE_PASS_GLOSSY_COLOR (1<<24)
-#define SCE_PASS_TRANSM_DIRECT (1<<25)
-#define SCE_PASS_TRANSM_INDIRECT (1<<26)
-#define SCE_PASS_TRANSM_COLOR (1<<27)
-#define SCE_PASS_SUBSURFACE_DIRECT (1<<28)
-#define SCE_PASS_SUBSURFACE_INDIRECT (1<<29)
-#define SCE_PASS_SUBSURFACE_COLOR (1<<30)
+typedef enum ScenePassType {
+ SCE_PASS_COMBINED = (1 << 0),
+ SCE_PASS_Z = (1 << 1),
+ SCE_PASS_RGBA = (1 << 2),
+ SCE_PASS_DIFFUSE = (1 << 3),
+ SCE_PASS_SPEC = (1 << 4),
+ SCE_PASS_SHADOW = (1 << 5),
+ SCE_PASS_AO = (1 << 6),
+ SCE_PASS_REFLECT = (1 << 7),
+ SCE_PASS_NORMAL = (1 << 8),
+ SCE_PASS_VECTOR = (1 << 9),
+ SCE_PASS_REFRACT = (1 << 10),
+ SCE_PASS_INDEXOB = (1 << 11),
+ SCE_PASS_UV = (1 << 12),
+ SCE_PASS_INDIRECT = (1 << 13),
+ SCE_PASS_MIST = (1 << 14),
+ SCE_PASS_RAYHITS = (1 << 15),
+ SCE_PASS_EMIT = (1 << 16),
+ SCE_PASS_ENVIRONMENT = (1 << 17),
+ SCE_PASS_INDEXMA = (1 << 18),
+ SCE_PASS_DIFFUSE_DIRECT = (1 << 19),
+ SCE_PASS_DIFFUSE_INDIRECT = (1 << 20),
+ SCE_PASS_DIFFUSE_COLOR = (1 << 21),
+ SCE_PASS_GLOSSY_DIRECT = (1 << 22),
+ SCE_PASS_GLOSSY_INDIRECT = (1 << 23),
+ SCE_PASS_GLOSSY_COLOR = (1 << 24),
+ SCE_PASS_TRANSM_DIRECT = (1 << 25),
+ SCE_PASS_TRANSM_INDIRECT = (1 << 26),
+ SCE_PASS_TRANSM_COLOR = (1 << 27),
+ SCE_PASS_SUBSURFACE_DIRECT = (1 << 28),
+ SCE_PASS_SUBSURFACE_INDIRECT = (1 << 29),
+ SCE_PASS_SUBSURFACE_COLOR = (1 << 30),
+} ScenePassType;
/* note, srl->passflag is treestore element 'nr' in outliner, short still... */
@@ -357,6 +360,42 @@ typedef struct ImageFormatData {
/* ImageFormatData.cineon_flag */
#define R_IMF_CINEON_FLAG_LOG (1<<0) /* was R_CINEON_LOG */
+typedef struct BakeData {
+ struct ImageFormatData im_format;
+
+ char filepath[1024]; /* FILE_MAX */
+
+ short width, height;
+ short margin, flag;
+
+ float cage_extrusion;
+ float pad2;
+
+ char normal_swizzle[3];
+ char normal_space;
+
+ char save_mode;
+ char pad[3];
+
+ char cage[64]; /* MAX_NAME */
+} BakeData;
+
+/* (char) normal_swizzle */
+typedef enum BakeNormalSwizzle {
+ R_BAKE_POSX = 0,
+ R_BAKE_POSY = 1,
+ R_BAKE_POSZ = 2,
+ R_BAKE_NEGX = 3,
+ R_BAKE_NEGY = 4,
+ R_BAKE_NEGZ = 5,
+} BakeNormalSwizzle;
+
+/* (char) save_mode */
+typedef enum BakeSaveMode {
+ R_BAKE_SAVE_INTERNAL = 0,
+ R_BAKE_SAVE_EXTERNAL = 1,
+} BakeSaveMode;
+
/* *************************************************************** */
/* Render Data */
@@ -562,6 +601,9 @@ typedef struct RenderData {
/* render engine */
char engine[32];
+
+ /* Cycles baking */
+ struct BakeData bake;
} RenderData;
/* *************************************************************** */
@@ -932,7 +974,9 @@ typedef struct UnifiedPaintSettings {
float brush_rotation;
- // all this below is used to communicate with the cursor drawing routine
+ /*********************************************************************************
+ * all data below are used to communicate with cursor drawing and tex sampling *
+ *********************************************************************************/
int draw_anchored;
int anchored_size;
float anchored_initial_mouse[2];
@@ -941,7 +985,7 @@ typedef struct UnifiedPaintSettings {
int stroke_active;
/* drawing pressure */
- float pressure_value;
+ float size_pressure_value;
/* position of mouse, used to sample the texture */
float tex_mouse[2];
@@ -949,9 +993,14 @@ typedef struct UnifiedPaintSettings {
/* position of mouse, used to sample the mask texture */
float mask_tex_mouse[2];
+ /* ColorSpace cache to avoid locking up during sampling */
+ int do_linear_conversion;
+ struct ColorSpace *colorspace;
+
/* radius of brush, premultiplied with pressure.
* In case of anchored brushes contains that radius */
float pixel_radius;
+ int pad2;
} UnifiedPaintSettings;
typedef enum {
@@ -1166,12 +1215,8 @@ typedef struct Scene {
short flag; /* various settings */
char use_nodes;
-
- /* Openmp Global Settings */
- char omp_threads_mode;
- short omp_threads;
- char pad[6];
-
+ char pad[1];
+
struct bNodeTree *nodetree;
struct Editing *ed; /* sequence editor data is allocated here */
@@ -1237,6 +1282,8 @@ typedef struct Scene {
/* use preview range */
#define SCER_PRV_RANGE (1<<0)
#define SCER_LOCK_FRAME_SELECTION (1<<1)
+ /* timeline/keyframe jumping - only selected items (on by default) */
+#define SCE_KEYS_NO_SELONLY (1<<2)
/* mode (int now) */
#define R_OSA 0x0001
@@ -1299,7 +1346,7 @@ typedef struct Scene {
/* raytrace structure */
#define R_RAYSTRUCTURE_AUTO 0
#define R_RAYSTRUCTURE_OCTREE 1
-#define R_RAYSTRUCTURE_BLIBVH 2
+#define R_RAYSTRUCTURE_BLIBVH 2 /* removed */
#define R_RAYSTRUCTURE_VBVH 3
#define R_RAYSTRUCTURE_SIMD_SVBVH 4 /* needs SIMD */
#define R_RAYSTRUCTURE_SIMD_QBVH 5 /* needs SIMD */
@@ -1395,6 +1442,8 @@ enum {
#define R_BAKE_LORES_MESH 32
#define R_BAKE_VCOL 64
#define R_BAKE_USERSCALE 128
+#define R_BAKE_SPLIT_MAT 256
+#define R_BAKE_AUTO_NAME 512
/* bake_normal_space */
#define R_BAKE_SPACE_CAMERA 0
@@ -1773,10 +1822,6 @@ typedef enum SculptFlags {
#define USER_UNIT_OPT_SPLIT 1
#define USER_UNIT_ROT_RADIANS 2
-/* OpenMP settings */
-#define SCE_OMP_AUTO 0
-#define SCE_OMP_FIXED 1
-
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/makesdna/DNA_sensor_types.h b/source/blender/makesdna/DNA_sensor_types.h
index 1b946c829fd..fcdbbe31541 100644
--- a/source/blender/makesdna/DNA_sensor_types.h
+++ b/source/blender/makesdna/DNA_sensor_types.h
@@ -257,6 +257,7 @@ typedef struct bJoystickSensor {
#define SENS_NOT 8
#define SENS_VISIBLE 16
#define SENS_PIN 32
+#define SENS_DEACTIVATE 64
/* sensor->pulse */
#define SENS_PULSE_CONT 0
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 54fcb5c857b..c7a6d4809a5 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -209,6 +209,7 @@ typedef enum eSpaceButtons_Texture_Context {
SB_TEXC_LAMP = 2,
SB_TEXC_PARTICLES = 3,
SB_TEXC_OTHER = 4,
+ SB_TEXC_LINESTYLE = 5,
} eSpaceButtons_Texture_Context;
/* sbuts->align */
@@ -981,6 +982,7 @@ typedef enum eSpaceNode_TexFrom {
SNODE_TEX_OBJECT = 0,
SNODE_TEX_WORLD = 1,
SNODE_TEX_BRUSH = 2,
+ SNODE_TEX_LINESTYLE = 3,
} eSpaceNode_TexFrom;
/* snode->shaderfrom */
diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h
index a3025a7fb31..1906f71a230 100644
--- a/source/blender/makesdna/DNA_texture_types.h
+++ b/source/blender/makesdna/DNA_texture_types.h
@@ -479,6 +479,7 @@ typedef struct ColorMapping {
#define MTEX_BUMP_OBJECTSPACE 1024
#define MTEX_BUMP_TEXTURESPACE 2048
/* #define MTEX_BUMP_FLIPPED 4096 */ /* UNUSED */
+#define MTEX_TIPS 4096 /* should use with_freestyle flag? */
#define MTEX_BICUBIC_BUMP 8192
#define MTEX_MAPTO_BOUNDS 16384
diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h
index a5079cb6c6f..c471cb26892 100644
--- a/source/blender/makesdna/DNA_tracking_types.h
+++ b/source/blender/makesdna/DNA_tracking_types.h
@@ -61,14 +61,21 @@ typedef struct MovieReconstructedCamera {
typedef struct MovieTrackingCamera {
void *intrinsics; /* intrinsics handle */
+ short distortion_model;
+ short pad;
+
float sensor_width; /* width of CCD sensor */
float pixel_aspect; /* pixel aspect ratio */
- float pad;
float focal; /* focal length */
short units; /* units of focal length user is working with */
short pad1;
float principal[2]; /* principal point */
- float k1, k2, k3; /* radial distortion */
+
+ /* Polynomial distortion */
+ float k1, k2, k3; /* polynomial radial distortion */
+
+ /* Division distortion model coefficients */
+ float division_k1, division_k2;
} MovieTrackingCamera;
typedef struct MovieTrackingMarker {
@@ -348,6 +355,12 @@ typedef struct MovieTracking {
MovieTrackingDopesheet dopesheet; /* dopesheet data */
} MovieTracking;
+/* MovieTrackingCamera->distortion_model */
+enum {
+ TRACKING_DISTORTION_MODEL_POLYNOMIAL = 0,
+ TRACKING_DISTORTION_MODEL_DIVISION = 1
+};
+
/* MovieTrackingCamera->units */
enum {
CAMERA_UNITS_PX = 0,
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 0d2e7828d13..98c12e9cc11 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -101,8 +101,6 @@ typedef struct RegionView3D {
float clip_local[6][4]; /* clip in object space, means we can test for clipping in editmode without first going into worldspace */
struct BoundBox *clipbb;
- struct bGPdata *gpd; /* Grease-Pencil Data (annotation layers) */
-
struct RegionView3D *localvd; /* allocated backup of its self while in localview */
struct RenderInfo *ri;
struct RenderEngine *render_engine;
@@ -125,7 +123,7 @@ typedef struct RegionView3D {
* also matches -viewinv[3][0:3] in ortho mode.*/
float camzoom; /* viewport zoom on the camera frame, see BKE_screen_view3d_zoom_to_fac */
char is_persp; /* check if persp/ortho view, since 'persp' cant be used for this since
- * it can have cameras assigned as well. (only set in setwinmatrixview3d) */
+ * it can have cameras assigned as well. (only set in view3d_winmatrix_set) */
char persp;
char view;
char viewlock;
@@ -247,6 +245,7 @@ typedef struct View3D {
#define RV3D_CLIPPING 4
#define RV3D_NAVIGATING 8
#define RV3D_GPULIGHT_UPDATE 16
+#define RV3D_IS_GAME_ENGINE 32 /* runtime flag, used to check if LoD's should be used */
/* RegionView3d->viewlock */
#define RV3D_LOCKED (1 << 0)
diff --git a/source/blender/makesdna/intern/SConscript b/source/blender/makesdna/intern/SConscript
index 35b4ff262ed..50c26eb6732 100644
--- a/source/blender/makesdna/intern/SConscript
+++ b/source/blender/makesdna/intern/SConscript
@@ -85,15 +85,9 @@ dna.Depends ('dna.c', makesdna)
dna.Depends ('dna.c', header_files)
if env['OURPLATFORM'] != 'linuxcross':
- if env['OURPLATFORM'] in ('win32-vc', 'win64-vc', 'win32-mingw', 'win64-mingw'):
- dna.Command ('dna.c', '', "\"" + root_build_dir+os.sep+"makesdna\" $TARGET")
- else:
- dna.Command ('dna.c', '', "\"" + root_build_dir+os.sep+"makesdna\" $TARGET")
+ dna.Command ('dna.c', '', "\"" + root_build_dir+os.sep+"makesdna\" $TARGET")
else:
- if USE_WINE:
- dna.Command ('dna.c', '', 'wine ' + root_build_dir+os.sep+"makesdna $TARGET")
- else:
- dna.Command ('dna.c', '', root_build_dir+os.sep+"makesdna.exe $TARGET")
+ dna.Command ('dna.c', '', ('', 'wine ')[USE_WINE] + root_build_dir+os.sep+"makesdna $TARGET")
# TODO, get WITH_DNA_GHASH working, see CMake's 'WITH_DNA_GHASH'
obj = ['intern/dna.c', 'intern/dna_genfile.c']
diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c
index 525c7030029..bc1ee28d582 100644
--- a/source/blender/makesdna/intern/dna_genfile.c
+++ b/source/blender/makesdna/intern/dna_genfile.c
@@ -51,17 +51,9 @@
#include "DNA_genfile.h"
#include "DNA_sdna_types.h" // for SDNA ;-)
-
-/* gcc 4.1 on mingw was complaining that __int64 was already defined
- * actually is saw the line below as typedef long long long long...
- * Anyhow, since its already defined, its safe to do an ifndef here- Campbell */
-#ifdef FREE_WINDOWS
-# ifndef __int64
-typedef long long __int64;
-# endif
-#endif
-
-/*
+/**
+ * \section dna_genfile Overview
+ *
* - please note: no builtin security to detect input of double structs
* - if you want a struct not to be in DNA file: add two hash marks above it (#<enter>#<enter>)
*
@@ -72,6 +64,7 @@ typedef long long __int64;
*
* Create a structDNA: only needed when one of the input include (.h) files change.
* File Syntax:
+ * <pre>
* SDNA (4 bytes) (magic number)
* NAME (4 bytes)
* <nr> (4 bytes) amount of names (int)
@@ -93,12 +86,13 @@ typedef long long __int64;
* STRC (4 bytes)
* <nr> amount of structs (int)
* <typenr><nr_of_elems> <typenr><namenr> <typenr><namenr> ...
+ *</pre>
*
- * !!Remember to read/write integer and short aligned!!
+ * **Remember to read/write integer and short aligned!**
*
* While writing a file, the names of a struct is indicated with a type number,
- * to be found with: type = findstruct_nr(SDNA *, char *)
- * The value of 'type' corresponds with the the index within the structs array
+ * to be found with: ``type = DNA_struct_find_nr(SDNA *, const char *)``
+ * The value of ``type`` corresponds with the the index within the structs array
*
* For the moment: the complete DNA file is included in a .blend file. For
* the future we can think of smarter methods, like only included the used
@@ -114,7 +108,7 @@ typedef long long __int64;
* - change of a pointer type: when the name doesn't change the contents is copied
*
* NOT YET:
- * - array (vec[3]) to float struct (vec3f)
+ * - array (``vec[3]``) to float struct (``vec3f``)
*
* DONE:
* - endian compatibility
@@ -307,7 +301,7 @@ static short *findstruct_name(SDNA *sdna, const char *str)
*/
int DNA_struct_find_nr(SDNA *sdna, const char *str)
{
- short *sp = NULL;
+ const short *sp = NULL;
if (sdna->lastfind < sdna->nr_structs) {
sp = sdna->structs[sdna->lastfind];
@@ -566,7 +560,7 @@ SDNA *DNA_sdna_from_data(const void *data, const int datalen, bool do_endian_swa
static void recurs_test_compflags(const SDNA *sdna, char *compflags, int structnr)
{
int a, b, typenr, elems;
- short *sp;
+ const short *sp;
const char *cp;
/* check all structs, test if it's inside another struct */
@@ -810,11 +804,7 @@ static void cast_elem(
*/
static void cast_pointer(int curlen, int oldlen, const char *name, char *curdata, const char *olddata)
{
-#ifdef WIN32
- __int64 lval;
-#else
- long long lval;
-#endif
+ int64_t lval;
int arrlen;
arrlen = DNA_elem_array_size(name);
@@ -825,22 +815,15 @@ static void cast_pointer(int curlen, int oldlen, const char *name, char *curdata
memcpy(curdata, olddata, curlen);
}
else if (curlen == 4 && oldlen == 8) {
-#ifdef WIN32
- lval = *( (__int64 *)olddata);
-#else
- lval = *( (long long *)olddata);
-#endif
+ lval = *((int64_t *)olddata);
+
/* WARNING: 32-bit Blender trying to load file saved by 64-bit Blender,
* pointers may lose uniqueness on truncation! (Hopefully this wont
* happen unless/until we ever get to multi-gigabyte .blend files...) */
*((int *)curdata) = lval >> 3;
}
else if (curlen == 8 && oldlen == 4) {
-#ifdef WIN32
- *( (__int64 *)curdata) = *((int *)olddata);
-#else
- *( (long long *)curdata) = *((int *)olddata);
-#endif
+ *((int64_t *)curdata) = *((int *)olddata);
}
else {
/* for debug */
@@ -1307,7 +1290,7 @@ int DNA_elem_offset(SDNA *sdna, const char *stype, const char *vartype, const ch
const int SDNAnr = DNA_struct_find_nr(sdna, stype);
const short * const spo = sdna->structs[SDNAnr];
- char * const cp = find_elem(sdna, vartype, name, spo, NULL, NULL);
+ const char * const cp = find_elem(sdna, vartype, name, spo, NULL, NULL);
BLI_assert(SDNAnr != -1);
return (int)((intptr_t)cp);
}
@@ -1319,7 +1302,7 @@ bool DNA_struct_elem_find(SDNA *sdna, const char *stype, const char *vartype, co
if (SDNAnr != -1) {
const short * const spo = sdna->structs[SDNAnr];
- char * const cp = find_elem(sdna, vartype, name, spo, NULL, NULL);
+ const char * const cp = find_elem(sdna, vartype, name, spo, NULL, NULL);
if (cp) return true;
return (int)((intptr_t)cp);
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index 3845e7cde2c..51a0c5a7b0f 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -723,7 +723,7 @@ static int arraysize(const char *str)
static int calculate_structlens(int firststruct)
{
int a, b, len_native, len_32, len_64, unknown = nr_structs, lastunknown, structtype, type, mul, namelen;
- short *sp, *structpoin;
+ const short *sp, *structpoin;
const char *cp;
int has_pointer, dna_error = 0;
@@ -907,7 +907,7 @@ static void dna_write(FILE *file, const void *pntr, const int size)
{
static int linelength = 0;
int i;
- char *data;
+ const char *data;
data = (char *) pntr;
@@ -925,7 +925,7 @@ void printStructLengths(void)
{
int a, unknown = nr_structs, structtype;
/*int lastunknown;*/ /*UNUSED*/
- short *structpoin;
+ const short *structpoin;
printf("\n\n*** All detected structs:\n");
while (unknown) {
@@ -948,7 +948,7 @@ void printStructLengths(void)
static int make_structDNA(const char *baseDirectory, FILE *file)
{
int len, i;
- short *sp;
+ const short *sp;
/* str contains filenames. Since we now include paths, I stretched */
/* it a bit. Hope this is enough :) -nzc- */
char str[SDNA_MAX_FILENAME_LENGTH], *cp;
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index f385d61601a..add59bafc3f 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -331,6 +331,7 @@ extern StructRNA RNA_LineStyleGeometryModifier_SinusDisplacement;
extern StructRNA RNA_LineStyleGeometryModifier_SpatialNoise;
extern StructRNA RNA_LineStyleGeometryModifier_TipRemover;
extern StructRNA RNA_LineStyleModifier;
+extern StructRNA RNA_LineStyleTextureSlot;
extern StructRNA RNA_LineStyleThicknessModifier;
extern StructRNA RNA_LineStyleThicknessModifier_AlongStroke;
extern StructRNA RNA_LineStyleThicknessModifier_Calligraphy;
@@ -692,22 +693,22 @@ extern const PointerRNA PointerRNA_NULL;
StructRNA *RNA_struct_find(const char *identifier);
-const char *RNA_struct_identifier(StructRNA *type);
-const char *RNA_struct_ui_name(StructRNA *type);
-const char *RNA_struct_ui_name_raw(StructRNA *type);
-const char *RNA_struct_ui_description(StructRNA *type);
-const char *RNA_struct_ui_description_raw(StructRNA *type);
-const char *RNA_struct_translation_context(StructRNA *type);
-int RNA_struct_ui_icon(StructRNA *type);
+const char *RNA_struct_identifier(const StructRNA *type);
+const char *RNA_struct_ui_name(const StructRNA *type);
+const char *RNA_struct_ui_name_raw(const StructRNA *type);
+const char *RNA_struct_ui_description(const StructRNA *type);
+const char *RNA_struct_ui_description_raw(const StructRNA *type);
+const char *RNA_struct_translation_context(const StructRNA *type);
+int RNA_struct_ui_icon(const StructRNA *type);
PropertyRNA *RNA_struct_name_property(StructRNA *type);
PropertyRNA *RNA_struct_iterator_property(StructRNA *type);
StructRNA *RNA_struct_base(StructRNA *type);
-bool RNA_struct_is_ID(StructRNA *type);
-bool RNA_struct_is_a(StructRNA *type, StructRNA *srna);
+bool RNA_struct_is_ID(const StructRNA *type);
+bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna);
-bool RNA_struct_undo_check(StructRNA *type);
+bool RNA_struct_undo_check(const StructRNA *type);
StructRegisterFunc RNA_struct_register(StructRNA *type);
StructUnregisterFunc RNA_struct_unregister(StructRNA *type);
@@ -721,7 +722,7 @@ void RNA_struct_blender_type_set(StructRNA *srna, void *blender_type);
struct IDProperty *RNA_struct_idprops(PointerRNA *ptr, bool create);
bool RNA_struct_idprops_check(StructRNA *srna);
-bool RNA_struct_idprops_register_check(StructRNA *type);
+bool RNA_struct_idprops_register_check(const StructRNA *type);
bool RNA_struct_idprops_unset(PointerRNA *ptr, const char *identifier);
PropertyRNA *RNA_struct_find_property(PointerRNA *ptr, const char *identifier);
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h
index 0b73fc932a9..3d4ed0d6f51 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -65,9 +65,14 @@ extern EnumPropertyItem modifier_triangulate_ngon_method_items[];
extern EnumPropertyItem image_type_items[];
extern EnumPropertyItem image_color_mode_items[];
-extern EnumPropertyItem image_depth_mode_items[];
+extern EnumPropertyItem image_color_depth_items[];
extern EnumPropertyItem image_generated_type_items[];
+extern EnumPropertyItem normal_space_items[];
+extern EnumPropertyItem normal_swizzle_items[];
+extern EnumPropertyItem bake_save_mode_items[];
+
+extern EnumPropertyItem exr_codec_items[];
extern EnumPropertyItem color_sets_items[];
extern EnumPropertyItem beztriple_keyframe_type_items[];
@@ -119,6 +124,8 @@ extern EnumPropertyItem object_axis_unsigned_items[];
extern EnumPropertyItem controller_type_items[];
+extern EnumPropertyItem render_pass_type_items[];
+
extern EnumPropertyItem keymap_propvalue_items[];
extern EnumPropertyItem operator_context_items[];
diff --git a/source/blender/makesrna/intern/SConscript b/source/blender/makesrna/intern/SConscript
index 29d84a8d245..ff75d9a1721 100644
--- a/source/blender/makesrna/intern/SConscript
+++ b/source/blender/makesrna/intern/SConscript
@@ -211,10 +211,7 @@ if env['OURPLATFORM'] != 'linuxcross':
else:
rna.Command (generated_files, '', "\"" + root_build_dir+os.sep+"makesrna\" \"" + build_dir + '"' )
else:
- if USE_WINE:
- rna.Command (generated_files, '', 'wine ' + root_build_dir+os.sep+"makesrna.exe " + build_dir)
- else:
- rna.Command (generated_files, '', root_build_dir+os.sep+"makesrna.exe " + build_dir)
+ rna.Command (generated_files, '', ('', 'wine ')[USE_WINE] + root_build_dir+os.sep+"makesrna.exe " + build_dir)
obj = ['intern/rna_access.c']
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 029e25f3e99..7f1f04cdb6a 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -659,7 +659,7 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr
if (dp->dnaarraylength == 1) {
if (prop->type == PROP_BOOLEAN && dp->booleanbit) {
- fprintf(f, " values[i] = %s((data->%s & (%d << i)) != 0);\n",
+ fprintf(f, " values[i] = %s((data->%s & (%du << i)) != 0);\n",
(dp->booleannegative) ? "!" : "", dp->dnaname, dp->booleanbit);
}
else {
@@ -897,14 +897,14 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr
if (prop->flag & PROP_DYNAMIC) {
char *lenfunc = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier),
"set_length");
- fprintf(f, " int i, arraylen[RNA_MAX_ARRAY_DIMENSION];\n");
- fprintf(f, " int len = %s(ptr, arraylen);\n\n", lenfunc);
+ fprintf(f, " unsigned int i, arraylen[RNA_MAX_ARRAY_DIMENSION];\n");
+ fprintf(f, " unsigned int len = %s(ptr, arraylen);\n\n", lenfunc);
rna_clamp_value_range(f, prop);
fprintf(f, " for (i = 0; i < len; i++) {\n");
MEM_freeN(lenfunc);
}
else {
- fprintf(f, " int i;\n\n");
+ fprintf(f, " unsigned int i;\n\n");
rna_clamp_value_range(f, prop);
fprintf(f, " for (i = 0; i < %u; i++) {\n", prop->totarraylength);
}
@@ -913,7 +913,7 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr
if (prop->type == PROP_BOOLEAN && dp->booleanbit) {
fprintf(f, " if (%svalues[i]) data->%s |= (%d<<i);\n",
(dp->booleannegative) ? "!" : "", dp->dnaname, dp->booleanbit);
- fprintf(f, " else data->%s &= ~(%d << i);\n", dp->dnaname, dp->booleanbit);
+ fprintf(f, " else data->%s &= ~(%du << i);\n", dp->dnaname, dp->booleanbit);
}
else {
fprintf(f, " (&data->%s)[i] = %s", dp->dnaname, (dp->booleannegative) ? "!" : "");
@@ -1536,7 +1536,7 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
{
PropertyRNA *prop;
- char *func;
+ const char *func;
prop = dp->prop;
@@ -2156,7 +2156,7 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
PropertyType type;
const char *funcname, *valstr;
const char *ptrstr;
- const short has_data = (dfunc->cont.properties.first != NULL);
+ const bool has_data = (dfunc->cont.properties.first != NULL);
int flag, pout, cptr, first;
srna = dsrna->srna;
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index b0ed7e29c6a..ded0278b44d 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -460,7 +460,7 @@ static PropertyRNA *rna_ensure_property(PropertyRNA *prop)
}
}
-static const char *rna_ensure_property_identifier(PropertyRNA *prop)
+static const char *rna_ensure_property_identifier(const PropertyRNA *prop)
{
if (prop->magic == RNA_MAGIC)
return prop->identifier;
@@ -491,7 +491,7 @@ static const char *rna_ensure_property_description(PropertyRNA *prop)
return description;
}
-static const char *rna_ensure_property_name(PropertyRNA *prop)
+static const char *rna_ensure_property_name(const PropertyRNA *prop)
{
const char *name;
@@ -516,22 +516,22 @@ StructRNA *RNA_struct_find(const char *identifier)
return NULL;
}
-const char *RNA_struct_identifier(StructRNA *type)
+const char *RNA_struct_identifier(const StructRNA *type)
{
return type->identifier;
}
-const char *RNA_struct_ui_name(StructRNA *type)
+const char *RNA_struct_ui_name(const StructRNA *type)
{
return CTX_IFACE_(type->translation_context, type->name);
}
-const char *RNA_struct_ui_name_raw(StructRNA *type)
+const char *RNA_struct_ui_name_raw(const StructRNA *type)
{
return type->name;
}
-int RNA_struct_ui_icon(StructRNA *type)
+int RNA_struct_ui_icon(const StructRNA *type)
{
if (type)
return type->icon;
@@ -539,17 +539,17 @@ int RNA_struct_ui_icon(StructRNA *type)
return ICON_DOT;
}
-const char *RNA_struct_ui_description(StructRNA *type)
+const char *RNA_struct_ui_description(const StructRNA *type)
{
return TIP_(type->description);
}
-const char *RNA_struct_ui_description_raw(StructRNA *type)
+const char *RNA_struct_ui_description_raw(const StructRNA *type)
{
return type->description;
}
-const char *RNA_struct_translation_context(StructRNA *type)
+const char *RNA_struct_translation_context(const StructRNA *type)
{
return type->translation_context;
}
@@ -569,17 +569,17 @@ StructRNA *RNA_struct_base(StructRNA *type)
return type->base;
}
-bool RNA_struct_is_ID(StructRNA *type)
+bool RNA_struct_is_ID(const StructRNA *type)
{
return (type->flag & STRUCT_ID) != 0;
}
-bool RNA_struct_undo_check(StructRNA *type)
+bool RNA_struct_undo_check(const StructRNA *type)
{
return (type->flag & STRUCT_UNDO) != 0;
}
-bool RNA_struct_idprops_register_check(StructRNA *type)
+bool RNA_struct_idprops_register_check(const StructRNA *type)
{
return (type->flag & STRUCT_NO_IDPROPERTIES) == 0;
}
@@ -600,9 +600,9 @@ bool RNA_struct_idprops_unset(PointerRNA *ptr, const char *identifier)
return false;
}
-bool RNA_struct_is_a(StructRNA *type, StructRNA *srna)
+bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
{
- StructRNA *base;
+ const StructRNA *base;
if (srna == &RNA_AnyType)
return true;
@@ -2035,7 +2035,7 @@ void RNA_property_int_get_array(PointerRNA *ptr, PropertyRNA *prop, int *values)
BLI_assert(RNA_property_array_check(prop) != false);
if ((idprop = rna_idproperty_check(&prop, ptr))) {
- BLI_assert(idprop->len == RNA_property_array_length(ptr, prop));
+ BLI_assert(idprop->len == RNA_property_array_length(ptr, prop) || (prop->flag & PROP_IDPROPERTY));
if (prop->arraydimension == 0)
values[0] = RNA_property_int_get(ptr, prop);
else
@@ -2124,7 +2124,7 @@ void RNA_property_int_set_array(PointerRNA *ptr, PropertyRNA *prop, const int *v
BLI_assert(RNA_property_array_check(prop) != false);
if ((idprop = rna_idproperty_check(&prop, ptr))) {
- BLI_assert(idprop->len == RNA_property_array_length(ptr, prop));
+ BLI_assert(idprop->len == RNA_property_array_length(ptr, prop) || (prop->flag & PROP_IDPROPERTY));
if (prop->arraydimension == 0)
IDP_Int(idprop) = values[0];
else
@@ -2297,7 +2297,7 @@ void RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, float *val
BLI_assert(RNA_property_array_check(prop) != false);
if ((idprop = rna_idproperty_check(&prop, ptr))) {
- BLI_assert(idprop->len == RNA_property_array_length(ptr, prop));
+ BLI_assert(idprop->len == RNA_property_array_length(ptr, prop) || (prop->flag & PROP_IDPROPERTY));
if (prop->arraydimension == 0)
values[0] = RNA_property_float_get(ptr, prop);
else if (idprop->subtype == IDP_FLOAT) {
@@ -2392,7 +2392,7 @@ void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const floa
BLI_assert(RNA_property_array_check(prop) != false);
if ((idprop = rna_idproperty_check(&prop, ptr))) {
- BLI_assert(idprop->len == RNA_property_array_length(ptr, prop));
+ BLI_assert(idprop->len == RNA_property_array_length(ptr, prop) || (prop->flag & PROP_IDPROPERTY));
if (prop->arraydimension == 0) {
if (idprop->type == IDP_FLOAT)
IDP_Float(idprop) = values[0];
@@ -6104,7 +6104,7 @@ int RNA_function_call_direct_va(bContext *C, ReportList *reports, PointerRNA *pt
}
case PROP_STRING:
{
- char *arg = va_arg(args, char *);
+ const char *arg = va_arg(args, char *);
err = rna_function_parameter_parse(&funcptr, parm, type, ftype, len, iter.data, &arg,
NULL, tid, fid, pid);
break;
@@ -6176,7 +6176,7 @@ int RNA_function_call_direct_va(bContext *C, ReportList *reports, PointerRNA *pt
}
case PROP_STRING:
{
- char **arg = va_arg(args, char **);
+ const char **arg = va_arg(args, const char **);
err = rna_function_parameter_parse(&funcptr, parm, type, ftype, len, arg, retdata,
NULL, tid, fid, pid);
break;
diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c
index e5545f9cb95..fd04fb46cf1 100644
--- a/source/blender/makesrna/intern/rna_actuator.c
+++ b/source/blender/makesrna/intern/rna_actuator.c
@@ -573,6 +573,11 @@ static void rna_def_actuator(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Expanded", "Set actuator expanded in the user interface");
RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
+ prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ACT_DEACTIVATE);
+ RNA_def_property_ui_text(prop, "Active", "Set the active state of the actuator");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
RNA_api_actuator(srna);
}
@@ -656,7 +661,7 @@ static void rna_def_action_actuator(BlenderRNA *brna)
RNA_def_property_update(prop, NC_LOGIC, NULL);
prop = RNA_def_property(srna, "layer", PROP_INT, PROP_NONE);
- RNA_def_property_range(prop, 0, 7); /* This should match BL_ActionManager::MAX_ACTION_LAYERS - 1 */
+ RNA_def_property_range(prop, 0, 32766); /* This should match BL_ActionManager::MAX_ACTION_LAYERS - 1 */
RNA_def_property_ui_text(prop, "Layer", "The animation layer to play the action on");
RNA_def_property_update(prop, NC_LOGIC, NULL);
diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c
index 612ce14f039..1bccceab5ab 100644
--- a/source/blender/makesrna/intern/rna_armature.c
+++ b/source/blender/makesrna/intern/rna_armature.c
@@ -401,6 +401,12 @@ static void rna_EditBone_matrix_get(PointerRNA *ptr, float *values)
ED_armature_ebone_to_mat4(ebone, (float(*)[4])values);
}
+static void rna_EditBone_matrix_set(PointerRNA *ptr, const float *values)
+{
+ EditBone *ebone = (EditBone *)(ptr->data);
+ ED_armature_ebone_from_mat4(ebone, (float(*)[4])values);
+}
+
static void rna_Armature_editbone_transform_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
bArmature *arm = (bArmature *)ptr->id.data;
@@ -795,11 +801,12 @@ static void rna_def_edit_bone(BlenderRNA *brna)
prop = RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX);
/*RNA_def_property_float_sdna(prop, NULL, ""); *//* doesnt access any real data */
RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ //RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_flag(prop, PROP_THICK_WRAP); /* no reference to original data */
- RNA_def_property_ui_text(prop, "Editbone Matrix", "Read-only matrix calculated from the roll (armature space)");
- /* TODO - this could be made writable also */
- RNA_def_property_float_funcs(prop, "rna_EditBone_matrix_get", NULL, NULL);
+ RNA_def_property_ui_text(prop, "Editbone Matrix",
+ "Matrix combining loc/rot of the bone (head position, direction and roll), "
+ "in armature space (WARNING: does not include/support bone's length/size)");
+ RNA_def_property_float_funcs(prop, "rna_EditBone_matrix_get", "rna_EditBone_matrix_set", NULL);
RNA_api_armature_edit_bone(srna);
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 8b2c55afb93..9c81d5893bf 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -49,13 +49,16 @@ static EnumPropertyItem prop_direction_items[] = {
{0, NULL, 0, NULL, NULL}
};
-static EnumPropertyItem brush_stroke_method_items[] = {
+static EnumPropertyItem sculpt_stroke_method_items[] = {
{0, "DOTS", 0, "Dots", "Apply paint on each mouse move step"},
+ {BRUSH_DRAG_DOT, "DRAG_DOT", 0, "Drag Dot", "Allows a single dot to be carefully positioned"},
{BRUSH_SPACE, "SPACE", 0, "Space", "Limit brush application to the distance specified by spacing"},
{BRUSH_AIRBRUSH, "AIRBRUSH", 0, "Airbrush", "Keep applying paint effect while holding mouse (spray)"},
+ {BRUSH_ANCHORED, "ANCHORED", 0, "Anchored", "Keep the brush anchored to the initial location"},
{0, NULL, 0, NULL, NULL}
};
+
EnumPropertyItem brush_sculpt_tool_items[] = {
{SCULPT_TOOL_BLOB, "BLOB", ICON_BRUSH_BLOB, "Blob", ""},
{SCULPT_TOOL_CLAY, "CLAY", ICON_BRUSH_CLAY, "Clay", ""},
@@ -475,17 +478,15 @@ static EnumPropertyItem *rna_Brush_direction_itemf(bContext *UNUSED(C), PointerR
static EnumPropertyItem *rna_Brush_stroke_itemf(bContext *C, PointerRNA *UNUSED(ptr),
PropertyRNA *UNUSED(prop), bool *UNUSED(r_free))
{
- static EnumPropertyItem sculpt_stroke_method_items[] = {
+ PaintMode mode = BKE_paintmode_get_active_from_context(C);
+
+ static EnumPropertyItem brush_stroke_method_items[] = {
{0, "DOTS", 0, "Dots", "Apply paint on each mouse move step"},
- {BRUSH_DRAG_DOT, "DRAG_DOT", 0, "Drag Dot", "Allows a single dot to be carefully positioned"},
{BRUSH_SPACE, "SPACE", 0, "Space", "Limit brush application to the distance specified by spacing"},
- {BRUSH_ANCHORED, "ANCHORED", 0, "Anchored", "Keep the brush anchored to the initial location"},
{BRUSH_AIRBRUSH, "AIRBRUSH", 0, "Airbrush", "Keep applying paint effect while holding mouse (spray)"},
{0, NULL, 0, NULL, NULL}
};
- PaintMode mode = BKE_paintmode_get_active_from_context(C);
-
switch (mode) {
case PAINT_SCULPT:
return sculpt_stroke_method_items;
@@ -706,7 +707,7 @@ static void rna_def_brush(BlenderRNA *brna)
prop = RNA_def_property(srna, "stroke_method", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
- RNA_def_property_enum_items(prop, brush_stroke_method_items);
+ RNA_def_property_enum_items(prop, sculpt_stroke_method_items);
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Brush_stroke_itemf");
RNA_def_property_ui_text(prop, "Stroke Method", "");
RNA_def_property_update(prop, 0, "rna_Brush_update");
diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c
index c0ad4fecc39..5fbaae71482 100644
--- a/source/blender/makesrna/intern/rna_constraint.c
+++ b/source/blender/makesrna/intern/rna_constraint.c
@@ -237,7 +237,7 @@ static void rna_Constraint_name_set(PointerRNA *ptr, const char *value)
/* if we have the list, check for unique name, otherwise give up */
if (list)
- BKE_unique_constraint_name(con, list);
+ BKE_constraint_unique_name(con, list);
}
/* fix all the animation data which may link to this */
@@ -323,7 +323,7 @@ static EnumPropertyItem *rna_Constraint_target_space_itemf(bContext *UNUSED(C),
PropertyRNA *UNUSED(prop), bool *UNUSED(r_free))
{
bConstraint *con = (bConstraint *)ptr->data;
- bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
@@ -1581,9 +1581,9 @@ static void rna_def_constraint_transform(BlenderRNA *brna)
PropertyRNA *prop;
static EnumPropertyItem transform_items[] = {
- {0, "LOCATION", 0, "Loc", ""},
- {1, "ROTATION", 0, "Rot", ""},
- {2, "SCALE", 0, "Scale", ""},
+ {TRANS_LOCATION, "LOCATION", 0, "Loc", ""},
+ {TRANS_ROTATION, "ROTATION", 0, "Rot", ""},
+ {TRANS_SCALE, "SCALE", 0, "Scale", ""},
{0, NULL, 0, NULL, NULL}
};
@@ -1644,6 +1644,7 @@ static void rna_def_constraint_transform(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Extrapolate Motion", "Extrapolate ranges");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+ /* Loc */
prop = RNA_def_property(srna, "from_min_x", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "from_min[0]");
RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
@@ -1715,6 +1716,152 @@ static void rna_def_constraint_transform(BlenderRNA *brna)
RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
RNA_def_property_ui_text(prop, "To Maximum Z", "Top range of Z axis destination motion");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
+ /* Rot */
+ prop = RNA_def_property(srna, "from_min_x_rot", PROP_FLOAT, PROP_ANGLE);
+ RNA_def_property_float_sdna(prop, NULL, "from_min_rot[0]");
+ RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
+ RNA_def_property_ui_text(prop, "From Minimum X", "Bottom range of X axis source motion");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
+ prop = RNA_def_property(srna, "from_min_y_rot", PROP_FLOAT, PROP_ANGLE);
+ RNA_def_property_float_sdna(prop, NULL, "from_min_rot[1]");
+ RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
+ RNA_def_property_ui_text(prop, "From Minimum Y", "Bottom range of Y axis source motion");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
+ prop = RNA_def_property(srna, "from_min_z_rot", PROP_FLOAT, PROP_ANGLE);
+ RNA_def_property_float_sdna(prop, NULL, "from_min_rot[2]");
+ RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
+ RNA_def_property_ui_text(prop, "From Minimum Z", "Bottom range of Z axis source motion");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
+ prop = RNA_def_property(srna, "from_max_x_rot", PROP_FLOAT, PROP_ANGLE);
+ RNA_def_property_float_sdna(prop, NULL, "from_max_rot[0]");
+ RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
+ RNA_def_property_ui_text(prop, "From Maximum X", "Top range of X axis source motion");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
+ prop = RNA_def_property(srna, "from_max_y_rot", PROP_FLOAT, PROP_ANGLE);
+ RNA_def_property_float_sdna(prop, NULL, "from_max_rot[1]");
+ RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
+ RNA_def_property_ui_text(prop, "From Maximum Y", "Top range of Y axis source motion");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
+ prop = RNA_def_property(srna, "from_max_z_rot", PROP_FLOAT, PROP_ANGLE);
+ RNA_def_property_float_sdna(prop, NULL, "from_max_rot[2]");
+ RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
+ RNA_def_property_ui_text(prop, "From Maximum Z", "Top range of Z axis source motion");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
+ prop = RNA_def_property(srna, "to_min_x_rot", PROP_FLOAT, PROP_ANGLE);
+ RNA_def_property_float_sdna(prop, NULL, "to_min_rot[0]");
+ RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
+ RNA_def_property_ui_text(prop, "To Minimum X", "Bottom range of X axis destination motion");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
+ prop = RNA_def_property(srna, "to_min_y_rot", PROP_FLOAT, PROP_ANGLE);
+ RNA_def_property_float_sdna(prop, NULL, "to_min_rot[1]");
+ RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
+ RNA_def_property_ui_text(prop, "To Minimum Y", "Bottom range of Y axis destination motion");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
+ prop = RNA_def_property(srna, "to_min_z_rot", PROP_FLOAT, PROP_ANGLE);
+ RNA_def_property_float_sdna(prop, NULL, "to_min_rot[2]");
+ RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
+ RNA_def_property_ui_text(prop, "To Minimum Z", "Bottom range of Z axis destination motion");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
+ prop = RNA_def_property(srna, "to_max_x_rot", PROP_FLOAT, PROP_ANGLE);
+ RNA_def_property_float_sdna(prop, NULL, "to_max_rot[0]");
+ RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
+ RNA_def_property_ui_text(prop, "To Maximum X", "Top range of X axis destination motion");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
+ prop = RNA_def_property(srna, "to_max_y_rot", PROP_FLOAT, PROP_ANGLE);
+ RNA_def_property_float_sdna(prop, NULL, "to_max_rot[1]");
+ RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
+ RNA_def_property_ui_text(prop, "To Maximum Y", "Top range of Y axis destination motion");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
+ prop = RNA_def_property(srna, "to_max_z_rot", PROP_FLOAT, PROP_ANGLE);
+ RNA_def_property_float_sdna(prop, NULL, "to_max_rot[2]");
+ RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
+ RNA_def_property_ui_text(prop, "To Maximum Z", "Top range of Z axis destination motion");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
+ /* Scale */
+ prop = RNA_def_property(srna, "from_min_x_scale", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "from_min_scale[0]");
+ RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
+ RNA_def_property_ui_text(prop, "From Minimum X", "Bottom range of X axis source motion");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
+ prop = RNA_def_property(srna, "from_min_y_scale", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "from_min_scale[1]");
+ RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
+ RNA_def_property_ui_text(prop, "From Minimum Y", "Bottom range of Y axis source motion");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
+ prop = RNA_def_property(srna, "from_min_z_scale", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "from_min_scale[2]");
+ RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
+ RNA_def_property_ui_text(prop, "From Minimum Z", "Bottom range of Z axis source motion");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
+ prop = RNA_def_property(srna, "from_max_x_scale", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "from_max_scale[0]");
+ RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
+ RNA_def_property_ui_text(prop, "From Maximum X", "Top range of X axis source motion");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
+ prop = RNA_def_property(srna, "from_max_y_scale", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "from_max_scale[1]");
+ RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
+ RNA_def_property_ui_text(prop, "From Maximum Y", "Top range of Y axis source motion");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
+ prop = RNA_def_property(srna, "from_max_z_scale", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "from_max_scale[2]");
+ RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
+ RNA_def_property_ui_text(prop, "From Maximum Z", "Top range of Z axis source motion");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
+ prop = RNA_def_property(srna, "to_min_x_scale", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "to_min_scale[0]");
+ RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
+ RNA_def_property_ui_text(prop, "To Minimum X", "Bottom range of X axis destination motion");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
+ prop = RNA_def_property(srna, "to_min_y_scale", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "to_min_scale[1]");
+ RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
+ RNA_def_property_ui_text(prop, "To Minimum Y", "Bottom range of Y axis destination motion");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
+ prop = RNA_def_property(srna, "to_min_z_scale", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "to_min_scale[2]");
+ RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
+ RNA_def_property_ui_text(prop, "To Minimum Z", "Bottom range of Z axis destination motion");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
+ prop = RNA_def_property(srna, "to_max_x_scale", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "to_max_scale[0]");
+ RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
+ RNA_def_property_ui_text(prop, "To Maximum X", "Top range of X axis destination motion");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
+ prop = RNA_def_property(srna, "to_max_y_scale", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "to_max_scale[1]");
+ RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
+ RNA_def_property_ui_text(prop, "To Maximum Y", "Top range of Y axis destination motion");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
+ prop = RNA_def_property(srna, "to_max_z_scale", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "to_max_scale[2]");
+ RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
+ RNA_def_property_ui_text(prop, "To Maximum Z", "Top range of Z axis destination motion");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
}
static void rna_def_constraint_location_limit(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_controller.c b/source/blender/makesrna/intern/rna_controller.c
index 3b789b16f52..8b5074eaf0d 100644
--- a/source/blender/makesrna/intern/rna_controller.c
+++ b/source/blender/makesrna/intern/rna_controller.c
@@ -228,6 +228,11 @@ void RNA_def_controller(BlenderRNA *brna)
RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
RNA_def_property_update(prop, NC_LOGIC, NULL);
+ prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CONT_DEACTIVATE);
+ RNA_def_property_ui_text(prop, "Active", "Set the active state of the controller");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
prop = RNA_def_property(srna, "use_priority", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CONT_PRIO);
RNA_def_property_ui_text(prop, "Priority",
diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c
index f720a695ef1..142b4ed6574 100644
--- a/source/blender/makesrna/intern/rna_curve.c
+++ b/source/blender/makesrna/intern/rna_curve.c
@@ -71,26 +71,24 @@ EnumPropertyItem keyframe_handle_type_items[] = {
EnumPropertyItem beztriple_interpolation_mode_items[] = {
/* interpolation */
{0, "", 0, N_("Interpolation"), "Standard transitions between keyframes"},
- {BEZT_IPO_CONST, "CONSTANT", 0, "Constant", "No interpolation, value of A gets held until B is encountered"},
- {BEZT_IPO_LIN, "LINEAR", 0, "Linear", "Straight-line interpolation between A and B (i.e. no ease in/out)"},
- {BEZT_IPO_BEZ, "BEZIER", 0, "Bezier", "Smooth interpolation between A and B, with some control over curve shape"},
+ {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_QUAD, "QUAD", 0, "Quadratic", "Quadratic easing (weakest)"},
- {BEZT_IPO_CUBIC, "CUBIC", 0, "Cubic", "Cubic easing"},
- {BEZT_IPO_QUART, "QUART", 0, "Quartic", "Quartic easing"},
- {BEZT_IPO_QUINT, "QUINT", 0, "Quintic", "Quintic easing"},
- {BEZT_IPO_EXPO, "EXPO", 0, "Exponential", "Exponential easing (strongest)"},
+ {BEZT_IPO_SINE, "SINE", ICON_IPO_SINE, "Sinusoidal", "Sinusoidal easing (weakest, almost linear but with a slight curvature)"},
+ {BEZT_IPO_QUAD, "QUAD", ICON_IPO_QUAD, "Quadratic", "Quadratic easing"},
+ {BEZT_IPO_CUBIC, "CUBIC", ICON_IPO_CUBIC, "Cubic", "Cubic easing"},
+ {BEZT_IPO_QUART, "QUART", ICON_IPO_QUART, "Quartic", "Quartic easing"},
+ {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", 0, "Back", "Cubic easing with overshoot and settle"},
- {BEZT_IPO_BOUNCE, "BOUNCE", 0, "Bounce", "Exponentially decaying parabolic bounce, like when objects collide"},
- {BEZT_IPO_ELASTIC, "ELASTIC", 0, "Elastic", "Exponentially decaying sine wave, like an elastic band"},
-
- {0, "", 0, N_("Other"), "Other easing equations"},
- {BEZT_IPO_SINE, "SINE", 0, "Sinusoidal", "Sinusoidal easing"},
- {BEZT_IPO_CIRC, "CIRC", 0, "Circular", "Circular easing"},
+ {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}
};
@@ -1418,14 +1416,14 @@ static void rna_def_curve(BlenderRNA *brna)
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 skips this property)");
+ "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 skips this property)");
+ "Surface resolution in V direction used while rendering (zero uses preview resolution)");
prop = RNA_def_property(srna, "eval_time", PROP_FLOAT, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index 5b760446f11..6668ce812cf 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -324,7 +324,7 @@ static int rna_member_cmp(const char *name, const char *oname)
static int rna_find_sdna_member(SDNA *sdna, const char *structname, const char *membername, DNAStructMember *smember)
{
const char *dnaname;
- short *sp;
+ const short *sp;
int a, b, structnr, totmember, cmp;
structnr = DNA_struct_find_nr(sdna, structname);
diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c
index 55e60047194..266bc1bf0a5 100644
--- a/source/blender/makesrna/intern/rna_fcurve.c
+++ b/source/blender/makesrna/intern/rna_fcurve.c
@@ -78,9 +78,14 @@ EnumPropertyItem beztriple_keyframe_type_items[] = {
};
EnumPropertyItem beztriple_interpolation_easing_items[] = {
- {BEZT_IPO_EASE_IN, "EASE_IN", 0, "Ease In", "Only on the end closest to the next keyframe"},
- {BEZT_IPO_EASE_OUT, "EASE_OUT", 0, "Ease Out", "Only on the end closest to the first keyframe"},
- {BEZT_IPO_EASE_IN_OUT, "EASE_IN_OUT", 0, "Ease In and Out", "Segment between both keyframes"},
+ /* XXX: auto-easing is currently using a placeholder icon... */
+ {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"},
{0, NULL, 0, NULL, NULL}
};
@@ -139,7 +144,11 @@ static void rna_ChannelDriver_update_data(Main *bmain, Scene *scene, PointerRNA
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);
}
@@ -733,7 +742,7 @@ static void rna_FModifierStepped_end_frame_range(PointerRNA *ptr, float *min, fl
static BezTriple *rna_FKeyframe_points_insert(FCurve *fcu, float frame, float value, int flag)
{
- int index = insert_vert_fcurve(fcu, frame, value, flag);
+ int index = insert_vert_fcurve(fcu, frame, value, flag | INSERTKEY_NO_USERPREF);
return ((fcu->bezt) && (index >= 0)) ? (fcu->bezt + index) : NULL;
}
@@ -741,15 +750,8 @@ static void rna_FKeyframe_points_add(FCurve *fcu, int tot)
{
if (tot > 0) {
BezTriple *bezt;
- if (fcu->totvert) {
- BezTriple *nbezt = MEM_callocN(sizeof(BezTriple) * (fcu->totvert + tot), "rna_FKeyframe_points_add");
- memcpy(nbezt, fcu->bezt, sizeof(BezTriple) * fcu->totvert);
- MEM_freeN(fcu->bezt);
- fcu->bezt = nbezt;
- }
- else {
- fcu->bezt = MEM_callocN(sizeof(BezTriple) * tot, "rna_FKeyframe_points_add");
- }
+
+ fcu->bezt = MEM_recallocN(fcu->bezt, sizeof(BezTriple) * (fcu->totvert + tot));
bezt = fcu->bezt + fcu->totvert;
fcu->totvert += tot;
diff --git a/source/blender/makesrna/intern/rna_linestyle.c b/source/blender/makesrna/intern/rna_linestyle.c
index 0619bb0352a..2b20dc2485d 100644
--- a/source/blender/makesrna/intern/rna_linestyle.c
+++ b/source/blender/makesrna/intern/rna_linestyle.c
@@ -84,6 +84,8 @@ EnumPropertyItem linestyle_geometry_modifier_type_items[] = {
#ifdef RNA_RUNTIME
#include "BKE_linestyle.h"
+#include "BKE_texture.h"
+#include "BKE_depsgraph.h"
static StructRNA *rna_LineStyle_color_modifier_refine(struct PointerRNA *ptr)
{
@@ -249,10 +251,148 @@ static void rna_LineStyleGeometryModifier_name_set(PointerRNA *ptr, const char *
offsetof(LineStyleModifier, name), sizeof(m->name));
}
+static void rna_LineStyle_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+{
+ FreestyleLineStyle *linestyle = (FreestyleLineStyle *)ptr->id.data;
+ rna_iterator_array_begin(iter, (void *)linestyle->mtex, sizeof(MTex *), MAX_MTEX, 0, NULL);
+}
+
+static PointerRNA rna_LineStyle_active_texture_get(PointerRNA *ptr)
+{
+ FreestyleLineStyle *linestyle = (FreestyleLineStyle *)ptr->id.data;
+ Tex *tex;
+
+ tex = give_current_linestyle_texture(linestyle);
+ return rna_pointer_inherit_refine(ptr, &RNA_Texture, tex);
+}
+
+static void rna_LineStyle_active_texture_set(PointerRNA *ptr, PointerRNA value)
+{
+ FreestyleLineStyle *linestyle = (FreestyleLineStyle *)ptr->id.data;
+
+ set_current_linestyle_texture(linestyle, value.data);
+}
+
+static void rna_LineStyle_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
+{
+ FreestyleLineStyle *linestyle = ptr->id.data;
+
+ DAG_id_tag_update(&linestyle->id, 0);
+ WM_main_add_notifier(NC_LINESTYLE, linestyle);
+}
+
#else
#include "BLI_math.h"
+static void rna_def_linestyle_mtex(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ static EnumPropertyItem texco_items[] = {
+ {TEXCO_WINDOW, "WINDOW", 0, "Window", "Use screen coordinates as texture coordinates"},
+ {TEXCO_GLOB, "GLOBAL", 0, "Global", "Use global coordinates for the texture coordinates"},
+ {TEXCO_STROKE, "ALONG_STROKE", 0, "Along stroke", "Use stroke lenght for texture coordinates"},
+ {TEXCO_ORCO, "ORCO", 0, "Generated", "Use the original undeformed coordinates of the object"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ static EnumPropertyItem prop_mapping_items[] = {
+ {MTEX_FLAT, "FLAT", 0, "Flat", "Map X and Y coordinates directly"},
+ {MTEX_CUBE, "CUBE", 0, "Cube", "Map using the normal vector"},
+ {MTEX_TUBE, "TUBE", 0, "Tube", "Map with Z as central axis"},
+ {MTEX_SPHERE, "SPHERE", 0, "Sphere", "Map with Z as central axis"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ static EnumPropertyItem prop_x_mapping_items[] = {
+ {0, "NONE", 0, "None", ""},
+ {1, "X", 0, "X", ""},
+ {2, "Y", 0, "Y", ""},
+ {3, "Z", 0, "Z", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ static EnumPropertyItem prop_y_mapping_items[] = {
+ {0, "NONE", 0, "None", ""},
+ {1, "X", 0, "X", ""},
+ {2, "Y", 0, "Y", ""},
+ {3, "Z", 0, "Z", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ static EnumPropertyItem prop_z_mapping_items[] = {
+ {0, "NONE", 0, "None", ""},
+ {1, "X", 0, "X", ""},
+ {2, "Y", 0, "Y", ""},
+ {3, "Z", 0, "Z", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ srna = RNA_def_struct(brna, "LineStyleTextureSlot", "TextureSlot");
+ RNA_def_struct_sdna(srna, "MTex");
+ RNA_def_struct_ui_text(srna, "LineStyle Texture Slot", "Texture slot for textures in a LineStyle datablock");
+
+ prop = RNA_def_property(srna, "mapping_x", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "projx");
+ 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_LineStyle_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_y_mapping_items);
+ RNA_def_property_ui_text(prop, "Y Mapping", "");
+ RNA_def_property_update(prop, 0, "rna_LineStyle_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_z_mapping_items);
+ RNA_def_property_ui_text(prop, "Z Mapping", "");
+ RNA_def_property_update(prop, 0, "rna_LineStyle_update");
+
+ 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", "");
+ RNA_def_property_update(prop, 0, "rna_LineStyle_update");
+
+ /* map to */
+ prop = RNA_def_property(srna, "use_map_color_diffuse", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_COL);
+ RNA_def_property_ui_text(prop, "Diffuse Color", "The texture affects basic color of the stroke");
+ RNA_def_property_update(prop, 0, "rna_LineStyle_update");
+
+ prop = RNA_def_property(srna, "use_map_alpha", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_ALPHA);
+ RNA_def_property_ui_text(prop, "Alpha", "The texture affects the alpha value");
+ RNA_def_property_update(prop, 0, "rna_LineStyle_update");
+
+ prop = RNA_def_property(srna, "use_tips", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "texflag", MTEX_TIPS);
+ RNA_def_property_ui_text(prop, "Use tips", "Lower half of the texture is for tips of the stroke");
+ RNA_def_property_update(prop, 0, "rna_LineStyle_update");
+
+ prop = RNA_def_property(srna, "texture_coords", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "texco");
+ RNA_def_property_enum_items(prop, texco_items);
+ RNA_def_property_ui_text(prop, "Texture Coordinates",
+ "Texture coordinates used to map the texture onto the background");
+ RNA_def_property_update(prop, 0, "rna_LineStyle_update");
+
+ prop = RNA_def_property(srna, "alpha_factor", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "alphafac");
+ RNA_def_property_ui_range(prop, -1, 1, 10, 3);
+ RNA_def_property_ui_text(prop, "Alpha Factor", "Amount texture affects alpha");
+ RNA_def_property_update(prop, 0, "rna_LineStyle_update");
+
+ prop = RNA_def_property(srna, "diffuse_color_factor", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "colfac");
+ RNA_def_property_ui_range(prop, 0, 1, 10, 3);
+ RNA_def_property_ui_text(prop, "Diffuse Color Factor", "Amount texture affects diffuse color");
+ RNA_def_property_update(prop, 0, "rna_LineStyle_update");
+}
+
static void rna_def_modifier_type_common(StructRNA *srna, EnumPropertyItem *modifier_type_items,
const char *set_name_func, const bool blend, const bool color)
{
@@ -892,6 +1032,7 @@ static void rna_def_linestyle(BlenderRNA *brna)
{LS_PANEL_ALPHA, "ALPHA", 0, "Alpha", "Show the panel for alpha transparency options"},
{LS_PANEL_THICKNESS, "THICKNESS", 0, "Thickness", "Show the panel for line thickness options"},
{LS_PANEL_GEOMETRY, "GEOMETRY", 0, "Geometry", "Show the panel for stroke geometry options"},
+ {LS_PANEL_TEXTURE, "TEXTURE", 0, "Texture", "Show the panel for stroke texture options"},
#if 0 /* hidden for now */
{LS_PANEL_MISC, "MISC", 0, "Misc", "Show the panel for miscellaneous options"},
#endif
@@ -909,10 +1050,28 @@ static void rna_def_linestyle(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}
};
static EnumPropertyItem thickness_position_items[] = {
- {LS_THICKNESS_CENTER, "CENTER", 0, "Center", "Stroke is centered along stroke geometry"},
- {LS_THICKNESS_INSIDE, "INSIDE", 0, "Inside", "Stroke is drawn inside stroke geometry"},
- {LS_THICKNESS_OUTSIDE, "OUTSIDE", 0, "Outside", "Stroke is drawn outside stroke geometry"},
- {LS_THICKNESS_RELATIVE, "RELATIVE", 0, "Relative", "Stroke thickness is split by a user-defined ratio"},
+ {LS_THICKNESS_CENTER, "CENTER", 0, "Center", "Silhouettes and border edges are centered along stroke geometry"},
+ {LS_THICKNESS_INSIDE, "INSIDE", 0, "Inside", "Silhouettes and border edges are drawn inside of stroke geometry"},
+ {LS_THICKNESS_OUTSIDE, "OUTSIDE", 0, "Outside", "Silhouettes and border edges are drawn outside of stroke geometry"},
+ {LS_THICKNESS_RELATIVE, "RELATIVE", 0, "Relative", "Silhouettes and border edges are shifted by a user-defined ratio"},
+ {0, NULL, 0, NULL, NULL}
+ };
+ static EnumPropertyItem sort_key_items[] = {
+ {LS_SORT_KEY_DISTANCE_FROM_CAMERA, "DISTANCE_FROM_CAMERA", 0, "Distance from Camera", "Sort by distance from camera (closer lines lie on top of further lines)"},
+ {LS_SORT_KEY_2D_LENGTH, "2D_LENGTH", 0, "2D Length", "Sort by curvilinear 2D length (longer lines lie on top of shorter lines)"},
+ {0, NULL, 0, NULL, NULL}
+ };
+ static EnumPropertyItem sort_order_items[] = {
+ {0, "DEFAULT", 0, "Default", "Default order of the sort key"},
+ {LS_REVERSE_ORDER, "REVERSE", 0, "Reverse", "Reverse order"},
+ {0, NULL, 0, NULL, NULL}
+ };
+ static EnumPropertyItem integration_type_items[] = {
+ {LS_INTEGRATION_MEAN, "MEAN", 0, "Mean", "The value computed for the chain is the mean of the values obtained for chain vertices"},
+ {LS_INTEGRATION_MIN, "MIN", 0, "Min", "The value computed for the chain is the minimum of the values obtained for chain vertices"},
+ {LS_INTEGRATION_MAX, "MAX", 0, "Max", "The value computed for the chain is the maximum of the values obtained for chain vertices"},
+ {LS_INTEGRATION_FIRST, "FIRST", 0, "First", "The value computed for the chain is the value obtained for the first chain vertex"},
+ {LS_INTEGRATION_LAST, "LAST", 0, "Last", "The value computed for the chain is the value obtained for the last chain vertex"},
{0, NULL, 0, NULL, NULL}
};
@@ -920,6 +1079,9 @@ static void rna_def_linestyle(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Freestyle Line Style", "Freestyle line style, reusable by multiple line sets");
RNA_def_struct_ui_icon(srna, ICON_LINE_DATA);
+ rna_def_mtex_common(brna, srna, "rna_LineStyle_mtex_begin", "rna_LineStyle_active_texture_get",
+ "rna_LineStyle_active_texture_set", NULL, "LineStyleTextureSlot", "LineStyleTextureSlots", "rna_LineStyle_update");
+
prop = RNA_def_property(srna, "panel", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "panel");
RNA_def_property_enum_items(prop, panel_items);
@@ -935,7 +1097,7 @@ static void rna_def_linestyle(BlenderRNA *brna)
prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "alpha");
RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Alpha",
+ RNA_def_property_ui_text(prop, "Alpha Transparency",
"Base alpha transparency, possibly modified by alpha transparency modifiers");
RNA_def_property_update(prop, NC_LINESTYLE, NULL);
@@ -948,7 +1110,8 @@ static void rna_def_linestyle(BlenderRNA *brna)
prop = RNA_def_property(srna, "thickness_position", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "thickness_position");
RNA_def_property_enum_items(prop, thickness_position_items);
- RNA_def_property_ui_text(prop, "Thickness Position", "Select the position of stroke thickness");
+ RNA_def_property_ui_text(prop, "Thickness Position",
+ "Thickness position of silhouettes and border edges (applicable when plain chaining is used with the Same Object option)");
RNA_def_property_update(prop, NC_LINESTYLE, NULL);
prop = RNA_def_property(srna, "thickness_ratio", PROP_FLOAT, PROP_FACTOR);
@@ -982,7 +1145,7 @@ static void rna_def_linestyle(BlenderRNA *brna)
prop = RNA_def_property(srna, "chaining", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "chaining");
RNA_def_property_enum_items(prop, chaining_items);
- RNA_def_property_ui_text(prop, "Chaining", "Select the way how feature edges are jointed to form chains");
+ RNA_def_property_ui_text(prop, "Chaining Method", "Select the way how feature edges are jointed to form chains");
RNA_def_property_update(prop, NC_LINESTYLE, NULL);
prop = RNA_def_property(srna, "rounds", PROP_INT, PROP_UNSIGNED);
@@ -1104,6 +1267,29 @@ static void rna_def_linestyle(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Material Boundary", "If true, chains of feature edges are split at material boundaries");
RNA_def_property_update(prop, NC_LINESTYLE, NULL);
+ prop = RNA_def_property(srna, "use_sorting", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", LS_NO_SORTING);
+ RNA_def_property_ui_text(prop, "Sorting", "Arrange the stacking order of strokes");
+ RNA_def_property_update(prop, NC_LINESTYLE, NULL);
+
+ prop = RNA_def_property(srna, "sort_key", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "sort_key");
+ RNA_def_property_enum_items(prop, sort_key_items);
+ RNA_def_property_ui_text(prop, "Sort Key", "Select the sort key to determine the stacking order of chains");
+ RNA_def_property_update(prop, NC_LINESTYLE, NULL);
+
+ prop = RNA_def_property(srna, "sort_order", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
+ RNA_def_property_enum_items(prop, sort_order_items);
+ RNA_def_property_ui_text(prop, "Sort Order", "Select the sort order");
+ RNA_def_property_update(prop, NC_LINESTYLE, NULL);
+
+ prop = RNA_def_property(srna, "integration_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "integration_type");
+ RNA_def_property_enum_items(prop, integration_type_items);
+ RNA_def_property_ui_text(prop, "Integration Type", "Select the way how the sort key is computed for each chain");
+ RNA_def_property_update(prop, NC_LINESTYLE, NULL);
+
prop = RNA_def_property(srna, "use_dashed_line", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_DASHED_LINE);
RNA_def_property_ui_text(prop, "Dashed Line", "Enable or disable dashed line");
@@ -1112,7 +1298,7 @@ static void rna_def_linestyle(BlenderRNA *brna)
prop = RNA_def_property(srna, "caps", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "caps");
RNA_def_property_enum_items(prop, cap_items);
- RNA_def_property_ui_text(prop, "Cap", "Select the shape of both ends of strokes");
+ RNA_def_property_ui_text(prop, "Caps", "Select the shape of both ends of strokes");
RNA_def_property_update(prop, NC_LINESTYLE, NULL);
prop = RNA_def_property(srna, "dash1", PROP_INT, PROP_UNSIGNED);
@@ -1150,12 +1336,36 @@ static void rna_def_linestyle(BlenderRNA *brna)
RNA_def_property_range(prop, 0, USHRT_MAX);
RNA_def_property_ui_text(prop, "Gap 3", "Length of the 3rd gap for dashed lines");
RNA_def_property_update(prop, NC_LINESTYLE, NULL);
+
+ prop = RNA_def_property(srna, "use_texture", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_TEXTURE);
+ RNA_def_property_ui_text(prop, "Use Textures", "Enable or disable textured strokes");
+ RNA_def_property_update(prop, NC_LINESTYLE, NULL);
+
+ prop = RNA_def_property(srna, "texture_spacing", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "texstep");
+ RNA_def_property_range(prop, 0.01f, 100.0f);
+ RNA_def_property_ui_text(prop, "Texture spacing", "Spacing for textures along stroke lenght");
+ RNA_def_property_update(prop, NC_LINESTYLE, NULL);
+
+ /* nodes */
+ 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");
+
+ prop = RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_ui_text(prop, "Use Nodes", "Use texture nodes for the line style");
+ RNA_def_property_update(prop, NC_LINESTYLE, NULL);
}
void RNA_def_linestyle(BlenderRNA *brna)
{
rna_def_linestyle_modifiers(brna);
rna_def_linestyle(brna);
+ rna_def_linestyle_mtex(brna);
}
#endif
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c
index f7080375902..bac1f132126 100644
--- a/source/blender/makesrna/intern/rna_main_api.c
+++ b/source/blender/makesrna/intern/rna_main_api.c
@@ -292,216 +292,19 @@ Mesh *rna_Main_meshes_new_from_object(
Main *bmain, ReportList *reports, Scene *sce,
Object *ob, int apply_modifiers, int settings, int calc_tessface, int calc_undeformed)
{
- Mesh *tmpmesh;
- Curve *tmpcu = NULL, *copycu;
- Object *tmpobj = NULL;
- const bool use_render_resolution = (settings == eModifierMode_Render);
- int i;
- int cage = !apply_modifiers;
-
- /* perform the mesh extraction based on type */
switch (ob->type) {
case OB_FONT:
case OB_CURVE:
case OB_SURF:
- {
- ListBase dispbase = {NULL, NULL};
- DerivedMesh *derivedFinal = NULL;
- int uv_from_orco;
-
- /* copies object and modifiers (but not the data) */
- tmpobj = BKE_object_copy_ex(bmain, ob, true);
- tmpcu = (Curve *)tmpobj->data;
- tmpcu->id.us--;
-
- /* if getting the original caged mesh, delete object modifiers */
- if (cage)
- BKE_object_free_modifiers(tmpobj);
-
- /* copies the data */
- copycu = tmpobj->data = BKE_curve_copy((Curve *) ob->data);
-
- /* temporarily set edit so we get updates from edit mode, but
- * also because for text datablocks copying it while in edit
- * mode gives invalid data structures */
- copycu->editfont = tmpcu->editfont;
- copycu->editnurb = tmpcu->editnurb;
-
- /* get updated display list, and convert to a mesh */
- BKE_displist_make_curveTypes_forRender(sce, tmpobj, &dispbase, &derivedFinal, false, use_render_resolution);
-
- copycu->editfont = NULL;
- copycu->editnurb = NULL;
-
- tmpobj->derivedFinal = derivedFinal;
-
- /* convert object type to mesh */
- uv_from_orco = (tmpcu->flag & CU_UV_ORCO) != 0;
- BKE_mesh_from_nurbs_displist(tmpobj, &dispbase, uv_from_orco);
-
- tmpmesh = tmpobj->data;
-
- BKE_displist_free(&dispbase);
-
- /* BKE_mesh_from_nurbs changes the type to a mesh, check it worked.
- * 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(G.main, tmpobj);
- return NULL;
- }
-
- BKE_mesh_texspace_copy_from_object(tmpmesh, ob);
-
- BKE_libblock_free_us(bmain, tmpobj);
- break;
- }
-
case OB_MBALL:
- {
- /* metaballs don't have modifiers, so just convert to mesh */
- Object *basis_ob = BKE_mball_basis_find(sce, ob);
- /* todo, re-generatre for render-res */
- /* metaball_polygonize(scene, ob) */
-
- if (ob != basis_ob)
- return NULL; /* only do basis metaball */
-
- tmpmesh = BKE_mesh_add(bmain, "Mesh");
- /* BKE_mesh_add gives us a user count we don't need */
- tmpmesh->id.us--;
-
- if (use_render_resolution) {
- ListBase disp = {NULL, NULL};
- /* TODO(sergey): This is gonna to work for until EvaluationContext
- * only contains for_render flag. As soon as CoW is
- * implemented, this is to be rethinked.
- */
- EvaluationContext eval_ctx = {0};
- eval_ctx.for_render = use_render_resolution;
- BKE_displist_make_mball_forRender(&eval_ctx, sce, ob, &disp);
- BKE_mesh_from_metaball(&disp, tmpmesh);
- BKE_displist_free(&disp);
- }
- else {
- ListBase disp = {NULL, NULL};
- if (ob->curve_cache) {
- disp = ob->curve_cache->disp;
- }
- BKE_mesh_from_metaball(&disp, tmpmesh);
- }
-
- BKE_mesh_texspace_copy_from_object(tmpmesh, ob);
-
- break;
-
- }
case OB_MESH:
- /* copies object and modifiers (but not the data) */
- if (cage) {
- /* copies the data */
- tmpmesh = BKE_mesh_copy_ex(bmain, ob->data);
- /* if not getting the original caged mesh, get final derived mesh */
- }
- else {
- /* Make a dummy mesh, saves copying */
- DerivedMesh *dm;
- /* CustomDataMask mask = CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL; */
- CustomDataMask mask = CD_MASK_MESH; /* this seems more suitable, exporter,
- * for example, needs CD_MASK_MDEFORMVERT */
-
- if (calc_undeformed)
- mask |= CD_MASK_ORCO;
-
- /* Write the display mesh into the dummy mesh */
- if (use_render_resolution)
- dm = mesh_create_derived_render(sce, ob, mask);
- else
- dm = mesh_create_derived_view(sce, ob, mask);
-
- tmpmesh = BKE_mesh_add(bmain, "Mesh");
- DM_to_mesh(dm, tmpmesh, ob, mask);
- dm->release(dm);
- }
-
- /* BKE_mesh_add/copy gives us a user count we don't need */
- tmpmesh->id.us--;
-
break;
default:
BKE_report(reports, RPT_ERROR, "Object does not have geometry data");
return NULL;
}
- /* Copy materials to new mesh */
- switch (ob->type) {
- case OB_SURF:
- case OB_FONT:
- case OB_CURVE:
- tmpmesh->totcol = tmpcu->totcol;
-
- /* free old material list (if it exists) and adjust user counts */
- if (tmpcu->mat) {
- for (i = tmpcu->totcol; i-- > 0; ) {
- /* are we an object material or data based? */
-
- tmpmesh->mat[i] = ob->matbits[i] ? ob->mat[i] : tmpcu->mat[i];
-
- if (tmpmesh->mat[i]) {
- tmpmesh->mat[i]->id.us++;
- }
- }
- }
- break;
-
-#if 0
- /* Crashes when assigning the new material, not sure why */
- case OB_MBALL:
- tmpmb = (MetaBall *)ob->data;
- tmpmesh->totcol = tmpmb->totcol;
-
- /* free old material list (if it exists) and adjust user counts */
- if (tmpmb->mat) {
- for (i = tmpmb->totcol; i-- > 0; ) {
- tmpmesh->mat[i] = tmpmb->mat[i]; /* CRASH HERE ??? */
- if (tmpmesh->mat[i]) {
- tmpmb->mat[i]->id.us++;
- }
- }
- }
- break;
-#endif
-
- case OB_MESH:
- if (!cage) {
- Mesh *origmesh = ob->data;
- tmpmesh->flag = origmesh->flag;
- tmpmesh->mat = MEM_dupallocN(origmesh->mat);
- tmpmesh->totcol = origmesh->totcol;
- tmpmesh->smoothresh = origmesh->smoothresh;
- if (origmesh->mat) {
- for (i = origmesh->totcol; i-- > 0; ) {
- /* are we an object material or data based? */
- tmpmesh->mat[i] = ob->matbits[i] ? ob->mat[i] : origmesh->mat[i];
-
- if (tmpmesh->mat[i]) {
- tmpmesh->mat[i]->id.us++;
- }
- }
- }
- }
- break;
- } /* end copy materials */
-
- if (calc_tessface) {
- /* cycles and exporters rely on this still */
- BKE_mesh_tessface_ensure(tmpmesh);
- }
-
- /* make sure materials get updated in objects */
- test_object_materials(bmain, &tmpmesh->id);
-
- return tmpmesh;
+ return BKE_mesh_new_from_object(bmain, sce, ob, apply_modifiers, settings, calc_tessface, calc_undeformed);
}
static void rna_Main_meshes_remove(Main *bmain, ReportList *reports, PointerRNA *mesh_ptr)
@@ -957,6 +760,7 @@ static int rna_Main_armatures_is_updated_get(PointerRNA *ptr) { return DAG_id_ty
static int rna_Main_actions_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_AC); }
static int rna_Main_particles_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_PA); }
static int rna_Main_gpencil_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_GD); }
+static int rna_Main_linestyle_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_LS); }
#else
@@ -1979,6 +1783,7 @@ 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);
@@ -2002,6 +1807,10 @@ void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Remove a line style instance from the current blendfile");
parm = RNA_def_pointer(func, "linestyle", "FreestyleLineStyle", "", "Line style to remove");
RNA_def_property_flag(parm, PROP_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_linestyle_is_updated_get", NULL);
}
#endif
diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c
index 44fdfe73015..061f1595c8c 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -1907,6 +1907,12 @@ void RNA_def_material(BlenderRNA *brna)
"Replace the object's base alpha value with alpha from UV map image textures");
RNA_def_property_update(prop, 0, "rna_Material_update");
+ prop = RNA_def_property(srna, "use_cast_shadows", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "mode2", MA_CASTSHADOW);
+ RNA_def_property_ui_text(prop, "Cast Shadows",
+ "Allow this material to cast shadows");
+ RNA_def_property_update(prop, 0, "rna_Material_update");
+
prop = RNA_def_property(srna, "use_cast_shadows_only", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_ONLYCAST);
RNA_def_property_ui_text(prop, "Cast Shadows Only",
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index bdd94b73c44..8c0f9980108 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -398,7 +398,7 @@ static float rna_MeshPolygon_area_get(PointerRNA *ptr)
Mesh *me = (Mesh *)ptr->id.data;
MPoly *mp = (MPoly *)ptr->data;
- return BKE_mesh_calc_poly_area(mp, me->mloop + mp->loopstart, me->mvert, NULL);
+ return BKE_mesh_calc_poly_area(mp, me->mloop + mp->loopstart, me->mvert);
}
static void rna_MeshTessFace_normal_get(PointerRNA *ptr, float *values)
@@ -413,6 +413,21 @@ static void rna_MeshTessFace_normal_get(PointerRNA *ptr, float *values)
normal_tri_v3(values, me->mvert[mface->v1].co, me->mvert[mface->v2].co, me->mvert[mface->v3].co);
}
+static void rna_MeshTessFace_split_normals_get(PointerRNA *ptr, float *values)
+{
+ Mesh *me = rna_mesh(ptr);
+ MFace *mface = (MFace *)ptr->data;
+ const short (*vec)[4][3] = CustomData_get(&me->fdata, (int)(mface - me->mface), CD_TESSLOOPNORMAL);
+ int i = 4;
+
+ if (!vec) {
+ while (i--) zero_v3(&values[i * 3]);
+ }
+ else {
+ while (i--) normal_short_to_float_v3(&values[i * 3], (const short *)(*vec)[i]);
+ }
+}
+
static float rna_MeshTessFace_area_get(PointerRNA *ptr)
{
Mesh *me = rna_mesh(ptr);
@@ -727,6 +742,58 @@ static void rna_CustomDataLayer_clone_set(PointerRNA *ptr, CustomData *data, int
CustomData_set_layer_clone_index(data, type, n);
}
+static int rna_MEdge_freestyle_edge_mark_get(PointerRNA *ptr)
+{
+ Mesh *me = rna_mesh(ptr);
+ MEdge *medge = (MEdge *)ptr->data;
+ FreestyleEdge *fed = CustomData_get(&me->edata, (int)(medge - me->medge), CD_FREESTYLE_EDGE);
+
+ return fed && (fed->flag & FREESTYLE_EDGE_MARK) != 0;
+}
+
+static void rna_MEdge_freestyle_edge_mark_set(PointerRNA *ptr, int value)
+{
+ Mesh *me = rna_mesh(ptr);
+ MEdge *medge = (MEdge *)ptr->data;
+ FreestyleEdge *fed = CustomData_get(&me->edata, (int)(medge - me->medge), CD_FREESTYLE_EDGE);
+
+ if (!fed) {
+ fed = CustomData_add_layer(&me->edata, CD_FREESTYLE_EDGE, CD_CALLOC, NULL, me->totedge);
+ }
+ if (value) {
+ fed->flag |= FREESTYLE_EDGE_MARK;
+ }
+ else {
+ fed->flag &= ~FREESTYLE_EDGE_MARK;
+ }
+}
+
+static int rna_MPoly_freestyle_face_mark_get(PointerRNA *ptr)
+{
+ Mesh *me = rna_mesh(ptr);
+ MPoly *mpoly = (MPoly *)ptr->data;
+ FreestyleFace *ffa = CustomData_get(&me->pdata, (int)(mpoly - me->mpoly), CD_FREESTYLE_FACE);
+
+ return ffa && (ffa->flag & FREESTYLE_FACE_MARK) != 0;
+}
+
+static void rna_MPoly_freestyle_face_mark_set(PointerRNA *ptr, int value)
+{
+ Mesh *me = rna_mesh(ptr);
+ MPoly *mpoly = (MPoly *)ptr->data;
+ FreestyleFace *ffa = CustomData_get(&me->pdata, (int)(mpoly - me->mpoly), CD_FREESTYLE_FACE);
+
+ if (!ffa) {
+ ffa = CustomData_add_layer(&me->pdata, CD_FREESTYLE_FACE, CD_CALLOC, NULL, me->totpoly);
+ }
+ if (value) {
+ ffa->flag |= FREESTYLE_FACE_MARK;
+ }
+ else {
+ ffa->flag &= ~FREESTYLE_FACE_MARK;
+ }
+}
+
/* Generic UV rename! */
static void rna_MeshUVLayer_name_set(PointerRNA *ptr, const char *name)
{
@@ -1105,20 +1172,6 @@ static void rna_TextureFace_image_set(PointerRNA *ptr, PointerRNA value)
tf->tpage = (struct Image *)id;
}
-static void rna_Mesh_auto_smooth_angle_set(PointerRNA *ptr, float value)
-{
- Mesh *me = rna_mesh(ptr);
- value = RAD2DEGF(value);
- CLAMP(value, 1.0f, 80.0f);
- me->smoothresh = (int)value;
-}
-
-static float rna_Mesh_auto_smooth_angle_get(PointerRNA *ptr)
-{
- Mesh *me = rna_mesh(ptr);
- return DEG2RADF((float)me->smoothresh);
-}
-
static int rna_MeshTessFace_verts_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
{
MFace *face = (MFace *)ptr->data;
@@ -1807,6 +1860,11 @@ static void rna_def_medge(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_LOOSEEDGE);
RNA_def_property_ui_text(prop, "Loose", "Loose edge");
+ prop = RNA_def_property(srna, "use_freestyle_mark", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_MEdge_freestyle_edge_mark_get", "rna_MEdge_freestyle_edge_mark_set");
+ RNA_def_property_ui_text(prop, "Freestyle Edge Mark", "Edge mark for Freestyle line rendering");
+ RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
+
prop = RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_int_funcs(prop, "rna_MeshEdge_index_get", NULL, NULL);
@@ -1817,6 +1875,7 @@ static void rna_def_mface(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
+ const int splitnor_dim[] = {4, 3};
srna = RNA_def_struct(brna, "MeshTessFace", NULL);
RNA_def_struct_sdna(srna, "MFace");
@@ -1868,6 +1927,16 @@ static void rna_def_mface(BlenderRNA *brna)
RNA_def_property_float_funcs(prop, "rna_MeshTessFace_normal_get", NULL, NULL);
RNA_def_property_ui_text(prop, "Face Normal", "Local space unit length normal vector for this face");
+ prop = RNA_def_property(srna, "split_normals", PROP_FLOAT, PROP_DIRECTION);
+ RNA_def_property_multi_array(prop, 2, splitnor_dim);
+ RNA_def_property_range(prop, -1.0f, 1.0f);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_float_funcs(prop, "rna_MeshTessFace_split_normals_get", NULL, NULL);
+ RNA_def_property_ui_text(prop, "Split Normals",
+ "Local space unit length split normals vectors of the vertices of this face "
+ "(must be computed beforehand using calc_normals_split or calc_tangents, "
+ "and then calc_tessface)");
+
prop = RNA_def_property(srna, "area", PROP_FLOAT, PROP_UNSIGNED);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_float_funcs(prop, "rna_MeshTessFace_area_get", NULL, NULL);
@@ -1995,6 +2064,11 @@ static void rna_def_mpolygon(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Smooth", "");
RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
+ prop = RNA_def_property(srna, "use_freestyle_mark", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_MPoly_freestyle_face_mark_get", "rna_MPoly_freestyle_face_mark_set");
+ RNA_def_property_ui_text(prop, "Freestyle Face Mark", "Face mark for Freestyle line rendering");
+ RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
+
prop = RNA_def_property(srna, "normal", PROP_FLOAT, PROP_DIRECTION);
RNA_def_property_array(prop, 3);
RNA_def_property_range(prop, -1.0f, 1.0f);
@@ -3113,19 +3187,17 @@ static void rna_def_mesh(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_AUTOSMOOTH);
RNA_def_property_ui_text(prop, "Auto Smooth",
"Treat all set-smoothed faces with angles less than the specified angle "
- "as 'smooth' during render");
+ "as 'smooth', unless they are linked by a sharp edge");
+ RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
-#if 1 /* expose as radians */
prop = RNA_def_property(srna, "auto_smooth_angle", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_float_funcs(prop, "rna_Mesh_auto_smooth_angle_get", "rna_Mesh_auto_smooth_angle_set", NULL);
- RNA_def_property_ui_range(prop, DEG2RAD(1.0), DEG2RAD(80), 1.0, 1);
-#else
- prop = RNA_def_property(srna, "auto_smooth_angle", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "smoothresh");
- RNA_def_property_range(prop, 1, 80);
-#endif
+ RNA_def_property_float_sdna(prop, NULL, "smoothresh");
+ RNA_def_property_float_default(prop, DEG2RADF(180.0f));
+ RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f));
+ RNA_def_property_ui_range(prop, DEG2RADF(0.0f), DEG2RADF(180.0f), 1.0, 1);
RNA_def_property_ui_text(prop, "Auto Smooth Angle",
"Maximum angle between face normals that 'Auto Smooth' will operate on");
+ RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
prop = RNA_def_property(srna, "show_double_sided", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_TWOSIDED);
@@ -3183,6 +3255,11 @@ static void rna_def_mesh(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Draw Normals", "Display face normals as lines");
RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
+ prop = RNA_def_property(srna, "show_normal_loop", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_LNORMALS);
+ RNA_def_property_ui_text(prop, "Draw Split Normals", "Display vertex-per-face normals as lines");
+ RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
+
prop = RNA_def_property(srna, "show_normal_vertex", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_VNORMALS);
RNA_def_property_ui_text(prop, "Draw Vertex Normals", "Display vertex normals as lines");
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 91333af30b2..191d6d230db 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -2455,7 +2455,7 @@ static void rna_def_modifier_simpledeform(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "factor");
RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
RNA_def_property_float_default(prop, DEG2RADF(45.0f));
- RNA_def_property_ui_range(prop, -10, 10, 1, 3);
+ RNA_def_property_ui_range(prop, -M_PI, M_PI, DEG2RAD(1), 3);
RNA_def_property_ui_text(prop, "Angle", "Angle of deformation");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 0f2380cbad4..c39d3826d8b 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -129,7 +129,8 @@ EnumPropertyItem node_math_items[] = {
{14, "ROUND", 0, "Round", ""},
{15, "LESS_THAN", 0, "Less Than", ""},
{16, "GREATER_THAN", 0, "Greater Than", ""},
- {17, "MODULO", 0, "Modulo", ""},
+ {17, "MODULO", 0, "Modulo", ""},
+ {18, "ABSOLUTE", 0, "Absolute", ""},
{0, NULL, 0, NULL, NULL}
};
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 193d7baad33..38073293df8 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -987,7 +987,7 @@ static void rna_GameObjectSettings_physics_type_set(PointerRNA *ptr, int value)
switch (ob->body_type) {
case OB_BODY_TYPE_SENSOR:
- ob->gameflag |= OB_SENSOR | OB_COLLISION | OB_GHOST;
+ ob->gameflag |= OB_SENSOR | OB_COLLISION;
ob->gameflag &= ~(OB_OCCLUDER | OB_CHARACTER | OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_ACTOR |
OB_ANISOTROPIC_FRICTION | OB_DO_FH | OB_ROT_FH | OB_COLLISION_RESPONSE | OB_NAVMESH);
break;
@@ -1009,7 +1009,7 @@ static void rna_GameObjectSettings_physics_type_set(PointerRNA *ptr, int value)
ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_CHARACTER | OB_OCCLUDER | OB_DYNAMIC | OB_NAVMESH);
break;
case OB_BODY_TYPE_CHARACTER:
- ob->gameflag |= OB_COLLISION | OB_GHOST | OB_CHARACTER;
+ ob->gameflag |= OB_COLLISION | OB_CHARACTER;
ob->gameflag &= ~(OB_SENSOR | OB_OCCLUDER | OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_ACTOR |
OB_ANISOTROPIC_FRICTION | OB_DO_FH | OB_ROT_FH | OB_COLLISION_RESPONSE | OB_NAVMESH);
break;
@@ -1284,20 +1284,20 @@ static PointerRNA rna_Object_collision_get(PointerRNA *ptr)
static PointerRNA rna_Object_active_constraint_get(PointerRNA *ptr)
{
Object *ob = (Object *)ptr->id.data;
- bConstraint *con = BKE_constraints_get_active(&ob->constraints);
+ bConstraint *con = BKE_constraints_active_get(&ob->constraints);
return rna_pointer_inherit_refine(ptr, &RNA_Constraint, con);
}
static void rna_Object_active_constraint_set(PointerRNA *ptr, PointerRNA value)
{
Object *ob = (Object *)ptr->id.data;
- BKE_constraints_set_active(&ob->constraints, (bConstraint *)value.data);
+ BKE_constraints_active_set(&ob->constraints, (bConstraint *)value.data);
}
static bConstraint *rna_Object_constraints_new(Object *object, int type)
{
WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_ADDED, object);
- return BKE_add_ob_constraint(object, NULL, type);
+ return BKE_constraint_add_for_object(object, NULL, type);
}
static void rna_Object_constraints_remove(Object *object, ReportList *reports, PointerRNA *con_ptr)
@@ -1308,7 +1308,7 @@ static void rna_Object_constraints_remove(Object *object, ReportList *reports, P
return;
}
- BKE_remove_constraint(&object->constraints, con);
+ BKE_constraint_remove(&object->constraints, con);
RNA_POINTER_INVALIDATE(con_ptr);
ED_object_constraint_update(object);
@@ -1318,7 +1318,7 @@ static void rna_Object_constraints_remove(Object *object, ReportList *reports, P
static void rna_Object_constraints_clear(Object *object)
{
- BKE_free_constraints(&object->constraints);
+ BKE_constraints_free(&object->constraints);
ED_object_constraint_update(object);
ED_object_constraint_set_active(object, NULL);
@@ -1482,7 +1482,12 @@ int rna_Object_use_dynamic_topology_sculpting_get(PointerRNA *ptr)
static void rna_Object_lod_distance_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
Object *ob = (Object *)ptr->id.data;
+
+#ifdef WITH_GAMEENGINE
BKE_object_lod_sort(ob);
+#else
+ (void)ob;
+#endif
}
#else
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index a7be3daea20..18e4ac6b004 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -481,14 +481,14 @@ static void rna_pose_pgroup_name_set(PointerRNA *ptr, const char *value, char *r
static PointerRNA rna_PoseChannel_active_constraint_get(PointerRNA *ptr)
{
bPoseChannel *pchan = (bPoseChannel *)ptr->data;
- bConstraint *con = BKE_constraints_get_active(&pchan->constraints);
+ bConstraint *con = BKE_constraints_active_get(&pchan->constraints);
return rna_pointer_inherit_refine(ptr, &RNA_Constraint, con);
}
static void rna_PoseChannel_active_constraint_set(PointerRNA *ptr, PointerRNA value)
{
bPoseChannel *pchan = (bPoseChannel *)ptr->data;
- BKE_constraints_set_active(&pchan->constraints, (bConstraint *)value.data);
+ BKE_constraints_active_set(&pchan->constraints, (bConstraint *)value.data);
}
static bConstraint *rna_PoseChannel_constraints_new(bPoseChannel *pchan, int type)
@@ -496,7 +496,7 @@ static bConstraint *rna_PoseChannel_constraints_new(bPoseChannel *pchan, int typ
/*WM_main_add_notifier(NC_OBJECT|ND_CONSTRAINT|NA_ADDED, object); */
/* TODO, pass object also */
/* TODO, new pose bones don't have updated draw flags */
- return BKE_add_pose_constraint(NULL, pchan, NULL, type);
+ return BKE_constraint_add_for_pose(NULL, pchan, NULL, type);
}
static void rna_PoseChannel_constraints_remove(ID *id, bPoseChannel *pchan, ReportList *reports, PointerRNA *con_ptr)
@@ -510,12 +510,12 @@ static void rna_PoseChannel_constraints_remove(ID *id, bPoseChannel *pchan, Repo
return;
}
- BKE_remove_constraint(&pchan->constraints, con);
+ BKE_constraint_remove(&pchan->constraints, con);
RNA_POINTER_INVALIDATE(con_ptr);
ED_object_constraint_update(ob);
- BKE_constraints_set_active(&pchan->constraints, NULL); /* XXX, is this really needed? - Campbell */
+ BKE_constraints_active_set(&pchan->constraints, NULL); /* XXX, is this really needed? - Campbell */
WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, id);
diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c
index 1ec11c280cb..16cc82bbca1 100644
--- a/source/blender/makesrna/intern/rna_render.c
+++ b/source/blender/makesrna/intern/rna_render.c
@@ -38,7 +38,41 @@
#include "RE_engine.h"
#include "RE_pipeline.h"
+#include "RE_engine.h"
+
+EnumPropertyItem render_pass_type_items[] = {
+ {SCE_PASS_COMBINED, "COMBINED", 0, "Combined", ""},
+ {SCE_PASS_Z, "Z", 0, "Z", ""},
+ {SCE_PASS_RGBA, "COLOR", 0, "Color", ""},
+ {SCE_PASS_DIFFUSE, "DIFFUSE", 0, "Diffuse", ""},
+ {SCE_PASS_SPEC, "SPECULAR", 0, "Specular", ""},
+ {SCE_PASS_SHADOW, "SHADOW", 0, "Shadow", ""},
+ {SCE_PASS_AO, "AO", 0, "AO", ""},
+ {SCE_PASS_REFLECT, "REFLECTION", 0, "Reflection", ""},
+ {SCE_PASS_NORMAL, "NORMAL", 0, "Normal", ""},
+ {SCE_PASS_VECTOR, "VECTOR", 0, "Vector", ""},
+ {SCE_PASS_REFRACT, "REFRACTION", 0, "Refraction", ""},
+ {SCE_PASS_INDEXOB, "OBJECT_INDEX", 0, "Object Index", ""},
+ {SCE_PASS_UV, "UV", 0, "UV", ""},
+ {SCE_PASS_MIST, "MIST", 0, "Mist", ""},
+ {SCE_PASS_EMIT, "EMIT", 0, "Emit", ""},
+ {SCE_PASS_ENVIRONMENT, "ENVIRONMENT", 0, "Environment", ""},
+ {SCE_PASS_INDEXMA, "MATERIAL_INDEX", 0, "Material Index", ""},
+ {SCE_PASS_DIFFUSE_DIRECT, "DIFFUSE_DIRECT", 0, "Diffuse Direct", ""},
+ {SCE_PASS_DIFFUSE_INDIRECT, "DIFFUSE_INDIRECT", 0, "Diffuse Indirect", ""},
+ {SCE_PASS_DIFFUSE_COLOR, "DIFFUSE_COLOR", 0, "Diffuse Color", ""},
+ {SCE_PASS_GLOSSY_DIRECT, "GLOSSY_DIRECT", 0, "Glossy Direct", ""},
+ {SCE_PASS_GLOSSY_INDIRECT, "GLOSSY_INDIRECT", 0, "Glossy Indirect", ""},
+ {SCE_PASS_GLOSSY_COLOR, "GLOSSY_COLOR", 0, "Glossy Color", ""},
+ {SCE_PASS_TRANSM_DIRECT, "TRANSMISSION_DIRECT", 0, "Transmission Direct", ""},
+ {SCE_PASS_TRANSM_INDIRECT, "TRANSMISSION_INDIRECT", 0, "Transmission Indirect", ""},
+ {SCE_PASS_TRANSM_COLOR, "TRANSMISSION_COLOR", 0, "Transmission Color", ""},
+ {SCE_PASS_SUBSURFACE_DIRECT, "SUBSURFACE_DIRECT", 0, "Subsurface Direct", ""},
+ {SCE_PASS_SUBSURFACE_INDIRECT, "SUBSURFACE_INDIRECT", 0, "Subsurface Indirect", ""},
+ {SCE_PASS_SUBSURFACE_COLOR, "SUBSURFACE_COLOR", 0, "Subsurface Color", ""},
+ {0, NULL, 0, NULL, NULL}
+};
#ifdef RNA_RUNTIME
@@ -117,6 +151,30 @@ static void engine_render(RenderEngine *engine, struct Scene *scene)
RNA_parameter_list_free(&list);
}
+static void engine_bake(RenderEngine *engine, struct Scene *scene, struct Object *object, const int pass_type,
+ const struct BakePixel *pixel_array, const int num_pixels, const int depth, void *result)
+{
+ extern FunctionRNA rna_RenderEngine_bake_func;
+ PointerRNA ptr;
+ ParameterList list;
+ FunctionRNA *func;
+
+ RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr);
+ func = &rna_RenderEngine_bake_func;
+
+ RNA_parameter_list_create(&list, &ptr, func);
+ RNA_parameter_set_lookup(&list, "scene", &scene);
+ RNA_parameter_set_lookup(&list, "object", &object);
+ RNA_parameter_set_lookup(&list, "pass_type", &pass_type);
+ RNA_parameter_set_lookup(&list, "pixel_array", &pixel_array);
+ RNA_parameter_set_lookup(&list, "num_pixels", &num_pixels);
+ RNA_parameter_set_lookup(&list, "depth", &depth);
+ RNA_parameter_set_lookup(&list, "result", &result);
+ engine->type->ext.call(NULL, &ptr, func, &list);
+
+ RNA_parameter_list_free(&list);
+}
+
static void engine_view_update(RenderEngine *engine, const struct bContext *context)
{
extern FunctionRNA rna_RenderEngine_view_update_func;
@@ -189,7 +247,7 @@ static StructRNA *rna_RenderEngine_register(Main *bmain, ReportList *reports, vo
RenderEngineType *et, dummyet = {NULL};
RenderEngine dummyengine = {NULL};
PointerRNA dummyptr;
- int have_function[5];
+ int have_function[6];
/* setup dummy engine & engine type to store static properties in */
dummyengine.type = &dummyet;
@@ -226,9 +284,10 @@ static StructRNA *rna_RenderEngine_register(Main *bmain, ReportList *reports, vo
et->update = (have_function[0]) ? engine_update : NULL;
et->render = (have_function[1]) ? engine_render : NULL;
- et->view_update = (have_function[2]) ? engine_view_update : NULL;
- et->view_draw = (have_function[3]) ? engine_view_draw : NULL;
- et->update_script_node = (have_function[4]) ? engine_update_script_node : NULL;
+ et->bake = (have_function[2]) ? engine_bake : NULL;
+ et->view_update = (have_function[3]) ? engine_view_update : NULL;
+ et->view_draw = (have_function[4]) ? engine_view_draw : NULL;
+ et->update_script_node = (have_function[5]) ? engine_update_script_node : NULL;
BLI_addtail(&R_engines, et);
@@ -317,6 +376,12 @@ void rna_RenderPass_rect_set(PointerRNA *ptr, const float *values)
memcpy(rpass->rect, values, sizeof(float) * rpass->rectx * rpass->recty * rpass->channels);
}
+static PointerRNA rna_BakePixel_next_get(PointerRNA *ptr)
+{
+ BakePixel *bp = ptr->data;
+ return rna_pointer_inherit_refine(ptr, &RNA_BakePixel, bp + 1);
+}
+
#else /* RNA_RUNTIME */
static void rna_def_render_engine(BlenderRNA *brna)
@@ -344,6 +409,25 @@ static void rna_def_render_engine(BlenderRNA *brna)
RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
RNA_def_pointer(func, "scene", "Scene", "", "");
+ func = RNA_def_function(srna, "bake", NULL);
+ RNA_def_function_ui_description(func, "Bake passes");
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
+ prop = RNA_def_pointer(func, "scene", "Scene", "", "");
+ RNA_def_property_flag(prop, PROP_REQUIRED);
+ prop = RNA_def_pointer(func, "object", "Object", "", "");
+ RNA_def_property_flag(prop, PROP_REQUIRED);
+ prop = RNA_def_enum(func, "pass_type", render_pass_type_items, 0, "Pass", "Pass to bake");
+ RNA_def_property_flag(prop, PROP_REQUIRED);
+ prop = RNA_def_pointer(func, "pixel_array", "BakePixel", "", "");
+ RNA_def_property_flag(prop, PROP_REQUIRED);
+ prop = RNA_def_int(func, "num_pixels", 0, 0, INT_MAX, "Number of Pixels", "Size of the baking batch", 0, INT_MAX);
+ RNA_def_property_flag(prop, PROP_REQUIRED);
+ prop = RNA_def_int(func, "depth", 0, 0, INT_MAX, "Pixels depth", "Number of channels", 1, INT_MAX);
+ RNA_def_property_flag(prop, PROP_REQUIRED);
+ /* TODO, see how array size of 0 works, this shouldnt be used */
+ prop = RNA_def_pointer(func, "result", "AnyType", "", "");
+ RNA_def_property_flag(prop, PROP_REQUIRED);
+
/* viewport render callbacks */
func = RNA_def_function(srna, "view_update", NULL);
RNA_def_function_ui_description(func, "Update on data changes for viewport render");
@@ -588,39 +672,6 @@ static void rna_def_render_pass(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
- static EnumPropertyItem pass_type_items[] = {
- {SCE_PASS_COMBINED, "COMBINED", 0, "Combined", ""},
- {SCE_PASS_Z, "Z", 0, "Z", ""},
- {SCE_PASS_RGBA, "COLOR", 0, "Color", ""},
- {SCE_PASS_DIFFUSE, "DIFFUSE", 0, "Diffuse", ""},
- {SCE_PASS_SPEC, "SPECULAR", 0, "Specular", ""},
- {SCE_PASS_SHADOW, "SHADOW", 0, "Shadow", ""},
- {SCE_PASS_AO, "AO", 0, "AO", ""},
- {SCE_PASS_REFLECT, "REFLECTION", 0, "Reflection", ""},
- {SCE_PASS_NORMAL, "NORMAL", 0, "Normal", ""},
- {SCE_PASS_VECTOR, "VECTOR", 0, "Vector", ""},
- {SCE_PASS_REFRACT, "REFRACTION", 0, "Refraction", ""},
- {SCE_PASS_INDEXOB, "OBJECT_INDEX", 0, "Object Index", ""},
- {SCE_PASS_UV, "UV", 0, "UV", ""},
- {SCE_PASS_MIST, "MIST", 0, "Mist", ""},
- {SCE_PASS_EMIT, "EMIT", 0, "Emit", ""},
- {SCE_PASS_ENVIRONMENT, "ENVIRONMENT", 0, "Environment", ""},
- {SCE_PASS_INDEXMA, "MATERIAL_INDEX", 0, "Material Index", ""},
- {SCE_PASS_DIFFUSE_DIRECT, "DIFFUSE_DIRECT", 0, "Diffuse Direct", ""},
- {SCE_PASS_DIFFUSE_INDIRECT, "DIFFUSE_INDIRECT", 0, "Diffuse Indirect", ""},
- {SCE_PASS_DIFFUSE_COLOR, "DIFFUSE_COLOR", 0, "Diffuse Color", ""},
- {SCE_PASS_GLOSSY_DIRECT, "GLOSSY_DIRECT", 0, "Glossy Direct", ""},
- {SCE_PASS_GLOSSY_INDIRECT, "GLOSSY_INDIRECT", 0, "Glossy Indirect", ""},
- {SCE_PASS_GLOSSY_COLOR, "GLOSSY_COLOR", 0, "Glossy Color", ""},
- {SCE_PASS_TRANSM_DIRECT, "TRANSMISSION_DIRECT", 0, "Transmission Direct", ""},
- {SCE_PASS_TRANSM_INDIRECT, "TRANSMISSION_INDIRECT", 0, "Transmission Indirect", ""},
- {SCE_PASS_TRANSM_COLOR, "TRANSMISSION_COLOR", 0, "Transmission Color", ""},
- {SCE_PASS_SUBSURFACE_DIRECT, "SUBSURFACE_DIRECT", 0, "Subsurface Direct", ""},
- {SCE_PASS_SUBSURFACE_INDIRECT, "SUBSURFACE_INDIRECT", 0, "Subsurface Indirect", ""},
- {SCE_PASS_SUBSURFACE_COLOR, "SUBSURFACE_COLOR", 0, "Subsurface Color", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
srna = RNA_def_struct(brna, "RenderPass", NULL);
RNA_def_struct_ui_text(srna, "Render Pass", "");
@@ -641,7 +692,7 @@ static void rna_def_render_pass(BlenderRNA *brna)
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "passtype");
- RNA_def_property_enum_items(prop, pass_type_items);
+ RNA_def_property_enum_items(prop, render_pass_type_items);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
prop = RNA_def_property(srna, "rect", PROP_FLOAT, PROP_NONE);
@@ -653,12 +704,56 @@ static void rna_def_render_pass(BlenderRNA *brna)
RNA_define_verify_sdna(1);
}
+static void rna_def_render_bake_pixel(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "BakePixel", NULL);
+ RNA_def_struct_ui_text(srna, "Bake Pixel", "");
+
+ RNA_define_verify_sdna(0);
+
+ prop = RNA_def_property(srna, "primitive_id", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "primitive_id");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
+ prop = RNA_def_property(srna, "uv", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_array(prop, 2);
+ RNA_def_property_float_sdna(prop, NULL, "uv");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
+ prop = RNA_def_property(srna, "du_dx", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "du_dx");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
+ prop = RNA_def_property(srna, "du_dy", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "du_dy");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
+ prop = RNA_def_property(srna, "dv_dx", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "dv_dx");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
+ prop = RNA_def_property(srna, "dv_dy", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "dv_dy");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
+ prop = RNA_def_property(srna, "next", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "BakePixel");
+ RNA_def_property_pointer_funcs(prop, "rna_BakePixel_next_get", NULL, NULL, NULL);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
+ RNA_define_verify_sdna(1);
+}
+
void RNA_def_render(BlenderRNA *brna)
{
rna_def_render_engine(brna);
rna_def_render_result(brna);
rna_def_render_layer(brna);
rna_def_render_pass(brna);
+ rna_def_render_bake_pixel(brna);
}
#endif /* RNA_RUNTIME */
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index ea9dda40488..bf2858c44e6 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -75,6 +75,17 @@
#include "BLI_threads.h"
+#ifdef WITH_OPENEXR
+EnumPropertyItem exr_codec_items[] = {
+ {R_IMF_EXR_CODEC_NONE, "NONE", 0, "None", ""},
+ {R_IMF_EXR_CODEC_PXR24, "PXR24", 0, "Pxr24 (lossy)", ""},
+ {R_IMF_EXR_CODEC_ZIP, "ZIP", 0, "ZIP (lossless)", ""},
+ {R_IMF_EXR_CODEC_PIZ, "PIZ", 0, "PIZ (lossless)", ""},
+ {R_IMF_EXR_CODEC_RLE, "RLE", 0, "RLE (lossless)", ""},
+ {0, NULL, 0, NULL, NULL}
+};
+#endif
+
EnumPropertyItem uv_sculpt_relaxation_items[] = {
{UV_SCULPT_TOOL_RELAX_LAPLACIAN, "LAPLACIAN", 0, "Laplacian", "Use Laplacian method for relaxation"},
{UV_SCULPT_TOOL_RELAX_HC, "HC", 0, "HC", "Use HC method for relaxation"},
@@ -295,6 +306,28 @@ EnumPropertyItem image_color_depth_items[] = {
{0, NULL, 0, NULL, NULL}
};
+EnumPropertyItem normal_space_items[] = {
+ {R_BAKE_SPACE_OBJECT, "OBJECT", 0, "Object", "Bake the normals in object space"},
+ {R_BAKE_SPACE_TANGENT, "TANGENT", 0, "Tangent", "Bake the normals in tangent space"},
+ {0, NULL, 0, NULL, NULL}
+};
+
+EnumPropertyItem normal_swizzle_items[] = {
+ {R_BAKE_POSX, "POS_X", 0, "+X", ""},
+ {R_BAKE_POSY, "POS_Y", 0, "+Y", ""},
+ {R_BAKE_POSZ, "POS_Z", 0, "+Z", ""},
+ {R_BAKE_NEGX, "NEG_X", 0, "-X", ""},
+ {R_BAKE_NEGY, "NEG_Y", 0, "-Y", ""},
+ {R_BAKE_NEGZ, "NEG_Z", 0, "-Z", ""},
+ {0, NULL, 0, NULL, NULL}
+};
+
+EnumPropertyItem bake_save_mode_items[] = {
+ {R_BAKE_SAVE_INTERNAL, "INTERNAL", 0, "Internal", "Save the baking map in an internal image datablock"},
+ {R_BAKE_SAVE_EXTERNAL, "EXTERNAL", 0, "External", "Save the baking map in an external file"},
+ {0, NULL, 0, NULL, NULL}
+};
+
#ifdef RNA_RUNTIME
#include "DNA_anim_types.h"
@@ -681,12 +714,6 @@ static char *rna_RenderSettings_path(PointerRNA *UNUSED(ptr))
return BLI_sprintfN("render");
}
-static int rna_omp_threads_get(PointerRNA *ptr)
-{
- Scene *scene = (Scene *)ptr->data;
- return BKE_scene_num_omp_threads(scene);
-}
-
static int rna_RenderSettings_threads_get(PointerRNA *ptr)
{
RenderData *rd = (RenderData *)ptr->data;
@@ -1556,6 +1583,34 @@ static void rna_FreestyleLineSet_linestyle_set(PointerRNA *ptr, PointerRNA value
lineset->linestyle->id.us++;
}
+static FreestyleLineSet *FreestyleSettings_lineset_add(ID *id, struct FreestyleSettings *config, const char *name)
+{
+ Scene *scene = (Scene *)id;
+ FreestyleLineSet *lineset = BKE_freestyle_lineset_add((FreestyleConfig *)config, name);
+
+ DAG_id_tag_update(&scene->id, 0);
+ WM_main_add_notifier(NC_SCENE | ND_RENDER_OPTIONS, NULL);
+
+ return lineset;
+}
+
+static void FreestyleSettings_lineset_remove(ID *id, struct FreestyleSettings *config, ReportList *reports,
+ PointerRNA *lineset_ptr)
+{
+ FreestyleLineSet *lineset = lineset_ptr->data;
+ Scene *scene = (Scene *)id;
+
+ if (!BKE_freestyle_lineset_delete((FreestyleConfig *)config, lineset)) {
+ BKE_reportf(reports, RPT_ERROR, "Line set '%s' could not be removed", lineset->name);
+ return;
+ }
+
+ RNA_POINTER_INVALIDATE(lineset_ptr);
+
+ DAG_id_tag_update(&scene->id, 0);
+ WM_main_add_notifier(NC_SCENE | ND_RENDER_OPTIONS, NULL);
+}
+
static PointerRNA rna_FreestyleSettings_active_lineset_get(PointerRNA *ptr)
{
FreestyleConfig *config = (FreestyleConfig *)ptr->data;
@@ -2260,6 +2315,8 @@ void rna_def_render_layer_common(StructRNA *srna, int scene)
else RNA_def_property_boolean_funcs(prop, NULL, "rna_RenderLayer_layer_set");
if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ /* this seems to be too much trouble with depsgraph updates/etc. currently (20140423) */
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
prop = RNA_def_property(srna, "layers_zmask", PROP_BOOLEAN, PROP_LAYER);
RNA_def_property_boolean_sdna(prop, NULL, "lay_zmask", 1);
@@ -2598,6 +2655,8 @@ static void rna_def_freestyle_linesets(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
PropertyRNA *prop;
+ FunctionRNA *func;
+ PropertyRNA *parm;
RNA_def_property_srna(cprop, "Linesets");
srna = RNA_def_struct(brna, "Linesets", NULL);
@@ -2616,6 +2675,21 @@ static void rna_def_freestyle_linesets(BlenderRNA *brna, PropertyRNA *cprop)
"rna_FreestyleSettings_active_lineset_index_range");
RNA_def_property_ui_text(prop, "Active Line Set Index", "Index of active line set slot");
RNA_def_property_update(prop, NC_SCENE, NULL);
+
+ func = RNA_def_function(srna, "new", "FreestyleSettings_lineset_add");
+ RNA_def_function_ui_description(func, "Add a line set to scene render layer Freestyle settings");
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID);
+ parm = RNA_def_string(func, "name", "LineSet", 0, "", "New name for the line set (not unique)");
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ parm = RNA_def_pointer(func, "lineset", "FreestyleLineSet", "", "Newly created line set");
+ RNA_def_function_return(func, parm);
+
+ func = RNA_def_function(srna, "remove", "FreestyleSettings_lineset_remove");
+ RNA_def_function_ui_description(func, "Remove a line set from scene render layer Freestyle settings");
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_REPORTS);
+ parm = RNA_def_pointer(func, "lineset", "FreestyleLineSet", "", "Line set to remove");
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
}
static void rna_def_freestyle_settings(BlenderRNA *brna)
@@ -2631,9 +2705,9 @@ static void rna_def_freestyle_settings(BlenderRNA *brna)
};
static EnumPropertyItem edge_type_combination_items[] = {
- {0, "OR", 0, "Logical OR", "Combine feature edge type conditions by logical OR (logical disjunction)"},
+ {0, "OR", 0, "Logical OR", "Select feature edges satisfying at least one of edge type conditions"},
{FREESTYLE_LINESET_FE_AND, "AND", 0, "Logical AND",
- "Combine feature edge type conditions by logical AND (logical conjunction)"},
+ "Select feature edges satisfying all edge type conditions"},
{0, NULL, 0, NULL, NULL}
};
@@ -2652,15 +2726,15 @@ static void rna_def_freestyle_settings(BlenderRNA *brna)
};
static EnumPropertyItem face_mark_condition_items[] = {
- {0, "ONE", 0, "One Face", "Select feature edges if one of faces on the right and left has a face mark"},
+ {0, "ONE", 0, "One Face", "Select a feature edge if either of its adjacent faces is marked"},
{FREESTYLE_LINESET_FM_BOTH, "BOTH", 0, "Both Faces",
- "Select feature edges if both faces on the right and left faces have a face mark"},
+ "Select a feature edge if both of its adjacent faces are marked"},
{0, NULL, 0, NULL, NULL}
};
static EnumPropertyItem freestyle_ui_mode_items[] = {
{FREESTYLE_CONTROL_SCRIPT_MODE, "SCRIPT", 0, "Python Scripting Mode",
- "Advanced mode for using style modules in Python"},
+ "Advanced mode for using style modules written in Python"},
{FREESTYLE_CONTROL_EDITOR_MODE, "EDITOR", 0, "Parameter Editor Mode",
"Basic mode for interactive style parameter editing"},
{0, NULL, 0, NULL, NULL}
@@ -2731,14 +2805,14 @@ static void rna_def_freestyle_settings(BlenderRNA *brna)
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
RNA_def_property_enum_items(prop, edge_type_negation_items);
RNA_def_property_ui_text(prop, "Edge Type Negation",
- "Set the negation operation for conditions on feature edge types");
+ "Specify either inclusion or exclusion of feature edges selected by edge types");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "edge_type_combination", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
RNA_def_property_enum_items(prop, edge_type_combination_items);
RNA_def_property_ui_text(prop, "Edge Type Combination",
- "Set the combination operation for conditions on feature edge types");
+ "Specify a logical combination of selection conditions on feature edge types");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
@@ -2752,45 +2826,45 @@ static void rna_def_freestyle_settings(BlenderRNA *brna)
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
RNA_def_property_enum_items(prop, group_negation_items);
RNA_def_property_ui_text(prop, "Group Negation",
- "Set the negation operation for conditions on feature edge types");
+ "Specify either inclusion or exclusion of feature edges belonging to a group of objects");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "face_mark_negation", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
RNA_def_property_enum_items(prop, face_mark_negation_items);
RNA_def_property_ui_text(prop, "Face Mark Negation",
- "Set the negation operation for the condition on face marks");
+ "Specify either inclusion or exclusion of feature edges selected by face marks");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "face_mark_condition", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
RNA_def_property_enum_items(prop, face_mark_condition_items);
- RNA_def_property_ui_text(prop, "Face Mark Condition", "Set a feature edge selection condition on face marks");
+ RNA_def_property_ui_text(prop, "Face Mark Condition", "Specify a feature edge selection condition based on face marks");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "select_silhouette", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_SILHOUETTE);
- RNA_def_property_ui_text(prop, "Silhouette", "Select silhouette edges");
+ RNA_def_property_ui_text(prop, "Silhouette", "Select silhouettes (edges at the boundary of visible and hidden faces)");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "select_border", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_BORDER);
- RNA_def_property_ui_text(prop, "Border", "Select border edges");
+ RNA_def_property_ui_text(prop, "Border", "Select border edges (open mesh edges)");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "select_crease", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_CREASE);
- RNA_def_property_ui_text(prop, "Crease", "Select crease edges");
+ RNA_def_property_ui_text(prop, "Crease", "Select crease edges (those between two faces making an angle smaller than the Crease Angle)");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "select_ridge_valley", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_RIDGE_VALLEY);
- RNA_def_property_ui_text(prop, "Ridge & Valley", "Select ridges and valleys");
+ RNA_def_property_ui_text(prop, "Ridge & Valley", "Select ridges and valleys (boundary lines between convex and concave areas of surface)");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "select_suggestive_contour", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_SUGGESTIVE_CONTOUR);
- RNA_def_property_ui_text(prop, "Suggestive Contour", "Select suggestive contours");
+ RNA_def_property_ui_text(prop, "Suggestive Contour", "Select suggestive contours (almost silhouette/contour edges)");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "select_material_boundary", PROP_BOOLEAN, PROP_NONE);
@@ -2800,17 +2874,17 @@ static void rna_def_freestyle_settings(BlenderRNA *brna)
prop = RNA_def_property(srna, "select_contour", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_CONTOUR);
- RNA_def_property_ui_text(prop, "Contour", "Select contours");
+ RNA_def_property_ui_text(prop, "Contour", "Select contours (outer silhouettes of each object)");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "select_external_contour", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_EXTERNAL_CONTOUR);
- RNA_def_property_ui_text(prop, "External Contour", "Select external contours");
+ RNA_def_property_ui_text(prop, "External Contour", "Select external contours (outer silhouettes of occluding and occluded objects)");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "select_edge_mark", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_EDGE_MARK);
- RNA_def_property_ui_text(prop, "Edge Mark", "Select edge marks");
+ RNA_def_property_ui_text(prop, "Edge Mark", "Select edge marks (edges annotated by Freestyle edge marks)");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "exclude_silhouette", PROP_BOOLEAN, PROP_NONE);
@@ -3066,6 +3140,110 @@ static void rna_def_scene_game_recast_data(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SCENE, NULL);
}
+
+static void rna_def_bake_data(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "BakeSettings", NULL);
+ RNA_def_struct_sdna(srna, "BakeData");
+ RNA_def_struct_nested(brna, srna, "RenderSettings");
+ RNA_def_struct_ui_text(srna, "Bake Data", "Bake data for a Scene datablock");
+
+ prop = RNA_def_property(srna, "cage", PROP_STRING, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Cage", "Object to use as cage");
+ RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+
+ prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
+ RNA_def_property_ui_text(prop, "File Path", "Image filepath to use when saving externally");
+ RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+
+ prop = RNA_def_property(srna, "width", PROP_INT, PROP_PIXEL);
+ RNA_def_property_range(prop, 4, 10000);
+ RNA_def_property_ui_text(prop, "Width", "Horizontal dimension of the baking map");
+ RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+
+ prop = RNA_def_property(srna, "height", PROP_INT, PROP_PIXEL);
+ RNA_def_property_range(prop, 4, 10000);
+ RNA_def_property_ui_text(prop, "Height", "Vertical dimension of the baking map");
+ RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+
+ prop = RNA_def_property(srna, "margin", PROP_INT, PROP_PIXEL);
+ RNA_def_property_range(prop, 0, SHRT_MAX);
+ RNA_def_property_ui_range(prop, 0, 64, 1, 1);
+ RNA_def_property_ui_text(prop, "Margin", "Extends the baked result as a post process filter");
+ RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+
+ prop = RNA_def_property(srna, "cage_extrusion", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_range(prop, 0.0, MAXFLOAT);
+ RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 3);
+ RNA_def_property_ui_text(prop, "Cage Extrusion",
+ "Distance to use for the inward ray cast when using selected to active");
+ RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+
+ prop = RNA_def_property(srna, "normal_space", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_bitflag_sdna(prop, NULL, "normal_space");
+ RNA_def_property_enum_items(prop, normal_space_items);
+ RNA_def_property_ui_text(prop, "Normal Space", "Choose normal space for baking");
+ RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+
+ prop = RNA_def_property(srna, "normal_r", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_bitflag_sdna(prop, NULL, "normal_swizzle[0]");
+ RNA_def_property_enum_items(prop, normal_swizzle_items);
+ RNA_def_property_ui_text(prop, "Normal Space", "Axis to bake in red channel");
+ RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+
+ prop = RNA_def_property(srna, "normal_g", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_bitflag_sdna(prop, NULL, "normal_swizzle[1]");
+ RNA_def_property_enum_items(prop, normal_swizzle_items);
+ RNA_def_property_ui_text(prop, "Normal Space", "Axis to bake in green channel");
+ RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+
+ prop = RNA_def_property(srna, "normal_b", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_bitflag_sdna(prop, NULL, "normal_swizzle[2]");
+ RNA_def_property_enum_items(prop, normal_swizzle_items);
+ RNA_def_property_ui_text(prop, "Normal Space", "Axis to bake in blue channel");
+ RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+
+ prop = RNA_def_property(srna, "image_settings", PROP_POINTER, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NEVER_NULL);
+ RNA_def_property_pointer_sdna(prop, NULL, "im_format");
+ RNA_def_property_struct_type(prop, "ImageFormatSettings");
+ RNA_def_property_ui_text(prop, "Image Format", "");
+
+ prop = RNA_def_property(srna, "save_mode", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_bitflag_sdna(prop, NULL, "save_mode");
+ RNA_def_property_enum_items(prop, bake_save_mode_items);
+ RNA_def_property_ui_text(prop, "Save Mode", "Choose how to save the baking map");
+ RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+
+ /* flags */
+ prop = RNA_def_property(srna, "use_selected_to_active", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", R_BAKE_TO_ACTIVE);
+ RNA_def_property_ui_text(prop, "Selected to Active",
+ "Bake shading on the surface of selected objects to the active object");
+ RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+
+ prop = RNA_def_property(srna, "use_clear", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", R_BAKE_CLEAR);
+ RNA_def_property_ui_text(prop, "Clear",
+ "Clear Images before baking (internal only)");
+ RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+
+ prop = RNA_def_property(srna, "use_split_materials", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", R_BAKE_SPLIT_MAT);
+ RNA_def_property_ui_text(prop, "Split Materials",
+ "Split external images per material (external only)");
+ RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+
+ prop = RNA_def_property(srna, "use_automatic_name", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", R_BAKE_AUTO_NAME);
+ RNA_def_property_ui_text(prop, "Automatic Name",
+ "Automatically name the output file with the pass type (external only)");
+ RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+}
+
static void rna_def_scene_game_data(BlenderRNA *brna)
{
StructRNA *srna;
@@ -3595,16 +3773,6 @@ static void rna_def_render_layers(BlenderRNA *brna, PropertyRNA *cprop)
static void rna_def_scene_image_format_data(BlenderRNA *brna)
{
-#ifdef WITH_OPENEXR
- static EnumPropertyItem exr_codec_items[] = {
- {R_IMF_EXR_CODEC_NONE, "NONE", 0, "None", ""},
- {R_IMF_EXR_CODEC_PXR24, "PXR24", 0, "Pxr24 (lossy)", ""},
- {R_IMF_EXR_CODEC_ZIP, "ZIP", 0, "ZIP (lossless)", ""},
- {R_IMF_EXR_CODEC_PIZ, "PIZ", 0, "PIZ (lossless)", ""},
- {R_IMF_EXR_CODEC_RLE, "RLE", 0, "RLE (lossless)", ""},
- {0, NULL, 0, NULL, NULL}
- };
-#endif
#ifdef WITH_OPENJPEG
static EnumPropertyItem jp2_codec_items[] = {
@@ -4100,7 +4268,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
static EnumPropertyItem raytrace_structure_items[] = {
{R_RAYSTRUCTURE_AUTO, "AUTO", 0, "Auto", "Automatically select acceleration structure"},
{R_RAYSTRUCTURE_OCTREE, "OCTREE", 0, "Octree", "Use old Octree structure"},
- {R_RAYSTRUCTURE_BLIBVH, "BLIBVH", 0, "BLI BVH", "Use BLI K-Dop BVH.c"},
{R_RAYSTRUCTURE_VBVH, "VBVH", 0, "vBVH", "Use vBVH"},
{R_RAYSTRUCTURE_SIMD_SVBVH, "SIMD_SVBVH", 0, "SIMD SVBVH", "Use SIMD SVBVH"},
{R_RAYSTRUCTURE_SIMD_QBVH, "SIMD_QBVH", 0, "SIMD QBVH", "Use SIMD QBVH"},
@@ -4877,6 +5044,21 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_range(prop, 0.f, 10000.f);
RNA_def_property_ui_text(prop, "Line Thickness", "Line thickness in pixels");
+ /* Bake Settings */
+ prop = RNA_def_property(srna, "bake", PROP_POINTER, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NEVER_NULL);
+ RNA_def_property_pointer_sdna(prop, NULL, "bake");
+ RNA_def_property_struct_type(prop, "BakeSettings");
+ RNA_def_property_ui_text(prop, "Bake Data", "");
+
+ /* Nestled Data */
+ /* *** Non-Animated *** */
+ RNA_define_animate_sdna(false);
+ rna_def_bake_data(brna);
+ RNA_define_animate_sdna(true);
+
+ /* *** Animated *** */
+
/* Scene API */
RNA_api_scene_render(srna);
}
@@ -5095,12 +5277,6 @@ void RNA_def_scene(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}
};
- static EnumPropertyItem omp_threads_mode_items[] = {
- {SCE_OMP_AUTO, "AUTO", 0, "Auto-detect", "Automatically determine the number of threads"},
- {SCE_OMP_FIXED, "FIXED", 0, "Fixed", "Manually determine the number of threads"},
- {0, NULL, 0, NULL, NULL}
- };
-
/* Struct definition */
srna = RNA_def_struct(brna, "Scene", "ID");
RNA_def_struct_ui_text(srna, "Scene",
@@ -5246,6 +5422,14 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Preview Range End Frame", "Alternative end frame for UI playback");
RNA_def_property_update(prop, NC_SCENE | ND_FRAME, NULL);
+ /* Timeline / Time Navigation settings */
+ prop = RNA_def_property(srna, "show_keys_from_selected_only", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SCE_KEYS_NO_SELONLY);
+ RNA_def_property_ui_text(prop, "Only Keyframes from Selected Channels",
+ "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");
@@ -5463,16 +5647,6 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "ColorManagedSequencerColorspaceSettings");
RNA_def_property_ui_text(prop, "Sequencer Color Space Settings", "Settings of color space sequencer is working in");
- prop = RNA_def_property(srna, "omp_threads", PROP_INT, PROP_NONE);
- RNA_def_property_range(prop, 1, BLENDER_MAX_THREADS);
- RNA_def_property_int_funcs(prop, "rna_omp_threads_get", NULL, NULL);
- RNA_def_property_ui_text(prop, "OpenMP Threads",
- "Number of CPU threads to use for openmp");
-
- prop = RNA_def_property(srna, "omp_threads_mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_items(prop, omp_threads_mode_items);
- RNA_def_property_ui_text(prop, "OpenMP Mode", "Determine the amount of openmp threads used");
-
/* Nestled Data */
/* *** Non-Animated *** */
RNA_define_animate_sdna(false);
diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c
index 1d9464ab7c5..e0431fcff16 100644
--- a/source/blender/makesrna/intern/rna_screen.c
+++ b/source/blender/makesrna/intern/rna_screen.c
@@ -176,9 +176,9 @@ static void rna_View2D_region_to_view(struct View2D *v2d, int x, int y, float re
static void rna_View2D_view_to_region(struct View2D *v2d, float x, float y, int clip, int result[2])
{
if (clip)
- UI_view2d_view_to_region(v2d, x, y, &result[0], &result[1]);
+ UI_view2d_view_to_region_clip(v2d, x, y, &result[0], &result[1]);
else
- UI_view2d_to_region_no_clip(v2d, x, y, &result[0], &result[1]);
+ UI_view2d_view_to_region(v2d, x, y, &result[0], &result[1]);
}
#else
diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c
index e570daa8281..f5e59119baa 100644
--- a/source/blender/makesrna/intern/rna_sensor.c
+++ b/source/blender/makesrna/intern/rna_sensor.c
@@ -296,6 +296,11 @@ static void rna_def_sensor(BlenderRNA *brna)
RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1);
RNA_def_property_update(prop, NC_LOGIC, NULL);
+ prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SENS_DEACTIVATE);
+ RNA_def_property_ui_text(prop, "Active", "Set active state of the sensor");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_SHOW);
RNA_def_property_ui_text(prop, "Expanded", "Set sensor expanded in the user interface");
diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c
index 574472ae453..d478bf41287 100644
--- a/source/blender/makesrna/intern/rna_sequencer.c
+++ b/source/blender/makesrna/intern/rna_sequencer.c
@@ -1559,13 +1559,13 @@ static void rna_def_editor(BlenderRNA *brna)
prop = RNA_def_property(srna, "sequences", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "seqbase", NULL);
RNA_def_property_struct_type(prop, "Sequence");
- RNA_def_property_ui_text(prop, "Sequences", "");
+ RNA_def_property_ui_text(prop, "Sequences", "Top-level strips only");
RNA_api_sequences(brna, prop);
prop = RNA_def_property(srna, "sequences_all", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "seqbase", NULL);
RNA_def_property_struct_type(prop, "Sequence");
- RNA_def_property_ui_text(prop, "Sequences", "");
+ RNA_def_property_ui_text(prop, "All Sequences", "All strips, recursively including those inside metastrips");
RNA_def_property_collection_funcs(prop, "rna_SequenceEditor_sequences_all_begin",
"rna_SequenceEditor_sequences_all_next", NULL, NULL, NULL, NULL, NULL, NULL);
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 8fe5376322e..39d6e665077 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -112,8 +112,13 @@ static EnumPropertyItem transform_orientation_items[] = {
#ifndef RNA_RUNTIME
static EnumPropertyItem autosnap_items[] = {
{SACTSNAP_OFF, "NONE", 0, "No Auto-Snap", ""},
- {SACTSNAP_STEP, "STEP", 0, "Time Step", "Snap to 1.0 frame/second intervals"},
- {SACTSNAP_FRAME, "FRAME", 0, "Nearest Frame", "Snap to actual frames/seconds (nla-action time)"},
+ /* {-1, "", 0, "", ""}, */
+ {SACTSNAP_STEP, "STEP", 0, "Frame Step", "Snap to 1.0 frame intervals"},
+ {SACTSNAP_TSTEP, "TIME_STEP", 0, "Second Step", "Snap to 1.0 second intervals"},
+ /* {-1, "", 0, "", ""}, */
+ {SACTSNAP_FRAME, "FRAME", 0, "Nearest Frame", "Snap to actual frames (nla-action time)"},
+ {SACTSNAP_SECOND, "SECOND", 0, "Nearest Second", "Snap to actual seconds (nla-action time)"},
+ /* {-1, "", 0, "", ""}, */
{SACTSNAP_MARKER, "MARKER", 0, "Nearest Marker", "Snap to nearest marker"},
{0, NULL, 0, NULL, NULL}
};
@@ -161,6 +166,7 @@ static EnumPropertyItem buttons_texture_context_items[] = {
{SB_TEXC_WORLD, "WORLD", ICON_WORLD, "", "Show world textures"},
{SB_TEXC_LAMP, "LAMP", ICON_LAMP, "", "Show lamp textures"},
{SB_TEXC_PARTICLES, "PARTICLES", ICON_PARTICLES, "", "Show particles textures"},
+ {SB_TEXC_LINESTYLE, "LINESTYLE", ICON_LINE_DATA, "", "Show linestyle textures"},
{SB_TEXC_OTHER, "OTHER", ICON_TEXTURE, "", "Show other data textures"},
{0, NULL, 0, NULL, NULL}
};
@@ -284,6 +290,55 @@ static void rna_area_region_from_regiondata(PointerRNA *ptr, ScrArea **r_sa, ARe
area_region_from_regiondata(sc, regiondata, r_sa, r_ar);
}
+static int rna_Space_view2d_sync_get(PointerRNA *ptr)
+{
+ ScrArea *sa;
+ ARegion *ar;
+
+ sa = rna_area_from_space(ptr); /* can be NULL */
+ ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+ if (ar) {
+ View2D *v2d = &ar->v2d;
+ return (v2d->flag & V2D_VIEWSYNC_SCREEN_TIME) != 0;
+ }
+
+ return false;
+}
+
+static void rna_Space_view2d_sync_set(PointerRNA *ptr, int value)
+{
+ ScrArea *sa;
+ ARegion *ar;
+
+ sa = rna_area_from_space(ptr); /* can be NULL */
+ ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+ if (ar) {
+ View2D *v2d = &ar->v2d;
+ if (value) {
+ v2d->flag |= V2D_VIEWSYNC_SCREEN_TIME;
+ }
+ else {
+ v2d->flag &= ~V2D_VIEWSYNC_SCREEN_TIME;
+ }
+ }
+}
+
+static void rna_Space_view2d_sync_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
+{
+ ScrArea *sa;
+ ARegion *ar;
+
+ sa = rna_area_from_space(ptr); /* can be NULL */
+ ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+
+ if (ar) {
+ bScreen *sc = (bScreen *)ptr->id.data;
+ View2D *v2d = &ar->v2d;
+
+ UI_view2d_sync(sc, sa, v2d, V2D_LOCK_SET);
+ }
+}
+
static PointerRNA rna_CurrentOrientation_get(PointerRNA *ptr)
{
Scene *scene = ((bScreen *)ptr->id.data)->scene;
@@ -929,6 +984,10 @@ static EnumPropertyItem *rna_SpaceProperties_texture_context_itemf(bContext *C,
RNA_enum_items_add_value(&item, &totitem, buttons_texture_context_items, SB_TEXC_PARTICLES);
}
+ if (ED_texture_context_check_linestyle(C)) {
+ RNA_enum_items_add_value(&item, &totitem, buttons_texture_context_items, SB_TEXC_LINESTYLE);
+ }
+
if (ED_texture_context_check_others(C)) {
RNA_enum_items_add_value(&item, &totitem, buttons_texture_context_items, SB_TEXC_OTHER);
}
@@ -1315,6 +1374,12 @@ static void rna_def_space(BlenderRNA *brna)
RNA_def_property_enum_items(prop, space_type_items);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Type", "Space data type");
+
+ /* access to V2D_VIEWSYNC_SCREEN_TIME */
+ prop = RNA_def_property(srna, "show_locked_time", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_Space_view2d_sync_get", "rna_Space_view2d_sync_set");
+ RNA_def_property_ui_text(prop, "Lock Time to Other Windows", "");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Space_view2d_sync_update");
}
/* for all spaces that use a mask */
@@ -2936,12 +3001,6 @@ static void rna_def_space_time(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Space Timeline Editor", "Timeline editor space data");
/* view settings */
- prop = RNA_def_property(srna, "show_only_selected", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", TIME_ONLYACTSEL);
- RNA_def_property_ui_text(prop, "Only Selected Channels",
- "Show keyframes for active Object and/or its selected bones only");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
-
prop = RNA_def_property(srna, "show_frame_indicator", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", TIME_CFRA_NUM);
RNA_def_property_ui_text(prop, "Show Frame Number Indicator",
@@ -3339,6 +3398,7 @@ static void rna_def_space_node(BlenderRNA *brna)
{SNODE_TEX_OBJECT, "OBJECT", ICON_OBJECT_DATA, "Object", "Edit texture nodes from Object"},
{SNODE_TEX_WORLD, "WORLD", ICON_WORLD_DATA, "World", "Edit texture nodes from World"},
{SNODE_TEX_BRUSH, "BRUSH", ICON_BRUSH_DATA, "Brush", "Edit texture nodes from Brush"},
+ {SNODE_TEX_LINESTYLE, "LINESTYLE", ICON_LINE_DATA, "Line Style", "Edit texture nodes from Line Style"},
{0, NULL, 0, NULL, NULL}
};
diff --git a/source/blender/makesrna/intern/rna_speaker.c b/source/blender/makesrna/intern/rna_speaker.c
index 8a75aa2d227..d237dcffc96 100644
--- a/source/blender/makesrna/intern/rna_speaker.c
+++ b/source/blender/makesrna/intern/rna_speaker.c
@@ -65,15 +65,13 @@ static void rna_def_speaker(BlenderRNA *brna)
RNA_def_property_translation_context(prop, BLF_I18NCONTEXT_ID_SOUND);
/* RNA_def_property_update(prop, 0, "rna_Speaker_update"); */
-#if 0 /* This shouldn't be changed actually, hiding it! */
prop = RNA_def_property(srna, "relative", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SPK_RELATIVE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Relative", "Whether the source is relative to the camera or not");
/* RNA_def_property_update(prop, 0, "rna_Speaker_update"); */
-#endif
prop = RNA_def_property(srna, "sound", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "sound");
RNA_def_property_struct_type(prop, "Sound");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -82,7 +80,6 @@ static void rna_def_speaker(BlenderRNA *brna)
/* RNA_def_property_update(prop, 0, "rna_Speaker_update"); */
prop = RNA_def_property(srna, "volume_max", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "volume_max");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Maximum Volume", "Maximum volume, no matter how near the object is");
@@ -90,7 +87,6 @@ static void rna_def_speaker(BlenderRNA *brna)
/* RNA_def_property_update(prop, 0, "rna_Speaker_update"); */
prop = RNA_def_property(srna, "volume_min", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "volume_min");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Minimum Volume", "Minimum volume, no matter how far away the object is");
@@ -98,7 +94,6 @@ static void rna_def_speaker(BlenderRNA *brna)
/* RNA_def_property_update(prop, 0, "rna_Speaker_update"); */
prop = RNA_def_property(srna, "distance_max", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "distance_max");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_text(prop, "Maximum Distance",
@@ -107,7 +102,6 @@ static void rna_def_speaker(BlenderRNA *brna)
/* RNA_def_property_update(prop, 0, "rna_Speaker_update"); */
prop = RNA_def_property(srna, "distance_reference", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "distance_reference");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_text(prop, "Reference Distance", "Reference distance at which volume is 100 %");
@@ -115,7 +109,6 @@ static void rna_def_speaker(BlenderRNA *brna)
/* RNA_def_property_update(prop, 0, "rna_Speaker_update"); */
prop = RNA_def_property(srna, "attenuation", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "attenuation");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_text(prop, "Attenuation", "How strong the distance affects volume, depending on distance model");
@@ -123,7 +116,6 @@ static void rna_def_speaker(BlenderRNA *brna)
/* RNA_def_property_update(prop, 0, "rna_Speaker_update"); */
prop = RNA_def_property(srna, "cone_angle_outer", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "cone_angle_outer");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_range(prop, 0.0f, 360.0f);
RNA_def_property_ui_text(prop, "Outer Cone Angle",
@@ -133,7 +125,6 @@ static void rna_def_speaker(BlenderRNA *brna)
/* RNA_def_property_update(prop, 0, "rna_Speaker_update"); */
prop = RNA_def_property(srna, "cone_angle_inner", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "cone_angle_inner");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_range(prop, 0.0f, 360.0f);
RNA_def_property_ui_text(prop, "Inner Cone Angle",
@@ -142,7 +133,6 @@ static void rna_def_speaker(BlenderRNA *brna)
/* RNA_def_property_update(prop, 0, "rna_Speaker_update"); */
prop = RNA_def_property(srna, "cone_volume_outer", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "cone_volume_outer");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Outer Cone Volume", "Volume outside the outer cone");
@@ -150,7 +140,6 @@ static void rna_def_speaker(BlenderRNA *brna)
/* RNA_def_property_update(prop, 0, "rna_Speaker_update"); */
prop = RNA_def_property(srna, "volume", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "volume");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Volume", "How loud the sound is");
RNA_def_property_translation_context(prop, BLF_I18NCONTEXT_ID_SOUND);
@@ -158,7 +147,6 @@ static void rna_def_speaker(BlenderRNA *brna)
/* RNA_def_property_update(prop, 0, "rna_Speaker_update"); */
prop = RNA_def_property(srna, "pitch", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "pitch");
RNA_def_property_range(prop, 0.1f, 10.0f);
RNA_def_property_ui_text(prop, "Pitch", "Playback pitch of the sound");
RNA_def_property_translation_context(prop, BLF_I18NCONTEXT_ID_SOUND);
diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c
index 0d327d6da0a..f098a659671 100644
--- a/source/blender/makesrna/intern/rna_texture.c
+++ b/source/blender/makesrna/intern/rna_texture.c
@@ -245,6 +245,9 @@ void rna_TextureSlot_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRN
case ID_BR:
WM_main_add_notifier(NC_BRUSH, id);
break;
+ case ID_LS:
+ WM_main_add_notifier(NC_LINESTYLE, id);
+ break;
case ID_PA:
{
MTex *mtex = ptr->data;
diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c
index 847efa2fad5..537ffe630a2 100644
--- a/source/blender/makesrna/intern/rna_tracking.c
+++ b/source/blender/makesrna/intern/rna_tracking.c
@@ -372,6 +372,17 @@ static void rna_tracking_stabTracks_active_index_range(PointerRNA *ptr, int *min
*max = max_ii(0, clip->tracking.stabilization.tot_track - 1);
}
+static void rna_tracking_resetIntrinsics(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
+{
+ MovieClip *clip = (MovieClip *)ptr->id.data;
+ MovieTracking *tracking = &clip->tracking;
+
+ if (tracking->camera.intrinsics) {
+ BKE_tracking_distortion_free(tracking->camera.intrinsics);
+ tracking->camera.intrinsics = NULL;
+ }
+}
+
static void rna_tracking_flushUpdate(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
{
MovieClip *clip = (MovieClip *)ptr->id.data;
@@ -990,6 +1001,13 @@ static void rna_def_trackingCamera(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
+ static EnumPropertyItem distortion_model_items[] = {
+ {TRACKING_DISTORTION_MODEL_POLYNOMIAL, "POLYNOMIAL", 0, "Polynomial", "Radial distortion model which fits common cameras"},
+ {TRACKING_DISTORTION_MODEL_DIVISION, "DIVISION", 0, "Divisions", "Division distortion model which "
+ "better represents wide-angle cameras"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
static EnumPropertyItem camera_units_items[] = {
{CAMERA_UNITS_PX, "PIXELS", 0, "px", "Use pixels for units of focal length"},
{CAMERA_UNITS_MM, "MILLIMETERS", 0, "mm", "Use millimeters for units of focal length"},
@@ -1000,6 +1018,13 @@ static void rna_def_trackingCamera(BlenderRNA *brna)
RNA_def_struct_path_func(srna, "rna_trackingCamera_path");
RNA_def_struct_ui_text(srna, "Movie tracking camera data", "Match-moving camera data for tracking");
+ /* Distortion model */
+ prop = RNA_def_property(srna, "distortion_model", PROP_ENUM, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_enum_items(prop, distortion_model_items);
+ RNA_def_property_ui_text(prop, "Distortion Model", "Distortion model used for camera lenses");
+ RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_tracking_resetIntrinsics");
+
/* Sensor */
prop = RNA_def_property(srna, "sensor_width", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "sensor_width");
@@ -1065,6 +1090,19 @@ static void rna_def_trackingCamera(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "K3", "Third coefficient of third order polynomial radial distortion");
RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_tracking_flushUpdate");
+ /* Division distortion parameters */
+ prop = RNA_def_property(srna, "division_k1", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_range(prop, -10, 10, 0.1, 3);
+ RNA_def_property_ui_text(prop, "K1", "First coefficient of second order division distortion");
+ RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_tracking_flushUpdate");
+
+ prop = RNA_def_property(srna, "division_k2", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_range(prop, -10, 10, 0.1, 3);
+ RNA_def_property_ui_text(prop, "K2", "First coefficient of second order division distortion");
+ RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_tracking_flushUpdate");
+
/* pixel aspect */
prop = RNA_def_property(srna, "pixel_aspect", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "pixel_aspect");
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 7271d35086e..7c101fb19be 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -2252,6 +2252,12 @@ static void rna_def_userdef_theme_space_image(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Other Object UVs", "");
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");
+
rna_def_userdef_theme_spaces_curves(srna, false, false, false);
}
@@ -4059,11 +4065,11 @@ static void rna_def_userdef_input(BlenderRNA *brna)
/* 3D mouse settings */
/* global options */
prop = RNA_def_property(srna, "ndof_sensitivity", PROP_FLOAT, PROP_NONE);
- RNA_def_property_range(prop, 0.25f, 40.0f);
+ 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.25f, 40.0f);
+ 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");
prop = RNA_def_property(srna, "ndof_pan_yz_swap_axis", PROP_BOOLEAN, PROP_NONE);
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index 694b66b5076..0a4a6140c02 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -39,9 +39,7 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
-#include "BLI_string.h"
#include "BLI_ghash.h"
-#include "BLI_edgehash.h"
#include "DNA_curve_types.h"
#include "DNA_meshdata_types.h"
@@ -51,9 +49,7 @@
#include "BKE_cdderivedmesh.h"
#include "BKE_displist.h"
#include "BKE_curve.h"
-#include "BKE_mesh.h"
#include "BKE_modifier.h"
-#include "BKE_object.h"
#include "MOD_util.h"
@@ -191,7 +187,7 @@ static int *find_doubles_index_map(BMesh *bm, BMOperator *dupe_op,
}
/* above loops over all, so set all to dirty, if this is somehow
* setting valid values, this line can be removed - campbell */
- bm->elem_index_dirty |= BM_VERT | BM_EDGE | BM_FACE;
+ bm->elem_index_dirty |= BM_ALL;
(*index_map_length) = i;
index_map = MEM_callocN(sizeof(int) * (*index_map_length), "index_map");
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index e5e7e004bbf..fc65990df20 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -41,16 +41,12 @@
#include "BKE_cdderivedmesh.h"
#include "BKE_deform.h"
#include "BKE_modifier.h"
-#include "BKE_mesh.h"
#include "MOD_util.h"
#include "bmesh.h"
#include "bmesh_tools.h"
-#include "MEM_guardedalloc.h"
-
-
static void initData(ModifierData *md)
{
BevelModifierData *bmd = (BevelModifierData *) md;
diff --git a/source/blender/modifiers/intern/MOD_boolean_util.c b/source/blender/modifiers/intern/MOD_boolean_util.c
index e0f8a18d54a..99016a0a41b 100644
--- a/source/blender/modifiers/intern/MOD_boolean_util.c
+++ b/source/blender/modifiers/intern/MOD_boolean_util.c
@@ -27,18 +27,16 @@
* \ingroup modifiers
*/
+#include "MEM_guardedalloc.h"
+
#include "DNA_material_types.h"
#include "DNA_meshdata_types.h"
-#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
-#include "MEM_guardedalloc.h"
-
#include "BLI_utildefines.h"
#include "BLI_alloca.h"
#include "BLI_ghash.h"
#include "BLI_math.h"
-#include "BLI_polyfill2d.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_material.h"
@@ -91,6 +89,41 @@ static void DM_loop_interp_from_poly(DerivedMesh *source_dm,
source_poly->totloop, target_loop_index);
}
+typedef struct DMArrays {
+ MVert *mvert;
+ MEdge *medge;
+ MLoop *mloop;
+ MPoly *mpoly;
+ bool mvert_allocated;
+ bool medge_allocated;
+ bool mloop_allocated;
+ bool mpoly_allocated;
+} DMArrays;
+
+static void dm_arrays_get(DerivedMesh *dm, DMArrays *arrays)
+{
+ arrays->mvert = DM_get_vert_array(dm, &arrays->mvert_allocated);
+ arrays->medge = DM_get_edge_array(dm, &arrays->medge_allocated);
+ arrays->mloop = DM_get_loop_array(dm, &arrays->mloop_allocated);
+ arrays->mpoly = DM_get_poly_array(dm, &arrays->mpoly_allocated);
+}
+
+static void dm_arrays_free(DMArrays *arrays)
+{
+ if (arrays->mvert_allocated) {
+ MEM_freeN(arrays->mvert);
+ }
+ if (arrays->medge_allocated) {
+ MEM_freeN(arrays->medge);
+ }
+ if (arrays->mloop_allocated) {
+ MEM_freeN(arrays->mloop);
+ }
+ if (arrays->mpoly_allocated) {
+ MEM_freeN(arrays->mpoly);
+ }
+}
+
/* **** Importer from derived mesh to Carve **** */
typedef struct ImportMeshData {
@@ -636,25 +669,30 @@ static int operation_from_optype(int int_op_type)
return operation;
}
-static void prepare_import_data(Object *object, DerivedMesh *dm, ImportMeshData *import_data)
+static void prepare_import_data(Object *object,
+ DerivedMesh *dm,
+ const DMArrays *dm_arrays,
+ ImportMeshData *import_data)
{
import_data->dm = dm;
copy_m4_m4(import_data->obmat, object->obmat);
- import_data->mvert = dm->getVertArray(dm);
- import_data->medge = dm->getEdgeArray(dm);
- import_data->mloop = dm->getLoopArray(dm);
- import_data->mpoly = dm->getPolyArray(dm);
+ import_data->mvert = dm_arrays->mvert;
+ import_data->medge = dm_arrays->medge;
+ import_data->mloop = dm_arrays->mloop;
+ import_data->mpoly = dm_arrays->mpoly;
}
-static struct CarveMeshDescr *carve_mesh_from_dm(Object *object, DerivedMesh *dm)
+static struct CarveMeshDescr *carve_mesh_from_dm(Object *object,
+ DerivedMesh *dm,
+ const DMArrays *dm_arrays)
{
ImportMeshData import_data;
- prepare_import_data(object, dm, &import_data);
+ prepare_import_data(object, dm, dm_arrays, &import_data);
return carve_addMesh(&import_data, &MeshImporter);
}
-static void prepare_export_data(Object *object_left, DerivedMesh *dm_left,
- Object *object_right, DerivedMesh *dm_right,
+static void prepare_export_data(Object *object_left, DerivedMesh *dm_left, const DMArrays *dm_left_arrays,
+ Object *object_right, DerivedMesh *dm_right, const DMArrays *dm_right_arrays,
ExportMeshData *export_data)
{
float object_right_imat[4][4];
@@ -667,12 +705,12 @@ static void prepare_export_data(Object *object_left, DerivedMesh *dm_left,
export_data->dm_left = dm_left;
export_data->dm_right = dm_right;
- export_data->mvert_left = dm_left->getVertArray(dm_left);
- export_data->mloop_left = dm_left->getLoopArray(dm_left);
- export_data->mpoly_left = dm_left->getPolyArray(dm_left);
- export_data->mvert_right = dm_right->getVertArray(dm_right);
- export_data->mloop_right = dm_right->getLoopArray(dm_right);
- export_data->mpoly_right = dm_right->getPolyArray(dm_right);
+ export_data->mvert_left = dm_left_arrays->mvert;
+ export_data->mloop_left = dm_left_arrays->mloop;
+ export_data->mpoly_left = dm_left_arrays->mpoly;
+ export_data->mvert_right = dm_right_arrays->mvert;
+ export_data->mloop_right = dm_right_arrays->mloop;
+ export_data->mpoly_right = dm_right_arrays->mpoly;
export_data->material_hash = BLI_ghash_ptr_new("CSG_mat gh");
@@ -693,6 +731,7 @@ DerivedMesh *NewBooleanDerivedMesh(DerivedMesh *dm, struct Object *ob,
DerivedMesh *output_dm = NULL;
int operation;
bool result;
+ DMArrays dm_left_arrays, dm_right_arrays;
if (dm == NULL || dm_select == NULL) {
return NULL;
@@ -703,8 +742,11 @@ DerivedMesh *NewBooleanDerivedMesh(DerivedMesh *dm, struct Object *ob,
return NULL;
}
- left = carve_mesh_from_dm(ob_select, dm_select);
- right = carve_mesh_from_dm(ob, dm);
+ dm_arrays_get(dm_select, &dm_left_arrays);
+ dm_arrays_get(dm, &dm_right_arrays);
+
+ left = carve_mesh_from_dm(ob_select, dm_select, &dm_left_arrays);
+ right = carve_mesh_from_dm(ob, dm, &dm_right_arrays);
result = carve_performBooleanOperation(left, right, operation, &output);
@@ -714,7 +756,9 @@ DerivedMesh *NewBooleanDerivedMesh(DerivedMesh *dm, struct Object *ob,
if (result) {
ExportMeshData export_data;
- prepare_export_data(ob_select, dm_select, ob, dm, &export_data);
+ prepare_export_data(ob_select, dm_select, &dm_left_arrays,
+ ob, dm, &dm_right_arrays,
+ &export_data);
carve_exportMesh(output, &MeshExporter, &export_data);
output_dm = export_data.dm;
@@ -726,5 +770,8 @@ DerivedMesh *NewBooleanDerivedMesh(DerivedMesh *dm, struct Object *ob,
carve_deleteMesh(output);
}
+ dm_arrays_free(&dm_left_arrays);
+ dm_arrays_free(&dm_right_arrays);
+
return output_dm;
}
diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c
index ab9c15f88db..f6ade2bf303 100644
--- a/source/blender/modifiers/intern/MOD_build.c
+++ b/source/blender/modifiers/intern/MOD_build.c
@@ -46,7 +46,6 @@
#include "BKE_cdderivedmesh.h"
#include "BKE_mesh.h"
#include "BKE_modifier.h"
-#include "BKE_object.h"
#include "BKE_particle.h"
#include "BKE_scene.h"
diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c
index 76a0ed59d06..ec077631c85 100644
--- a/source/blender/modifiers/intern/MOD_cast.c
+++ b/source/blender/modifiers/intern/MOD_cast.c
@@ -38,7 +38,6 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
-#include "BLI_string.h"
#include "BKE_deform.h"
diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c
index 1f24662960a..8f6c533ae4c 100644
--- a/source/blender/modifiers/intern/MOD_collision.c
+++ b/source/blender/modifiers/intern/MOD_collision.c
@@ -33,7 +33,6 @@
*/
-#include "DNA_scene_types.h"
#include "DNA_object_types.h"
#include "DNA_meshdata_types.h"
@@ -47,7 +46,6 @@
#include "BKE_cdderivedmesh.h"
#include "BKE_global.h"
#include "BKE_modifier.h"
-#include "BKE_object.h"
#include "BKE_pointcache.h"
#include "BKE_scene.h"
diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c
index 792fc7e7cf8..fbc72cef0e8 100644
--- a/source/blender/modifiers/intern/MOD_curve.c
+++ b/source/blender/modifiers/intern/MOD_curve.c
@@ -39,7 +39,6 @@
#include "DNA_object_types.h"
#include "BLI_utildefines.h"
-#include "BLI_string.h"
#include "BKE_cdderivedmesh.h"
diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c
index 54f2e688f31..a23873fcd8a 100644
--- a/source/blender/modifiers/intern/MOD_displace.c
+++ b/source/blender/modifiers/intern/MOD_displace.c
@@ -36,9 +36,7 @@
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
-#include "BLI_math.h"
#include "BLI_utildefines.h"
-#include "BLI_string.h"
#include "BKE_cdderivedmesh.h"
diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c
index df72d31596c..838ceb5cfe0 100644
--- a/source/blender/modifiers/intern/MOD_dynamicpaint.c
+++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c
@@ -32,8 +32,6 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
-#include "MEM_guardedalloc.h"
-
#include "BLI_utildefines.h"
#include "BKE_cdderivedmesh.h"
diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c
index 139a3db17f2..127972a2e40 100644
--- a/source/blender/modifiers/intern/MOD_explode.c
+++ b/source/blender/modifiers/intern/MOD_explode.c
@@ -48,7 +48,6 @@
#include "BKE_lattice.h"
#include "BKE_mesh.h"
#include "BKE_modifier.h"
-#include "BKE_object.h"
#include "BKE_particle.h"
#include "BKE_scene.h"
@@ -801,7 +800,7 @@ static DerivedMesh *explodeMesh(ExplodeModifierData *emd,
float rot[4];
float cfra;
/* float timestep; */
- int *facepa = emd->facepa;
+ const int *facepa = emd->facepa;
int totdup = 0, totvert = 0, totface = 0, totpart = 0, delface = 0;
int i, v, u;
unsigned int ed_v1, ed_v2, mindex = 0;
diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c
index e7eb5d64b9d..77fbb482f8b 100644
--- a/source/blender/modifiers/intern/MOD_fluidsim_util.c
+++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c
@@ -45,12 +45,9 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
-#include "BLI_threads.h"
-#include "BKE_main.h"
#include "BKE_fluidsim.h" /* ensure definitions here match */
#include "BKE_cdderivedmesh.h"
-#include "BKE_mesh.h"
#include "BKE_global.h" /* G.main->name only */
#include "MOD_fluidsim_util.h"
diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c
index 31aad533727..c89bc8c1d41 100644
--- a/source/blender/modifiers/intern/MOD_hook.c
+++ b/source/blender/modifiers/intern/MOD_hook.c
@@ -33,13 +33,11 @@
*/
-#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
-#include "BLI_string.h"
#include "BKE_action.h"
#include "BKE_cdderivedmesh.h"
diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c
index 31bae2a192e..d3bd05baa6d 100644
--- a/source/blender/modifiers/intern/MOD_laplaciandeform.c
+++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c
@@ -34,7 +34,6 @@
#include "MEM_guardedalloc.h"
-#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_particle.h"
diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.c b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
index e494fbf23fd..9ba0bfc7ce9 100644
--- a/source/blender/modifiers/intern/MOD_laplaciansmooth.c
+++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
@@ -34,18 +34,12 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
-#include "BLI_string.h"
#include "MEM_guardedalloc.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_deform.h"
-#include "BKE_displist.h"
-#include "BKE_mesh.h"
#include "BKE_modifier.h"
-#include "BKE_object.h"
-#include "BKE_particle.h"
-#include "BKE_editmesh.h"
#include "MOD_modifiertypes.h"
#include "MOD_util.h"
diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c
index 0a1ca6e52c4..7f21376ef48 100644
--- a/source/blender/modifiers/intern/MOD_mask.c
+++ b/source/blender/modifiers/intern/MOD_mask.c
@@ -37,7 +37,6 @@
#include "BLI_utildefines.h"
#include "BLI_listbase.h"
-#include "BLI_string.h"
#include "BLI_ghash.h"
#include "DNA_armature_types.h"
@@ -47,7 +46,6 @@
#include "BKE_action.h" /* BKE_pose_channel_find_name */
#include "BKE_cdderivedmesh.h"
-#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "BKE_deform.h"
diff --git a/source/blender/modifiers/intern/MOD_meshcache_pc2.c b/source/blender/modifiers/intern/MOD_meshcache_pc2.c
index 1897454e132..ac0363f8673 100644
--- a/source/blender/modifiers/intern/MOD_meshcache_pc2.c
+++ b/source/blender/modifiers/intern/MOD_meshcache_pc2.c
@@ -30,7 +30,6 @@
#include "BLI_sys_types.h"
#include "BLI_utildefines.h"
-#include "BLI_endian_switch.h"
#include "BLI_fileops.h"
#include "BLI_math.h"
diff --git a/source/blender/modifiers/intern/MOD_meshcache_util.c b/source/blender/modifiers/intern/MOD_meshcache_util.c
index 10560a85a3f..c263c4810e4 100644
--- a/source/blender/modifiers/intern/MOD_meshcache_util.c
+++ b/source/blender/modifiers/intern/MOD_meshcache_util.c
@@ -27,12 +27,8 @@
#include "BLI_utildefines.h"
#include "BLI_math.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
-#include "MEM_guardedalloc.h"
-
#include "MOD_meshcache_util.h"
void MOD_meshcache_calc_range(const float frame, const char interp,
diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c
index 63e60d4b898..959bbdcbca9 100644
--- a/source/blender/modifiers/intern/MOD_meshdeform.c
+++ b/source/blender/modifiers/intern/MOD_meshdeform.c
@@ -32,9 +32,9 @@
* \ingroup modifiers
*/
-#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
@@ -43,7 +43,6 @@
#include "BKE_cdderivedmesh.h"
#include "BKE_global.h"
-#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "BKE_deform.h"
#include "BKE_editmesh.h"
@@ -187,12 +186,10 @@ static void meshdeformModifier_do(
float (*vertexCos)[3], int numVerts)
{
MeshDeformModifierData *mmd = (MeshDeformModifierData *) md;
- struct Mesh *me = (mmd->object) ? mmd->object->data : NULL;
- BMEditMesh *em = me ? me->edit_btmesh : NULL;
DerivedMesh *tmpdm, *cagedm;
MDeformVert *dvert = NULL;
MDefInfluence *influences;
- int *offsets;
+ const int *offsets;
float imat[4][4], cagemat[4][4], iobmat[4][4], icagemat[3][3], cmat[4][4];
float weight, totweight, fac, co[3], (*dco)[3], (*bindcagecos)[3];
int a, b, totvert, totcagevert, defgrp_index;
@@ -201,8 +198,18 @@ static void meshdeformModifier_do(
if (!mmd->object || (!mmd->bindcagecos && !mmd->bindfunc))
return;
- /* get cage derivedmesh */
- if (em) {
+ /* Get cage derivedmesh.
+ *
+ * Only do this is the target object is in edit mode by itself, meaning
+ * we don't allow linked edit meshes here.
+ * This is because editbmesh_get_derived_cage_and_final() might easily
+ * conflict with the thread which evaluates object which is in the edit
+ * mode for this mesh.
+ *
+ * We'll support this case once granular dependency graph is landed.
+ */
+ if (mmd->object == md->scene->obedit) {
+ BMEditMesh *em = BKE_editmesh_from_object(mmd->object);
tmpdm = editbmesh_get_derived_cage_and_final(md->scene, mmd->object, em, &cagedm, 0);
if (tmpdm)
tmpdm->release(tmpdm);
diff --git a/source/blender/modifiers/intern/MOD_mirror.c b/source/blender/modifiers/intern/MOD_mirror.c
index a3ac09d87f2..5cece9d349f 100644
--- a/source/blender/modifiers/intern/MOD_mirror.c
+++ b/source/blender/modifiers/intern/MOD_mirror.c
@@ -39,7 +39,6 @@
#include "BLI_math.h"
#include "BKE_cdderivedmesh.h"
-#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "BKE_deform.h"
diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c
index 91b1b2cbbca..a324702a6ae 100644
--- a/source/blender/modifiers/intern/MOD_ocean.c
+++ b/source/blender/modifiers/intern/MOD_ocean.c
@@ -29,22 +29,17 @@
* \ingroup modifiers
*/
-#include "MEM_guardedalloc.h"
-
#include "DNA_customdata_types.h"
#include "DNA_object_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_scene_types.h"
-#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_math_inline.h"
#include "BLI_utildefines.h"
-#include "BLI_string.h"
#include "BKE_cdderivedmesh.h"
-#include "BKE_global.h"
#include "BKE_modifier.h"
#include "BKE_ocean.h"
diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c
index 8e72c49740f..a41fbb03462 100644
--- a/source/blender/modifiers/intern/MOD_particlesystem.c
+++ b/source/blender/modifiers/intern/MOD_particlesystem.c
@@ -41,10 +41,8 @@
#include "BKE_cdderivedmesh.h"
-#include "BKE_material.h"
#include "BKE_modifier.h"
#include "BKE_particle.h"
-#include "BKE_scene.h"
#include "MOD_util.h"
diff --git a/source/blender/modifiers/intern/MOD_remesh.c b/source/blender/modifiers/intern/MOD_remesh.c
index 8f0db9f8ebf..6d76dc51ac7 100644
--- a/source/blender/modifiers/intern/MOD_remesh.c
+++ b/source/blender/modifiers/intern/MOD_remesh.c
@@ -32,7 +32,6 @@
#include "BKE_cdderivedmesh.h"
#include "BKE_DerivedMesh.h"
-#include "BKE_mesh.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c
index 9e5b4fad439..ff7cc01232b 100644
--- a/source/blender/modifiers/intern/MOD_screw.c
+++ b/source/blender/modifiers/intern/MOD_screw.c
@@ -190,7 +190,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
unsigned int vc_tot_linked = 0;
short other_axis_1, other_axis_2;
- float *tmpf1, *tmpf2;
+ const float *tmpf1, *tmpf2;
unsigned int edge_offset;
diff --git a/source/blender/modifiers/intern/MOD_shapekey.c b/source/blender/modifiers/intern/MOD_shapekey.c
index fef4c7ccedb..45725d1c453 100644
--- a/source/blender/modifiers/intern/MOD_shapekey.c
+++ b/source/blender/modifiers/intern/MOD_shapekey.c
@@ -32,22 +32,18 @@
* \ingroup modifiers
*/
-
#include "BLI_math.h"
#include "DNA_key_types.h"
#include "BLI_utildefines.h"
-
#include "BKE_cdderivedmesh.h"
#include "BKE_key.h"
#include "BKE_particle.h"
#include "MOD_modifiertypes.h"
-#include "MEM_guardedalloc.h"
-
static void deformVerts(ModifierData *md, Object *ob,
DerivedMesh *UNUSED(derivedData),
float (*vertexCos)[3],
diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c
index 5a9c2b4ffe1..ccba2097264 100644
--- a/source/blender/modifiers/intern/MOD_simpledeform.c
+++ b/source/blender/modifiers/intern/MOD_simpledeform.c
@@ -37,11 +37,9 @@
#include "DNA_object_types.h"
#include "BLI_math.h"
-#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BKE_cdderivedmesh.h"
-#include "BKE_lattice.h"
#include "BKE_modifier.h"
#include "BKE_deform.h"
#include "BKE_shrinkwrap.h"
diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c
index 6dc3f9cf240..019eb54a9ee 100644
--- a/source/blender/modifiers/intern/MOD_skin.c
+++ b/source/blender/modifiers/intern/MOD_skin.c
@@ -59,7 +59,6 @@
#include "MEM_guardedalloc.h"
-#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_modifier_types.h"
@@ -67,10 +66,8 @@
#include "BLI_utildefines.h"
#include "BLI_array.h"
#include "BLI_heap.h"
-#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_stack.h"
-#include "BLI_string.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_deform.h"
@@ -752,7 +749,7 @@ static EMat *build_edge_mats(const MVertSkin *vs,
* having any special cases for dealing with sharing a frame between
* two hulls.) */
static int calc_edge_subdivisions(const MVert *mvert, const MVertSkin *nodes,
- const MEdge *e, int *degree)
+ const MEdge *e, const int *degree)
{
/* prevent memory errors [#38003] */
#define NUM_SUBDIVISIONS_MAX 128
diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c
index eb8c62cfd89..d1ad8f1fcfc 100644
--- a/source/blender/modifiers/intern/MOD_smooth.c
+++ b/source/blender/modifiers/intern/MOD_smooth.c
@@ -37,7 +37,6 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
-#include "BLI_string.h"
#include "MEM_guardedalloc.h"
diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c
index 721a77df29c..c212c13e396 100644
--- a/source/blender/modifiers/intern/MOD_solidify.c
+++ b/source/blender/modifiers/intern/MOD_solidify.c
@@ -37,7 +37,6 @@
#include "BLI_utildefines.h"
#include "BLI_bitmap.h"
#include "BLI_math.h"
-#include "BLI_string.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_mesh.h"
@@ -538,13 +537,13 @@ static DerivedMesh *applyModifier(
LIKELY(((orig_medge[ml[i_curr].e].flag & ME_EDGE_TMP_TAG) == 0) &&
((orig_medge[ml[i_next].e].flag & ME_EDGE_TMP_TAG) == 0)))
{
- vert_angles[vidx] += shell_angle_to_dist(angle_normalized_v3v3(vert_nors[vidx], face_nors[i])) * angle;
+ vert_angles[vidx] += shell_v3v3_normalized_to_dist(vert_nors[vidx], face_nors[i]) * angle;
}
else {
vert_angles[vidx] += angle;
}
#else
- vert_angles[vidx] += shell_angle_to_dist(angle_normalized_v3v3(vert_nors[vidx], face_nors[i])) * angle;
+ vert_angles[vidx] += shell_v3v3_normalized_to_dist(vert_nors[vidx], face_nors[i]) * angle;
#endif
/* --- end non-angle-calc section --- */
diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c
index 0cc9b8bb77b..386d6d985fb 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -34,7 +34,6 @@
#include "DNA_curve_types.h"
#include "DNA_image_types.h"
-#include "DNA_lattice_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c
index a9c0ac9b93d..2ff93efdb86 100644
--- a/source/blender/modifiers/intern/MOD_uvproject.c
+++ b/source/blender/modifiers/intern/MOD_uvproject.c
@@ -38,10 +38,8 @@
#include "DNA_meshdata_types.h"
#include "DNA_camera_types.h"
#include "DNA_object_types.h"
-#include "DNA_scene_types.h"
#include "BLI_math.h"
-#include "BLI_string.h"
#include "BLI_uvproject.h"
#include "BLI_utildefines.h"
diff --git a/source/blender/modifiers/intern/MOD_uvwarp.c b/source/blender/modifiers/intern/MOD_uvwarp.c
index 4640a36909b..f5ff30e35d9 100644
--- a/source/blender/modifiers/intern/MOD_uvwarp.c
+++ b/source/blender/modifiers/intern/MOD_uvwarp.c
@@ -31,7 +31,6 @@
#include "DNA_object_types.h"
#include "BLI_math.h"
-#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BKE_action.h" /* BKE_pose_channel_find_name */
diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c
index b9c89f404bb..f6714e79401 100644
--- a/source/blender/modifiers/intern/MOD_warp.c
+++ b/source/blender/modifiers/intern/MOD_warp.c
@@ -34,7 +34,6 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
-#include "BLI_string.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_modifier.h"
diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c
index 1a81b1fdf4c..47e4c502a90 100644
--- a/source/blender/modifiers/intern/MOD_wave.c
+++ b/source/blender/modifiers/intern/MOD_wave.c
@@ -40,13 +40,11 @@
#include "DNA_object_types.h"
#include "BLI_utildefines.h"
-#include "BLI_string.h"
#include "BKE_deform.h"
#include "BKE_DerivedMesh.h"
#include "BKE_library.h"
-#include "BKE_object.h"
#include "BKE_scene.h"
#include "BKE_texture.h"
diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c
index a9062c31e66..f36abcceae0 100644
--- a/source/blender/modifiers/intern/MOD_weightvgedit.c
+++ b/source/blender/modifiers/intern/MOD_weightvgedit.c
@@ -30,8 +30,6 @@
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
-#include "BLI_math.h"
-#include "BLI_string.h"
#include "BLI_listbase.h"
#include "BLI_rand.h"
@@ -45,7 +43,6 @@
#include "BKE_colortools.h" /* CurveMapping. */
#include "BKE_deform.h"
#include "BKE_library.h"
-#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "BKE_texture.h" /* Texture masking. */
diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c
index cc930213cb5..bdc1099d682 100644
--- a/source/blender/modifiers/intern/MOD_weightvgmix.c
+++ b/source/blender/modifiers/intern/MOD_weightvgmix.c
@@ -30,10 +30,8 @@
#include "BLI_utildefines.h"
#include "BLI_math.h"
-#include "BLI_string.h"
#include "BLI_listbase.h"
-#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
@@ -41,7 +39,6 @@
#include "BKE_cdderivedmesh.h"
#include "BKE_deform.h"
#include "BKE_library.h"
-#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "BKE_texture.h" /* Texture masking. */
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index b2ba495d043..f5ae8561300 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -32,7 +32,6 @@
#include "BLI_ghash.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
-#include "BLI_string.h"
#include "BLI_rand.h"
#include "DNA_mesh_types.h"
@@ -43,7 +42,6 @@
#include "BKE_cdderivedmesh.h"
#include "BKE_deform.h"
#include "BKE_library.h"
-#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "BKE_shrinkwrap.h" /* For SpaceTransform stuff. */
#include "BKE_texture.h" /* Texture masking. */
diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c
index a1bc369fd94..cd69cf4982d 100644
--- a/source/blender/nodes/composite/node_composite_tree.c
+++ b/source/blender/nodes/composite/node_composite_tree.c
@@ -32,20 +32,16 @@
#include <stdio.h>
-#include "DNA_anim_types.h"
#include "DNA_color_types.h"
#include "DNA_scene_types.h"
#include "DNA_node_types.h"
#include "BLI_listbase.h"
-#include "BLI_threads.h"
#include "BLF_translation.h"
-#include "BKE_animsys.h"
#include "BKE_colortools.h"
#include "BKE_context.h"
-#include "BKE_fcurve.h"
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_node.h"
diff --git a/source/blender/nodes/composite/nodes/node_composite_common.c b/source/blender/nodes/composite/nodes/node_composite_common.c
index 69f912346f6..36c12693bdf 100644
--- a/source/blender/nodes/composite/nodes/node_composite_common.c
+++ b/source/blender/nodes/composite/nodes/node_composite_common.c
@@ -58,7 +58,7 @@ void register_node_type_cmp_group(void)
RNA_struct_blender_type_set(ntype.ext.srna, &ntype);
node_type_socket_templates(&ntype, NULL, NULL);
- node_type_size(&ntype, 120, 60, 400);
+ node_type_size(&ntype, 140, 60, 400);
node_type_label(&ntype, node_group_label);
node_type_update(&ntype, NULL, node_group_verify);
diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c
index af9108b2559..ae834f9e7cc 100644
--- a/source/blender/nodes/intern/node_common.c
+++ b/source/blender/nodes/intern/node_common.c
@@ -36,17 +36,11 @@
#include "DNA_node_types.h"
#include "BLI_listbase.h"
-#include "BLI_math.h"
-#include "BLI_path_util.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BLF_translation.h"
-#include "BKE_global.h"
-#include "BKE_idprop.h"
-#include "BKE_library.h"
-#include "BKE_main.h"
#include "BKE_node.h"
#include "RNA_access.h"
@@ -384,7 +378,7 @@ void node_group_input_verify(bNodeTree *ntree, bNode *node, ID *id)
static void node_group_input_update(bNodeTree *ntree, bNode *node)
{
bNodeSocket *extsock = node->outputs.last;
- bNodeLink *link;
+ bNodeLink *link, *linknext, *exposelink;
/* Adding a tree socket and verifying will remove the extension socket!
* This list caches the existing links from the extension socket
* so they can be recreated after verification.
@@ -393,26 +387,37 @@ static void node_group_input_update(bNodeTree *ntree, bNode *node)
/* find links from the extension socket and store them */
BLI_listbase_clear(&tmplinks);
- for (link = ntree->links.first; link; link = link->next) {
+ 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);
}
}
- if (tmplinks.first) {
- bNodeSocket *gsock, *newsock;
+ /* find valid link to expose */
+ exposelink = NULL;
+ for (link = tmplinks.first; link; link = link->next) {
/* XXX Multiple sockets can be connected to the extension socket at once,
* in that case the arbitrary first link determines name and type.
* This could be improved by choosing the "best" type among all links,
* whatever that means.
*/
- bNodeLink *exposelink = tmplinks.first;
+ if (link->tosock->type != SOCK_CUSTOM) {
+ exposelink = link;
+ break;
+ }
+ }
+
+ if (exposelink) {
+ bNodeSocket *gsock, *newsock;
- /* XXX what if connecting virtual to virtual socket?? */
gsock = ntreeAddSocketInterfaceFromSocket(ntree, exposelink->tonode, exposelink->tosock);
node_group_input_verify(ntree, node, (ID *)ntree);
@@ -423,8 +428,9 @@ static void node_group_input_update(bNodeTree *ntree, bNode *node)
nodeAddLink(ntree, node, newsock, link->tonode, link->tosock);
}
- BLI_freelistN(&tmplinks);
}
+
+ BLI_freelistN(&tmplinks);
}
void register_node_type_group_input(void)
@@ -471,7 +477,7 @@ void node_group_output_verify(bNodeTree *ntree, bNode *node, ID *id)
static void node_group_output_update(bNodeTree *ntree, bNode *node)
{
bNodeSocket *extsock = node->inputs.last;
- bNodeLink *link;
+ bNodeLink *link, *linknext, *exposelink;
/* Adding a tree socket and verifying will remove the extension socket!
* This list caches the existing links to the extension socket
* so they can be recreated after verification.
@@ -480,24 +486,36 @@ static void node_group_output_update(bNodeTree *ntree, bNode *node)
/* find links to the extension socket and store them */
BLI_listbase_clear(&tmplinks);
- for (link = ntree->links.first; link; link = link->next) {
+ 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);
}
}
- if (tmplinks.first) {
- bNodeSocket *gsock, *newsock;
+ /* find valid link to expose */
+ exposelink = NULL;
+ for (link = tmplinks.first; link; link = link->next) {
/* XXX Multiple sockets can be connected to the extension socket at once,
* in that case the arbitrary first link determines name and type.
* This could be improved by choosing the "best" type among all links,
* whatever that means.
*/
- bNodeLink *exposelink = tmplinks.first;
+ if (link->fromsock->type != SOCK_CUSTOM) {
+ exposelink = link;
+ break;
+ }
+ }
+
+ if (exposelink) {
+ bNodeSocket *gsock, *newsock;
/* XXX what if connecting virtual to virtual socket?? */
gsock = ntreeAddSocketInterfaceFromSocket(ntree, exposelink->fromnode, exposelink->fromsock);
@@ -509,9 +527,9 @@ static void node_group_output_update(bNodeTree *ntree, bNode *node)
for (link = tmplinks.first; link; link = link->next) {
nodeAddLink(ntree, link->fromnode, link->fromsock, node, newsock);
}
-
- BLI_freelistN(&tmplinks);
}
+
+ BLI_freelistN(&tmplinks);
}
void register_node_type_group_output(void)
diff --git a/source/blender/nodes/intern/node_exec.c b/source/blender/nodes/intern/node_exec.c
index 2ae2da6d6b4..0e5f72c831b 100644
--- a/source/blender/nodes/intern/node_exec.c
+++ b/source/blender/nodes/intern/node_exec.c
@@ -33,7 +33,6 @@
#include "DNA_node_types.h"
#include "BLI_listbase.h"
-#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BKE_global.h"
diff --git a/source/blender/nodes/intern/node_socket.c b/source/blender/nodes/intern/node_socket.c
index b30658fa2be..2ac1a2c85f3 100644
--- a/source/blender/nodes/intern/node_socket.c
+++ b/source/blender/nodes/intern/node_socket.c
@@ -39,7 +39,6 @@
#include "BLI_string.h"
#include "BKE_node.h"
-#include "BKE_idprop.h"
#include "RNA_access.h"
#include "RNA_define.h"
diff --git a/source/blender/nodes/intern/node_util.c b/source/blender/nodes/intern/node_util.c
index dcc58d38d31..cc8249b0f57 100644
--- a/source/blender/nodes/intern/node_util.c
+++ b/source/blender/nodes/intern/node_util.c
@@ -32,7 +32,6 @@
#include <limits.h>
#include <string.h>
-#include "DNA_action_types.h"
#include "DNA_node_types.h"
#include "BLI_listbase.h"
diff --git a/source/blender/nodes/shader/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c
index e40d1d1a9c7..b00d96de935 100644
--- a/source/blender/nodes/shader/node_shader_util.c
+++ b/source/blender/nodes/shader/node_shader_util.c
@@ -54,7 +54,7 @@ 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)
{
- float *from = ns->vec;
+ const float *from = ns->vec;
if (type_in == SOCK_FLOAT) {
if (ns->sockettype == SOCK_FLOAT)
diff --git a/source/blender/nodes/shader/nodes/node_shader_bump.c b/source/blender/nodes/shader/nodes/node_shader_bump.c
index fb10efe1569..3ce01ce03bf 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bump.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bump.c
@@ -61,7 +61,7 @@ void register_node_type_sh_bump(void)
sh_node_type_base(&ntype, SH_NODE_BUMP, "Bump", NODE_CLASS_OP_VECTOR, 0);
node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_bump_in, sh_node_bump_out);
- node_type_storage(&ntype, "BumpNode", node_free_standard_storage, node_copy_standard_storage);
+ node_type_storage(&ntype, "", NULL, NULL);
node_type_gpu(&ntype, gpu_shader_bump);
nodeRegisterType(&ntype);
diff --git a/source/blender/nodes/shader/nodes/node_shader_camera.c b/source/blender/nodes/shader/nodes/node_shader_camera.c
index d1ff30ef7d1..231af7e7d37 100644
--- a/source/blender/nodes/shader/nodes/node_shader_camera.c
+++ b/source/blender/nodes/shader/nodes/node_shader_camera.c
@@ -64,7 +64,7 @@ void register_node_type_sh_camera(void)
sh_node_type_base(&ntype, SH_NODE_CAMERA, "Camera Data", NODE_CLASS_INPUT, 0);
node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_socket_templates(&ntype, NULL, sh_node_camera_out);
- node_type_storage(&ntype, "node_camera", NULL, NULL);
+ node_type_storage(&ntype, "", NULL, NULL);
node_type_exec(&ntype, NULL, NULL, node_shader_exec_camera);
node_type_gpu(&ntype, gpu_shader_camera);
diff --git a/source/blender/nodes/shader/nodes/node_shader_common.c b/source/blender/nodes/shader/nodes/node_shader_common.c
index de30b92f8fe..7ff60ac716a 100644
--- a/source/blender/nodes/shader/nodes/node_shader_common.c
+++ b/source/blender/nodes/shader/nodes/node_shader_common.c
@@ -243,7 +243,7 @@ void register_node_type_sh_group(void)
node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_socket_templates(&ntype, NULL, NULL);
- node_type_size(&ntype, 120, 60, 400);
+ 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);
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 9d769b284b1..023c6ea02a9 100644
--- a/source/blender/nodes/shader/nodes/node_shader_light_path.c
+++ b/source/blender/nodes/shader/nodes/node_shader_light_path.c
@@ -39,6 +39,7 @@ static bNodeSocketTemplate sh_node_light_path_out[] = {
{ SOCK_FLOAT, 0, N_("Is Transmission Ray"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, N_("Ray Length"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, N_("Ray Depth"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_FLOAT, 0, N_("Transparent Depth"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/shader/nodes/node_shader_math.c b/source/blender/nodes/shader/nodes/node_shader_math.c
index b6c755571c0..d5ba8231cce 100644
--- a/source/blender/nodes/shader/nodes/node_shader_math.c
+++ b/source/blender/nodes/shader/nodes/node_shader_math.c
@@ -216,6 +216,11 @@ static void node_shader_exec_math(void *UNUSED(data), int UNUSED(thread), bNode
r = fmod(a, b);
break;
}
+ case 18: /* Absolute */
+ {
+ r = fabs(a);
+ break;
+ }
}
out[0]->vec[0] = r;
@@ -226,7 +231,7 @@ static int gpu_shader_math(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(
static const char *names[] = {"math_add", "math_subtract", "math_multiply",
"math_divide", "math_sine", "math_cosine", "math_tangent", "math_asin",
"math_acos", "math_atan", "math_pow", "math_log", "math_min", "math_max",
- "math_round", "math_less_than", "math_greater_than", "math_modulo"};
+ "math_round", "math_less_than", "math_greater_than", "math_modulo", "math_absolute"};
switch (node->custom1) {
case 0:
@@ -279,7 +284,7 @@ void register_node_type_sh_math(void)
node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_math_in, sh_node_math_out);
node_type_label(&ntype, node_math_label);
- node_type_storage(&ntype, "node_math", NULL, NULL);
+ node_type_storage(&ntype, "", NULL, NULL);
node_type_exec(&ntype, NULL, NULL, node_shader_exec_math);
node_type_gpu(&ntype, gpu_shader_math);
diff --git a/source/blender/nodes/shader/nodes/node_shader_squeeze.c b/source/blender/nodes/shader/nodes/node_shader_squeeze.c
index c884f2c3353..a4c995748d9 100644
--- a/source/blender/nodes/shader/nodes/node_shader_squeeze.c
+++ b/source/blender/nodes/shader/nodes/node_shader_squeeze.c
@@ -68,7 +68,7 @@ void register_node_type_sh_squeeze(void)
sh_node_type_base(&ntype, SH_NODE_SQUEEZE, "Squeeze Value", NODE_CLASS_CONVERTOR, 0);
node_type_compatibility(&ntype, NODE_OLD_SHADING);
node_type_socket_templates(&ntype, sh_node_squeeze_in, sh_node_squeeze_out);
- node_type_storage(&ntype, "node_squeeze", NULL, NULL);
+ node_type_storage(&ntype, "", NULL, NULL);
node_type_exec(&ntype, NULL, NULL, node_shader_exec_squeeze);
node_type_gpu(&ntype, gpu_shader_squeeze);
diff --git a/source/blender/nodes/shader/nodes/node_shader_texture.c b/source/blender/nodes/shader/nodes/node_shader_texture.c
index 4e5d2e712dc..d02d72563ba 100644
--- a/source/blender/nodes/shader/nodes/node_shader_texture.c
+++ b/source/blender/nodes/shader/nodes/node_shader_texture.c
@@ -75,7 +75,7 @@ static void node_shader_exec_texture(void *data, int UNUSED(thread), bNode *node
retval = multitex_nodes((Tex *)node->id, vec, fp, fp + 3, shi->osatex, &texres, thread, which_output, NULL, NULL, NULL);
}
else if (in[0]->datatype == NS_OSA_VALUES) {
- float *fp = in[0]->data;
+ const float *fp = in[0]->data;
float dxt[3], dyt[3];
dxt[0] = fp[0]; dxt[1] = dxt[2] = 0.0f;
diff --git a/source/blender/nodes/shader/nodes/node_shader_vectMath.c b/source/blender/nodes/shader/nodes/node_shader_vectMath.c
index e3868627444..b40bf6bc71a 100644
--- a/source/blender/nodes/shader/nodes/node_shader_vectMath.c
+++ b/source/blender/nodes/shader/nodes/node_shader_vectMath.c
@@ -147,7 +147,7 @@ void register_node_type_sh_vect_math(void)
node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_vect_math_in, sh_node_vect_math_out);
node_type_label(&ntype, node_vect_math_label);
- node_type_storage(&ntype, "node_vect_math", NULL, NULL);
+ node_type_storage(&ntype, "", NULL, NULL);
node_type_exec(&ntype, NULL, NULL, node_shader_exec_vect_math);
node_type_gpu(&ntype, gpu_shader_vect_math);
diff --git a/source/blender/nodes/texture/node_texture_tree.c b/source/blender/nodes/texture/node_texture_tree.c
index 7e9360b271c..882c843f317 100644
--- a/source/blender/nodes/texture/node_texture_tree.c
+++ b/source/blender/nodes/texture/node_texture_tree.c
@@ -92,7 +92,7 @@ static void texture_get_from_context(const bContext *C, bNodeTreeType *UNUSED(tr
}
}
}
- else {
+ else if (snode->texfrom == SNODE_TEX_BRUSH) {
struct Brush *brush = NULL;
if (ob && (ob->mode & OB_MODE_SCULPT))
@@ -109,6 +109,17 @@ static void texture_get_from_context(const bContext *C, bNodeTreeType *UNUSED(tr
}
}
}
+ else if (snode->texfrom == SNODE_TEX_LINESTYLE) {
+ FreestyleLineStyle *linestyle = CTX_data_linestyle_from_scene(scene);
+ if (linestyle) {
+ *r_from = (ID *)linestyle;
+ tx = give_current_linestyle_texture(linestyle);
+ if (tx) {
+ *r_id = &tx->id;
+ *r_ntree = tx->nodetree;
+ }
+ }
+ }
}
static void foreach_nodeclass(Scene *UNUSED(scene), void *calldata, bNodeClassCallback func)
diff --git a/source/blender/nodes/texture/nodes/node_texture_common.c b/source/blender/nodes/texture/nodes/node_texture_common.c
index 7e65c472eef..914f1ef5110 100644
--- a/source/blender/nodes/texture/nodes/node_texture_common.c
+++ b/source/blender/nodes/texture/nodes/node_texture_common.c
@@ -172,7 +172,7 @@ void register_node_type_tex_group(void)
RNA_struct_blender_type_set(ntype.ext.srna, &ntype);
node_type_socket_templates(&ntype, NULL, NULL);
- node_type_size(&ntype, 120, 60, 400);
+ 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);
diff --git a/source/blender/nodes/texture/nodes/node_texture_coord.c b/source/blender/nodes/texture/nodes/node_texture_coord.c
index 1b742b4c8fd..5221d456b88 100644
--- a/source/blender/nodes/texture/nodes/node_texture_coord.c
+++ b/source/blender/nodes/texture/nodes/node_texture_coord.c
@@ -54,7 +54,7 @@ void register_node_type_tex_coord(void)
tex_node_type_base(&ntype, TEX_NODE_COORD, "Coordinates", NODE_CLASS_INPUT, 0);
node_type_socket_templates(&ntype, NULL, outputs);
- node_type_storage(&ntype, "node_coord", NULL, NULL);
+ 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_distance.c b/source/blender/nodes/texture/nodes/node_texture_distance.c
index 97d2d8f2caf..76a5b79c7a9 100644
--- a/source/blender/nodes/texture/nodes/node_texture_distance.c
+++ b/source/blender/nodes/texture/nodes/node_texture_distance.c
@@ -67,7 +67,7 @@ void register_node_type_tex_distance(void)
tex_node_type_base(&ntype, TEX_NODE_DISTANCE, "Distance", NODE_CLASS_CONVERTOR, 0);
node_type_socket_templates(&ntype, inputs, outputs);
- node_type_storage(&ntype, "node_distance", NULL, NULL);
+ 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_image.c b/source/blender/nodes/texture/nodes/node_texture_image.c
index 6c348d33b88..9b13589f3e1 100644
--- a/source/blender/nodes/texture/nodes/node_texture_image.c
+++ b/source/blender/nodes/texture/nodes/node_texture_image.c
@@ -52,7 +52,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **UNUSED(i
float xoff, yoff;
int px, py;
- float *result;
+ const float *result;
xsize = ibuf->x / 2;
ysize = ibuf->y / 2;
diff --git a/source/blender/nodes/texture/nodes/node_texture_math.c b/source/blender/nodes/texture/nodes/node_texture_math.c
index 8d69d79d847..4765ee5f02a 100644
--- a/source/blender/nodes/texture/nodes/node_texture_math.c
+++ b/source/blender/nodes/texture/nodes/node_texture_math.c
@@ -174,7 +174,7 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
break;
}
- case 17: /* Modulo */
+ case 17: /* Modulo */
{
if (in1 == 0.0f)
*out = 0.0f;
@@ -182,6 +182,13 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
*out = fmod(in0, in1);
break;
}
+
+ case 18: /* Absolute */
+ {
+ *out = fabs(in0);
+ break;
+ }
+
default:
{
BLI_assert(0);
@@ -202,7 +209,7 @@ void register_node_type_tex_math(void)
tex_node_type_base(&ntype, TEX_NODE_MATH, "Math", NODE_CLASS_CONVERTOR, 0);
node_type_socket_templates(&ntype, inputs, outputs);
node_type_label(&ntype, node_math_label);
- node_type_storage(&ntype, "node_math", NULL, NULL);
+ 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_output.c b/source/blender/nodes/texture/nodes/node_texture_output.c
index a0d54cdae4e..57165a8cb09 100644
--- a/source/blender/nodes/texture/nodes/node_texture_output.c
+++ b/source/blender/nodes/texture/nodes/node_texture_output.c
@@ -84,7 +84,7 @@ static void unique_name(bNode *node)
int new_len = 0;
int suffix;
bNode *i;
- char *name = tno->name;
+ const char *name = tno->name;
new_name[0] = '\0';
i = node;
diff --git a/source/blender/python/bmesh/bmesh_py_ops_call.c b/source/blender/python/bmesh/bmesh_py_ops_call.c
index f4fe1ede088..9c9b69186ab 100644
--- a/source/blender/python/bmesh/bmesh_py_ops_call.c
+++ b/source/blender/python/bmesh/bmesh_py_ops_call.c
@@ -768,7 +768,7 @@ PyObject *BPy_BMO_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *kw)
/* temp code, strip off '.out' while we keep this convention */
{
char slot_name_strip[MAX_SLOTNAME];
- char *ch = strchr(slot->slot_name, '.'); /* can't fail! */
+ const char *ch = strchr(slot->slot_name, '.'); /* can't fail! */
int tot = ch - slot->slot_name;
BLI_assert(ch != NULL);
memcpy(slot_name_strip, slot->slot_name, tot);
diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c
index 6302561cb7e..c2b496f914b 100644
--- a/source/blender/python/bmesh/bmesh_py_types.c
+++ b/source/blender/python/bmesh/bmesh_py_types.c
@@ -176,9 +176,7 @@ static int bpy_bm_elem_index_set(BPy_BMElem *self, PyObject *value, void *UNUSED
BM_elem_index_set(self->ele, param); /* set_dirty! */
/* when setting the index assume its set invalid */
- if (self->ele->head.htype & (BM_VERT | BM_EDGE | BM_FACE)) {
- self->bm->elem_index_dirty |= self->ele->head.htype;
- }
+ self->bm->elem_index_dirty |= self->ele->head.htype;
return 0;
}
@@ -2264,11 +2262,9 @@ static PyObject *bpy_bmelemseq_index_update(BPy_BMElemSeq *self)
index++;
}
- if (htype & (BM_VERT | BM_EDGE | BM_FACE)) {
- /* since this isn't the normal vert/edge/face loops,
- * we're setting dirty values here. so tag as dirty. */
- bm->elem_index_dirty |= htype;
- }
+ /* since this isn't the normal vert/edge/face loops,
+ * we're setting dirty values here. so tag as dirty. */
+ bm->elem_index_dirty |= htype;
break;
}
diff --git a/source/blender/python/bmesh/bmesh_py_types_customdata.c b/source/blender/python/bmesh/bmesh_py_types_customdata.c
index 4fbfbd88c05..dfb3ae75df4 100644
--- a/source/blender/python/bmesh/bmesh_py_types_customdata.c
+++ b/source/blender/python/bmesh/bmesh_py_types_customdata.c
@@ -33,7 +33,6 @@
#include <Python.h>
#include "BLI_utildefines.h"
-#include "BLI_string.h"
#include "BLI_math_vector.h"
#include "bmesh.h"
diff --git a/source/blender/python/bmesh/bmesh_py_types_select.c b/source/blender/python/bmesh/bmesh_py_types_select.c
index 1906fc8c90e..b8e04a0cab8 100644
--- a/source/blender/python/bmesh/bmesh_py_types_select.c
+++ b/source/blender/python/bmesh/bmesh_py_types_select.c
@@ -43,9 +43,7 @@
#include "bmesh_py_types.h"
#include "bmesh_py_types_select.h"
-#include "BKE_editmesh.h"
-#include "DNA_mesh_types.h"
#include "../generic/py_capi_utils.h"
diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c
index d1d0ec96315..292d3317a2e 100644
--- a/source/blender/python/generic/bgl.c
+++ b/source/blender/python/generic/bgl.c
@@ -1905,7 +1905,7 @@ PyObject *BPyInit_bgl(void)
static PyObject *Method_ShaderSource(PyObject *UNUSED(self), PyObject *args)
{
unsigned int shader;
- char *source;
+ const char *source;
if (!PyArg_ParseTuple(args, "Is", &shader, &source))
return NULL;
diff --git a/source/blender/python/generic/blf_py_api.c b/source/blender/python/generic/blf_py_api.c
index 768c5506b8c..655542e320a 100644
--- a/source/blender/python/generic/blf_py_api.c
+++ b/source/blender/python/generic/blf_py_api.c
@@ -146,7 +146,7 @@ PyDoc_STRVAR(py_blf_draw_doc,
);
static PyObject *py_blf_draw(PyObject *UNUSED(self), PyObject *args)
{
- char *text;
+ const char *text;
int text_length;
int fontid;
@@ -172,7 +172,7 @@ PyDoc_STRVAR(py_blf_dimensions_doc,
);
static PyObject *py_blf_dimensions(PyObject *UNUSED(self), PyObject *args)
{
- char *text;
+ const char *text;
float r_width, r_height;
PyObject *ret;
int fontid;
@@ -356,7 +356,7 @@ PyDoc_STRVAR(py_blf_load_doc,
);
static PyObject *py_blf_load(PyObject *UNUSED(self), PyObject *args)
{
- char *filename;
+ const char *filename;
if (!PyArg_ParseTuple(args, "s:blf.load", &filename))
return NULL;
@@ -374,7 +374,7 @@ PyDoc_STRVAR(py_blf_unload_doc,
);
static PyObject *py_blf_unload(PyObject *UNUSED(self), PyObject *args)
{
- char *filename;
+ const char *filename;
if (!PyArg_ParseTuple(args, "s:blf.unload", &filename))
return NULL;
diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c
index af41c3b426b..2d19fdb87b3 100644
--- a/source/blender/python/generic/bpy_internal_import.c
+++ b/source/blender/python/generic/bpy_internal_import.c
@@ -47,6 +47,8 @@
#include "BKE_text.h" /* txt_to_buf */
#include "BKE_main.h"
+#include "py_capi_utils.h"
+
#include "bpy_internal_import.h" /* own include */
static Main *bpy_import_main = NULL;
@@ -133,6 +135,7 @@ void bpy_text_filename_get(char *fn, size_t fn_len, Text *text)
bool bpy_text_compile(Text *text)
{
char fn_dummy[FILE_MAX];
+ PyObject *fn_dummy_py;
char *buf;
bpy_text_filename_get(fn_dummy, sizeof(fn_dummy), text);
@@ -140,10 +143,14 @@ bool bpy_text_compile(Text *text)
/* if previously compiled, free the object */
free_compiled_text(text);
+ fn_dummy_py = PyC_UnicodeFromByte(fn_dummy);
+
buf = txt_to_buf(text);
- text->compiled = Py_CompileString(buf, fn_dummy, Py_file_input);
+ text->compiled = Py_CompileStringObject(buf, fn_dummy_py, Py_file_input, NULL, -1);
MEM_freeN(buf);
+ Py_DECREF(fn_dummy_py);
+
if (PyErr_Occurred()) {
PyErr_Print();
PyErr_Clear();
@@ -226,7 +233,7 @@ PyObject *bpy_text_reimport(PyObject *module, int *found)
{
Text *text;
const char *name;
- char *filepath;
+ const char *filepath;
//XXX Main *maggie = bpy_import_main ? bpy_import_main:G.main;
Main *maggie = bpy_import_main;
@@ -265,7 +272,7 @@ PyObject *bpy_text_reimport(PyObject *module, int *found)
static PyObject *blender_import(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
{
PyObject *exception, *err, *tb;
- char *name;
+ const char *name;
int found = 0;
PyObject *globals = NULL, *locals = NULL, *fromlist = NULL;
int level = 0; /* relative imports */
diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c
index 5821d48b994..dcdda2c440e 100644
--- a/source/blender/python/generic/idprop_py_api.c
+++ b/source/blender/python/generic/idprop_py_api.c
@@ -29,7 +29,6 @@
#include "MEM_guardedalloc.h"
-#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "idprop_py_api.h"
@@ -599,7 +598,7 @@ static PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop)
switch (prop->subtype) {
case IDP_FLOAT:
{
- float *array = (float *)IDP_Array(prop);
+ const float *array = (float *)IDP_Array(prop);
for (i = 0; i < prop->len; i++) {
PyList_SET_ITEM(seq, i, PyFloat_FromDouble(array[i]));
}
@@ -607,7 +606,7 @@ static PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop)
}
case IDP_DOUBLE:
{
- double *array = (double *)IDP_Array(prop);
+ const double *array = (double *)IDP_Array(prop);
for (i = 0; i < prop->len; i++) {
PyList_SET_ITEM(seq, i, PyFloat_FromDouble(array[i]));
}
@@ -615,7 +614,7 @@ static PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop)
}
case IDP_INT:
{
- int *array = (int *)IDP_Array(prop);
+ const int *array = (int *)IDP_Array(prop);
for (i = 0; i < prop->len; i++) {
PyList_SET_ITEM(seq, i, PyLong_FromLong(array[i]));
}
@@ -881,7 +880,7 @@ static PyObject *BPy_IDGroup_clear(BPy_IDProperty *self)
static PyObject *BPy_IDGroup_Get(BPy_IDProperty *self, PyObject *args)
{
IDProperty *idprop;
- char *key;
+ const char *key;
PyObject *def = Py_None;
if (!PyArg_ParseTuple(args, "s|O:get", &key, &def))
@@ -1158,7 +1157,7 @@ static PyObject *BPy_IDArray_slice(BPy_IDArray *self, int begin, int end)
switch (prop->subtype) {
case IDP_FLOAT:
{
- float *array = (float *)IDP_Array(prop);
+ const float *array = (float *)IDP_Array(prop);
for (count = begin; count < end; count++) {
PyTuple_SET_ITEM(tuple, count - begin, PyFloat_FromDouble(array[count]));
}
@@ -1166,7 +1165,7 @@ static PyObject *BPy_IDArray_slice(BPy_IDArray *self, int begin, int end)
}
case IDP_DOUBLE:
{
- double *array = (double *)IDP_Array(prop);
+ const double *array = (double *)IDP_Array(prop);
for (count = begin; count < end; count++) {
PyTuple_SET_ITEM(tuple, count - begin, PyFloat_FromDouble(array[count]));
}
@@ -1174,7 +1173,7 @@ static PyObject *BPy_IDArray_slice(BPy_IDArray *self, int begin, int end)
}
case IDP_INT:
{
- int *array = (int *)IDP_Array(prop);
+ const int *array = (int *)IDP_Array(prop);
for (count = begin; count < end; count++) {
PyTuple_SET_ITEM(tuple, count - begin, PyLong_FromLong(array[count]));
}
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c
index a37933d027e..33ff63a9a28 100644
--- a/source/blender/python/generic/py_capi_utils.c
+++ b/source/blender/python/generic/py_capi_utils.c
@@ -284,7 +284,7 @@ PyObject *PyC_Object_GetAttrStringArgs(PyObject *o, Py_ssize_t n, ...)
{
Py_ssize_t i;
PyObject *item = o;
- char *attr;
+ const char *attr;
va_list vargs;
@@ -647,7 +647,7 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
va_start(vargs, n);
for (i = 0; i * 2 < n; i++) {
- char *format = va_arg(vargs, char *);
+ const char *format = va_arg(vargs, char *);
void *ptr = va_arg(vargs, void *);
ret = PyObject_CallFunction(calcsize, (char *)"s", format);
@@ -704,7 +704,7 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
/* now get the values back */
va_start(vargs, n);
for (i = 0; i * 2 < n; i++) {
- char *format = va_arg(vargs, char *);
+ const char *format = va_arg(vargs, char *);
void *ptr = va_arg(vargs, void *);
PyObject *item;
@@ -762,6 +762,9 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
PyGILState_Release(gilstate);
}
+ else {
+ fprintf(stderr, "%s: '%s' missing\n", __func__, filepath);
+ }
}
/* generic function to avoid depending on RNA */
@@ -901,19 +904,3 @@ PyObject *PyC_FlagSet_FromBitfield(PyC_FlagSet *items, int flag)
return ret;
}
-
-/* compat only */
-#if PY_VERSION_HEX < 0x03030200
-int
-_PyLong_AsInt(PyObject *obj)
-{
- int overflow;
- long result = PyLong_AsLongAndOverflow(obj, &overflow);
- if (overflow || result > INT_MAX || result < INT_MIN) {
- PyErr_SetString(PyExc_OverflowError,
- "Python int too large to convert to C int");
- return -1;
- }
- return (int)result;
-}
-#endif
diff --git a/source/blender/python/generic/py_capi_utils.h b/source/blender/python/generic/py_capi_utils.h
index 27dd1bba6d6..0afc4dd98d9 100644
--- a/source/blender/python/generic/py_capi_utils.h
+++ b/source/blender/python/generic/py_capi_utils.h
@@ -73,8 +73,4 @@ int PyC_FlagSet_ValueFromID(PyC_FlagSet *item, const char *identifier, int
int PyC_FlagSet_ToBitfield(PyC_FlagSet *items, PyObject *value, int *r_value, const char *error_prefix);
PyObject *PyC_FlagSet_FromBitfield(PyC_FlagSet *items, int flag);
-#if PY_VERSION_HEX < 0x03030200
-int _PyLong_AsInt(PyObject *obj);
-#endif
-
#endif /* __PY_CAPI_UTILS_H__ */
diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c
index ae57588985d..89104821cb0 100644
--- a/source/blender/python/intern/bpy.c
+++ b/source/blender/python/intern/bpy.c
@@ -144,8 +144,8 @@ static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObjec
// PyDoc_STRVAR(bpy_user_resource_doc[] = // now in bpy/utils.py
static PyObject *bpy_user_resource(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
{
- char *type;
- char *subdir = NULL;
+ const char *type;
+ const char *subdir = NULL;
int folder_id;
static const char *kwlist[] = {"type", "subdir", NULL};
@@ -189,7 +189,7 @@ PyDoc_STRVAR(bpy_resource_path_doc,
);
static PyObject *bpy_resource_path(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
{
- char *type;
+ const char *type;
int major = BLENDER_VERSION / 100, minor = BLENDER_VERSION % 100;
static const char *kwlist[] = {"type", "major", "minor", NULL};
int folder_id;
diff --git a/source/blender/python/intern/bpy_app_build_options.c b/source/blender/python/intern/bpy_app_build_options.c
index f5dc2942e63..f43b67cf42f 100644
--- a/source/blender/python/intern/bpy_app_build_options.c
+++ b/source/blender/python/intern/bpy_app_build_options.c
@@ -25,7 +25,6 @@
*/
#include <Python.h>
-#include "BLI_utildefines.h"
#include "bpy_app_build_options.h"
diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c
index f8725d61167..b3be5a819fb 100644
--- a/source/blender/python/intern/bpy_app_handlers.c
+++ b/source/blender/python/intern/bpy_app_handlers.c
@@ -174,7 +174,7 @@ static PyObject *py_cb_array[BLI_CB_EVT_TOT] = {NULL};
static PyObject *make_app_cb_info(void)
{
PyObject *app_cb_info;
- int pos = 0;
+ int pos;
app_cb_info = PyStructSequence_New(&BlenderAppCbType);
if (app_cb_info == NULL) {
diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c
index 7141db7352a..b51de01103c 100644
--- a/source/blender/python/intern/bpy_driver.c
+++ b/source/blender/python/intern/bpy_driver.c
@@ -186,7 +186,7 @@ float BPY_driver_exec(ChannelDriver *driver, const float evaltime)
/* get the py expression to be evaluated */
expr = driver->expression;
- if ((expr == NULL) || (expr[0] == '\0'))
+ if (expr[0] == '\0')
return 0.0f;
if (!(G.f & G_SCRIPT_AUTOEXEC)) {
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index 93bced364d2..045acc65d1e 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -37,13 +37,16 @@
#include <Python.h>
+#ifdef WIN32
+# include "BLI_math_base.h" /* finite */
+#endif
+
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
#include "BLI_path_util.h"
#include "BLI_fileops.h"
#include "BLI_listbase.h"
-#include "BLI_math_base.h"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
#include "BLI_threads.h"
@@ -58,7 +61,6 @@
#include "bpy_traceback.h"
#include "bpy_intern_string.h"
-#include "DNA_space_types.h"
#include "DNA_text_types.h"
#include "BKE_context.h"
@@ -255,11 +257,7 @@ void BPY_python_start(int argc, const char **argv)
* an error, this is highly annoying, another stumbling block for devs,
* so use a more relaxed error handler and enforce utf-8 since the rest of
* blender is utf-8 too - campbell */
-
- /* XXX, update: this is unreliable! 'PYTHONIOENCODING' is ignored in MS-Windows
- * when dynamically linked, see: [#31555] for details.
- * Python doesn't expose a good way to set this. */
- BLI_setenv("PYTHONIOENCODING", "utf-8:surrogateescape");
+ Py_SetStandardStreamEncoding("utf-8", "surrogateescape");
/* Update, Py3.3 resolves attempting to parse non-existing header */
#if 0
@@ -275,24 +273,6 @@ void BPY_python_start(int argc, const char **argv)
Py_Initialize();
- /* THIS IS BAD: see http://bugs.python.org/issue16129 */
- /* this clobbers the stdout on exit (no 'MEM_printmemlist_stats') */
-#if 0
- /* until python provides a reliable way to set the env var */
- PyRun_SimpleString("import sys, io\n"
- "sys.__backup_stdio__ = sys.__stdout__, sys.__stderr__\n" /* else we loose the FD's [#32720] */
- "sys.__stdout__ = sys.stdout = io.TextIOWrapper(io.open(sys.stdout.fileno(), 'wb', -1), "
- "encoding='utf-8', errors='surrogateescape', newline='\\n', line_buffering=True)\n"
- "sys.__stderr__ = sys.stderr = io.TextIOWrapper(io.open(sys.stderr.fileno(), 'wb', -1), "
- "encoding='utf-8', errors='surrogateescape', newline='\\n', line_buffering=True)\n");
- if (PyErr_Occurred()) {
- PyErr_Print();
- PyErr_Clear();
- }
-#endif
- /* end the baddness */
-
-
// PySys_SetArgv(argc, argv); /* broken in py3, not a huge deal */
/* sigh, why do python guys not have a (char **) version anymore? */
{
@@ -463,12 +443,17 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text,
bpy_text_filename_get(fn_dummy, sizeof(fn_dummy), text);
if (text->compiled == NULL) { /* if it wasn't already compiled, do it now */
- char *buf = txt_to_buf(text);
+ char *buf;
+ PyObject *fn_dummy_py;
- text->compiled = Py_CompileString(buf, fn_dummy, Py_file_input);
+ fn_dummy_py = PyC_UnicodeFromByte(fn_dummy);
+ buf = txt_to_buf(text);
+ text->compiled = Py_CompileStringObject(buf, fn_dummy_py, Py_file_input, NULL, -1);
MEM_freeN(buf);
+ Py_DECREF(fn_dummy_py);
+
if (PyErr_Occurred()) {
if (do_jump) {
python_script_error_jump_text(text);
diff --git a/source/blender/python/intern/bpy_library.c b/source/blender/python/intern/bpy_library.c
index 7e84070e930..3d7d08024c7 100644
--- a/source/blender/python/intern/bpy_library.c
+++ b/source/blender/python/intern/bpy_library.c
@@ -38,7 +38,6 @@
#include "BLI_string.h"
#include "BLI_linklist.h"
#include "BLI_path_util.h"
-#include "BLI_listbase.h"
#include "BLO_readfile.h"
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index e867aa00958..2c526601fcd 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -65,10 +65,10 @@
static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
{
wmOperatorType *ot;
- char *opname;
+ const char *opname;
PyObject *context_dict = NULL; /* optional args */
PyObject *context_dict_back;
- char *context_str = NULL;
+ const char *context_str = NULL;
PyObject *ret;
int context = WM_OP_EXEC_DEFAULT;
@@ -139,8 +139,8 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
PointerRNA ptr;
int operator_ret = OPERATOR_CANCELLED;
- char *opname;
- char *context_str = NULL;
+ const char *opname;
+ const char *context_str = NULL;
PyObject *kw = NULL; /* optional args */
PyObject *context_dict = NULL; /* optional args */
PyObject *context_dict_back;
@@ -310,7 +310,7 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args)
wmOperatorType *ot;
PointerRNA ptr;
- char *opname;
+ const char *opname;
PyObject *kw = NULL; /* optional args */
int all_args = 1;
int macro_args = 1;
diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c
index efee9b13d58..11e27ca3e3c 100644
--- a/source/blender/python/intern/bpy_operator_wrap.c
+++ b/source/blender/python/intern/bpy_operator_wrap.c
@@ -163,7 +163,7 @@ PyObject *PYOP_wrap_macro_define(PyObject *UNUSED(self), PyObject *args)
PointerRNA ptr_otmacro;
StructRNA *srna;
- char *opname;
+ const char *opname;
const char *macroname;
if (!PyArg_ParseTuple(args, "Os:_bpy.ops.macro_define", &macro, &opname))
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c
index b2f9547b81a..6e36680ec4a 100644
--- a/source/blender/python/intern/bpy_props.c
+++ b/source/blender/python/intern/bpy_props.c
@@ -1881,7 +1881,7 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
PropertyRNA *prop;
PyObject *pyopts = NULL;
int opts = 0;
- char *pysubtype = NULL;
+ const char *pysubtype = NULL;
int subtype = PROP_NONE;
PyObject *update_cb = NULL;
PyObject *get_cb = NULL;
@@ -1967,7 +1967,7 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
PyObject *pydef = NULL;
PyObject *pyopts = NULL;
int opts = 0;
- char *pysubtype = NULL;
+ const char *pysubtype = NULL;
int subtype = PROP_NONE;
PyObject *update_cb = NULL;
PyObject *get_cb = NULL;
@@ -2062,7 +2062,7 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
PropertyRNA *prop;
PyObject *pyopts = NULL;
int opts = 0;
- char *pysubtype = NULL;
+ const char *pysubtype = NULL;
int subtype = PROP_NONE;
PyObject *update_cb = NULL;
PyObject *get_cb = NULL;
@@ -2154,7 +2154,7 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
PyObject *pydef = NULL;
PyObject *pyopts = NULL;
int opts = 0;
- char *pysubtype = NULL;
+ const char *pysubtype = NULL;
int subtype = PROP_NONE;
PyObject *update_cb = NULL;
PyObject *get_cb = NULL;
@@ -2259,9 +2259,9 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
PropertyRNA *prop;
PyObject *pyopts = NULL;
int opts = 0;
- char *pysubtype = NULL;
+ const char *pysubtype = NULL;
int subtype = PROP_NONE;
- char *pyunit = NULL;
+ const char *pyunit = NULL;
int unit = PROP_UNIT_NONE;
PyObject *update_cb = NULL;
PyObject *get_cb = NULL;
@@ -2365,9 +2365,9 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
PyObject *pydef = NULL;
PyObject *pyopts = NULL;
int opts = 0;
- char *pysubtype = NULL;
+ const char *pysubtype = NULL;
int subtype = PROP_NONE;
- char *pyunit = NULL;
+ const char *pyunit = NULL;
int unit = PROP_UNIT_NONE;
PyObject *update_cb = NULL;
PyObject *get_cb = NULL;
@@ -2468,7 +2468,7 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw
PropertyRNA *prop;
PyObject *pyopts = NULL;
int opts = 0;
- char *pysubtype = NULL;
+ const char *pysubtype = NULL;
int subtype = PROP_NONE;
PyObject *update_cb = NULL;
PyObject *get_cb = NULL;
@@ -2847,7 +2847,7 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw
else {
static const char *kwlist[] = {"attr", NULL};
- char *id = NULL;
+ const char *id = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kw,
"s:RemoveProperty",
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index cf13efae60e..38a0f74f009 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -73,8 +73,6 @@
#include "BKE_report.h"
#include "BKE_idprop.h"
-#include "BKE_animsys.h"
-#include "BKE_fcurve.h"
#include "../generic/idprop_py_api.h" /* for IDprop lookups */
#include "../generic/py_capi_utils.h"
@@ -2171,7 +2169,7 @@ static int pyrna_prop_collection_subscript_str_lib_pair_ptr(BPy_PropertyRNA *sel
PointerRNA *r_ptr
)
{
- char *keyname;
+ const char *keyname;
/* first validate the args, all we know is that they are a tuple */
if (PyTuple_GET_SIZE(key) != 2) {
@@ -4883,7 +4881,7 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat
break;
case PROP_STRING:
{
- char *data_ch;
+ const char *data_ch;
PyObject *value_coerce = NULL;
const int subtype = RNA_property_subtype(prop);
diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c
index 3320043aeb5..ed51ba5bd1f 100644
--- a/source/blender/python/intern/bpy_rna_anim.c
+++ b/source/blender/python/intern/bpy_rna_anim.c
@@ -168,8 +168,13 @@ static int pyrna_struct_keyframe_parse(
*cfra = CTX_data_scene(BPy_GetContext())->r.cfra;
/* flag may be null (no option currently for remove keyframes e.g.). */
- if (pyoptions && options && (pyrna_set_to_enum_bitfield(keying_flag_items, pyoptions, options, error_prefix) == -1))
- return -1;
+ if (options) {
+ if (pyoptions && (pyrna_set_to_enum_bitfield(keying_flag_items, pyoptions, options, error_prefix) == -1)) {
+ return -1;
+ }
+
+ *options |= INSERTKEY_NO_USERPREF;
+ }
return 0; /* success */
}
diff --git a/source/blender/python/intern/bpy_rna_array.c b/source/blender/python/intern/bpy_rna_array.c
index bb40a21eed9..033f8a3f3ec 100644
--- a/source/blender/python/intern/bpy_rna_array.c
+++ b/source/blender/python/intern/bpy_rna_array.c
@@ -30,12 +30,12 @@
#include "RNA_types.h"
-#include "BLI_utildefines.h"
-
#include "bpy_rna.h"
#include "BKE_global.h"
#include "MEM_guardedalloc.h"
+#include "BLI_utildefines.h"
+
#include "RNA_access.h"
#define USE_MATHUTILS
@@ -83,7 +83,7 @@ static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[]
for (i = 0; i < seq_size; i++) {
Py_ssize_t item_seq_size;
PyObject *item;
- int ok = 1;
+ bool ok = true;
item = PySequence_GetItem(seq, i);
if (item == NULL) {
diff --git a/source/blender/python/intern/bpy_rna_callback.c b/source/blender/python/intern/bpy_rna_callback.c
index 9aefe5a733f..87c3a6eb4ef 100644
--- a/source/blender/python/intern/bpy_rna_callback.c
+++ b/source/blender/python/intern/bpy_rna_callback.c
@@ -182,8 +182,8 @@ PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args)
void *handle;
PyObject *cls;
PyObject *cb_func, *cb_args;
- char *cb_regiontype_str;
- char *cb_event_str;
+ const char *cb_regiontype_str;
+ const char *cb_event_str;
int cb_event;
int cb_regiontype;
StructRNA *srna;
@@ -248,7 +248,7 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar
void *handle;
void *customdata;
StructRNA *srna;
- char *cb_regiontype_str;
+ const char *cb_regiontype_str;
int cb_regiontype;
if (PyTuple_GET_SIZE(args) < 2) {
diff --git a/source/blender/python/intern/bpy_traceback.c b/source/blender/python/intern/bpy_traceback.c
index 81d12e9d9a6..bff778b9c9e 100644
--- a/source/blender/python/intern/bpy_traceback.c
+++ b/source/blender/python/intern/bpy_traceback.c
@@ -31,7 +31,9 @@
#include "BLI_utildefines.h"
#include "BLI_path_util.h"
-#include "BLI_string.h"
+#ifdef WIN32
+# include "BLI_string.h" /* BLI_strcasecmp */
+#endif
#include "bpy_traceback.h"
@@ -40,10 +42,12 @@ static const char *traceback_filepath(PyTracebackObject *tb, PyObject **coerce)
return PyBytes_AS_STRING((*coerce = PyUnicode_EncodeFSDefault(tb->tb_frame->f_code->co_filename)));
}
-/* copied from pythonrun.c, 3.3.0 */
+/* copied from pythonrun.c, 3.4.0 */
+_Py_static_string(PyId_string, "<string>");
+
static int
-parse_syntax_error(PyObject *err, PyObject **message, const char **filename,
- int *lineno, int *offset, const char **text)
+parse_syntax_error(PyObject *err, PyObject **message, PyObject **filename,
+ int *lineno, int *offset, PyObject **text)
{
long hold;
PyObject *v;
@@ -54,6 +58,7 @@ parse_syntax_error(PyObject *err, PyObject **message, const char **filename,
_Py_IDENTIFIER(text);
*message = NULL;
+ *filename = NULL;
/* new style errors. `err' is an instance */
*message = _PyObject_GetAttrId(err, &PyId_msg);
@@ -65,13 +70,13 @@ parse_syntax_error(PyObject *err, PyObject **message, const char **filename,
goto finally;
if (v == Py_None) {
Py_DECREF(v);
- *filename = NULL;
+ *filename = _PyUnicode_FromId(&PyId_string);
+ if (*filename == NULL)
+ goto finally;
+ Py_INCREF(*filename);
}
else {
- *filename = _PyUnicode_AsString(v);
- Py_DECREF(v);
- if (!*filename)
- goto finally;
+ *filename = v;
}
v = _PyObject_GetAttrId(err, &PyId_lineno);
@@ -105,15 +110,13 @@ parse_syntax_error(PyObject *err, PyObject **message, const char **filename,
*text = NULL;
}
else {
- *text = _PyUnicode_AsString(v);
- Py_DECREF(v);
- if (!*text)
- goto finally;
+ *text = v;
}
return 1;
finally:
Py_XDECREF(*message);
+ Py_XDECREF(*filename);
return 0;
}
/* end copied function! */
@@ -137,9 +140,10 @@ void python_script_error_jump(const char *filepath, int *lineno, int *offset)
if (value) { /* should always be true */
PyObject *message;
- const char *filename, *text;
+ PyObject *filename_py, *text_py;
- if (parse_syntax_error(value, &message, &filename, lineno, offset, &text)) {
+ if (parse_syntax_error(value, &message, &filename_py, lineno, offset, &text_py)) {
+ const char *filename = _PyUnicode_AsString(filename_py);
/* python adds a '/', prefix, so check for both */
if ((BLI_path_cmp(filename, filepath) == 0) ||
((filename[0] == '\\' || filename[0] == '/') && BLI_path_cmp(filename + 1, filepath) == 0))
diff --git a/source/blender/python/intern/bpy_util.c b/source/blender/python/intern/bpy_util.c
index b0b0f346944..93183a4f320 100644
--- a/source/blender/python/intern/bpy_util.c
+++ b/source/blender/python/intern/bpy_util.c
@@ -86,7 +86,7 @@ short BPy_errors_to_report(ReportList *reports)
{
PyObject *pystring;
PyObject *pystring_format = NULL; /* workaround, see below */
- char *cstring;
+ const char *cstring;
const char *filename;
int lineno;
diff --git a/source/blender/python/intern/bpy_util.h b/source/blender/python/intern/bpy_util.h
index b007e123cfc..d19696aa230 100644
--- a/source/blender/python/intern/bpy_util.h
+++ b/source/blender/python/intern/bpy_util.h
@@ -27,8 +27,8 @@
#ifndef __BPY_UTIL_H__
#define __BPY_UTIL_H__
-#if PY_VERSION_HEX < 0x03030000
-# error "Python 3.3 or greater is required, you'll need to update your python."
+#if PY_VERSION_HEX < 0x03040000
+# error "Python 3.4 or greater is required, you'll need to update your python."
#endif
struct EnumPropertyItem;
diff --git a/source/blender/python/intern/gpu.c b/source/blender/python/intern/gpu.c
index 5dcf67e5417..26e3bde57a3 100644
--- a/source/blender/python/intern/gpu.c
+++ b/source/blender/python/intern/gpu.c
@@ -42,8 +42,6 @@
#include "DNA_scene_types.h"
#include "DNA_image_types.h"
#include "DNA_material_types.h"
-#include "DNA_lamp_types.h"
-#include "DNA_object_types.h"
#include "DNA_ID.h"
#include "DNA_customdata_types.h"
diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c
index 1c8718aa122..6129bb869f5 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.c
+++ b/source/blender/python/mathutils/mathutils_Matrix.c
@@ -42,6 +42,7 @@ typedef enum eMatrixAccess_t {
MAT_ACCESS_COL
} eMatrixAccess_t;
+static PyObject *Matrix_copy_notest(MatrixObject *self, const float *matrix);
static PyObject *Matrix_copy(MatrixObject *self);
static PyObject *Matrix_deepcopy(MatrixObject *self, PyObject *args);
static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *value);
@@ -550,7 +551,9 @@ PyDoc_STRVAR(C_Matrix_Translation_doc,
);
static PyObject *C_Matrix_Translation(PyObject *cls, PyObject *value)
{
- float mat[4][4] = MAT4_UNITY;
+ float mat[4][4];
+
+ unit_m4(mat);
if (mathutils_array_parse(mat[3], 3, 4, value, "mathutils.Matrix.Translation(vector), invalid vector arg") == -1)
return NULL;
@@ -881,8 +884,17 @@ void matrix_as_3x3(float mat[3][3], MatrixObject *self)
copy_v3_v3(mat[2], MATRIX_COL_PTR(self, 2));
}
+static void matrix_copy(MatrixObject *mat_dst, const MatrixObject *mat_src)
+{
+ BLI_assert((mat_dst->num_col == mat_src->num_col) &&
+ (mat_dst->num_row == mat_src->num_row));
+ BLI_assert(mat_dst != mat_src);
+
+ memcpy(mat_dst->matrix, mat_src->matrix, sizeof(float) * (mat_dst->num_col * mat_dst->num_row));
+}
+
/* assumes rowsize == colsize is checked and the read callback has run */
-static float matrix_determinant_internal(MatrixObject *self)
+static float matrix_determinant_internal(const MatrixObject *self)
{
if (self->num_col == 2) {
return determinant_m2(MATRIX_ITEM(self, 0, 0), MATRIX_ITEM(self, 0, 1),
@@ -898,6 +910,58 @@ static float matrix_determinant_internal(MatrixObject *self)
}
}
+/**
+ * \param r_mat can be from ``self->matrix`` or not. */
+static bool matrix_invert_internal(const MatrixObject *self, float *r_mat)
+{
+ float det;
+
+ det = matrix_determinant_internal(self);
+
+ if (det != 0.0f) {
+ float mat[MATRIX_MAX_DIM * MATRIX_MAX_DIM];
+ int x, y, z;
+
+ /* calculate the classical adjoint */
+ switch (self->num_col) {
+ case 2:
+ {
+ adjoint_m2_m2((float (*)[2])mat, (float (*)[2])self->matrix);
+ break;
+ }
+ case 3:
+ {
+ adjoint_m3_m3((float (*)[3])mat, (float (*)[3])self->matrix);
+ break;
+ }
+ case 4:
+ {
+ adjoint_m4_m4((float (*)[4])mat, (float (*)[4])self->matrix);
+ break;
+ }
+ default:
+ BLI_assert(0);
+ }
+ /* divide by determinate */
+ for (x = 0; x < (self->num_col * self->num_row); x++) {
+ mat[x] /= det;
+ }
+ /* set values */
+ z = 0;
+ for (x = 0; x < self->num_col; x++) {
+ for (y = 0; y < self->num_row; y++) {
+ r_mat[MATRIX_ITEM_INDEX(self, y, x)] = mat[z];
+ z++;
+ }
+ }
+
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
/*-----------------------------METHODS----------------------------*/
PyDoc_STRVAR(Matrix_to_quaternion_doc,
@@ -1013,7 +1077,7 @@ PyDoc_STRVAR(Matrix_resize_4x4_doc,
);
static PyObject *Matrix_resize_4x4(MatrixObject *self)
{
- float mat[4][4] = MAT4_UNITY;
+ float mat[4][4];
int col;
if (self->wrapped == Py_WRAP) {
@@ -1029,7 +1093,7 @@ static PyObject *Matrix_resize_4x4(MatrixObject *self)
return NULL;
}
- self->matrix = PyMem_Realloc(self->matrix, (sizeof(float) * 16));
+ self->matrix = PyMem_Realloc(self->matrix, (sizeof(float) * (MATRIX_MAX_DIM * MATRIX_MAX_DIM)));
if (self->matrix == NULL) {
PyErr_SetString(PyExc_MemoryError,
"Matrix.resize_4x4(): "
@@ -1037,6 +1101,8 @@ static PyObject *Matrix_resize_4x4(MatrixObject *self)
return NULL;
}
+ unit_m4(mat);
+
for (col = 0; col < self->num_col; col++) {
memcpy(mat[col], MATRIX_COL_PTR(self, col), self->num_row * sizeof(float));
}
@@ -1163,79 +1229,104 @@ static PyObject *Matrix_to_scale(MatrixObject *self)
}
/*---------------------------matrix.invert() ---------------------*/
+
+/* re-usable checks for invert */
+static bool matrix_invert_is_compat(const MatrixObject *self)
+{
+ if (self->num_col != self->num_row) {
+ PyErr_SetString(PyExc_ValueError,
+ "Matrix.invert(ed): "
+ "only square matrices are supported");
+ return false;
+ }
+ else {
+ return true;
+ }
+}
+
+static bool matrix_invert_args_check(const MatrixObject *self, PyObject *args, bool check_type)
+{
+ switch (PyTuple_GET_SIZE(args)) {
+ case 0:
+ return true;
+ case 1:
+ if (check_type) {
+ const MatrixObject *fallback = (MatrixObject *)PyTuple_GET_ITEM(args, 0);
+ if (!MatrixObject_Check(fallback)) {
+ PyErr_SetString(PyExc_TypeError,
+ "Matrix.invert: "
+ "expects a matrix argument or nothing");
+ return false;
+ }
+
+ if ((self->num_col != fallback->num_col) ||
+ (self->num_row != fallback->num_row))
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "Matrix.invert: "
+ "matrix argument has different dimensions");
+ return false;
+ }
+ }
+
+ return true;
+ default:
+ PyErr_SetString(PyExc_ValueError,
+ "Matrix.invert(ed): "
+ "takes at most one argument");
+ return false;
+ }
+}
+
+static void matrix_invert_raise_degenerate(void)
+{
+ PyErr_SetString(PyExc_ValueError,
+ "Matrix.invert(ed): "
+ "matrix does not have an inverse");
+}
+
PyDoc_STRVAR(Matrix_invert_doc,
-".. method:: invert()\n"
+".. method:: invert(fallback=None)\n"
"\n"
" Set the matrix to its inverse.\n"
"\n"
-" .. note:: When the matrix cant be inverted a :exc:`ValueError` exception is raised.\n"
+" :arg fallback: Set the matrix to this value when the inverse can't be calculated\n"
+" (instead of raising a :exc:`ValueError` exception).\n"
+" :type fallback: :class:`Matrix`\n"
"\n"
" .. seealso:: <http://en.wikipedia.org/wiki/Inverse_matrix>\n"
);
-static PyObject *Matrix_invert(MatrixObject *self)
+static PyObject *Matrix_invert(MatrixObject *self, PyObject *args)
{
-
- int x, y, z = 0;
- float det = 0.0f;
- float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f};
-
if (BaseMath_ReadCallback(self) == -1)
return NULL;
- if (self->num_col != self->num_row) {
- PyErr_SetString(PyExc_ValueError,
- "Matrix.invert(ed): "
- "only square matrices are supported");
+ if (matrix_invert_is_compat(self) == false) {
return NULL;
}
- /* calculate the determinant */
- det = matrix_determinant_internal(self);
+ if (matrix_invert_args_check(self, args, true) == false) {
+ return NULL;
+ }
- if (det != 0) {
- /* calculate the classical adjoint */
- switch (self->num_col) {
- case 2:
- {
- adjoint_m2_m2((float (*)[2])mat, (float (*)[2])self->matrix);
- break;
- }
- case 3:
- {
- adjoint_m3_m3((float (*)[3])mat, (float (*)[3])self->matrix);
- break;
- }
- case 4:
- {
- adjoint_m4_m4((float (*)[4])mat, (float (*)[4])self->matrix);
- break;
- }
- default:
- PyErr_Format(PyExc_ValueError,
- "Matrix invert(ed): size (%d) unsupported",
- (int)self->num_col);
+ if (matrix_invert_internal(self, self->matrix)) {
+ /* pass */
+ }
+ else {
+ if (PyTuple_GET_SIZE(args) == 1) {
+ MatrixObject *fallback = (MatrixObject *)PyTuple_GET_ITEM(args, 0);
+
+ if (BaseMath_ReadCallback(fallback) == -1)
return NULL;
- }
- /* divide by determinate */
- for (x = 0; x < (self->num_col * self->num_row); x++) {
- mat[x] /= det;
- }
- /* set values */
- for (x = 0; x < self->num_col; x++) {
- for (y = 0; y < self->num_row; y++) {
- MATRIX_ITEM(self, y, x) = mat[z];
- z++;
+
+ if (self != fallback) {
+ matrix_copy(self, fallback);
}
}
- }
- else {
- PyErr_SetString(PyExc_ValueError,
- "Matrix.invert(ed): "
- "matrix does not have an inverse");
- return NULL;
+ else {
+ matrix_invert_raise_degenerate();
+ return NULL;
+ }
}
(void)BaseMath_WriteCallback(self);
@@ -1243,18 +1334,68 @@ static PyObject *Matrix_invert(MatrixObject *self)
}
PyDoc_STRVAR(Matrix_inverted_doc,
-".. method:: inverted()\n"
+".. method:: inverted(fallback=None)\n"
"\n"
" Return an inverted copy of the matrix.\n"
"\n"
-" :return: the inverted matrix.\n"
+" :arg fallback: return this value when the inverse can't be calculated\n"
+" (instead of raising a :exc:`ValueError` exception).\n"
+" :type fallback: any\n"
+" :return: the inverted matrix or fallback when given.\n"
" :rtype: :class:`Matrix`\n"
-"\n"
-" .. note:: When the matrix cant be inverted a :exc:`ValueError` exception is raised.\n"
);
-static PyObject *Matrix_inverted(MatrixObject *self)
+static PyObject *Matrix_inverted(MatrixObject *self, PyObject *args)
{
- return matrix__apply_to_copy((PyNoArgsFunction)Matrix_invert, self);
+ float mat[MATRIX_MAX_DIM * MATRIX_MAX_DIM];
+
+ if (BaseMath_ReadCallback(self) == -1)
+ return NULL;
+
+ if (matrix_invert_args_check(self, args, false) == false) {
+ return NULL;
+ }
+
+ if (matrix_invert_is_compat(self) == false) {
+ return NULL;
+ }
+
+ if (matrix_invert_internal(self, mat)) {
+ /* pass */
+ }
+ else {
+ if (PyTuple_GET_SIZE(args) == 1) {
+ PyObject *fallback = PyTuple_GET_ITEM(args, 0);
+ Py_INCREF(fallback);
+ return fallback;
+ }
+ else {
+ matrix_invert_raise_degenerate();
+ return NULL;
+ }
+ }
+
+ return Matrix_copy_notest(self, mat);
+}
+
+static PyObject *Matrix_inverted_noargs(MatrixObject *self)
+{
+ if (BaseMath_ReadCallback(self) == -1)
+ return NULL;
+
+ if (matrix_invert_is_compat(self) == false) {
+ return NULL;
+ }
+
+ if (matrix_invert_internal(self, self->matrix)) {
+ /* pass */
+ }
+ else {
+ matrix_invert_raise_degenerate();
+ return NULL;
+ }
+
+ (void)BaseMath_WriteCallback(self);
+ Py_RETURN_NONE;
}
/*---------------------------matrix.adjugate() ---------------------*/
@@ -1633,6 +1774,12 @@ static PyObject *Matrix_identity(MatrixObject *self)
}
/*---------------------------Matrix.copy() ------------------*/
+
+static PyObject *Matrix_copy_notest(MatrixObject *self, const float *matrix)
+{
+ return Matrix_CreatePyObject((float *)matrix, self->num_col, self->num_row, Py_NEW, Py_TYPE(self));
+}
+
PyDoc_STRVAR(Matrix_copy_doc,
".. method:: copy()\n"
"\n"
@@ -1646,7 +1793,7 @@ static PyObject *Matrix_copy(MatrixObject *self)
if (BaseMath_ReadCallback(self) == -1)
return NULL;
- return Matrix_CreatePyObject((float (*))self->matrix, self->num_col, self->num_row, Py_NEW, Py_TYPE(self));
+ return Matrix_copy_notest(self, self->matrix);
}
static PyObject *Matrix_deepcopy(MatrixObject *self, PyObject *args)
{
@@ -1811,7 +1958,7 @@ static PyObject *Matrix_item_col(MatrixObject *self, int col)
static int Matrix_ass_item_row(MatrixObject *self, int row, PyObject *value)
{
int col;
- float vec[4];
+ float vec[MATRIX_MAX_DIM];
if (BaseMath_ReadCallback(self) == -1)
return -1;
@@ -1836,7 +1983,7 @@ static int Matrix_ass_item_row(MatrixObject *self, int row, PyObject *value)
static int Matrix_ass_item_col(MatrixObject *self, int col, PyObject *value)
{
int row;
- float vec[4];
+ float vec[MATRIX_MAX_DIM];
if (BaseMath_ReadCallback(self) == -1)
return -1;
@@ -1904,7 +2051,7 @@ static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *va
else {
const int size = end - begin;
int row, col;
- float mat[16];
+ float mat[MATRIX_MAX_DIM * MATRIX_MAX_DIM];
float vec[4];
if (PySequence_Fast_GET_SIZE(value_fast) != size) {
@@ -1946,7 +2093,7 @@ static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *va
*------------------------obj + obj------------------------------*/
static PyObject *Matrix_add(PyObject *m1, PyObject *m2)
{
- float mat[16];
+ float mat[MATRIX_MAX_DIM * MATRIX_MAX_DIM];
MatrixObject *mat1 = NULL, *mat2 = NULL;
mat1 = (MatrixObject *)m1;
@@ -1978,7 +2125,7 @@ static PyObject *Matrix_add(PyObject *m1, PyObject *m2)
* subtraction */
static PyObject *Matrix_sub(PyObject *m1, PyObject *m2)
{
- float mat[16];
+ float mat[MATRIX_MAX_DIM * MATRIX_MAX_DIM];
MatrixObject *mat1 = NULL, *mat2 = NULL;
mat1 = (MatrixObject *)m1;
@@ -2010,7 +2157,7 @@ static PyObject *Matrix_sub(PyObject *m1, PyObject *m2)
* multiplication */
static PyObject *matrix_mul_float(MatrixObject *mat, const float scalar)
{
- float tmat[16];
+ float tmat[MATRIX_MAX_DIM * MATRIX_MAX_DIM];
mul_vn_vn_fl(tmat, mat->matrix, mat->num_col * mat->num_row, scalar);
return Matrix_CreatePyObject(tmat, mat->num_col, mat->num_row, Py_NEW, Py_TYPE(mat));
}
@@ -2035,10 +2182,7 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2)
if (mat1 && mat2) {
/* MATRIX * MATRIX */
- float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f};
+ float mat[MATRIX_MAX_DIM * MATRIX_MAX_DIM];
int col, row, item;
@@ -2071,7 +2215,7 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2)
/* MATRIX * VECTOR */
if (VectorObject_Check(m2)) {
VectorObject *vec2 = (VectorObject *)m2;
- float tvec[4];
+ float tvec[MATRIX_MAX_DIM];
if (BaseMath_ReadCallback(vec2) == -1)
return NULL;
if (column_vector_multiplication(tvec, vec2, mat1) == -1) {
@@ -2205,7 +2349,7 @@ static PyNumberMethods Matrix_NumMethods = {
(unaryfunc) 0, /*tp_positive*/
(unaryfunc) 0, /*tp_absolute*/
(inquiry) 0, /*tp_bool*/
- (unaryfunc) Matrix_inverted, /*nb_invert*/
+ (unaryfunc) Matrix_inverted_noargs, /*nb_invert*/
NULL, /*nb_lshift*/
(binaryfunc)0, /*nb_rshift*/
NULL, /*nb_and*/
@@ -2413,8 +2557,8 @@ static struct PyMethodDef Matrix_methods[] = {
{"transposed", (PyCFunction) Matrix_transposed, METH_NOARGS, Matrix_transposed_doc},
{"normalize", (PyCFunction) Matrix_normalize, METH_NOARGS, Matrix_normalize_doc},
{"normalized", (PyCFunction) Matrix_normalized, METH_NOARGS, Matrix_normalized_doc},
- {"invert", (PyCFunction) Matrix_invert, METH_NOARGS, Matrix_invert_doc},
- {"inverted", (PyCFunction) Matrix_inverted, METH_NOARGS, Matrix_inverted_doc},
+ {"invert", (PyCFunction) Matrix_invert, METH_VARARGS, Matrix_invert_doc},
+ {"inverted", (PyCFunction) Matrix_inverted, METH_VARARGS, Matrix_inverted_doc},
{"adjugate", (PyCFunction) Matrix_adjugate, METH_NOARGS, Matrix_adjugate_doc},
{"adjugated", (PyCFunction) Matrix_adjugated, METH_NOARGS, Matrix_adjugated_doc},
{"to_3x3", (PyCFunction) Matrix_to_3x3, METH_NOARGS, Matrix_to_3x3_doc},
diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c
index 7f191369cd7..a719691d5d4 100644
--- a/source/blender/python/mathutils/mathutils_Vector.c
+++ b/source/blender/python/mathutils/mathutils_Vector.c
@@ -1201,11 +1201,11 @@ static PyObject *Vector_lerp(VectorObject *self, PyObject *args)
PyDoc_STRVAR(Vector_slerp_doc,
".. function:: slerp(other, factor, fallback=None)\n"
"\n"
-" Returns the interpolation of two unit vectors (spherical coordinates).\n"
+" Returns the interpolation of two non-zero vectors (spherical coordinates).\n"
"\n"
" :arg other: value to interpolate with.\n"
" :type other: :class:`Vector`\n"
-" :arg factor: The interpolation value in [0.0, 1.0].\n"
+" :arg factor: The interpolation value typically in [0.0, 1.0].\n"
" :type factor: float\n"
" :arg fallback: return this value when the vector can't be calculated\n"
" (zero length vector or direct opposites)\n"
@@ -1218,8 +1218,8 @@ static PyObject *Vector_slerp(VectorObject *self, PyObject *args)
const int size = self->size;
PyObject *value = NULL;
float fac, cosom, w[2];
- float tvec[3], vec[3];
- double self_len_sq, other_len_sq;
+ float self_vec[3], other_vec[3], ret_vec[3];
+ float self_len_sq, other_len_sq;
int x;
PyObject *fallback = NULL;
@@ -1236,16 +1236,16 @@ static PyObject *Vector_slerp(VectorObject *self, PyObject *args)
return NULL;
}
- if (mathutils_array_parse(tvec, size, size, value, "Vector.slerp(other), invalid 'other' arg") == -1) {
+ if (mathutils_array_parse(other_vec, size, size, value, "Vector.slerp(other), invalid 'other' arg") == -1) {
return NULL;
}
- self_len_sq = len_squared_vn(self->vec, size);
- other_len_sq = len_squared_vn(tvec, size);
+ self_len_sq = normalize_vn_vn(self_vec, self->vec, size);
+ other_len_sq = normalize_vn(other_vec, size);
/* use fallbacks for zero length vectors */
- if (UNLIKELY((self_len_sq < (double)FLT_EPSILON) ||
- (other_len_sq < (double)FLT_EPSILON)))
+ if (UNLIKELY((self_len_sq < FLT_EPSILON) ||
+ (other_len_sq < FLT_EPSILON)))
{
/* avoid exception */
if (fallback) {
@@ -1260,18 +1260,8 @@ static PyObject *Vector_slerp(VectorObject *self, PyObject *args)
}
}
- /* no attempt made to normalize, no fallback */
- if (UNLIKELY((fabs(self_len_sq - 1.0) > (double)FLT_EPSILON) ||
- (fabs(other_len_sq - 1.0) > (double)FLT_EPSILON)))
- {
- PyErr_SetString(PyExc_ValueError,
- "Vector.slerp(): "
- "both vectors must be unit length");
- return NULL;
- }
-
/* We have sane state, execute slerp */
- cosom = (float)dot_vn_vn(self->vec, tvec, size);
+ cosom = (float)dot_vn_vn(self_vec, other_vec, size);
/* direct opposite, can't slerp */
if (UNLIKELY(cosom < (-1.0f + FLT_EPSILON))) {
@@ -1291,12 +1281,10 @@ static PyObject *Vector_slerp(VectorObject *self, PyObject *args)
interp_dot_slerp(fac, cosom, w);
for (x = 0; x < size; x++) {
- vec[x] = (w[0] * self->vec[x]) + (w[1] * tvec[x]);
+ ret_vec[x] = (w[0] * self_vec[x]) + (w[1] * other_vec[x]);
}
- interp_v3_v3v3_slerp_safe(vec, self->vec, tvec, fac);
-
- return Vector_CreatePyObject(vec, size, Py_NEW, Py_TYPE(self));
+ return Vector_CreatePyObject(ret_vec, size, Py_NEW, Py_TYPE(self));
}
PyDoc_STRVAR(Vector_rotate_doc,
diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c
index 142e5cadfd1..139764abb00 100644
--- a/source/blender/python/mathutils/mathutils_geometry.c
+++ b/source/blender/python/mathutils/mathutils_geometry.c
@@ -269,7 +269,7 @@ static PyObject *M_Geometry_intersect_sphere_sphere_2d(PyObject *UNUSED(self), P
{
PyObject *ret;
VectorObject *vec_a, *vec_b;
- float *v_a, *v_b;
+ const float *v_a, *v_b;
float rad_a, rad_b;
float v_ab[2];
float dist;
diff --git a/source/blender/python/mathutils/mathutils_noise.c b/source/blender/python/mathutils/mathutils_noise.c
index 61bc2b60861..8dfa7904300 100644
--- a/source/blender/python/mathutils/mathutils_noise.c
+++ b/source/blender/python/mathutils/mathutils_noise.c
@@ -36,13 +36,10 @@
#include "structseq.h"
-#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_noise.h"
#include "BLI_utildefines.h"
-#include "MEM_guardedalloc.h"
-
#include "DNA_texture_types.h"
#include "mathutils.h"
diff --git a/source/blender/render/CMakeLists.txt b/source/blender/render/CMakeLists.txt
index f369e5a2d77..8e326e770fc 100644
--- a/source/blender/render/CMakeLists.txt
+++ b/source/blender/render/CMakeLists.txt
@@ -48,12 +48,12 @@ set(SRC
intern/raytrace/rayobject_octree.cpp
intern/raytrace/rayobject_raycounter.cpp
intern/raytrace/rayobject_svbvh.cpp
- intern/raytrace/rayobject_blibvh.cpp
intern/raytrace/rayobject_instance.cpp
intern/raytrace/rayobject_qbvh.cpp
intern/raytrace/rayobject_rtbuild.cpp
intern/raytrace/rayobject_vbvh.cpp
intern/source/bake.c
+ intern/source/bake_api.c
intern/source/convertblender.c
intern/source/envmap.c
intern/source/external_engine.c
@@ -83,6 +83,7 @@ set(SRC
intern/source/zbuf.c
extern/include/RE_engine.h
+ extern/include/RE_bake.h
extern/include/RE_multires_bake.h
extern/include/RE_pipeline.h
extern/include/RE_render_ext.h
diff --git a/source/blender/render/extern/include/RE_bake.h b/source/blender/render/extern/include/RE_bake.h
new file mode 100644
index 00000000000..d59819c8ef4
--- /dev/null
+++ b/source/blender/render/extern/include/RE_bake.h
@@ -0,0 +1,105 @@
+/*
+ * ***** 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) 2010 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s):
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file RE_bake.h
+ * \ingroup render
+ */
+
+#ifndef __RE_BAKE_H__
+#define __RE_BAKE_H__
+
+struct Render;
+struct Mesh;
+
+typedef struct BakeImage {
+ struct Image *image;
+ int width;
+ int height;
+ int offset;
+} BakeImage;
+
+typedef struct BakeImages {
+ BakeImage *data; /* all the images of an object */
+ int *lookup; /* lookup table from Material to BakeImage */
+ int size;
+} BakeImages;
+
+typedef struct BakePixel {
+ int primitive_id;
+ float uv[2];
+ float du_dx, du_dy;
+ float dv_dx, dv_dy;
+} BakePixel;
+
+typedef struct BakeHighPolyData {
+ struct BakePixel *pixel_array;
+ struct Object *ob;
+ struct ModifierData *tri_mod;
+ struct Mesh *me;
+ char restrict_flag;
+ float mat_lowtohigh[4][4];
+} BakeHighPolyData;
+
+/* external_engine.c */
+bool RE_bake_has_engine(struct Render *re);
+
+bool RE_bake_engine(
+ struct Render *re, struct Object *object, const BakePixel pixel_array[],
+ const int num_pixels, const int depth, const ScenePassType pass_type, float result[]);
+
+/* bake.c */
+int RE_pass_depth(const ScenePassType pass_type);
+bool RE_bake_internal(
+ struct Render *re, struct Object *object, const BakePixel pixel_array[],
+ const int num_pixels, const int depth, const ScenePassType pass_type, float result[]);
+
+void RE_bake_pixels_populate_from_objects(
+ struct Mesh *me_low, BakePixel pixel_array_from[],
+ BakeHighPolyData highpoly[], const int tot_highpoly, const int num_pixels,
+ const float cage_extrusion);
+
+void RE_bake_pixels_populate(
+ struct Mesh *me, struct BakePixel *pixel_array,
+ const int num_pixels, const struct BakeImages *bake_images);
+
+void RE_bake_mask_fill(const BakePixel pixel_array[], const int num_pixels, char *mask);
+
+void RE_bake_margin(struct ImBuf *ibuf, char *mask, const int margin);
+
+void RE_bake_normal_world_to_object(
+ const BakePixel pixel_array[], const int num_pixels, const int depth, float result[],
+ struct Object *ob, const BakeNormalSwizzle normal_swizzle[3]);
+void RE_bake_normal_world_to_tangent(
+ const BakePixel pixel_array[], const int num_pixels, const int depth, float result[],
+ struct Mesh *me, const BakeNormalSwizzle normal_swizzle[3]);
+void RE_bake_normal_world_to_world(
+ const BakePixel pixel_array[], const int num_pixels, const int depth, float result[],
+ const BakeNormalSwizzle normal_swizzle[3]);
+
+void RE_bake_ibuf_clear(struct BakeImages *bake_images, const bool is_tangent);
+
+#endif /* __RE_BAKE_H__ */
diff --git a/source/blender/render/extern/include/RE_engine.h b/source/blender/render/extern/include/RE_engine.h
index bd976e6c14a..2c6492b5c5a 100644
--- a/source/blender/render/extern/include/RE_engine.h
+++ b/source/blender/render/extern/include/RE_engine.h
@@ -35,6 +35,7 @@
#include "DNA_listBase.h"
#include "DNA_scene_types.h"
#include "RNA_types.h"
+#include "RE_bake.h"
struct bNode;
struct bNodeTree;
@@ -47,6 +48,7 @@ struct RenderLayer;
struct RenderResult;
struct ReportList;
struct Scene;
+struct BakePixel;
/* External Engine */
@@ -85,6 +87,7 @@ typedef struct RenderEngineType {
void (*update)(struct RenderEngine *engine, struct Main *bmain, struct Scene *scene);
void (*render)(struct RenderEngine *engine, struct Scene *scene);
+ void (*bake)(struct RenderEngine *engine, struct Scene *scene, struct Object *object, const int pass_type, 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 (*view_draw)(struct RenderEngine *engine, const struct bContext *context);
@@ -153,6 +156,7 @@ RenderEngineType *RE_engines_find(const char *idname);
void RE_engine_get_current_tiles(struct Render *re, int *total_tiles_r, rcti **tiles_r);
struct RenderData *RE_engine_get_render_data(struct Render *re);
+void RE_bake_engine_set_engine_parameters(struct Render *re, struct Main *bmain, struct Scene *scene);
#endif /* __RE_ENGINE_H__ */
diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h
index 6d994b36f26..031d6b5a51a 100644
--- a/source/blender/render/extern/include/RE_pipeline.h
+++ b/source/blender/render/extern/include/RE_pipeline.h
@@ -257,6 +257,7 @@ void RE_stats_draw_cb (struct Render *re, void *handle, void (*f)(void *handle,
void RE_progress_cb (struct Render *re, void *handle, void (*f)(void *handle, float));
void RE_draw_lock_cb (struct Render *re, void *handle, void (*f)(void *handle, int));
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));
/* 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_shader_ext.h b/source/blender/render/extern/include/RE_shader_ext.h
index 70e3edccb2c..da847d235f2 100644
--- a/source/blender/render/extern/include/RE_shader_ext.h
+++ b/source/blender/render/extern/include/RE_shader_ext.h
@@ -81,7 +81,7 @@ struct ShadeInputCopy {
short osatex;
float vn[3], vno[3]; /* actual render normal, and a copy to restore it */
float n1[3], n2[3], n3[3]; /* vertex normals, corrected */
- int mode; /* base material mode (OR-ed result of entire node tree) */
+ int mode, mode2; /* base material mode (OR-ed result of entire node tree) */
};
typedef struct ShadeInputUV {
@@ -113,7 +113,7 @@ typedef struct ShadeInput {
short osatex;
float vn[3], vno[3]; /* actual render normal, and a copy to restore it */
float n1[3], n2[3], n3[3]; /* vertex normals, corrected */
- int mode; /* base material mode (OR-ed result of entire node tree) */
+ int mode, mode2; /* base material mode (OR-ed result of entire node tree) */
/* internal face coordinates */
float u, v, dx_u, dx_v, dy_u, dy_v;
diff --git a/source/blender/render/intern/include/rayintersection.h b/source/blender/render/intern/include/rayintersection.h
index 3607e66a237..9c0835af56f 100644
--- a/source/blender/render/intern/include/rayintersection.h
+++ b/source/blender/render/intern/include/rayintersection.h
@@ -121,7 +121,7 @@ typedef struct Isect {
/* arbitrary, but can't use e.g. FLT_MAX because of precision issues */
#define RE_RAYTRACE_MAXDIST 1e15f
-#define RE_RAYTRACE_EPSILON 0.0f
+#define RE_RAYTRACE_EPSILON -FLT_EPSILON
#ifdef __cplusplus
}
diff --git a/source/blender/render/intern/include/rayobject.h b/source/blender/render/intern/include/rayobject.h
index e9514b8585e..63135d01c23 100644
--- a/source/blender/render/intern/include/rayobject.h
+++ b/source/blender/render/intern/include/rayobject.h
@@ -59,7 +59,6 @@ RayObject *RE_rayobject_octree_create(int ocres, int size);
RayObject *RE_rayobject_instance_create(RayObject *target, float transform[4][4], void *ob, void *target_ob);
RayObject *RE_rayobject_empty_create(void);
-RayObject *RE_rayobject_blibvh_create(int size); /* BLI_kdopbvh.c */
RayObject *RE_rayobject_vbvh_create(int size); /* raytrace/rayobject_vbvh.c */
RayObject *RE_rayobject_svbvh_create(int size); /* raytrace/rayobject_svbvh.c */
RayObject *RE_rayobject_qbvh_create(int size); /* raytrace/rayobject_qbvh.c */
diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h
index b9e06d3e6f7..eeb0544cf73 100644
--- a/source/blender/render/intern/include/render_types.h
+++ b/source/blender/render/intern/include/render_types.h
@@ -108,8 +108,9 @@ typedef struct RenderPart {
rcti disprect; /* part coordinates within total picture */
int rectx, recty; /* the size */
+ int nr; /* nr is partnr */
short crop, status; /* crop is amount of pixels we crop, for filter */
- short sample, nr; /* sample can be used by zbuffers, nr is partnr */
+ short sample; /* sample can be used by zbuffers */
short thread; /* thread id */
char *clipflag; /* clipflags for part zbuffering */
@@ -255,6 +256,8 @@ struct Render
void *dch;
void (*display_update)(void *handle, RenderResult *rr, volatile rcti *rect);
void *duh;
+ void (*current_scene_update)(void *handle, struct Scene *scene);
+ void *suh;
void (*stats_draw)(void *handle, RenderStats *ri);
void *sdh;
diff --git a/source/blender/render/intern/include/renderdatabase.h b/source/blender/render/intern/include/renderdatabase.h
index 9b14560b5f5..da45a2bfead 100644
--- a/source/blender/render/intern/include/renderdatabase.h
+++ b/source/blender/render/intern/include/renderdatabase.h
@@ -33,6 +33,10 @@
#ifndef __RENDERDATABASE_H__
#define __RENDERDATABASE_H__
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct Object;
struct VlakRen;
struct VertRen;
@@ -159,6 +163,9 @@ void area_lamp_vectors(struct LampRen *lar);
void init_render_world(Render *re);
void RE_Database_FromScene_Vectors(Render *re, struct Main *bmain, struct Scene *sce, unsigned int lay);
+#ifdef __cplusplus
+}
+#endif
#endif /* __RENDERDATABASE_H__ */
diff --git a/source/blender/render/intern/raytrace/rayobject.cpp b/source/blender/render/intern/raytrace/rayobject.cpp
index 9e639501fdd..de6b9139363 100644
--- a/source/blender/render/intern/raytrace/rayobject.cpp
+++ b/source/blender/render/intern/raytrace/rayobject.cpp
@@ -43,6 +43,7 @@
#include "rayobject.h"
#include "raycounter.h"
#include "render_types.h"
+#include "renderdatabase.h"
/* RayFace
*
@@ -118,7 +119,7 @@ MALWAYS_INLINE int vlr_check_intersect(Isect *is, ObjectInstanceRen *obi, VlakRe
if (is->mode == RE_RAY_MIRROR)
return !(vlr->mat->mode & MA_ONLYCAST);
else
- return (is->lay & obi->lay);
+ return (vlr->mat->mode2 & MA_CASTSHADOW) && (is->lay & obi->lay);
}
MALWAYS_INLINE int vlr_check_intersect_solid(Isect *UNUSED(is), ObjectInstanceRen *UNUSED(obi), VlakRen *vlr)
@@ -326,15 +327,33 @@ MALWAYS_INLINE int intersect_rayface(RayObject *hit_obj, RayFace *face, Isect *i
if (dist < 0.1f && is->orig.ob == face->ob) {
VlakRen *a = (VlakRen *)is->orig.face;
VlakRen *b = (VlakRen *)face->face;
+ ObjectRen *obr = ((ObjectInstanceRen *)face->ob)->obr;
+
+ VertRen **va, **vb;
+ int *org_idx_a, *org_idx_b;
+ int i, j;
+ bool is_neighbor = false;
+
+ /* "same" vertex means either the actual same VertRen, or the same 'final org index', if available
+ * (autosmooth only, currently). */
+ for (i = 0, va = &a->v1; !is_neighbor && i < 4 && *va; ++i, ++va) {
+ org_idx_a = RE_vertren_get_origindex(obr, *va, false);
+ for (j = 0, vb = &b->v1; !is_neighbor && j < 4 && *vb; ++j, ++vb) {
+ if (*va == *vb) {
+ is_neighbor = true;
+ }
+ else if (org_idx_a) {
+ org_idx_b = RE_vertren_get_origindex(obr, *vb, 0);
+ if (org_idx_b && *org_idx_a == *org_idx_b) {
+ is_neighbor = true;
+ }
+ }
+ }
+ }
- /* so there's a shared edge or vertex, let's intersect ray with
- * face itself, if that's true we can safely return 1, otherwise
- * we assume the intersection is invalid, 0 */
- if (a->v1 == b->v1 || a->v2 == b->v1 || a->v3 == b->v1 || a->v4 == b->v1 ||
- a->v1 == b->v2 || a->v2 == b->v2 || a->v3 == b->v2 || a->v4 == b->v2 ||
- a->v1 == b->v3 || a->v2 == b->v3 || a->v3 == b->v3 || a->v4 == b->v3 ||
- (b->v4 && (a->v1 == b->v4 || a->v2 == b->v4 || a->v3 == b->v4 || a->v4 == b->v4)))
- {
+ /* So there's a shared edge or vertex, let's intersect ray with self, if that's true
+ * we can safely return 1, otherwise we assume the intersection is invalid, 0 */
+ if (is_neighbor) {
/* create RayFace from original face, transformed if necessary */
RayFace origface;
ObjectInstanceRen *ob = (ObjectInstanceRen *)is->orig.ob;
diff --git a/source/blender/render/intern/raytrace/rayobject_blibvh.cpp b/source/blender/render/intern/raytrace/rayobject_blibvh.cpp
deleted file mode 100644
index 18e8ba6cd14..00000000000
--- a/source/blender/render/intern/raytrace/rayobject_blibvh.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2009 Blender Foundation.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): André Pinto.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/raytrace/rayobject_blibvh.cpp
- * \ingroup render
- */
-
-#include <assert.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_kdopbvh.h"
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-
-#include "rayintersection.h"
-#include "rayobject.h"
-
-static int RE_rayobject_blibvh_intersect(RayObject *o, Isect *isec);
-static void RE_rayobject_blibvh_add(RayObject *o, RayObject *ob);
-static void RE_rayobject_blibvh_done(RayObject *o);
-static void RE_rayobject_blibvh_free(RayObject *o);
-static void RE_rayobject_blibvh_bb(RayObject *o, float min[3], float max[3]);
-
-static float RE_rayobject_blibvh_cost(RayObject *UNUSED(o))
-{
- //TODO calculate the expected cost to raycast on this structure
- return 1.0;
-}
-
-static void RE_rayobject_blibvh_hint_bb(RayObject *UNUSED(o), RayHint *UNUSED(hint),
- float *UNUSED(min), float *UNUSED(max))
-{
- return;
-}
-
-static RayObjectAPI bvh_api =
-{
- RE_rayobject_blibvh_intersect,
- RE_rayobject_blibvh_add,
- RE_rayobject_blibvh_done,
- RE_rayobject_blibvh_free,
- RE_rayobject_blibvh_bb,
- RE_rayobject_blibvh_cost,
- RE_rayobject_blibvh_hint_bb
-};
-
-typedef struct BVHObject {
- RayObject rayobj;
- RayObject **leafs, **next_leaf;
- BVHTree *bvh;
- float bb[2][3];
-} BVHObject;
-
-RayObject *RE_rayobject_blibvh_create(int size)
-{
- BVHObject *obj = (BVHObject *)MEM_callocN(sizeof(BVHObject), "BVHObject");
- assert(RE_rayobject_isAligned(obj)); /* RayObject API assumes real data to be 4-byte aligned */
-
- obj->rayobj.api = &bvh_api;
- obj->bvh = BLI_bvhtree_new(size, 0.0, 4, 6);
- obj->next_leaf = obj->leafs = (RayObject **)MEM_callocN(size * sizeof(RayObject *), "BVHObject leafs");
-
- INIT_MINMAX(obj->bb[0], obj->bb[1]);
- return RE_rayobject_unalignRayAPI((RayObject *) obj);
-}
-
-struct BVHCallbackUserData {
- Isect *isec;
- RayObject **leafs;
-};
-
-static void bvh_callback(void *userdata, int index, const BVHTreeRay *UNUSED(ray), BVHTreeRayHit *hit)
-{
- struct BVHCallbackUserData *data = (struct BVHCallbackUserData *)userdata;
- Isect *isec = data->isec;
- RayObject *face = data->leafs[index];
-
- if (RE_rayobject_intersect(face, isec)) {
- hit->index = index;
-
- if (isec->mode == RE_RAY_SHADOW)
- hit->dist = 0;
- else
- hit->dist = isec->dist;
- }
-}
-
-static int RE_rayobject_blibvh_intersect(RayObject *o, Isect *isec)
-{
- BVHObject *obj = (BVHObject *)o;
- BVHTreeRayHit hit;
- float dir[3];
- struct BVHCallbackUserData data;
- data.isec = isec;
- data.leafs = obj->leafs;
-
- copy_v3_v3(dir, isec->dir);
-
- hit.index = 0;
- hit.dist = isec->dist;
-
- return BLI_bvhtree_ray_cast(obj->bvh, isec->start, dir, 0.0, &hit, bvh_callback, (void *)&data);
-}
-
-static void RE_rayobject_blibvh_add(RayObject *o, RayObject *ob)
-{
- BVHObject *obj = (BVHObject *)o;
- float min_max[6];
- INIT_MINMAX(min_max, min_max + 3);
- RE_rayobject_merge_bb(ob, min_max, min_max + 3);
-
- DO_MIN(min_max, obj->bb[0]);
- DO_MAX(min_max + 3, obj->bb[1]);
-
- BLI_bvhtree_insert(obj->bvh, obj->next_leaf - obj->leafs, min_max, 2);
- *(obj->next_leaf++) = ob;
-}
-
-static void RE_rayobject_blibvh_done(RayObject *o)
-{
- BVHObject *obj = (BVHObject *)o;
- BLI_bvhtree_balance(obj->bvh);
-}
-
-static void RE_rayobject_blibvh_free(RayObject *o)
-{
- BVHObject *obj = (BVHObject *)o;
-
- if (obj->bvh)
- BLI_bvhtree_free(obj->bvh);
-
- if (obj->leafs)
- MEM_freeN(obj->leafs);
-
- MEM_freeN(obj);
-}
-
-static void RE_rayobject_blibvh_bb(RayObject *o, float min[3], float max[3])
-{
- BVHObject *obj = (BVHObject *)o;
- DO_MIN(obj->bb[0], min);
- DO_MAX(obj->bb[1], max);
-}
-
diff --git a/source/blender/render/intern/raytrace/reorganize.h b/source/blender/render/intern/raytrace/reorganize.h
index 5cb48f7e145..e25538cd584 100644
--- a/source/blender/render/intern/raytrace/reorganize.h
+++ b/source/blender/render/intern/raytrace/reorganize.h
@@ -287,6 +287,10 @@ static float bvh_refit(Node *node)
#define MAX_CUT_SIZE 4 /* svbvh assumes max 4 children! */
#define MAX_OPTIMIZE_CHILDS MAX_CUT_SIZE
+#define CUT_SIZE_IS_VALID(cut_size) ((cut_size) < MAX_CUT_SIZE && (cut_size) >= 0)
+#define CUT_SIZE_INVALID -1
+
+
struct OVBVHNode {
float bb[6];
@@ -300,6 +304,7 @@ struct OVBVHNode {
float cut_cost[MAX_CUT_SIZE];
float get_cost(int cutsize)
{
+ assert(CUT_SIZE_IS_VALID(cutsize - 1));
return cut_cost[cutsize - 1];
}
@@ -310,6 +315,7 @@ struct OVBVHNode {
int cut_size[MAX_CUT_SIZE];
int get_cut_size(int parent_cut_size)
{
+ assert(CUT_SIZE_IS_VALID(parent_cut_size - 1));
return cut_size[parent_cut_size - 1];
}
@@ -343,9 +349,9 @@ struct OVBVHNode {
{
if (RE_rayobject_isAligned(this->child)) {
//Calc new childs
- {
+ if (this->best_cutsize != CUT_SIZE_INVALID) {
OVBVHNode **cut = &(this->child);
- set_cut(best_cutsize, &cut);
+ set_cut(this->best_cutsize, &cut);
*cut = NULL;
}
@@ -468,12 +474,17 @@ struct VBVH_optimalPackSIMD {
}
}
}
- assert(node->cut_cost[0] != INFINITY);
+
+ if (node->cut_cost[0] == INFINITY) {
+ node->best_cutsize = CUT_SIZE_INVALID;
+ }
}
else {
node->cut_cost[0] = 1.0f;
for (int i = 1; i < MAX_CUT_SIZE; i++)
node->cut_cost[i] = INFINITY;
+
+ /* node->best_cutsize can remain unset here */
}
}
diff --git a/source/blender/render/intern/source/bake.c b/source/blender/render/intern/source/bake.c
index 59a2a0d78fc..f2793a9bc5b 100644
--- a/source/blender/render/intern/source/bake.c
+++ b/source/blender/render/intern/source/bake.c
@@ -34,7 +34,6 @@
#include "MEM_guardedalloc.h"
#include "BLI_math.h"
-#include "BLI_blenlib.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
@@ -55,6 +54,8 @@
#include "IMB_imbuf.h"
#include "IMB_colormanagement.h"
+#include "RE_bake.h"
+
/* local include */
#include "rayintersection.h"
#include "rayobject.h"
@@ -373,7 +374,7 @@ static void bake_displacement(void *handle, ShadeInput *UNUSED(shi), float dist,
bs->vcol->b = col[2];
}
else {
- char *imcol = (char *)(bs->rect + bs->rectx * y + x);
+ const char *imcol = (char *)(bs->rect + bs->rectx * y + x);
copy_v4_v4_char((char *)imcol, (char *)col);
}
}
@@ -936,8 +937,8 @@ void RE_bake_ibuf_filter(ImBuf *ibuf, char *mask, const int filter)
void RE_bake_ibuf_normalize_displacement(ImBuf *ibuf, float *displacement, char *mask, float displacement_min, float displacement_max)
{
int i;
- float *current_displacement = displacement;
- char *current_mask = mask;
+ const float *current_displacement = displacement;
+ const char *current_mask = mask;
float max_distance;
max_distance = max_ff(fabsf(displacement_min), fabsf(displacement_max));
diff --git a/source/blender/render/intern/source/bake_api.c b/source/blender/render/intern/source/bake_api.c
new file mode 100644
index 00000000000..258208eeec6
--- /dev/null
+++ b/source/blender/render/intern/source/bake_api.c
@@ -0,0 +1,867 @@
+/*
+ * ***** 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.
+ *
+ * Contributors:
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/render/intern/source/bake_api.c
+ * \ingroup render
+ *
+ * \brief The API itself is simple. Blender sends a populated array of BakePixels to the renderer, and gets back an
+ * array of floats with the result.
+ *
+ * \section bake_api Development Notes for External Engines
+ *
+ * The Bake API is fully implemented with Python rna functions. The operator expects/call a function:
+ *
+ * ``def bake(scene, object, pass_type, pixel_array, num_pixels, depth, result)``
+ * - scene: current scene (Python object)
+ * - object: object to render (Python object)
+ * - pass_type: pass to render (string, e.g., "COMBINED", "AO", "NORMAL", ...)
+ * - pixel_array: list of primitive ids and barycentric coordinates to bake(Python object, see bake_pixel)
+ * - num_pixels: size of pixel_array, number of pixels to bake (int)
+ * - depth: depth of pixels to return (int, assuming always 4 now)
+ * - result: array to be populated by the engine (float array, PyLong_AsVoidPtr)
+ *
+ * \note Normals are expected to be in World Space and in the +X, +Y, +Z orientation.
+ *
+ * \subsection bake_pixel BakePixel data structure
+ *
+ * pixel_array is a Python object storing BakePixel elements:
+ *
+ * <pre>
+ * struct BakePixel {
+ * int primitive_id;
+ * float uv[2];
+ * float du_dx, du_dy;
+ * float dv_dx, dv_dy;
+ * };
+ * </pre>
+ *
+ * In python you have access to:
+ * - ``primitive_id``, ``uv``, ``du_dx``, ``du_dy``, ``next``
+ * - ``next()`` is a function that returns the next #BakePixel in the array.
+ *
+ * \note Pixels that should not be baked have ``primitive_id == -1``
+ *
+ * For a complete implementation example look at the Cycles Bake commit.
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_math.h"
+
+#include "DNA_mesh_types.h"
+
+#include "BKE_cdderivedmesh.h"
+#include "BKE_image.h"
+#include "BKE_node.h"
+
+#include "IMB_imbuf_types.h"
+#include "IMB_imbuf.h"
+
+#include "RE_bake.h"
+
+/* local include */
+#include "render_types.h"
+#include "zbuf.h"
+
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */
+/* only to be used here in this file, it's for speed */
+extern struct Render R;
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+
+typedef struct BakeDataZSpan {
+ BakePixel *pixel_array;
+ int primitive_id;
+ BakeImage *bk_image;
+ ZSpan *zspan;
+ float du_dx, du_dy;
+ float dv_dx, dv_dy;
+} BakeDataZSpan;
+
+/**
+ * struct wrapping up tangent space data
+ */
+typedef struct TSpace {
+ float tangent[3];
+ float sign;
+} TSpace;
+
+typedef struct TriTessFace {
+ const MVert *mverts[3];
+ const TSpace *tspace[3];
+ float normal[3]; /* for flat faces */
+ bool is_smooth;
+} TriTessFace;
+
+static void store_bake_pixel(void *handle, int x, int y, float u, float v)
+{
+ BakeDataZSpan *bd = (BakeDataZSpan *)handle;
+ BakePixel *pixel;
+
+ const int width = bd->bk_image->width;
+ const int offset = bd->bk_image->offset;
+ const int i = offset + y * width + x;
+
+ pixel = &bd->pixel_array[i];
+ pixel->primitive_id = bd->primitive_id;
+
+ copy_v2_fl2(pixel->uv, u, v);
+
+ pixel->du_dx = bd->du_dx;
+ pixel->du_dy = bd->du_dy;
+ pixel->dv_dx = bd->dv_dx;
+ pixel->dv_dy = bd->dv_dy;
+}
+
+void RE_bake_mask_fill(const BakePixel pixel_array[], const int num_pixels, char *mask)
+{
+ int i;
+ if (!mask)
+ return;
+
+ /* only extend to pixels outside the mask area */
+ for (i = 0; i < num_pixels; i++) {
+ if (pixel_array[i].primitive_id != -1) {
+ mask[i] = FILTER_MASK_USED;
+ }
+ }
+}
+
+void RE_bake_margin(ImBuf *ibuf, char *mask, const int margin)
+{
+ /* margin */
+ IMB_filter_extend(ibuf, mask, margin);
+
+ if (ibuf->planes != R_IMF_PLANES_RGBA)
+ /* clear alpha added by filtering */
+ IMB_rectfill_alpha(ibuf, 1.0f);
+}
+
+/**
+ * This function returns the coordinate and normal of a barycentric u,v for a face defined by the primitive_id index.
+ */
+static void calc_point_from_barycentric(
+ TriTessFace *triangles, int primitive_id, float u, float v, float cage_extrusion,
+ float r_co[3], float r_dir[3])
+{
+ float data[3][3];
+ float coord[3];
+ float dir[3];
+ float cage[3];
+
+ TriTessFace *triangle = &triangles[primitive_id];
+
+ copy_v3_v3(data[0], triangle->mverts[0]->co);
+ copy_v3_v3(data[1], triangle->mverts[1]->co);
+ copy_v3_v3(data[2], triangle->mverts[2]->co);
+
+ interp_barycentric_tri_v3(data, u, v, coord);
+
+ normal_short_to_float_v3(data[0], triangle->mverts[0]->no);
+ normal_short_to_float_v3(data[1], triangle->mverts[1]->no);
+ normal_short_to_float_v3(data[2], triangle->mverts[2]->no);
+
+ interp_barycentric_tri_v3(data, u, v, dir);
+ normalize_v3_v3(cage, dir);
+ mul_v3_fl(cage, cage_extrusion);
+
+ add_v3_v3(coord, cage);
+
+ normalize_v3_v3(dir, dir);
+ mul_v3_fl(dir, -1.0f);
+
+ copy_v3_v3(r_co, coord);
+ copy_v3_v3(r_dir, dir);
+}
+
+/**
+ * This function returns the barycentric u,v of a face for a coordinate. The face is defined by its index.
+ */
+static void calc_barycentric_from_point(
+ TriTessFace *triangles, const int index, const float co[3],
+ int *r_primitive_id, float r_uv[2])
+{
+ TriTessFace *triangle = &triangles[index];
+ resolve_tri_uv_v3(r_uv, co,
+ triangle->mverts[0]->co,
+ triangle->mverts[1]->co,
+ triangle->mverts[2]->co);
+ *r_primitive_id = index;
+}
+
+/**
+ * This function populates pixel_array and returns TRUE if things are correct
+ */
+static bool cast_ray_highpoly(
+ BVHTreeFromMesh *treeData, TriTessFace *triangles[], BakeHighPolyData *highpoly,
+ float const co_low[3], const float dir[3], const int pixel_id, const int tot_highpoly,
+ const float du_dx, const float du_dy, const float dv_dx, const float dv_dy)
+{
+ int i;
+ int primitive_id = -1;
+ float uv[2];
+ int hit_mesh = -1;
+ float hit_distance = FLT_MAX;
+
+ BVHTreeRayHit *hits;
+ hits = MEM_mallocN(sizeof(BVHTreeRayHit) * tot_highpoly, "Bake Highpoly to Lowpoly: BVH Rays");
+
+ for (i = 0; i < tot_highpoly; i++) {
+ float co_high[3];
+ hits[i].index = -1;
+ /* TODO: we should use FLT_MAX here, but sweepsphere code isn't prepared for that */
+ hits[i].dist = 10000.0f;
+
+ copy_v3_v3(co_high, co_low);
+
+ /* transform the ray from the lowpoly to the highpoly space */
+ mul_m4_v3(highpoly[i].mat_lowtohigh, co_high);
+
+ /* cast ray */
+ BLI_bvhtree_ray_cast(treeData[i].tree, co_high, dir, 0.0f, &hits[i], treeData[i].raycast_callback, &treeData[i]);
+
+ if (hits[i].index != -1) {
+ /* cull backface */
+ const float dot = dot_v3v3(dir, hits[i].no);
+ if (dot < 0.0f) {
+ if (hits[i].dist < hit_distance) {
+ hit_mesh = i;
+ hit_distance = hits[i].dist;
+ }
+ }
+ }
+ }
+
+ for (i = 0; i < tot_highpoly; i++) {
+ if (hit_mesh == i) {
+ calc_barycentric_from_point(triangles[i], hits[i].index, hits[i].co, &primitive_id, uv);
+ highpoly[i].pixel_array[pixel_id].primitive_id = primitive_id;
+ copy_v2_v2(highpoly[i].pixel_array[pixel_id].uv, uv);
+
+ /* the differentials are relative to the UV/image space, so the highpoly differentials
+ * are the same as the low poly differentials */
+ highpoly[i].pixel_array[pixel_id].du_dx = du_dx;
+ highpoly[i].pixel_array[pixel_id].du_dy = du_dy;
+ highpoly[i].pixel_array[pixel_id].dv_dx = dv_dx;
+ highpoly[i].pixel_array[pixel_id].dv_dy = dv_dy;
+ }
+ else {
+ highpoly[i].pixel_array[pixel_id].primitive_id = -1;
+ }
+ }
+
+ MEM_freeN(hits);
+ return hit_mesh != -1;
+}
+
+/**
+ * This function populates an array of verts for the triangles of a mesh
+ * Tangent and Normals are also stored
+ */
+static void mesh_calc_tri_tessface(
+ TriTessFace *triangles, Mesh *me, bool tangent, DerivedMesh *dm)
+{
+ int i;
+ int p_id;
+ MFace *mface;
+ MVert *mvert;
+ TSpace *tspace;
+ float *precomputed_normals;
+ bool calculate_normal;
+
+ mface = CustomData_get_layer(&me->fdata, CD_MFACE);
+ mvert = CustomData_get_layer(&me->vdata, CD_MVERT);
+
+ if (tangent) {
+ DM_ensure_normals(dm);
+ DM_add_tangent_layer(dm);
+
+ precomputed_normals = dm->getTessFaceDataArray(dm, CD_NORMAL);
+ calculate_normal = precomputed_normals ? false : true;
+
+ //mface = dm->getTessFaceArray(dm);
+ //mvert = dm->getVertArray(dm);
+
+ tspace = dm->getTessFaceDataArray(dm, CD_TANGENT);
+ BLI_assert(tspace);
+ }
+
+ p_id = -1;
+ for (i = 0; i < me->totface; i++) {
+ MFace *mf = &mface[i];
+ TSpace *ts = &tspace[i * 4];
+
+ p_id++;
+
+ triangles[p_id].mverts[0] = &mvert[mf->v1];
+ triangles[p_id].mverts[1] = &mvert[mf->v2];
+ triangles[p_id].mverts[2] = &mvert[mf->v3];
+ triangles[p_id].is_smooth = (mf->flag & ME_SMOOTH) != 0;
+
+ if (tangent) {
+ triangles[p_id].tspace[0] = &ts[0];
+ triangles[p_id].tspace[1] = &ts[1];
+ triangles[p_id].tspace[2] = &ts[2];
+
+ if (calculate_normal) {
+ if (mf->v4 != 0) {
+ normal_quad_v3(triangles[p_id].normal,
+ mvert[mf->v1].co,
+ mvert[mf->v2].co,
+ mvert[mf->v3].co,
+ mvert[mf->v4].co);
+ }
+ else {
+ normal_tri_v3(triangles[p_id].normal,
+ triangles[p_id].mverts[0]->co,
+ triangles[p_id].mverts[1]->co,
+ triangles[p_id].mverts[2]->co);
+ }
+ }
+ else {
+ copy_v3_v3(triangles[p_id].normal, &precomputed_normals[3 * i]);
+ }
+ }
+
+ /* 4 vertices in the face */
+ if (mf->v4 != 0) {
+ p_id++;
+
+ triangles[p_id].mverts[0] = &mvert[mf->v1];
+ triangles[p_id].mverts[1] = &mvert[mf->v3];
+ triangles[p_id].mverts[2] = &mvert[mf->v4];
+ triangles[p_id].is_smooth = (mf->flag & ME_SMOOTH) != 0;
+
+ if (tangent) {
+ triangles[p_id].tspace[0] = &ts[0];
+ triangles[p_id].tspace[1] = &ts[2];
+ triangles[p_id].tspace[2] = &ts[3];
+
+ /* same normal as the other "triangle" */
+ copy_v3_v3(triangles[p_id].normal, triangles[p_id - 1].normal);
+ }
+ }
+ }
+
+ BLI_assert(p_id < me->totface * 2);
+}
+
+void RE_bake_pixels_populate_from_objects(
+ struct Mesh *me_low, BakePixel pixel_array_from[],
+ BakeHighPolyData highpoly[], const int tot_highpoly, const int num_pixels,
+ const float cage_extrusion)
+{
+ int i;
+ int primitive_id;
+ float u, v;
+
+ DerivedMesh **dm_highpoly;
+ BVHTreeFromMesh *treeData;
+
+ /* Note: all coordinates are in local space */
+ TriTessFace *tris_low;
+ TriTessFace **tris_high;
+
+ /* assume all lowpoly tessfaces can be quads */
+ tris_low = MEM_callocN(sizeof(TriTessFace) * (me_low->totface * 2), "MVerts Lowpoly Mesh");
+ tris_high = MEM_callocN(sizeof(TriTessFace *) * tot_highpoly, "MVerts Highpoly Mesh Array");
+
+ /* assume all highpoly tessfaces are triangles */
+ dm_highpoly = MEM_callocN(sizeof(DerivedMesh *) * tot_highpoly, "Highpoly Derived Meshes");
+ treeData = MEM_callocN(sizeof(BVHTreeFromMesh) * tot_highpoly, "Highpoly BVH Trees");
+
+ mesh_calc_tri_tessface(tris_low, me_low, false, NULL);
+
+ for (i = 0; i < tot_highpoly; i++) {
+ tris_high[i] = MEM_callocN(sizeof(TriTessFace) * highpoly[i].me->totface, "MVerts Highpoly Mesh");
+ mesh_calc_tri_tessface(tris_high[i], highpoly[i].me, false, NULL);
+
+ dm_highpoly[i] = CDDM_from_mesh(highpoly[i].me);
+
+ /* Create a bvh-tree for each highpoly object */
+ bvhtree_from_mesh_faces(&treeData[i], dm_highpoly[i], 0.0, 2, 6);
+
+ if (&treeData[i].tree == NULL) {
+ printf("Baking: Out of memory\n");
+ goto cleanup;
+ }
+ }
+
+ for (i = 0; i < num_pixels; i++) {
+ float co[3];
+ float dir[3];
+
+ primitive_id = pixel_array_from[i].primitive_id;
+
+ if (primitive_id == -1) {
+ int j;
+ for (j = 0; j < tot_highpoly; j++) {
+ highpoly[j].pixel_array[i].primitive_id = -1;
+ }
+ continue;
+ }
+
+ u = pixel_array_from[i].uv[0];
+ v = pixel_array_from[i].uv[1];
+
+ /* calculate from low poly mesh cage */
+ calc_point_from_barycentric(tris_low, primitive_id, u, v, cage_extrusion, co, dir);
+
+ /* cast ray */
+ if (!cast_ray_highpoly(treeData, tris_high, highpoly, co, dir, i, tot_highpoly,
+ pixel_array_from[i].du_dx, pixel_array_from[i].du_dy,
+ pixel_array_from[i].dv_dx, pixel_array_from[i].dv_dy)) {
+ /* if it fails mask out the original pixel array */
+ pixel_array_from[i].primitive_id = -1;
+ }
+ }
+
+
+ /* garbage collection */
+cleanup:
+ for (i = 0; i < tot_highpoly; i++) {
+ free_bvhtree_from_mesh(&treeData[i]);
+ dm_highpoly[i]->release(dm_highpoly[i]);
+ MEM_freeN(tris_high[i]);
+ }
+
+ MEM_freeN(tris_low);
+ MEM_freeN(tris_high);
+ MEM_freeN(treeData);
+ MEM_freeN(dm_highpoly);
+}
+
+static void bake_differentials(BakeDataZSpan *bd, const float *uv1, const float *uv2, const float *uv3)
+{
+ float A;
+
+ /* assumes dPdu = P1 - P3 and dPdv = P2 - P3 */
+ A = (uv2[0] - uv1[0]) * (uv3[1] - uv1[1]) - (uv3[0] - uv1[0]) * (uv2[1] - uv1[1]);
+
+ if (fabsf(A) > FLT_EPSILON) {
+ A = 0.5f / A;
+
+ bd->du_dx = (uv2[1] - uv3[1]) * A;
+ bd->dv_dx = (uv3[1] - uv1[1]) * A;
+
+ bd->du_dy = (uv3[0] - uv2[0]) * A;
+ bd->dv_dy = (uv1[0] - uv3[0]) * A;
+ }
+ else {
+ bd->du_dx = bd->du_dy = 0.0f;
+ bd->dv_dx = bd->dv_dy = 0.0f;
+ }
+}
+
+void RE_bake_pixels_populate(
+ Mesh *me, BakePixel pixel_array[],
+ const int num_pixels, const BakeImages *bake_images)
+{
+ BakeDataZSpan bd;
+ int i, a;
+ int p_id;
+
+ MTFace *mtface;
+ MFace *mface;
+
+ /* we can't bake in edit mode */
+ if (me->edit_btmesh)
+ return;
+
+ bd.pixel_array = pixel_array;
+ bd.zspan = MEM_callocN(sizeof(ZSpan) * bake_images->size, "bake zspan");
+
+ /* initialize all pixel arrays so we know which ones are 'blank' */
+ for (i = 0; i < num_pixels; i++) {
+ pixel_array[i].primitive_id = -1;
+ }
+
+ for (i = 0; i < bake_images->size; i++) {
+ zbuf_alloc_span(&bd.zspan[i], bake_images->data[i].width, bake_images->data[i].height, R.clipcrop);
+ }
+
+ mtface = CustomData_get_layer(&me->fdata, CD_MTFACE);
+ mface = CustomData_get_layer(&me->fdata, CD_MFACE);
+
+ if (mtface == NULL)
+ return;
+
+ p_id = -1;
+ for (i = 0; i < me->totface; i++) {
+ float vec[4][2];
+ MTFace *mtf = &mtface[i];
+ MFace *mf = &mface[i];
+ int mat_nr = mf->mat_nr;
+ int image_id = bake_images->lookup[mat_nr];
+
+ bd.bk_image = &bake_images->data[image_id];
+ bd.primitive_id = ++p_id;
+
+ for (a = 0; a < 4; a++) {
+ /* Note, workaround for pixel aligned UVs which are common and can screw up our intersection tests
+ * where a pixel gets in between 2 faces or the middle of a quad,
+ * camera aligned quads also have this problem but they are less common.
+ * Add a small offset to the UVs, fixes bug #18685 - Campbell */
+ vec[a][0] = mtf->uv[a][0] * (float)bd.bk_image->width - (0.5f + 0.001f);
+ vec[a][1] = mtf->uv[a][1] * (float)bd.bk_image->height - (0.5f + 0.002f);
+ }
+
+ bake_differentials(&bd, vec[0], vec[1], vec[2]);
+ zspan_scanconvert(&bd.zspan[image_id], (void *)&bd, vec[0], vec[1], vec[2], store_bake_pixel);
+
+ /* 4 vertices in the face */
+ if (mf->v4 != 0) {
+ bd.primitive_id = ++p_id;
+
+ bake_differentials(&bd, vec[0], vec[2], vec[3]);
+ zspan_scanconvert(&bd.zspan[image_id], (void *)&bd, vec[0], vec[2], vec[3], store_bake_pixel);
+ }
+ }
+
+ for (i = 0; i < bake_images->size; i++) {
+ zbuf_free_span(&bd.zspan[i]);
+ }
+ MEM_freeN(bd.zspan);
+}
+
+/* ******************** NORMALS ************************ */
+
+/**
+ * convert a normalized normal to the -1.0 1.0 range
+ * the input is expected to be POS_X, POS_Y, POS_Z
+ */
+static void normal_uncompress(float out[3], const float in[3])
+{
+ int i;
+ for (i = 0; i < 3; i++)
+ out[i] = 2.0f * in[i] - 1.0f;
+}
+
+static void normal_compress(float out[3], const float in[3], const BakeNormalSwizzle normal_swizzle[3])
+{
+ const int swizzle_index[6] = {
+ 0, /* R_BAKE_POSX */
+ 1, /* R_BAKE_POSY */
+ 2, /* R_BAKE_POSZ */
+ 0, /* R_BAKE_NEGX */
+ 1, /* R_BAKE_NEGY */
+ 2, /* R_BAKE_NEGZ */
+ };
+ const float swizzle_sign[6] = {
+ +1.0f, /* R_BAKE_POSX */
+ +1.0f, /* R_BAKE_POSY */
+ +1.0f, /* R_BAKE_POSZ */
+ -1.0f, /* R_BAKE_NEGX */
+ -1.0f, /* R_BAKE_NEGY */
+ -1.0f, /* R_BAKE_NEGZ */
+ };
+
+ int i;
+
+ for (i = 0; i < 3; i++) {
+ int index;
+ float sign;
+
+ sign = swizzle_sign[normal_swizzle[i]];
+ index = swizzle_index[normal_swizzle[i]];
+
+ /*
+ * There is a small 1e-5f bias for precision issues. otherwise
+ * we randomly get 127 or 128 for neutral colors in tangent maps.
+ * we choose 128 because it is the convention flat color. *
+ */
+
+ out[i] = sign * in[index] / 2.0f + 0.5f + 1e-5f;
+ }
+}
+
+/**
+ * This function converts an object space normal map to a tangent space normal map for a given low poly mesh
+ */
+void RE_bake_normal_world_to_tangent(
+ const BakePixel pixel_array[], const int num_pixels, const int depth,
+ float result[], Mesh *me, const BakeNormalSwizzle normal_swizzle[3])
+{
+ int i;
+
+ TriTessFace *triangles;
+
+ DerivedMesh *dm = CDDM_from_mesh(me);
+
+ triangles = MEM_callocN(sizeof(TriTessFace) * (me->totface * 2), "MVerts Mesh");
+ mesh_calc_tri_tessface(triangles, me, true, dm);
+
+ BLI_assert(num_pixels >= 3);
+
+ for (i = 0; i < num_pixels; i++) {
+ TriTessFace *triangle;
+ float tangents[3][3];
+ float normals[3][3];
+ float signs[3];
+ int j;
+
+ float tangent[3];
+ float normal[3];
+ float binormal[3];
+ float sign;
+ float u, v, w;
+
+ float tsm[3][3]; /* tangent space matrix */
+ float itsm[3][3];
+
+ int offset;
+ float nor[3]; /* texture normal */
+
+ bool is_smooth;
+
+ int primitive_id = pixel_array[i].primitive_id;
+
+ offset = i * depth;
+
+ if (primitive_id == -1) {
+ copy_v3_fl3(&result[offset], 0.5f, 0.5f, 1.0f);
+ continue;
+ }
+
+ triangle = &triangles[primitive_id];
+ is_smooth = triangle->is_smooth;
+
+ for (j = 0; j < 3; j++) {
+ const TSpace *ts;
+
+ if (is_smooth)
+ normal_short_to_float_v3(normals[j], triangle->mverts[j]->no);
+ else
+ normal[j] = triangle->normal[j];
+
+ ts = triangle->tspace[j];
+ copy_v3_v3(tangents[j], ts->tangent);
+ signs[j] = ts->sign;
+ }
+
+ u = pixel_array[i].uv[0];
+ v = pixel_array[i].uv[1];
+ w = 1.0f - u - v;
+
+ /* normal */
+ if (is_smooth)
+ interp_barycentric_tri_v3(normals, u, v, normal);
+
+ /* tangent */
+ interp_barycentric_tri_v3(tangents, u, v, tangent);
+
+ /* sign */
+ /* The sign is the same at all face vertices for any non degenerate face.
+ * Just in case we clamp the interpolated value though. */
+ sign = (signs[0] * u + signs[1] * v + signs[2] * w) < 0 ? (-1.0f) : 1.0f;
+
+ /* binormal */
+ /* B = sign * cross(N, T) */
+ cross_v3_v3v3(binormal, normal, tangent);
+ mul_v3_fl(binormal, sign);
+
+ /* populate tangent space matrix */
+ copy_v3_v3(tsm[0], tangent);
+ copy_v3_v3(tsm[1], binormal);
+ copy_v3_v3(tsm[2], normal);
+
+ /* texture values */
+ normal_uncompress(nor, &result[offset]);
+
+ invert_m3_m3(itsm, tsm);
+ mul_m3_v3(itsm, nor);
+ normalize_v3(nor);
+
+ /* save back the values */
+ normal_compress(&result[offset], nor, normal_swizzle);
+ }
+
+ /* garbage collection */
+ MEM_freeN(triangles);
+
+ if (dm)
+ dm->release(dm);
+}
+
+void RE_bake_normal_world_to_object(
+ const BakePixel pixel_array[], const int num_pixels, const int depth,
+ float result[], struct Object *ob, const BakeNormalSwizzle normal_swizzle[3])
+{
+ int i;
+ float iobmat[4][4];
+
+ invert_m4_m4(iobmat, ob->obmat);
+
+ for (i = 0; i < num_pixels; i++) {
+ int offset;
+ float nor[3];
+
+ if (pixel_array[i].primitive_id == -1)
+ continue;
+
+ offset = i * depth;
+ normal_uncompress(nor, &result[offset]);
+
+ mul_m4_v3(iobmat, nor);
+ normalize_v3(nor);
+
+ /* save back the values */
+ normal_compress(&result[offset], nor, normal_swizzle);
+ }
+}
+
+void RE_bake_normal_world_to_world(
+ const BakePixel pixel_array[], const int num_pixels, const int depth,
+ float result[], const BakeNormalSwizzle normal_swizzle[3])
+{
+ int i;
+
+ for (i = 0; i < num_pixels; i++) {
+ int offset;
+ float nor[3];
+
+ if (pixel_array[i].primitive_id == -1)
+ continue;
+
+ offset = i * depth;
+ normal_uncompress(nor, &result[offset]);
+
+ /* save back the values */
+ normal_compress(&result[offset], nor, normal_swizzle);
+ }
+}
+
+void RE_bake_ibuf_clear(BakeImages *bake_images, const bool is_tangent)
+{
+ ImBuf *ibuf;
+ void *lock;
+ Image *image;
+ int i;
+
+ const float vec_alpha[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ const float vec_solid[4] = {0.0f, 0.0f, 0.0f, 1.0f};
+ const float nor_alpha[4] = {0.5f, 0.5f, 1.0f, 0.0f};
+ const float nor_solid[4] = {0.5f, 0.5f, 1.0f, 1.0f};
+
+ for (i = 0; i < bake_images->size; i ++) {
+ image = bake_images->data[i].image;
+
+ ibuf = BKE_image_acquire_ibuf(image, NULL, &lock);
+ BLI_assert(ibuf);
+
+ if (is_tangent)
+ IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? nor_alpha : nor_solid);
+ else
+ IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? vec_alpha : vec_solid);
+
+ BKE_image_release_ibuf(image, ibuf, lock);
+ }
+}
+
+/* ************************************************************* */
+
+/**
+ * not the real UV, but the internal per-face UV instead
+ * I'm using it to test if everything is correct */
+static bool bake_uv(const BakePixel pixel_array[], const int num_pixels, const int depth, float result[])
+{
+ int i;
+
+ for (i=0; i < num_pixels; i++) {
+ int offset = i * depth;
+ copy_v2_v2(&result[offset], pixel_array[i].uv);
+ }
+
+ return true;
+}
+
+bool RE_bake_internal(
+ Render *UNUSED(re), Object *UNUSED(object), const BakePixel pixel_array[],
+ const int num_pixels, const int depth, const ScenePassType pass_type, float result[])
+{
+ switch (pass_type) {
+ case SCE_PASS_UV:
+ {
+ return bake_uv(pixel_array, num_pixels, depth, result);
+ break;
+ }
+ default:
+ break;
+ }
+ return false;
+}
+
+int RE_pass_depth(const ScenePassType pass_type)
+{
+ /* IMB_buffer_byte_from_float assumes 4 channels
+ * making it work for now - XXX */
+ return 4;
+
+ switch (pass_type) {
+ case SCE_PASS_Z:
+ case SCE_PASS_AO:
+ case SCE_PASS_MIST:
+ {
+ return 1;
+ }
+ case SCE_PASS_UV:
+ {
+ return 2;
+ }
+ case SCE_PASS_RGBA:
+ {
+ return 4;
+ }
+ case SCE_PASS_COMBINED:
+ case SCE_PASS_DIFFUSE:
+ case SCE_PASS_SPEC:
+ case SCE_PASS_SHADOW:
+ case SCE_PASS_REFLECT:
+ case SCE_PASS_NORMAL:
+ case SCE_PASS_VECTOR:
+ case SCE_PASS_REFRACT:
+ case SCE_PASS_INDEXOB: /* XXX double check */
+ case SCE_PASS_INDIRECT:
+ case SCE_PASS_RAYHITS: /* XXX double check */
+ case SCE_PASS_EMIT:
+ case SCE_PASS_ENVIRONMENT:
+ case SCE_PASS_INDEXMA:
+ case SCE_PASS_DIFFUSE_DIRECT:
+ case SCE_PASS_DIFFUSE_INDIRECT:
+ case SCE_PASS_DIFFUSE_COLOR:
+ case SCE_PASS_GLOSSY_DIRECT:
+ case SCE_PASS_GLOSSY_INDIRECT:
+ case SCE_PASS_GLOSSY_COLOR:
+ case SCE_PASS_TRANSM_DIRECT:
+ case SCE_PASS_TRANSM_INDIRECT:
+ case SCE_PASS_TRANSM_COLOR:
+ case SCE_PASS_SUBSURFACE_DIRECT:
+ case SCE_PASS_SUBSURFACE_INDIRECT:
+ case SCE_PASS_SUBSURFACE_COLOR:
+ default:
+ {
+ return 3;
+ }
+ }
+}
diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c
index e9d3e294b28..cb5f75efd16 100644
--- a/source/blender/render/intern/source/convertblender.c
+++ b/source/blender/render/intern/source/convertblender.c
@@ -39,56 +39,39 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "BLI_rand.h"
-#include "BLI_task.h"
#include "BLI_memarena.h"
-#include "BLI_linklist.h"
#ifdef WITH_FREESTYLE
# include "BLI_edgehash.h"
#endif
#include "BLF_translation.h"
-#include "DNA_armature_types.h"
-#include "DNA_camera_types.h"
#include "DNA_material_types.h"
#include "DNA_curve_types.h"
-#include "DNA_effect_types.h"
#include "DNA_group_types.h"
#include "DNA_lamp_types.h"
#include "DNA_image_types.h"
-#include "DNA_lattice_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
-#include "DNA_meta_types.h"
#include "DNA_modifier_types.h"
#include "DNA_node_types.h"
#include "DNA_object_types.h"
-#include "DNA_object_force.h"
#include "DNA_object_fluidsim.h"
#include "DNA_particle_types.h"
#include "DNA_scene_types.h"
#include "DNA_texture_types.h"
-#include "DNA_view3d_types.h"
#include "BKE_anim.h"
-#include "BKE_armature.h"
-#include "BKE_action.h"
#include "BKE_curve.h"
#include "BKE_customdata.h"
#include "BKE_colortools.h"
-#include "BKE_constraint.h"
#include "BKE_displist.h"
-#include "BKE_deform.h"
#include "BKE_depsgraph.h"
#include "BKE_DerivedMesh.h"
-#include "BKE_effect.h"
#include "BKE_global.h"
-#include "BKE_group.h"
#include "BKE_key.h"
-#include "BKE_ipo.h"
#include "BKE_image.h"
#include "BKE_lattice.h"
-#include "BKE_library.h"
#include "BKE_material.h"
#include "BKE_main.h"
#include "BKE_mball.h"
@@ -98,10 +81,7 @@
#include "BKE_object.h"
#include "BKE_particle.h"
#include "BKE_scene.h"
-#include "BKE_subsurf.h"
-#include "BKE_texture.h"
-#include "BKE_world.h"
#include "PIL_time.h"
#include "IMB_imbuf_types.h"
@@ -398,23 +378,25 @@ static void SetTSpace(const SMikkTSpaceContext *pContext, const float fvTangent[
}
}
-static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, bool do_tangent, bool do_nmap_tangent)
+static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, bool do_vertex_normal, bool do_tangent, bool do_nmap_tangent)
{
int a;
/* clear all vertex normals */
- for (a=0; a<obr->totvert; a++) {
- VertRen *ver= RE_findOrAddVert(obr, a);
- ver->n[0]=ver->n[1]=ver->n[2]= 0.0f;
+ if (do_vertex_normal) {
+ for (a=0; a<obr->totvert; a++) {
+ VertRen *ver= RE_findOrAddVert(obr, a);
+ ver->n[0]=ver->n[1]=ver->n[2]= 0.0f;
+ }
}
/* calculate cos of angles and point-masses, use as weight factor to
* add face normal to vertex */
for (a=0; a<obr->totvlak; a++) {
VlakRen *vlr= RE_findOrAddVlak(obr, a);
- if (vlr->flag & ME_SMOOTH) {
+ if (do_vertex_normal && vlr->flag & ME_SMOOTH) {
float *n4= (vlr->v4)? vlr->v4->n: NULL;
- float *c4= (vlr->v4)? vlr->v4->co: NULL;
+ const float *c4= (vlr->v4)? vlr->v4->co: NULL;
accumulate_vertex_normals(vlr->v1->n, vlr->v2->n, vlr->v3->n, n4,
vlr->n, vlr->v1->co, vlr->v2->co, vlr->v3->co, c4);
@@ -430,7 +412,7 @@ static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, bool do_tange
for (a=0; a<obr->totvlak; a++) {
VlakRen *vlr= RE_findOrAddVlak(obr, a);
- if ((vlr->flag & ME_SMOOTH)==0) {
+ if (do_vertex_normal && (vlr->flag & ME_SMOOTH)==0) {
if (is_zero_v3(vlr->v1->n)) copy_v3_v3(vlr->v1->n, vlr->n);
if (is_zero_v3(vlr->v2->n)) copy_v3_v3(vlr->v2->n, vlr->n);
if (is_zero_v3(vlr->v3->n)) copy_v3_v3(vlr->v3->n, vlr->n);
@@ -494,163 +476,153 @@ typedef struct ASface {
VertRen *nver[4];
} ASface;
-static void as_addvert(ASvert *asv, VertRen *v1, VlakRen *vlr)
+static int as_addvert(ASvert *asv, VertRen *v1, VlakRen *vlr)
{
ASface *asf;
- int a;
-
- if (v1 == NULL) return;
-
- if (asv->faces.first==NULL) {
- asf= MEM_callocN(sizeof(ASface), "asface");
- BLI_addtail(&asv->faces, asf);
- }
-
- asf= asv->faces.last;
- for (a=0; a<4; a++) {
- if (asf->vlr[a]==NULL) {
- asf->vlr[a]= vlr;
- asv->totface++;
- break;
+ int a = -1;
+
+ if (v1 == NULL)
+ return a;
+
+ asf = asv->faces.last;
+ if (asf) {
+ for (a = 0; a < 4 && asf->vlr[a]; a++) {
}
}
-
+ else {
+ a = 4;
+ }
+
/* new face struct */
- if (a==4) {
- asf= MEM_callocN(sizeof(ASface), "asface");
+ if (a == 4) {
+ a = 0;
+ asf = MEM_callocN(sizeof(ASface), "asface");
BLI_addtail(&asv->faces, asf);
- asf->vlr[0]= vlr;
- asv->totface++;
}
+
+ asf->vlr[a] = vlr;
+ asv->totface++;
+
+ return a;
}
-static int as_testvertex(VlakRen *vlr, VertRen *UNUSED(ver), ASvert *asv, float thresh)
+static VertRen *as_findvertex_lnor(VlakRen *vlr, VertRen *ver, ASvert *asv, const float lnor[3])
{
- /* return 1: vertex needs a copy */
+ /* return when new vertex already was made, or existing one is OK */
ASface *asf;
- float inp;
int a;
-
- if (vlr == NULL) return 0;
-
- asf= asv->faces.first;
- while (asf) {
- for (a=0; a<4; a++) {
- if (asf->vlr[a] && asf->vlr[a]!=vlr) {
- inp = fabsf(dot_v3v3(vlr->n, asf->vlr[a]->n));
- if (inp < thresh) return 1;
- }
- }
- asf= asf->next;
+
+ /* First face, we can use existing vert and assign it current lnor! */
+ if (asv->totface == 1) {
+ copy_v3_v3(ver->n, lnor);
+ return ver;
}
-
- return 0;
-}
-static VertRen *as_findvertex(VlakRen *vlr, VertRen *UNUSED(ver), ASvert *asv, float thresh)
-{
- /* return when new vertex already was made */
- ASface *asf;
- float inp;
- int a;
-
- asf= asv->faces.first;
+ /* In case existing ver has same normal as current lnor, we can simply use it! */
+ if (equals_v3v3(lnor, ver->n)) {
+ return ver;
+ }
+
+ asf = asv->faces.first;
while (asf) {
- for (a=0; a<4; a++) {
- if (asf->vlr[a] && asf->vlr[a]!=vlr) {
+ for (a = 0; a < 4; a++) {
+ if (asf->vlr[a] && asf->vlr[a] != vlr) {
/* this face already made a copy for this vertex! */
if (asf->nver[a]) {
- inp = fabsf(dot_v3v3(vlr->n, asf->vlr[a]->n));
- if (inp >= thresh) {
+ if (equals_v3v3(lnor, asf->nver[a]->n)) {
return asf->nver[a];
}
}
}
}
- asf= asf->next;
+ asf = asf->next;
}
-
+
return NULL;
}
+static void as_addvert_lnor(ObjectRen *obr, ASvert *asv, VertRen *ver, VlakRen *vlr, const short _lnor[3])
+{
+ VertRen *v1;
+ ASface *asf;
+ int asf_idx;
+ float lnor[3];
+
+ normal_short_to_float_v3(lnor, _lnor);
+
+ asf_idx = as_addvert(asv, ver, vlr);
+ if (asf_idx < 0) {
+ return;
+ }
+ asf = asv->faces.last;
+
+ /* already made a new vertex within threshold? */
+ v1 = as_findvertex_lnor(vlr, ver, asv, lnor);
+ if (v1 == NULL) {
+ /* make a new vertex */
+ v1 = RE_vertren_copy(obr, ver);
+ copy_v3_v3(v1->n, lnor);
+ }
+ if (v1 != ver) {
+ asf->nver[asf_idx] = v1;
+ if (vlr->v1 == ver) vlr->v1 = v1;
+ if (vlr->v2 == ver) vlr->v2 = v1;
+ if (vlr->v3 == ver) vlr->v3 = v1;
+ if (vlr->v4 == ver) vlr->v4 = v1;
+ }
+}
+
/* note; autosmooth happens in object space still, after applying autosmooth we rotate */
/* note2; actually, when original mesh and displist are equal sized, face normals are from original mesh */
-static void autosmooth(Render *UNUSED(re), ObjectRen *obr, float mat[4][4], int degr)
+static void autosmooth(Render *UNUSED(re), ObjectRen *obr, float mat[4][4], short (*lnors)[4][3])
{
- ASvert *asv, *asverts;
- ASface *asf;
- VertRen *ver, *v1;
+ ASvert *asverts;
+ VertRen *ver;
VlakRen *vlr;
- float thresh;
- int a, b, totvert;
-
- if (obr->totvert==0) return;
- asverts= MEM_callocN(sizeof(ASvert)*obr->totvert, "all smooth verts");
-
- thresh= cosf(DEG2RADF((0.5f + (float)degr)));
-
- /* step zero: give faces normals of original mesh, if this is provided */
-
-
- /* step one: construct listbase of all vertices and pointers to faces */
- for (a=0; a<obr->totvlak; a++) {
- vlr= RE_findOrAddVlak(obr, a);
- /* skip wire faces */
- if (vlr->v2 != vlr->v3) {
- as_addvert(asverts+vlr->v1->index, vlr->v1, vlr);
- as_addvert(asverts+vlr->v2->index, vlr->v2, vlr);
- as_addvert(asverts+vlr->v3->index, vlr->v3, vlr);
- if (vlr->v4)
- as_addvert(asverts+vlr->v4->index, vlr->v4, vlr);
- }
- }
-
- totvert= obr->totvert;
- /* we now test all vertices, when faces have a normal too much different: they get a new vertex */
- for (a=0, asv=asverts; a<totvert; a++, asv++) {
- if (asv->totface > 1) {
- ver= RE_findOrAddVert(obr, a);
+ int a, totvert;
- asf= asv->faces.first;
- while (asf) {
- for (b=0; b<4; b++) {
-
- /* is there a reason to make a new vertex? */
- vlr= asf->vlr[b];
- if ( as_testvertex(vlr, ver, asv, thresh) ) {
-
- /* already made a new vertex within threshold? */
- v1= as_findvertex(vlr, ver, asv, thresh);
- if (v1==NULL) {
- /* make a new vertex */
- v1= RE_vertren_copy(obr, ver);
- }
- asf->nver[b]= v1;
- if (vlr->v1==ver) vlr->v1= v1;
- if (vlr->v2==ver) vlr->v2= v1;
- if (vlr->v3==ver) vlr->v3= v1;
- if (vlr->v4==ver) vlr->v4= v1;
- }
- }
- asf= asf->next;
+ if (obr->totvert == 0)
+ return;
+
+ totvert = obr->totvert;
+ asverts = MEM_callocN(sizeof(ASvert) * totvert, "all smooth verts");
+
+ if (lnors) {
+ /* We construct listbase of all vertices and pointers to faces, and add new verts when needed
+ * (i.e. when existing ones do not share the same (loop)normal).
+ */
+ for (a = 0; a < obr->totvlak; a++, lnors++) {
+ vlr = RE_findOrAddVlak(obr, a);
+ /* skip wire faces */
+ if (vlr->v2 != vlr->v3) {
+ as_addvert_lnor(obr, asverts+vlr->v1->index, vlr->v1, vlr, (const short*)lnors[0][0]);
+ as_addvert_lnor(obr, asverts+vlr->v2->index, vlr->v2, vlr, (const short*)lnors[0][1]);
+ as_addvert_lnor(obr, asverts+vlr->v3->index, vlr->v3, vlr, (const short*)lnors[0][2]);
+ if (vlr->v4)
+ as_addvert_lnor(obr, asverts+vlr->v4->index, vlr->v4, vlr, (const short*)lnors[0][3]);
}
}
}
-
+
/* free */
- for (a=0; a<totvert; a++) {
+ for (a = 0; a < totvert; a++) {
BLI_freelistN(&asverts[a].faces);
}
MEM_freeN(asverts);
-
+
/* rotate vertices and calculate normal of faces */
- for (a=0; a<obr->totvert; a++) {
- ver= RE_findOrAddVert(obr, a);
+ for (a = 0; a < obr->totvert; a++) {
+ ver = RE_findOrAddVert(obr, a);
mul_m4_v3(mat, ver->co);
+ if (lnors) {
+ mul_mat3_m4_v3(mat, ver->n);
+ negate_v3(ver->n);
+ normalize_v3(ver->n);
+ }
}
- for (a=0; a<obr->totvlak; a++) {
- vlr= RE_findOrAddVlak(obr, a);
-
+ for (a = 0; a < obr->totvlak; a++) {
+ vlr = RE_findOrAddVlak(obr, a);
+
/* skip wire faces */
if (vlr->v2 != vlr->v3) {
if (vlr->v4)
@@ -1333,7 +1305,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
int totchild=0, step_nbr;
int seed, path_nbr=0, orco1=0, num;
int totface;
- char **uv_name = NULL;
+ const char **uv_name = NULL;
const int *index_mf_to_mpoly = NULL;
const int *index_mp_to_orig = NULL;
@@ -1351,7 +1323,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
if (part->ren_as==PART_DRAW_OB || part->ren_as==PART_DRAW_GR || part->ren_as==PART_DRAW_NOT)
return 1;
- if ((re->r.scemode & R_VIEWPORT_PREVIEW) && psys->edit)
+ if ((re->r.scemode & R_VIEWPORT_PREVIEW) && (ob->mode & OB_MODE_PARTICLE_EDIT))
return 0;
/* 2. start initializing things */
@@ -1899,7 +1871,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
}
if (path_nbr && (ma->mode_l & MA_TANGENT_STR)==0)
- calc_vertexnormals(re, obr, 0, 0);
+ calc_vertexnormals(re, obr, 1, 0, 0);
return 1;
}
@@ -2009,7 +1981,7 @@ static short test_for_displace(Render *re, Object *ob)
return 0;
}
-static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, VertRen *vr, int vindex, float *scale, float mat[4][4], float imat[3][3])
+static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, VertRen *vr, int vindex, float *scale)
{
MTFace *tface;
short texco= shi->mat->texco;
@@ -2022,15 +1994,6 @@ static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, Ve
/* vertex normal is used for textures type 'col' and 'var' */
copy_v3_v3(shi->vn, vr->n);
- if (mat)
- mul_m4_v3(mat, shi->co);
-
- if (imat) {
- shi->vn[0] = dot_v3v3(imat[0], vr->n);
- shi->vn[1] = dot_v3v3(imat[1], vr->n);
- shi->vn[2] = dot_v3v3(imat[2], vr->n);
- }
-
if (texco & TEXCO_UV) {
shi->totuv= 0;
shi->actuv= obr->actmtface;
@@ -2062,7 +2025,7 @@ static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, Ve
/* not (yet?) */
}
if (texco & TEXCO_STRESS) {
- float *s= RE_vertren_get_stress(obr, vr, 0);
+ const float *s= RE_vertren_get_stress(obr, vr, 0);
if (s) {
shi->stress= *s;
@@ -2083,9 +2046,6 @@ static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, Ve
displace[0]= shi->displace[0] * scale[0];
displace[1]= shi->displace[1] * scale[1];
displace[2]= shi->displace[2] * scale[2];
-
- if (mat)
- mul_m3_v3(imat, displace);
/* 0.5 could become button once? */
vr->co[0] += displace[0];
@@ -2108,7 +2068,7 @@ static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, Ve
return;
}
-static void displace_render_face(Render *re, ObjectRen *obr, VlakRen *vlr, float *scale, float mat[4][4], float imat[3][3])
+static void displace_render_face(Render *re, ObjectRen *obr, VlakRen *vlr, float *scale)
{
ShadeInput shi;
@@ -2137,17 +2097,17 @@ static void displace_render_face(Render *re, ObjectRen *obr, VlakRen *vlr, float
/* Displace the verts, flag is set when done */
if (!vlr->v1->flag)
- displace_render_vert(re, obr, &shi, vlr->v1, 0, scale, mat, imat);
+ displace_render_vert(re, obr, &shi, vlr->v1, 0, scale);
if (!vlr->v2->flag)
- displace_render_vert(re, obr, &shi, vlr->v2, 1, scale, mat, imat);
+ displace_render_vert(re, obr, &shi, vlr->v2, 1, scale);
if (!vlr->v3->flag)
- displace_render_vert(re, obr, &shi, vlr->v3, 2, scale, mat, imat);
+ displace_render_vert(re, obr, &shi, vlr->v3, 2, scale);
if (vlr->v4) {
if (!vlr->v4->flag)
- displace_render_vert(re, obr, &shi, vlr->v4, 3, scale, mat, imat);
+ displace_render_vert(re, obr, &shi, vlr->v4, 3, scale);
/* closest in displace value. This will help smooth edges. */
if (fabsf(vlr->v1->accum - vlr->v3->accum) > fabsf(vlr->v2->accum - vlr->v4->accum)) vlr->flag |= R_DIVIDE_24;
@@ -2163,7 +2123,7 @@ static void displace_render_face(Render *re, ObjectRen *obr, VlakRen *vlr, float
}
}
-static void do_displacement(Render *re, ObjectRen *obr, float mat[4][4], float imat[3][3])
+static void displace(Render *re, ObjectRen *obr)
{
VertRen *vr;
VlakRen *vlr;
@@ -2188,11 +2148,11 @@ static void do_displacement(Render *re, ObjectRen *obr, float mat[4][4], float i
for (i=0; i<obr->totvlak; i++) {
vlr=RE_findOrAddVlak(obr, i);
- displace_render_face(re, obr, vlr, scale, mat, imat);
+ displace_render_face(re, obr, vlr, scale);
}
/* Recalc vertex normals */
- calc_vertexnormals(re, obr, 0, 0);
+ calc_vertexnormals(re, obr, 1, 0, 0);
}
/* ------------------------------------------------------------------------- */
@@ -2587,7 +2547,7 @@ static void init_render_dm(DerivedMesh *dm, Render *re, ObjectRen *obr,
}
/* Normals */
- calc_vertexnormals(re, obr, 0, 0);
+ calc_vertexnormals(re, obr, 1, 0, 0);
}
}
@@ -2734,7 +2694,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset)
/* pass */
}
else if (dl->type==DL_INDEX3) {
- int *index;
+ const int *index;
startvert= obr->totvert;
data= dl->verts;
@@ -3105,7 +3065,7 @@ static EdgeHash *make_freestyle_edge_mark_hash(Mesh *me, DerivedMesh *dm)
FreestyleEdge *fed;
MEdge *medge;
int totedge, a;
- int *index;
+ const int *index;
medge = dm->getEdgeArray(dm);
totedge = dm->getNumEdges(dm);
@@ -3154,10 +3114,11 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset)
CustomDataMask mask;
float xn, yn, zn, imat[3][3], mat[4][4]; //nor[3],
float *orco = NULL;
+ short (*loop_nors)[4][3] = NULL;
bool need_orco = false, need_stress = false, need_nmap_tangent = false, need_tangent = false, need_origindex = false;
int a, a1, ok, vertofs;
int end, totvert = 0;
- bool do_autosmooth = false;
+ bool do_autosmooth = false, do_displace = false;
bool use_original_normals = false;
int recalc_normals = 0; /* false by default */
int negative_scale;
@@ -3207,18 +3168,19 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset)
}
need_nmap_tangent= 1;
}
-
- /* origindex currently only used when baking to vertex colors */
- if (re->flag & R_BAKING && re->r.bake_flag & R_BAKE_VCOL)
- need_origindex= 1;
- /* check autosmooth and displacement, we then have to skip only-verts optimize */
- do_autosmooth |= (me->flag & ME_AUTOSMOOTH) != 0;
- if (do_autosmooth)
- timeoffset= 0;
- if (test_for_displace(re, ob ) )
- timeoffset= 0;
-
+ /* check autosmooth and displacement, we then have to skip only-verts optimize
+ * Note: not sure what we want to give higher priority, currently do_displace
+ * takes precedence over do_autosmooth.
+ */
+ do_displace = test_for_displace(re, ob);
+ do_autosmooth = ((me->flag & ME_AUTOSMOOTH) != 0) && !do_displace;
+ if (do_autosmooth || do_displace)
+ timeoffset = 0;
+
+ /* origindex currently used when using autosmooth, or baking to vertex colors. */
+ need_origindex = (do_autosmooth || ((re->flag & R_BAKING) && (re->r.bake_flag & R_BAKE_VCOL)));
+
mask= CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL;
if (!timeoffset)
if (need_orco)
@@ -3301,6 +3263,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset)
}
if (!timeoffset) {
+ short (*lnp)[4][3] = NULL;
#ifdef WITH_FREESTYLE
EdgeHash *edge_hash;
@@ -3349,6 +3312,11 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset)
if (ok) {
end= dm->getNumTessFaces(dm);
mface= dm->getTessFaceArray(dm);
+ if (!loop_nors && do_autosmooth &&
+ (dm->getTessFaceDataArray(dm, CD_TESSLOOPNORMAL) != NULL))
+ {
+ lnp = loop_nors = MEM_mallocN(sizeof(*loop_nors) * end, __func__);
+ }
#ifdef WITH_FREESTYLE
index_mf_to_mpoly= dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
index_mp_to_orig= dm->getPolyDataArray(dm, CD_ORIGINDEX);
@@ -3360,7 +3328,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset)
if ( mface->mat_nr==a1 ) {
float len;
- int reverse_verts = (negative_scale != 0 && do_autosmooth == false);
+ bool reverse_verts = (negative_scale != 0 && do_autosmooth == false);
int rev_tab[] = {reverse_verts==0 ? 0 : 2, 1, reverse_verts==0 ? 2 : 0, 3};
v1= reverse_verts==0 ? mface->v1 : mface->v3;
v2= mface->v2;
@@ -3426,7 +3394,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset)
CustomDataLayer *layer;
MTFace *mtface, *mtf;
MCol *mcol, *mc;
- int index, mtfn= 0, mcn= 0, mtng=0, vindex;
+ int index, mtfn= 0, mcn= 0, mtng=0, mln = 0, vindex;
char *name;
int nr_verts = v4!=0 ? 4 : 3;
@@ -3459,6 +3427,21 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset)
normalize_v3(ftang+vindex*4);
}
}
+ mtng++;
+ }
+ else if (layer->type == CD_TESSLOOPNORMAL && mln < 1) {
+ if (loop_nors) {
+ const short (*lnors)[4][3] = (const short (*)[4][3])layer->data;
+ for (vindex = 0; vindex < 4; vindex++) {
+ //print_v3("lnors[a][rev_tab[vindex]]", lnors[a][rev_tab[vindex]]);
+ copy_v3_v3_short((short *)lnp[0][vindex], lnors[a][rev_tab[vindex]]);
+ /* If we copy loop normals, we are doing autosmooth, so we are still
+ * in object space, no need to multiply with mat!
+ */
+ }
+ lnp++;
+ }
+ mln++;
}
}
@@ -3541,24 +3524,22 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset)
if (need_stress)
calc_edge_stress(re, obr, me);
- if (test_for_displace(re, ob ) ) {
- recalc_normals= 1;
- calc_vertexnormals(re, obr, 0, 0);
- if (do_autosmooth)
- do_displacement(re, obr, mat, imat);
- else
- do_displacement(re, obr, NULL, NULL);
+ if (do_displace) {
+ calc_vertexnormals(re, obr, 1, 0, 0);
+ displace(re, obr);
+ recalc_normals = 0; /* Already computed by displace! */
}
-
- if (do_autosmooth) {
- recalc_normals= 1;
- autosmooth(re, obr, mat, me->smoothresh);
+ else if (do_autosmooth) {
+ recalc_normals = (loop_nors == NULL); /* Should never happen, but better be safe than sorry. */
+ autosmooth(re, obr, mat, loop_nors);
}
if (recalc_normals!=0 || need_tangent!=0)
- calc_vertexnormals(re, obr, need_tangent, need_nmap_tangent);
+ calc_vertexnormals(re, obr, recalc_normals, need_tangent, need_nmap_tangent);
}
+ MEM_SAFE_FREE(loop_nors);
+
dm->release(dm);
}
@@ -3930,14 +3911,30 @@ static GroupObject *add_render_lamp(Render *re, Object *ob)
return go;
}
-static bool is_object_hidden(Render *re, Object *ob)
+static bool is_object_restricted(Render *re, Object *ob)
{
if (re->r.scemode & R_VIEWPORT_PREVIEW)
- return (ob->restrictflag & OB_RESTRICT_VIEW) != 0 || ELEM(ob->dt, OB_BOUNDBOX, OB_WIRE);
+ return (ob->restrictflag & OB_RESTRICT_VIEW) != 0;
else
return (ob->restrictflag & OB_RESTRICT_RENDER) != 0;
}
+static bool is_object_hidden(Render *re, Object *ob)
+{
+ if (is_object_restricted(re, ob))
+ return true;
+
+ if (re->r.scemode & R_VIEWPORT_PREVIEW) {
+ /* Mesh deform cages and so on mess up the preview. To avoid the problem,
+ * viewport doesn't show mesh object if its draw type is bounding box or wireframe.
+ */
+ return ELEM(ob->dt, OB_BOUNDBOX, OB_WIRE);
+ }
+ else {
+ return false;
+ }
+}
+
/* layflag: allows material group to ignore layerflag */
static void add_lightgroup(Render *re, Group *group, int exclusive)
{
@@ -4357,7 +4354,7 @@ static void finalize_render_object(Render *re, ObjectRen *obr, int timeoffset)
* I will look at means to have autosmooth enabled for all object types
* and have it as general postprocess, like displace */
if (ob->type!=OB_MESH && test_for_displace(re, ob))
- do_displacement(re, obr, NULL, NULL);
+ displace(re, obr);
if (!timeoffset) {
/* phong normal interpolation can cause error in tracing
@@ -4803,6 +4800,9 @@ void RE_Database_Free(Render *re)
static int allow_render_object(Render *re, Object *ob, int nolamps, int onlyselected, Object *actob)
{
+ if (is_object_hidden(re, ob))
+ return 0;
+
/* override not showing object when duplis are used with particles */
if (ob->transflag & OB_DUPLIPARTS) {
/* pass */ /* let particle system(s) handle showing vs. not showing */
@@ -4934,13 +4934,6 @@ static void add_group_render_dupli_obs(Render *re, Group *group, int nolamps, in
}
}
-/* additional data for dupli objects outside
- * of the main dupli list
- */
-typedef struct DupliObjectExtra {
- float omat[4][4];
-} DupliObjectExtra;
-
static void database_init_objects(Render *re, unsigned int renderlay, int nolamps, int onlyselected, Object *actob, int timeoffset)
{
Base *base;
@@ -4983,7 +4976,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp
lay= (timeoffset)? renderlay & vectorlay: renderlay;
/* if the object has been restricted from rendering in the outliner, ignore it */
- if (is_object_hidden(re, ob)) continue;
+ if (is_object_restricted(re, ob)) continue;
/* OB_DONE means the object itself got duplicated, so was already converted */
if (ob->flag & OB_DONE) {
@@ -5000,28 +4993,22 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp
if ((ob->transflag & OB_DUPLI) && (ob->type!=OB_MBALL)) {
DupliObject *dob;
ListBase *duplilist;
- DupliObjectExtra *duplilist_extra = NULL;
- int totdob, i;
+ DupliApplyData *duplilist_apply_data = NULL;
+ int i;
/* create list of duplis generated by this object, particle
* system need to have render settings set for dupli particles */
dupli_render_particle_set(re, ob, timeoffset, 0, 1);
duplilist = object_duplilist(re->eval_ctx, re->scene, ob);
- totdob = BLI_countlist(duplilist);
- if (totdob > 0)
- duplilist_extra = MEM_mallocN(sizeof(DupliObjectExtra) * totdob, "DupliObject extra data");
+ duplilist_apply_data = duplilist_apply_matrix(duplilist);
dupli_render_particle_set(re, ob, timeoffset, 0, 0);
- /* set dupli obmats */
- for (dob= duplilist->first, i = 0; dob; dob= dob->next, ++i) {
- copy_m4_m4(duplilist_extra[i].omat, dob->ob->obmat);
- copy_m4_m4(dob->ob->obmat, dob->mat);
- }
-
for (dob= duplilist->first, i = 0; dob; dob= dob->next, ++i) {
- DupliObjectExtra *dob_extra = &duplilist_extra[i];
+ DupliExtraData *dob_extra = &duplilist_apply_data->extra[i];
Object *obd= dob->ob;
+ copy_m4_m4(obd->obmat, dob->mat);
+
/* group duplis need to set ob matrices correct, for deform. so no_draw is part handled */
if (!(obd->transflag & OB_RENDER_DUPLI) && dob->no_draw)
continue;
@@ -5035,8 +5022,6 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp
if (!allow_render_object(re, obd, nolamps, onlyselected, actob))
continue;
- copy_m4_m4(obd->obmat, dob->mat);
-
if (allow_render_dupli_instance(re, dob, obd)) {
ParticleSystem *psys;
ObjectRen *obr = NULL;
@@ -5054,7 +5039,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp
obi= RE_addRenderInstance(re, NULL, obd, ob, dob->persistent_id[0], 0, mat, ob->lay);
/* fill in instance variables for texturing */
- set_dupli_tex_mat(re, obi, dob, dob_extra->omat);
+ set_dupli_tex_mat(re, obi, dob, dob_extra->obmat);
if (dob->type != OB_DUPLIGROUP) {
copy_v3_v3(obi->dupliorco, dob->orco);
obi->dupliuv[0]= dob->uv[0];
@@ -5080,7 +5065,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp
mul_m4_m4m4(mat, re->viewmat, dob->mat);
obi= RE_addRenderInstance(re, NULL, obd, ob, dob->persistent_id[0], psysindex++, mat, obd->lay);
- set_dupli_tex_mat(re, obi, dob, dob_extra->omat);
+ set_dupli_tex_mat(re, obi, dob, dob_extra->obmat);
if (dob->type != OB_DUPLIGROUP) {
copy_v3_v3(obi->dupliorco, dob->orco);
obi->dupliuv[0]= dob->uv[0];
@@ -5096,7 +5081,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp
if (obi==NULL)
/* can't instance, just create the object */
- init_render_object(re, obd, ob, dob, dob_extra->omat, timeoffset);
+ init_render_object(re, obd, ob, dob, dob_extra->obmat, timeoffset);
if (dob->type != OB_DUPLIGROUP) {
obd->flag |= OB_DONE;
@@ -5104,22 +5089,16 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp
}
}
else
- init_render_object(re, obd, ob, dob, dob_extra->omat, timeoffset);
+ init_render_object(re, obd, ob, dob, dob_extra->obmat, timeoffset);
if (re->test_break(re->tbh)) break;
}
-
- /* restore obmats
- * NOTE: this has to happen in reverse order, since nested
- * dupli objects can repeatedly override the obmat
- */
- for (dob= duplilist->last, i = totdob - 1; dob; dob= dob->prev, --i) {
- copy_m4_m4(dob->ob->obmat, duplilist_extra[i].omat);
+
+ if (duplilist_apply_data) {
+ duplilist_restore_matrix(duplilist, duplilist_apply_data);
+ duplilist_free_apply_data(duplilist_apply_data);
}
-
free_object_duplilist(duplilist);
- if (duplilist_extra)
- MEM_freeN(duplilist_extra);
if (allow_render_object(re, ob, nolamps, onlyselected, actob))
init_render_object(re, ob, NULL, NULL, NULL, timeoffset);
diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c
index 39b9a0f0b63..28b29261e4e 100644
--- a/source/blender/render/intern/source/envmap.c
+++ b/source/blender/render/intern/source/envmap.c
@@ -31,7 +31,6 @@
#include <string.h>
/* external modules: */
-#include "MEM_guardedalloc.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
@@ -50,14 +49,10 @@
#include "DNA_scene_types.h"
#include "DNA_texture_types.h"
-#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_image.h" /* BKE_imbuf_write */
#include "BKE_texture.h"
-
-
-
/* this module */
#include "render_types.h"
#include "renderpipeline.h"
@@ -172,6 +167,8 @@ static Render *envmap_render_copy(Render *re, EnvMap *env)
envre->duh = re->duh;
envre->test_break = re->test_break;
envre->tbh = re->tbh;
+ envre->current_scene_update = re->current_scene_update;
+ envre->suh = re->suh;
/* and for the evil stuff; copy the database... */
envre->totvlak = re->totvlak;
@@ -321,6 +318,10 @@ void env_rotate_scene(Render *re, float mat[4][4], int do_rotate)
mul_m4_v3(tmat, har->co);
}
+
+ /* imat_ren is needed for correct texture coordinates */
+ mul_m4_m4m4(obr->ob->imat_ren, re->viewmat, obr->ob->obmat);
+ invert_m4(obr->ob->imat_ren);
}
for (go = re->lights.first; go; go = go->next) {
diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c
index f5901370c61..e8751210540 100644
--- a/source/blender/render/intern/source/external_engine.c
+++ b/source/blender/render/intern/source/external_engine.c
@@ -57,6 +57,7 @@
#include "RE_engine.h"
#include "RE_pipeline.h"
+#include "RE_bake.h"
#include "initrender.h"
#include "render_types.h"
@@ -67,7 +68,7 @@
static RenderEngineType internal_render_type = {
NULL, NULL,
"BLENDER_RENDER", N_("Blender Render"), RE_INTERNAL,
- NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL,
{NULL, NULL, NULL}
};
@@ -76,7 +77,7 @@ static RenderEngineType internal_render_type = {
static RenderEngineType internal_game_type = {
NULL, NULL,
"BLENDER_GAME", N_("Blender Game"), RE_INTERNAL | RE_GAME,
- NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL,
{NULL, NULL, NULL}
};
@@ -402,6 +403,84 @@ RenderData *RE_engine_get_render_data(Render *re)
return &re->r;
}
+/* Bake */
+void RE_bake_engine_set_engine_parameters(Render *re, Main *bmain, Scene *scene)
+{
+ re->scene = scene;
+ re->main = bmain;
+ re->r = scene->r;
+
+ /* prevent crash when freeing the scene
+ but it potentially leaves unfreed memory blocks
+ not sure how to fix this yet -- dfelinto */
+ re->r.layers.first = re->r.layers.last = NULL;
+}
+
+bool RE_bake_has_engine(Render *re)
+{
+ RenderEngineType *type = RE_engines_find(re->r.engine);
+ return (bool)(type->bake);
+}
+
+bool RE_bake_engine(
+ Render *re, Object *object, const BakePixel pixel_array[],
+ const int num_pixels, const int depth,
+ const ScenePassType pass_type, float result[])
+{
+ RenderEngineType *type = RE_engines_find(re->r.engine);
+ RenderEngine *engine;
+ int persistent_data = re->r.mode & R_PERSISTENT_DATA;
+
+ /* set render info */
+ re->i.cfra = re->scene->r.cfra;
+ BLI_strncpy(re->i.scene_name, re->scene->id.name + 2, sizeof(re->i.scene_name) - 2);
+ re->i.totface = re->i.totvert = re->i.totstrand = re->i.totlamp = re->i.tothalo = 0;
+
+ /* render */
+ engine = re->engine;
+
+ if (!engine) {
+ engine = RE_engine_create(type);
+ re->engine = engine;
+ }
+
+ engine->flag |= RE_ENGINE_RENDERING;
+
+ /* TODO: actually link to a parent which shouldn't happen */
+ engine->re = re;
+
+ engine->resolution_x = re->winx;
+ engine->resolution_y = re->winy;
+
+ RE_parts_init(re, false);
+ engine->tile_x = re->partx;
+ engine->tile_y = re->party;
+
+ /* update is only called so we create the engine.session */
+ if (type->update)
+ type->update(engine, re->main, re->scene);
+
+ if (type->bake)
+ type->bake(engine, re->scene, object, pass_type, pixel_array, num_pixels, depth, result);
+
+ engine->tile_x = 0;
+ engine->tile_y = 0;
+ engine->flag &= ~RE_ENGINE_RENDERING;
+
+ /* re->engine becomes zero if user changed active render engine during render */
+ if (!persistent_data || !re->engine) {
+ RE_engine_free(engine);
+ re->engine = NULL;
+ }
+
+ RE_parts_free(re);
+
+ if (BKE_reports_contain(re->reports, RPT_ERROR))
+ G.is_break = true;
+
+ return true;
+}
+
/* Render */
static bool render_layer_exclude_animated(Scene *scene, SceneRenderLayer *srl)
diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c
index 31748549768..7d4b70cea15 100644
--- a/source/blender/render/intern/source/imagetexture.c
+++ b/source/blender/render/intern/source/imagetexture.c
@@ -38,8 +38,6 @@
#include <io.h>
#endif
-#include "MEM_guardedalloc.h"
-
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
@@ -52,11 +50,8 @@
#include "BLI_threads.h"
#include "BLI_utildefines.h"
-#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_image.h"
-#include "BKE_texture.h"
-#include "BKE_library.h"
#include "RE_render_ext.h"
@@ -82,21 +77,21 @@ static void ibuf_get_color(float col[4], struct ImBuf *ibuf, int x, int y)
if (ibuf->rect_float) {
if (ibuf->channels==4) {
- float *fp= ibuf->rect_float + 4*ofs;
+ const float *fp= ibuf->rect_float + 4*ofs;
copy_v4_v4(col, fp);
}
else if (ibuf->channels==3) {
- float *fp= ibuf->rect_float + 3*ofs;
+ const float *fp= ibuf->rect_float + 3*ofs;
copy_v3_v3(col, fp);
col[3]= 1.0f;
}
else {
- float *fp= ibuf->rect_float + ofs;
+ const float *fp= ibuf->rect_float + ofs;
col[0]= col[1]= col[2]= col[3]= *fp;
}
}
else {
- char *rect = (char *)( ibuf->rect+ ofs);
+ const char *rect = (char *)( ibuf->rect+ ofs);
col[0] = ((float)rect[0])*(1.0f/255.0f);
col[1] = ((float)rect[1])*(1.0f/255.0f);
@@ -727,7 +722,7 @@ static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extf
}
}
else {
- char *rect = (char *)(ibuf->rect + x + y*ibuf->x);
+ const char *rect = (char *)(ibuf->rect + x + y*ibuf->x);
float inv_alpha_fac = (1.0f / 255.0f) * rect[3] * (1.0f / 255.0f);
col[0] = rect[0] * inv_alpha_fac;
col[1] = rect[1] * inv_alpha_fac;
diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c
index 2c431bf869c..5fd4747f19b 100644
--- a/source/blender/render/intern/source/initrender.c
+++ b/source/blender/render/intern/source/initrender.c
@@ -44,23 +44,12 @@
#include "BLI_utildefines.h"
#include "DNA_camera_types.h"
-#include "DNA_group_types.h"
#include "DNA_image_types.h"
-#include "DNA_lamp_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BKE_camera.h"
-#include "BKE_global.h"
-#include "BKE_material.h"
-#include "BKE_object.h"
-#include "BKE_image.h"
-#include "BKE_ipo.h"
-#include "BKE_key.h"
-#include "BKE_action.h"
-#include "BKE_writeavi.h"
-#include "BKE_scene.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
diff --git a/source/blender/render/intern/source/multires_bake.c b/source/blender/render/intern/source/multires_bake.c
index b0416c5d517..4ac1593d1bb 100644
--- a/source/blender/render/intern/source/multires_bake.c
+++ b/source/blender/render/intern/source/multires_bake.c
@@ -42,7 +42,6 @@
#include "BLI_threads.h"
#include "BKE_ccg.h"
-#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_image.h"
#include "BKE_multires.h"
@@ -76,7 +75,7 @@ typedef struct {
MFace *mface;
MTFace *mtface;
float *pvtangent;
- float *precomputed_normals;
+ const float *precomputed_normals;
int w, h;
int face_index;
int i0, i1, i2;
@@ -137,7 +136,7 @@ static void multiresbake_get_normal(const MResolvePixelData *data, float norm[],
}
else {
float nor[3];
- float *p0, *p1, *p2;
+ const float *p0, *p1, *p2;
const int iGetNrVerts = data->mface[face_num].v4 != 0 ? 4 : 3;
p0 = data->mvert[indices[0]].co;
@@ -145,7 +144,7 @@ static void multiresbake_get_normal(const MResolvePixelData *data, float norm[],
p2 = data->mvert[indices[2]].co;
if (iGetNrVerts == 4) {
- float *p3 = data->mvert[indices[3]].co;
+ const float *p3 = data->mvert[indices[3]].co;
normal_quad_v3(nor, p0, p1, p2, p3);
}
else {
@@ -156,7 +155,7 @@ static void multiresbake_get_normal(const MResolvePixelData *data, float norm[],
}
}
else {
- short *no = data->mvert[indices[vert_index]].no;
+ const short *no = data->mvert[indices[vert_index]].no;
normal_short_to_float_v3(norm, no);
normalize_v3(norm);
@@ -181,8 +180,8 @@ static void init_bake_rast(MBakeRast *bake_rast, const ImBuf *ibuf, const MResol
static void flush_pixel(const MResolvePixelData *data, const int x, const int y)
{
float st[2] = {(x + 0.5f) / data->w, (y + 0.5f) / data->h};
- float *st0, *st1, *st2;
- float *tang0, *tang1, *tang2;
+ const float *st0, *st1, *st2;
+ const float *tang0, *tang1, *tang2;
float no0[3], no1[3], no2[3];
float fUV[2], from_tang[3][3], to_tang[3][3];
float u, v, w, sign;
@@ -451,7 +450,7 @@ static void init_ccgdm_arrays(DerivedMesh *dm)
CCGElem **grid_data;
CCGKey key;
int grid_size;
- int *grid_offset;
+ const int *grid_offset;
grid_size = dm->getGridSize(dm);
grid_data = dm->getGridData(dm);
@@ -478,7 +477,7 @@ static void do_multires_bake(MultiresBakeRender *bkr, Image *ima, bool require_t
MVert *mvert = dm->getVertArray(dm);
MFace *mface = dm->getTessFaceArray(dm);
MTFace *mtface = dm->getTessFaceDataArray(dm, CD_MTFACE);
- float *precomputed_normals = dm->getTessFaceDataArray(dm, CD_NORMAL);
+ const float *precomputed_normals = dm->getTessFaceDataArray(dm, CD_NORMAL);
float *pvtangent = NULL;
ListBase threads;
diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c
index 91c9143f5a3..dd0b1f89da7 100644
--- a/source/blender/render/intern/source/occlusion.c
+++ b/source/blender/render/intern/source/occlusion.c
@@ -39,14 +39,12 @@
#include "DNA_material_types.h"
#include "BLI_math.h"
-#include "BLI_blenlib.h"
#include "BLI_memarena.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
#include "BLF_translation.h"
-#include "BKE_global.h"
#include "BKE_scene.h"
@@ -1176,7 +1174,7 @@ static void sample_occ_surface(ShadeInput *shi)
{
StrandRen *strand = shi->strand;
StrandSurface *mesh = strand->buffer->surface;
- int *face, *index = RE_strandren_get_face(shi->obr, strand, 0);
+ const int *face, *index = RE_strandren_get_face(shi->obr, strand, 0);
float w[4], *co1, *co2, *co3, *co4;
if (mesh && mesh->face && mesh->co && mesh->ao && index) {
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index 1a3d07f9aeb..232f9db1c65 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -35,7 +35,6 @@
#include <stdlib.h>
#include <stddef.h>
-#include "DNA_group_types.h"
#include "DNA_image_types.h"
#include "DNA_node_types.h"
#include "DNA_object_types.h"
@@ -80,7 +79,6 @@
#include "RE_pipeline.h"
#ifdef WITH_FREESTYLE
-# include "BKE_library.h"
# include "FRS_freestyle.h"
#endif
@@ -144,6 +142,7 @@ static int thread_break(void *UNUSED(arg))
/* default callbacks, set in each new render */
static void result_nothing(void *UNUSED(arg), RenderResult *UNUSED(rr)) {}
static void result_rcti_nothing(void *UNUSED(arg), RenderResult *UNUSED(rr), volatile struct rcti *UNUSED(rect)) {}
+static void current_scene_nothing(void *UNUSED(arg), Scene *UNUSED(scene)) {}
static void stats_nothing(void *UNUSED(arg), RenderStats *UNUSED(rs)) {}
static void float_nothing(void *UNUSED(arg), float UNUSED(val)) {}
static int default_break(void *UNUSED(arg)) { return G.is_break == true; }
@@ -395,6 +394,7 @@ void RE_InitRenderCB(Render *re)
re->display_init = result_nothing;
re->display_clear = result_nothing;
re->display_update = result_rcti_nothing;
+ re->current_scene_update = current_scene_nothing;
re->progress = float_nothing;
re->test_break = default_break;
if (G.background)
@@ -665,6 +665,10 @@ static void render_update_anim_renderdata(Render *re, RenderData *rd)
/* freestyle */
re->r.line_thickness_mode = rd->line_thickness_mode;
re->r.unit_line_thickness = rd->unit_line_thickness;
+
+ /* render layers */
+ BLI_freelistN(&re->r.layers);
+ BLI_duplicatelist(&re->r.layers, &rd->layers);
}
void RE_SetWindow(Render *re, rctf *viewplane, float clipsta, float clipend)
@@ -735,6 +739,11 @@ void RE_display_update_cb(Render *re, void *handle, void (*f)(void *handle, Rend
re->display_update = f;
re->duh = handle;
}
+void RE_current_scene_update_cb(Render *re, void *handle, void (*f)(void *handle, Scene *scene))
+{
+ re->current_scene_update = f;
+ re->suh = handle;
+}
void RE_stats_draw_cb(Render *re, void *handle, void (*f)(void *handle, RenderStats *rs))
{
re->stats_draw = f;
@@ -1186,6 +1195,8 @@ static void do_render_3d(Render *re)
{
int cfra_backup;
+ re->current_scene_update(re->suh, re->scene);
+
/* try external */
if (RE_engine_render(re, 0))
return;
@@ -1591,6 +1602,8 @@ static void render_scene(Render *re, Scene *sce, int cfra)
resc->tbh = re->tbh;
resc->stats_draw = re->stats_draw;
resc->sdh = re->sdh;
+ resc->current_scene_update = re->current_scene_update;
+ resc->suh = re->suh;
do_render_fields_blur_3d(resc);
}
@@ -2291,6 +2304,8 @@ static void do_render_seq(Render *re)
/* main loop: doing sequence + fields + blur + 3d render + compositing */
static void do_render_all_options(Render *re)
{
+ re->current_scene_update(re->suh, re->scene);
+
BKE_scene_camera_switch_update(re->scene);
re->i.starttime = PIL_check_seconds_timer();
diff --git a/source/blender/render/intern/source/pixelblending.c b/source/blender/render/intern/source/pixelblending.c
index 7f5b0a5b20b..460a6814f07 100644
--- a/source/blender/render/intern/source/pixelblending.c
+++ b/source/blender/render/intern/source/pixelblending.c
@@ -35,8 +35,6 @@
#include <string.h>
/* global includes */
-#include "BLI_math.h"
-#include "BLI_rand.h"
/* own includes */
#include "render_types.h"
diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c
index 0c3da335963..09a6a6374be 100644
--- a/source/blender/render/intern/source/pixelshading.c
+++ b/source/blender/render/intern/source/pixelshading.c
@@ -39,7 +39,6 @@
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
-#include "DNA_camera_types.h"
#include "DNA_group_types.h"
#include "DNA_material_types.h"
#include "DNA_object_types.h"
@@ -47,11 +46,7 @@
#include "DNA_texture_types.h"
#include "DNA_lamp_types.h"
-#include "BKE_colortools.h"
-#include "BKE_image.h"
-#include "BKE_global.h"
#include "BKE_material.h"
-#include "BKE_texture.h"
/* own module */
diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c
index b085ac5812b..799f7fa2f2e 100644
--- a/source/blender/render/intern/source/pointdensity.c
+++ b/source/blender/render/intern/source/pointdensity.c
@@ -43,10 +43,8 @@
#include "BLF_translation.h"
#include "BKE_DerivedMesh.h"
-#include "BKE_global.h"
#include "BKE_lattice.h"
#include "BKE_main.h"
-#include "BKE_object.h"
#include "BKE_particle.h"
#include "BKE_scene.h"
#include "BKE_texture.h"
@@ -350,7 +348,7 @@ void free_pointdensities(Render *re)
typedef struct PointDensityRangeData {
float *density;
float squared_radius;
- float *point_data;
+ const float *point_data;
float *vec;
float softness;
short falloff_type;
diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c
index 7e6fd04c3f4..7e56d93f23b 100644
--- a/source/blender/render/intern/source/rayshade.c
+++ b/source/blender/render/intern/source/rayshade.c
@@ -48,7 +48,6 @@
#include "BLF_translation.h"
-#include "BKE_global.h"
#include "BKE_node.h"
@@ -119,8 +118,6 @@ RayObject *RE_rayobject_create(int type, int size, int octree_resolution)
if (type == R_RAYSTRUCTURE_OCTREE) //TODO dynamic ocres
res = RE_rayobject_octree_create(octree_resolution, size);
- else if (type == R_RAYSTRUCTURE_BLIBVH)
- res = RE_rayobject_blibvh_create(size);
else if (type == R_RAYSTRUCTURE_VBVH)
res = RE_rayobject_vbvh_create(size);
else if (type == R_RAYSTRUCTURE_SIMD_SVBVH)
@@ -478,9 +475,9 @@ static void shade_ray_set_derivative(ShadeInput *shi)
t10= v3[axis1]-v2[axis1]; t11= v3[axis2]-v2[axis2];
}
else {
- float *v1= shi->v1->co;
- float *v2= shi->v2->co;
- float *v3= shi->v3->co;
+ const float *v1= shi->v1->co;
+ const float *v2= shi->v2->co;
+ const float *v3= shi->v3->co;
/* same as above */
t00= v3[axis1]-v1[axis1]; t01= v3[axis2]-v1[axis2];
@@ -2329,7 +2326,7 @@ static void ray_shadow_qmc(ShadeInput *shi, LampRen *lar, const float lampco[3],
static void ray_shadow_jitter(ShadeInput *shi, LampRen *lar, const float lampco[3], float shadfac[4], Isect *isec)
{
/* area soft shadow */
- float *jitlamp;
+ const float *jitlamp;
float fac=0.0f, div=0.0f, vec[3];
int a, j= -1, mask;
RayHint point_hint;
diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c
index f63deff04ae..40de1080634 100644
--- a/source/blender/render/intern/source/render_result.c
+++ b/source/blender/render/intern/source/render_result.c
@@ -36,7 +36,6 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
-#include "BLI_fileops.h"
#include "BLI_listbase.h"
#include "BLI_path_util.h"
#include "BLI_rect.h"
@@ -49,7 +48,6 @@
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_report.h"
-#include "BKE_freestyle.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
@@ -483,10 +481,14 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf
if (strcmp(srl->name, layername) != 0)
continue;
- if ((re->r.scemode & R_SINGLE_LAYER) && nr != re->r.actlay)
- continue;
- if (srl->layflag & SCE_LAY_DISABLE)
- continue;
+ if (re->r.scemode & R_SINGLE_LAYER) {
+ if (nr != re->r.actlay)
+ continue;
+ }
+ else {
+ if (srl->layflag & SCE_LAY_DISABLE)
+ continue;
+ }
rl = MEM_callocN(sizeof(RenderLayer), "new render layer");
BLI_addtail(&rr->layers, rl);
@@ -587,6 +589,8 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf
/* duplicate code... */
if (rr->do_exr_tile) {
+ rl->display_buffer = MEM_mapallocN(rectx * recty * sizeof(unsigned int), "Combined display space rgba");
+
rl->exrhandle = IMB_exr_get_handle();
IMB_exr_add_channel(rl->exrhandle, rl->name, "Combined.R", 0, 0, NULL);
diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c
index 3ed216518de..597f93a2659 100644
--- a/source/blender/render/intern/source/render_texture.c
+++ b/source/blender/render/intern/source/render_texture.c
@@ -33,7 +33,6 @@
#include <string.h>
#include <math.h>
-#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_noise.h"
#include "BLI_rand.h"
@@ -43,7 +42,6 @@
#include "DNA_texture_types.h"
#include "DNA_object_types.h"
#include "DNA_lamp_types.h"
-#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_material_types.h"
#include "DNA_image_types.h"
@@ -53,7 +51,6 @@
#include "IMB_imbuf.h"
#include "IMB_colormanagement.h"
-#include "BKE_colortools.h"
#include "BKE_image.h"
#include "BKE_node.h"
@@ -64,10 +61,7 @@
#include "BKE_material.h"
#include "BKE_scene.h"
-#include "BKE_library.h"
#include "BKE_texture.h"
-#include "BKE_key.h"
-#include "BKE_ipo.h"
#include "MEM_guardedalloc.h"
@@ -643,10 +637,10 @@ static float voronoiTex(Tex *tex, const float texvec[3], TexResult *texres)
{
int rv = TEX_INT;
float da[4], pa[12]; /* distance and point coordinate arrays of 4 nearest neighbors */
- float aw1 = fabs(tex->vn_w1);
- float aw2 = fabs(tex->vn_w2);
- float aw3 = fabs(tex->vn_w3);
- float aw4 = fabs(tex->vn_w4);
+ float aw1 = fabsf(tex->vn_w1);
+ float aw2 = fabsf(tex->vn_w2);
+ float aw3 = fabsf(tex->vn_w3);
+ float aw4 = fabsf(tex->vn_w4);
float sc = (aw1 + aw2 + aw3 + aw4);
if (sc!=0.f) sc = tex->ns_outscale/sc;
@@ -751,9 +745,9 @@ static int cubemap_glob(const float n[3], float x, float y, float z, float *adr1
}
mul_mat3_m4_v3(R.viewinv, nor);
- x1= fabs(nor[0]);
- y1= fabs(nor[1]);
- z1= fabs(nor[2]);
+ x1 = fabsf(nor[0]);
+ y1 = fabsf(nor[1]);
+ z1 = fabsf(nor[2]);
if (z1>=x1 && z1>=y1) {
*adr1 = (x + 1.0f) / 2.0f;
@@ -844,9 +838,9 @@ static int cubemap_ob(Object *ob, const float n[3], float x, float y, float z, f
copy_v3_v3(nor, n);
if (ob) mul_mat3_m4_v3(ob->imat, nor);
- x1= fabs(nor[0]);
- y1= fabs(nor[1]);
- z1= fabs(nor[2]);
+ x1 = fabsf(nor[0]);
+ y1 = fabsf(nor[1]);
+ z1 = fabsf(nor[2]);
if (z1>=x1 && z1>=y1) {
*adr1 = (x + 1.0f) / 2.0f;
@@ -1420,12 +1414,9 @@ void texture_rgb_blend(float in[3], const float tex[3], const float out[3], floa
fact*= facg;
facm= 1.0f-fact;
- col= tex[0]+((1-tex[0])*facm);
- if (col < out[0]) in[0]= col; else in[0]= out[0];
- col= tex[1]+((1-tex[1])*facm);
- if (col < out[1]) in[1]= col; else in[1]= out[1];
- col= tex[2]+((1-tex[2])*facm);
- if (col < out[2]) in[2]= col; else in[2]= out[2];
+ 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;
break;
case MTEX_LIGHT:
@@ -1522,8 +1513,7 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen
break;
case MTEX_DARK:
- col= fact*tex;
- if (col < out) in= col; else in= out;
+ in = min_ff(out, tex)*fact + out*facm;
break;
case MTEX_LIGHT:
@@ -1683,7 +1673,7 @@ static void compatible_bump_uv_derivs(CompatibleBump *compat_bump, ShadeInput *s
}
if (tf) {
- float *uv1 = tf->uv[j1], *uv2 = tf->uv[j2], *uv3 = tf->uv[j3];
+ const float *uv1 = tf->uv[j1], *uv2 = tf->uv[j2], *uv3 = tf->uv[j3];
const float an[3] = {fabsf(compat_bump->nn[0]), fabsf(compat_bump->nn[1]), fabsf(compat_bump->nn[2])};
const int a1 = (an[0] > an[1] && an[0] > an[2]) ? 1 : 0;
const int a2 = (an[2] > an[0] && an[2] > an[1]) ? 1 : 2;
@@ -3713,7 +3703,7 @@ void RE_sample_material_color(Material *mat, float color[3], float *alpha, const
/* for every uv map set coords and name */
for (i=0; i<layers; i++) {
if (layer_index >= 0) {
- float *uv1, *uv2, *uv3;
+ const float *uv1, *uv2, *uv3;
float l;
CustomData *data = &orcoDm->faceData;
MTFace *tface = (MTFace *) data->layers[layer_index+i].data;
diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c
index 63fcafe2cc0..27bc449dce3 100644
--- a/source/blender/render/intern/source/rendercore.c
+++ b/source/blender/render/intern/source/rendercore.c
@@ -45,23 +45,12 @@
#include "BLI_threads.h"
#include "BLI_utildefines.h"
-
-
#include "DNA_image_types.h"
#include "DNA_lamp_types.h"
#include "DNA_material_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
#include "DNA_group_types.h"
-#include "BKE_customdata.h"
-#include "BKE_depsgraph.h"
-#include "BKE_global.h"
-#include "BKE_image.h"
#include "BKE_main.h"
-#include "BKE_node.h"
-#include "BKE_texture.h"
-#include "BKE_scene.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
@@ -348,7 +337,7 @@ static void lamphalo_tile(RenderPart *pa, RenderLayer *rl)
float *pass;
float fac, col[4];
intptr_t *rd= pa->rectdaps;
- int *rz= pa->rectz;
+ const int *rz= pa->rectz;
int x, y, sample, totsample, fullsample, od;
totsample= get_sample_layers(pa, rl, rlpp);
@@ -763,7 +752,7 @@ static void atm_tile(RenderPart *pa, RenderLayer *rl)
int sample;
for (sample=0; sample<totsample; sample++) {
- float *zrect= RE_RenderLayerGetPass(rlpp[sample], SCE_PASS_Z) + od;
+ const float *zrect= RE_RenderLayerGetPass(rlpp[sample], SCE_PASS_Z) + od;
float *rgbrect = rlpp[sample]->rectf + 4*od;
float rgb[3] = {0};
bool done = false;
@@ -1157,10 +1146,10 @@ static void make_pixelstructs(RenderPart *pa, ZSpan *zspan, int sample, void *da
ZbufSolidData *sdata = (ZbufSolidData *)data;
ListBase *lb= sdata->psmlist;
intptr_t *rd= pa->rectdaps;
- int *ro= zspan->recto;
- int *rp= zspan->rectp;
- int *rz= zspan->rectz;
- int *rm= zspan->rectmask;
+ const int *ro= zspan->recto;
+ const int *rp= zspan->rectp;
+ const int *rz= zspan->rectz;
+ const int *rm= zspan->rectmask;
int x, y;
int mask= 1<<sample;
@@ -1363,8 +1352,8 @@ void zbufshade_tile(RenderPart *pa)
rr->renlay= rl;
if (rl->layflag & SCE_LAY_SOLID) {
- float *fcol= rl->rectf;
- int *ro= pa->recto, *rp= pa->rectp, *rz= pa->rectz;
+ const float *fcol= rl->rectf;
+ const int *ro= pa->recto, *rp= pa->rectp, *rz= pa->rectz;
int x, y, offs=0, seed;
/* we set per pixel a fixed seed, for random AO and shadow samples */
@@ -1910,9 +1899,9 @@ static void renderflare(RenderResult *rr, float *rectf, HaloRen *har)
for (b=1; b<har->flarec; b++) {
- fla.r= fabs(rc[0]);
- fla.g= fabs(rc[1]);
- fla.b= fabs(rc[2]);
+ fla.r = fabsf(rc[0]);
+ fla.g = fabsf(rc[1]);
+ fla.b = fabsf(rc[2]);
fla.alfa= ma->flareboost*fabsf(alfa*visifac*rc[3]);
fla.hard= 20.0f + fabsf(70.0f*rc[7]);
fla.tex= 0;
diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c
index 0d5b0b920b4..6a3787289d8 100644
--- a/source/blender/render/intern/source/renderdatabase.c
+++ b/source/blender/render/intern/source/renderdatabase.c
@@ -66,16 +66,12 @@
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
-#include "BLI_ghash.h"
-#include "BLI_memarena.h"
#include "DNA_material_types.h"
-#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_texture_types.h"
#include "BKE_customdata.h"
-#include "BKE_texture.h"
#include "BKE_DerivedMesh.h"
#include "RE_render_ext.h" /* externtex */
diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c
index f534acd838d..9d337e542a1 100644
--- a/source/blender/render/intern/source/shadbuf.c
+++ b/source/blender/render/intern/source/shadbuf.c
@@ -660,7 +660,7 @@ static void shadowbuf_autoclip(Render *re, LampRen *lar)
if (vlr->mat!= ma) {
ma= vlr->mat;
ok= 1;
- if ((ma->mode & MA_SHADBUF)==0) ok= 0;
+ if ((ma->mode2 & MA_CASTSHADOW)==0 || (ma->mode & MA_SHADBUF)==0) ok= 0;
}
if (ok && (obi->lay & lay)) {
@@ -925,7 +925,7 @@ void freeshadowbuf(LampRen *lar)
}
else {
intptr_t *ztile= shsample->zbuf;
- char *ctile= shsample->cbuf;
+ const char *ctile= shsample->cbuf;
v= (shb->size*shb->size)/256;
for (b=0; b<v; b++, ztile++, ctile++)
@@ -949,7 +949,7 @@ static int firstreadshadbuf(ShadBuf *shb, ShadSampleBuf *shsample, int **rz, int
{
/* return a 1 if fully compressed shadbuf-tile && z==const */
int ofs;
- char *ct;
+ const char *ct;
if (shsample->deepbuf)
return 0;
@@ -1614,7 +1614,7 @@ static void isb_bsp_split(ISBBranch *root, MemArena *mem)
static int isb_bsp_insert(ISBBranch *root, MemArena *memarena, ISBSample *sample)
{
ISBBranch *bspn= root;
- float *zco= sample->zco;
+ const float *zco= sample->zco;
int i= 0;
/* debug counter, also used to check if something was filled in ever */
@@ -2013,7 +2013,7 @@ static void isb_bsp_fillfaces(Render *re, LampRen *lar, ISBBranch *root)
if (vlr->mat!= ma) {
ma= vlr->mat;
ok= 1;
- if ((ma->mode & MA_SHADBUF)==0) ok= 0;
+ if ((ma->mode2 & MA_CASTSHADOW)==0 || (ma->mode & MA_SHADBUF)==0) ok= 0;
if (ma->material_type == MA_TYPE_WIRE) ok= 0;
zspanstrand.shad_alpha= zspan.shad_alpha= ma->shad_alpha;
}
@@ -2120,7 +2120,7 @@ static int viewpixel_to_lampbuf(ShadBuf *shb, ObjectInstanceRen *obi, VlakRen *v
/* clip We can test for -1.0/1.0 because of the properties of the
* coordinate transformations. */
- fac= fabs(hoco[3]);
+ fac = fabsf(hoco[3]);
if (hoco[0]<-fac || hoco[0]>fac)
return 0;
if (hoco[1]<-fac || hoco[1]>fac)
@@ -2574,7 +2574,7 @@ float ISB_getshadow(ShadeInput *shi, ShadBuf *shb)
if (y >= 0 && y < isbdata->recty) {
if (isbdata->shadfacs) {
- short *sp= isbdata->shadfacs + y*isbdata->rectx + x;
+ const short *sp= isbdata->shadfacs + y*isbdata->rectx + x;
return *sp>=4096?0.0f:1.0f - ((float)*sp)/4096.0f;
}
else {
diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c
index 90e5def64f6..7aca6b9ac87 100644
--- a/source/blender/render/intern/source/shadeinput.c
+++ b/source/blender/render/intern/source/shadeinput.c
@@ -34,16 +34,12 @@
#include "BLI_math.h"
-#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
-#include "DNA_curve_types.h"
-#include "DNA_group_types.h"
#include "DNA_lamp_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_material_types.h"
-#include "BKE_colortools.h"
#include "BKE_scene.h"
#include "BKE_node.h"
@@ -276,6 +272,7 @@ void shade_input_set_triangle_i(ShadeInput *shi, ObjectInstanceRen *obi, VlakRen
shi->osatex = (shi->mat->texco & TEXCO_OSA);
shi->mode = shi->mat->mode_l; /* or-ed result for all nodes */
+ shi->mode2 = shi->mat->mode2_l;
/* facenormal copy, can get flipped */
shi->flippednor = 0;
@@ -395,7 +392,7 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert
}
if (mode & MA_STR_SURFDIFF) {
- float *surfnor = RE_strandren_get_surfnor(obr, strand, 0);
+ const float *surfnor = RE_strandren_get_surfnor(obr, strand, 0);
if (surfnor)
copy_v3_v3(shi->surfnor, surfnor);
@@ -411,7 +408,7 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert
}
if (R.r.mode & R_SPEED) {
- float *speed;
+ const float *speed;
speed = RE_strandren_get_winspeed(shi->obi, strand, 0);
if (speed)
@@ -450,7 +447,7 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert
if ((texco & TEXCO_UV) || (mode & (MA_VERTEXCOL | MA_VERTEXCOLP | MA_FACETEXTURE))) {
MCol *mcol;
- float *uv;
+ const float *uv;
char *name;
int i;
@@ -462,7 +459,7 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert
if (mode & (MA_VERTEXCOL | MA_VERTEXCOLP)) {
for (i = 0; (mcol = RE_strandren_get_mcol(obr, strand, i, &name, 0)); i++) {
ShadeInputCol *scol = &shi->col[i];
- char *cp = (char *)mcol;
+ const char *cp = (char *)mcol;
shi->totcol++;
scol->name = name;
@@ -885,7 +882,7 @@ void shade_input_set_shade_texco(ShadeInput *shi)
if (shi->vlr->flag & R_SMOOTH) {
if (shi->osatex && (texco & (TEXCO_NORM | TEXCO_REFL)) ) {
- float *n1 = shi->n1, *n2 = shi->n2, *n3 = shi->n3;
+ const float *n1 = shi->n1, *n2 = shi->n2, *n3 = shi->n3;
dl = shi->dx_u + shi->dx_v;
shi->dxno[0] = dl * n3[0] - shi->dx_u * n1[0] - shi->dx_v * n2[0];
@@ -901,7 +898,7 @@ void shade_input_set_shade_texco(ShadeInput *shi)
/* calc tangents */
if (mode & (MA_TANGENT_V | MA_NORMAP_TANG) || R.flag & R_NEED_TANGENT) {
- float *tangent, *s1, *s2, *s3;
+ const float *tangent, *s1, *s2, *s3;
float tl, tu, tv;
if (shi->vlr->flag & R_SMOOTH) {
@@ -973,7 +970,7 @@ void shade_input_set_shade_texco(ShadeInput *shi)
}
if (mode & MA_STR_SURFDIFF) {
- float *surfnor = RE_vlakren_get_surfnor(obr, shi->vlr, 0);
+ const float *surfnor = RE_vlakren_get_surfnor(obr, shi->vlr, 0);
if (surfnor) {
copy_v3_v3(shi->surfnor, surfnor);
@@ -987,7 +984,7 @@ void shade_input_set_shade_texco(ShadeInput *shi)
}
if (R.r.mode & R_SPEED) {
- float *s1, *s2, *s3;
+ const float *s1, *s2, *s3;
s1 = RE_vertren_get_winspeed(obi, v1, 0);
s2 = RE_vertren_get_winspeed(obi, v2, 0);
@@ -1012,7 +1009,7 @@ void shade_input_set_shade_texco(ShadeInput *shi)
if (texco & TEXCO_ORCO) {
if (v1->orco) {
- float *o1, *o2, *o3;
+ const float *o1, *o2, *o3;
o1 = v1->orco;
o2 = v2->orco;
@@ -1076,7 +1073,7 @@ void shade_input_set_shade_texco(ShadeInput *shi)
if ((mode & (MA_VERTEXCOL | MA_VERTEXCOLP)) || (R.flag & R_NEED_VCOL)) {
for (i = 0; (mcol = RE_vlakren_get_mcol(obr, vlr, i, &name, 0)); i++) {
ShadeInputCol *scol = &shi->col[i];
- char *cp1, *cp2, *cp3;
+ const char *cp1, *cp2, *cp3;
float a[3];
shi->totcol++;
@@ -1256,7 +1253,7 @@ void shade_input_set_shade_texco(ShadeInput *shi)
}
if (texco & TEXCO_STRESS) {
- float *s1, *s2, *s3;
+ const float *s1, *s2, *s3;
s1 = RE_vertren_get_stress(obr, v1, 0);
s2 = RE_vertren_get_stress(obr, v2, 0);
diff --git a/source/blender/render/intern/source/sss.c b/source/blender/render/intern/source/sss.c
index 09169259461..52d3815c4ad 100644
--- a/source/blender/render/intern/source/sss.c
+++ b/source/blender/render/intern/source/sss.c
@@ -61,11 +61,8 @@
#include "DNA_material_types.h"
-#include "BKE_colortools.h"
#include "BKE_global.h"
#include "BKE_main.h"
-#include "BKE_material.h"
-#include "BKE_node.h"
#include "BKE_scene.h"
@@ -934,7 +931,7 @@ static void sss_create_tree_mat(Render *re, Material *mat)
if (!re->test_break(re->tbh)) {
SSSData *sss= MEM_callocN(sizeof(*sss), "SSSData");
float ior= mat->sss_ior, cfac= mat->sss_colfac;
- float *radius= mat->sss_radius;
+ const float *radius = mat->sss_radius;
float fw= mat->sss_front, bw= mat->sss_back;
float error = mat->sss_error;
diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c
index 9a6a2b8ec9c..50343cfaa0b 100644
--- a/source/blender/render/intern/source/strand.c
+++ b/source/blender/render/intern/source/strand.c
@@ -79,7 +79,7 @@ void strand_eval_point(StrandSegment *sseg, StrandPoint *spoint)
{
Material *ma;
StrandBuffer *strandbuf;
- float *simplify;
+ const float *simplify;
float p[4][3], data[4], cross[3], w, dx, dy, t;
int type;
@@ -862,7 +862,7 @@ int zbuffer_strands_abuf(Render *re, RenderPart *pa, APixstrand *apixbuf, ListBa
/* test if we should skip it */
ma = obr->strandbuf->ma;
- if (shadow && !(ma->mode & MA_SHADBUF))
+ if (shadow && (!(ma->mode2 & MA_CASTSHADOW) || !(ma->mode & MA_SHADBUF)))
continue;
else if (!shadow && (ma->mode & MA_ONLYCAST))
continue;
diff --git a/source/blender/render/intern/source/sunsky.c b/source/blender/render/intern/source/sunsky.c
index e812b99287c..71ef5b8f62f 100644
--- a/source/blender/render/intern/source/sunsky.c
+++ b/source/blender/render/intern/source/sunsky.c
@@ -28,7 +28,6 @@
#include "sunsky.h"
#include "BLI_math.h"
-#include "BKE_global.h"
/**
* These macros are defined for vector operations
@@ -109,8 +108,8 @@ static float AngleBetween(float thetav, float phiv, float theta, float phi)
* */
static void DirectionToThetaPhi(float *toSun, float *theta, float *phi)
{
- *theta = acos(toSun[2]);
- if (fabs(*theta) < 1e-5)
+ *theta = acosf(toSun[2]);
+ if (fabsf(*theta) < 1e-5f)
*phi = 0;
else
*phi = atan2(toSun[1], toSun[0]);
diff --git a/source/blender/render/intern/source/volume_precache.c b/source/blender/render/intern/source/volume_precache.c
index 6cf83d0508f..6135a8761bb 100644
--- a/source/blender/render/intern/source/volume_precache.c
+++ b/source/blender/render/intern/source/volume_precache.c
@@ -60,7 +60,6 @@
#include "volumetric.h"
#include "volume_precache.h"
-#include "BKE_global.h"
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */
@@ -290,7 +289,7 @@ BLI_INLINE int lc_to_ms_I(int x, int y, int z, int *n)
static float total_ss_energy(Render *re, int do_test_break, VolumePrecache *vp)
{
int x, y, z;
- int *res = vp->res;
+ const int *res = vp->res;
float energy=0.f;
for (z=0; z < res[2]; z++) {
@@ -600,7 +599,7 @@ static void precache_launch_parts(Render *re, RayObject *tree, ShadeInput *shi,
float voxel[3];
int sizex, sizey, sizez;
float bbmin[3], bbmax[3];
- int *res;
+ const int *res;
int minx, maxx;
int miny, maxy;
int minz, maxz;
diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c
index 39950a1d417..fe3af5b840e 100644
--- a/source/blender/render/intern/source/volumetric.c
+++ b/source/blender/render/intern/source/volumetric.c
@@ -29,15 +29,11 @@
* \ingroup render
*/
-
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
-#include "MEM_guardedalloc.h"
-
-#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_rand.h"
#include "BLI_voxel.h"
@@ -50,7 +46,6 @@
#include "DNA_lamp_types.h"
#include "DNA_meta_types.h"
-#include "BKE_global.h"
#include "render_types.h"
#include "pixelshading.h"
@@ -661,7 +656,7 @@ static void volumeintegrate(struct ShadeInput *shi, float col[4], const float co
static void volume_trace(struct ShadeInput *shi, struct ShadeResult *shr, int inside_volume)
{
float hitco[3], col[4] = {0.f, 0.f, 0.f, 0.f};
- float *startco, *endco;
+ const float *startco, *endco;
int trace_behind = 1;
const int ztransp = ((shi->depth == 0) && (shi->mat->mode & MA_TRANSP) && (shi->mat->mode & MA_ZTRANSP));
Isect is;
@@ -758,7 +753,7 @@ void shade_volume_shadow(struct ShadeInput *shi, struct ShadeResult *shr, struct
float hitco[3];
float tr[3] = {1.0, 1.0, 1.0};
Isect is = {{0}};
- float *startco, *endco;
+ const float *startco, *endco;
memset(shr, 0, sizeof(ShadeResult));
diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c
index 24e32817a97..50b5e392b3f 100644
--- a/source/blender/render/intern/source/voxeldata.c
+++ b/source/blender/render/intern/source/voxeldata.c
@@ -154,7 +154,7 @@ static void load_frame_image_sequence(VoxelData *vd, Tex *tex)
ImageUser *tiuser = &tex->iuser;
ImageUser iuser = *(tiuser);
int x = 0, y = 0, z = 0;
- float *rf;
+ const float *rf;
if (!ima) return;
if (iuser.frames == 0) return;
diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c
index d50d53b5f53..28849ed7686 100644
--- a/source/blender/render/intern/source/zbuf.c
+++ b/source/blender/render/intern/source/zbuf.c
@@ -49,7 +49,6 @@
#include "MEM_guardedalloc.h"
#include "DNA_lamp_types.h"
-#include "DNA_mesh_types.h"
#include "DNA_node_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_material_types.h"
@@ -313,7 +312,7 @@ static void zbuffillAc4(ZSpan *zspan, int obi, int zvlnr,
double zxd, zyd, zy0, zverg;
float x0, y0, z0;
float x1, y1, z1, x2, y2, z2, xx1;
- float *span1, *span2;
+ const float *span1, *span2;
int *rz, *rm, x, y;
int sn1, sn2, rectx, *rectzofs, *rectmaskofs, my0, my2, mask;
@@ -436,7 +435,7 @@ static void zbuffillAc4(ZSpan *zspan, int obi, int zvlnr,
static void zbuflineAc(ZSpan *zspan, int obi, int zvlnr, const float vec1[3], const float vec2[3])
{
APixstr *ap, *apn;
- int *rectz, *rectmask;
+ const int *rectz, *rectmask;
int start, end, x, y, oldx, oldy, ofs;
int dz, vergz, mask, maxtest=0;
float dx, dy;
@@ -1053,10 +1052,10 @@ static void zbuffillGLinv4(ZSpan *zspan, int obi, int zvlnr,
double zxd, zyd, zy0, zverg;
float x0, y0, z0;
float x1, y1, z1, x2, y2, z2, xx1;
- float *span1, *span2;
+ const float *span1, *span2;
int *rectoofs, *ro;
int *rectpofs, *rp;
- int *rectmaskofs, *rm;
+ const int *rectmaskofs, *rm;
int *rz, x, y;
int sn1, sn2, rectx, *rectzofs, my0, my2;
@@ -1176,10 +1175,10 @@ static void zbuffillGL4(ZSpan *zspan, int obi, int zvlnr,
double zxd, zyd, zy0, zverg;
float x0, y0, z0;
float x1, y1, z1, x2, y2, z2, xx1;
- float *span1, *span2;
+ const float *span1, *span2;
int *rectoofs, *ro;
int *rectpofs, *rp;
- int *rectmaskofs, *rm;
+ const int *rectmaskofs, *rm;
int *rz, x, y;
int sn1, sn2, rectx, *rectzofs, my0, my2;
@@ -1307,7 +1306,7 @@ static void zbuffillGL_onlyZ(ZSpan *zspan, int UNUSED(obi), int UNUSED(zvlnr),
double zxd, zyd, zy0, zverg;
float x0, y0, z0;
float x1, y1, z1, x2, y2, z2, xx1;
- float *span1, *span2;
+ const float *span1, *span2;
int *rz, *rz1, x, y;
int sn1, sn2, rectx, *rectzofs, *rectzofs1= NULL, my0, my2;
@@ -1415,7 +1414,7 @@ void zspan_scanconvert_strand(ZSpan *zspan, void *handle, float *v1, float *v2,
{
float x0, y0, x1, y1, x2, y2, z0, z1, z2, z;
float u, v, uxd, uyd, vxd, vyd, uy0, vy0, zxd, zyd, zy0, xx1;
- float *span1, *span2;
+ const float *span1, *span2;
int x, y, sn1, sn2, rectx= zspan->rectx, my0, my2;
/* init */
@@ -1515,7 +1514,7 @@ void zspan_scanconvert(ZSpan *zspan, void *handle, float *v1, float *v2, float *
{
float x0, y0, x1, y1, x2, y2, z0, z1, z2;
float u, v, uxd, uyd, vxd, vyd, uy0, vy0, xx1;
- float *span1, *span2;
+ const float *span1, *span2;
int x, y, sn1, sn2, rectx= zspan->rectx, my0, my2;
/* init */
@@ -1831,7 +1830,9 @@ void zbuf_render_project(float winmat[4][4], const float co[3], float ho[4])
void zbuf_make_winmat(Render *re, float winmat[4][4])
{
if (re->r.mode & R_PANORAMA) {
- float panomat[4][4]= MAT4_UNITY;
+ float panomat[4][4];
+
+ unit_m4(panomat);
panomat[0][0]= re->panoco;
panomat[0][2]= re->panosi;
@@ -2367,7 +2368,7 @@ void zbuffer_shadow(Render *re, float winmat[4][4], LampRen *lar, int *rectz, in
if (vlr->mat!= ma) {
ma= vlr->mat;
ok= 1;
- if ((ma->mode & MA_SHADBUF)==0) ok= 0;
+ if ((ma->mode2 & MA_CASTSHADOW)==0 || (ma->mode & MA_SHADBUF)==0) ok= 0;
}
if (ok && (obi->lay & lay) && !(vlr->flag & R_HIDDEN)) {
@@ -2420,7 +2421,7 @@ void zbuffer_shadow(Render *re, float winmat[4][4], LampRen *lar, int *rectz, in
if (sseg.buffer->ma!= ma) {
ma= sseg.buffer->ma;
ok= 1;
- if ((ma->mode & MA_SHADBUF)==0) ok= 0;
+ if ((ma->mode2 & MA_CASTSHADOW)==0 || (ma->mode & MA_SHADBUF)==0) ok= 0;
}
if (ok && (sseg.buffer->lay & lay)) {
@@ -2658,7 +2659,7 @@ void zbuffer_sss(RenderPart *pa, unsigned int lay, void *handle, void (*func)(vo
/* ******************** VECBLUR ACCUM BUF ************************* */
typedef struct DrawBufPixel {
- float *colpoin;
+ const float *colpoin;
float alpha;
} DrawBufPixel;
@@ -2669,7 +2670,7 @@ static void zbuf_fill_in_rgba(ZSpan *zspan, DrawBufPixel *col, float *v1, float
double zxd, zyd, zy0, zverg;
float x0, y0, z0;
float x1, y1, z1, x2, y2, z2, xx1;
- float *span1, *span2;
+ const float *span1, *span2;
float *rectzofs, *rz;
int x, y;
int sn1, sn2, rectx, my0, my2;
@@ -3348,7 +3349,7 @@ static int zbuffer_abuf(Render *re, RenderPart *pa, APixstr *APixbuf, ListBase *
if (vlr->mat!=ma) {
ma= vlr->mat;
if (shadow)
- dofill= (ma->mode & MA_SHADBUF);
+ dofill= (ma->mode2 & MA_CASTSHADOW) && (ma->mode & MA_SHADBUF);
else
dofill= (((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP)) && !(ma->mode & MA_ONLYCAST));
}
@@ -3615,7 +3616,7 @@ static void merge_transp_passes(RenderLayer *rl, ShadeResult *shr)
for (samp= 1; samp<R.osa; samp++, shr_t++) {
if (shr_t->combined[3] > 0.0f) {
- float *speed= shr_t->winspeed;
+ const float *speed= shr_t->winspeed;
if ( (ABS(speed[0]) + ABS(speed[1]))< (ABS(fp[0]) + ABS(fp[1])) ) {
fp[0]= speed[0];
@@ -3631,7 +3632,7 @@ static void merge_transp_passes(RenderLayer *rl, ShadeResult *shr)
break;
}
if (col) {
- float *fp= col+delta;
+ const float *fp= col+delta;
int samp;
for (samp= 1; samp<R.osa; samp++, fp+=delta) {
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 661e940facb..64cada9f005 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -252,6 +252,7 @@ void WM_operator_properties_free(struct PointerRNA *ptr);
void WM_operator_properties_filesel(struct wmOperatorType *ot, int filter, short type, short action, short flag, short display);
void WM_operator_properties_border(struct wmOperatorType *ot);
void WM_operator_properties_border_to_rcti(struct wmOperator *op, struct rcti *rect);
+void WM_operator_properties_border_to_rctf(struct wmOperator *op, rctf *rect);
void WM_operator_properties_gesture_border(struct wmOperatorType *ot, bool extend);
void WM_operator_properties_mouse_select(struct wmOperatorType *ot);
void WM_operator_properties_gesture_straightline(struct wmOperatorType *ot, int cursor);
@@ -377,6 +378,7 @@ enum {
WM_JOB_TYPE_OBJECT_SIM_OCEAN,
WM_JOB_TYPE_OBJECT_SIM_FLUID,
WM_JOB_TYPE_OBJECT_BAKE_TEXTURE,
+ WM_JOB_TYPE_OBJECT_BAKE,
WM_JOB_TYPE_FILESEL_THUMBNAIL,
WM_JOB_TYPE_CLIP_BUILD_PROXY,
WM_JOB_TYPE_CLIP_TRACK_MARKERS,
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index 3c7a7676a63..28bddb47778 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -47,7 +47,6 @@
#include "BLI_blenlib.h"
#include "BLI_ghash.h"
-#include "BKE_blender.h"
#include "BKE_context.h"
#include "BKE_idprop.h"
#include "BKE_library.h"
diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c
index 01cd1514a3a..6fd3b426142 100644
--- a/source/blender/windowmanager/intern/wm_cursors.c
+++ b/source/blender/windowmanager/intern/wm_cursors.c
@@ -277,7 +277,7 @@ int wm_cursor_arrow_move(wmWindow *win, wmEvent *event)
void WM_cursor_time(wmWindow *win, int nr)
{
/* 10 8x8 digits */
- static char number_bitmaps[10][8] = {
+ const char number_bitmaps[10][8] = {
{0, 56, 68, 68, 68, 68, 68, 56},
{0, 24, 16, 16, 16, 16, 16, 56},
{0, 60, 66, 32, 16, 8, 4, 126},
@@ -300,7 +300,7 @@ void WM_cursor_time(wmWindow *win, int nr)
/* print number bottom right justified */
for (idx = 3; nr && idx >= 0; idx--) {
- char *digit = number_bitmaps[nr % 10];
+ const char *digit = number_bitmaps[nr % 10];
int x = idx % 2;
int y = idx / 2;
diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c
index 7675d4d4418..2aa177602cb 100644
--- a/source/blender/windowmanager/intern/wm_dragdrop.c
+++ b/source/blender/windowmanager/intern/wm_dragdrop.c
@@ -44,13 +44,8 @@
#include "BIF_gl.h"
#include "BIF_glutil.h"
-#include "BKE_blender.h"
#include "BKE_context.h"
-#include "BKE_idprop.h"
-#include "BKE_library.h"
-#include "BKE_main.h"
#include "BKE_screen.h"
-#include "BKE_global.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index e3a67c3824e..96824eca578 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -49,8 +49,6 @@
#include "BIF_gl.h"
#include "BKE_context.h"
-#include "BKE_global.h"
-#include "BKE_screen.h"
#include "GHOST_C-api.h"
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 9d04beac5ee..55f18661712 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -51,7 +51,6 @@
#include "BLI_utildefines.h"
#include "BLI_math.h"
-#include "BKE_blender.h"
#include "BKE_context.h"
#include "BKE_idprop.h"
#include "BKE_global.h"
@@ -64,7 +63,6 @@
#include "ED_fileselect.h"
#include "ED_info.h"
-#include "ED_render.h"
#include "ED_screen.h"
#include "ED_view3d.h"
#include "ED_util.h"
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 553f9a6318f..1ec2e6a3ee0 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -62,7 +62,6 @@
#include "BLF_translation.h"
-#include "DNA_anim_types.h"
#include "DNA_object_types.h"
#include "DNA_space_types.h"
#include "DNA_userdef_types.h"
@@ -75,18 +74,12 @@
#include "BKE_blender.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
-#include "BKE_DerivedMesh.h"
-#include "BKE_font.h"
#include "BKE_global.h"
-#include "BKE_library.h"
#include "BKE_main.h"
-#include "BKE_multires.h"
#include "BKE_packedFile.h"
#include "BKE_report.h"
#include "BKE_sound.h"
#include "BKE_screen.h"
-#include "BKE_texture.h"
-
#include "BLO_readfile.h"
#include "BLO_writefile.h"
@@ -99,9 +92,7 @@
#include "ED_datafiles.h"
#include "ED_fileselect.h"
-#include "ED_object.h"
#include "ED_screen.h"
-#include "ED_sculpt.h"
#include "ED_view3d.h"
#include "ED_util.h"
@@ -612,7 +603,7 @@ int wm_homefile_read(bContext *C, ReportList *reports, bool from_memory, const c
/* check new prefs only after startup.blend was finished */
if (!from_memory && BLI_exists(prefstr)) {
int done = BKE_read_file_userdef(prefstr, NULL);
- if (done) {
+ if (done != BKE_READ_FILE_FAIL) {
read_userdef_from_memory = false;
printf("Read new prefs: %s\n", prefstr);
}
@@ -708,7 +699,7 @@ void wm_read_history(void)
char name[FILE_MAX];
LinkNode *l, *lines;
struct RecentFile *recent;
- char *line;
+ const char *line;
int num;
const char * const cfgdir = BLI_get_folder(BLENDER_USER_CONFIG, NULL);
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index 9a00e709d85..c9ef473a442 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -247,7 +247,7 @@ static void draw_filled_lasso_px_cb(int x, int y, void *user_data)
static void draw_filled_lasso(wmWindow *win, wmGesture *gt)
{
- short *lasso = (short *)gt->customdata;
+ const short *lasso = (short *)gt->customdata;
const int tot = gt->points;
int (*moves)[2] = MEM_mallocN(sizeof(*moves) * (tot + 1), __func__);
int i;
@@ -295,7 +295,7 @@ static void draw_filled_lasso(wmWindow *win, wmGesture *gt)
static void wm_gesture_draw_lasso(wmWindow *win, wmGesture *gt, bool filled)
{
- short *lasso = (short *)gt->customdata;
+ const short *lasso = (short *)gt->customdata;
int i;
if (filled) {
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index d4a23dcc8b6..5dafadc5a47 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -39,12 +39,10 @@
#endif
#include "MEM_guardedalloc.h"
-#include "MEM_CacheLimiterC-Api.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
-#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_userdef_types.h"
#include "DNA_windowmanager_types.h"
@@ -59,10 +57,7 @@
#include "BKE_blender.h"
#include "BKE_context.h"
#include "BKE_screen.h"
-#include "BKE_curve.h"
-#include "BKE_displist.h"
#include "BKE_DerivedMesh.h"
-#include "BKE_font.h"
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_main.h"
@@ -71,7 +66,6 @@
#include "BKE_report.h"
#include "BKE_addon.h"
-#include "BKE_packedFile.h"
#include "BKE_sequencer.h" /* free seq clipboard */
#include "BKE_material.h" /* clear_matcopybuf */
#include "BKE_tracking.h" /* free tracking clipboard */
diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c
index 7c0d7bf3606..74c504050ae 100644
--- a/source/blender/windowmanager/intern/wm_jobs.c
+++ b/source/blender/windowmanager/intern/wm_jobs.c
@@ -40,13 +40,8 @@
#include "BLI_threads.h"
#include "BLI_utildefines.h"
-#include "BKE_blender.h"
#include "BKE_context.h"
-#include "BKE_idprop.h"
#include "BKE_global.h"
-#include "BKE_library.h"
-#include "BKE_main.h"
-#include "BKE_report.h"
#include "WM_api.h"
#include "WM_types.h"
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index c0326e3582b..0163517545f 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -43,11 +43,9 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
-#include "BKE_blender.h"
#include "BKE_context.h"
#include "BKE_idprop.h"
#include "BKE_global.h"
-#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_screen.h"
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 4ff987d1094..a73532680c5 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -91,7 +91,6 @@
#include "ED_screen.h"
#include "ED_util.h"
-#include "ED_object.h"
#include "ED_view3d.h"
#include "RNA_access.h"
@@ -340,7 +339,7 @@ static int wm_macro_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
- WM_cursor_grab_enable(CTX_wm_window(C), wrap, false, bounds);
+ WM_cursor_grab_enable(win, wrap, false, bounds);
}
}
}
@@ -497,7 +496,7 @@ bool WM_operatortype_remove(const char *idname)
/* SOME_OT_op -> some.op */
void WM_operator_py_idname(char *to, const char *from)
{
- char *sep = strstr(from, "_OT_");
+ const char *sep = strstr(from, "_OT_");
if (sep) {
int ofs = (sep - from);
@@ -519,7 +518,7 @@ void WM_operator_py_idname(char *to, const char *from)
void WM_operator_bl_idname(char *to, const char *from)
{
if (from) {
- char *sep = strchr(from, '.');
+ const char *sep = strchr(from, '.');
if (sep) {
int ofs = (sep - from);
@@ -1294,6 +1293,13 @@ void WM_operator_properties_border_to_rcti(struct wmOperator *op, rcti *rect)
rect->ymax = RNA_int_get(op->ptr, "ymax");
}
+void WM_operator_properties_border_to_rctf(struct wmOperator *op, rctf *rect)
+{
+ rcti rect_i;
+ WM_operator_properties_border_to_rcti(op, &rect_i);
+ BLI_rctf_rcti_copy(rect, &rect_i);
+}
+
void WM_operator_properties_gesture_border(wmOperatorType *ot, bool extend)
{
RNA_def_int(ot->srna, "gesture_mode", 0, INT_MIN, INT_MAX, "Gesture Mode", "", INT_MIN, INT_MAX);
@@ -1582,6 +1588,14 @@ static int wm_operator_props_popup_ex(bContext *C, wmOperator *op,
return OPERATOR_CANCELLED;
}
+ if (do_redo) {
+ if ((op->type->flag & OPTYPE_UNDO) == 0) {
+ BKE_reportf(op->reports, RPT_ERROR,
+ "Operator '%s' does not have undo enabled, incorrect invoke function", op->type->idname);
+ return OPERATOR_CANCELLED;
+ }
+ }
+
/* if we don't have global undo, we can't do undo push for automatic redo,
* so we require manual OK clicking in this popup */
if (!do_redo || !(U.uiflag & USER_GLOBALUNDO))
@@ -1756,11 +1770,10 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
uiBut *but;
uiLayout *layout, *split, *col;
uiStyle *style = UI_GetStyle();
- struct RecentFile *recent;
+ const struct RecentFile *recent;
int i;
MenuType *mt = WM_menutype_find("USERPREF_MT_splash", true);
char url[96];
- char file[FILE_MAX];
#ifndef WITH_HEADLESS
extern char datatoc_splash_png[];
@@ -1900,11 +1913,10 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
uiItemL(col, IFACE_("Recent"), ICON_NONE);
for (recent = G.recent_files.first, i = 0; (i < 5) && (recent); recent = recent->next, i++) {
- BLI_split_file_part(recent->filepath, file, sizeof(file));
- if (BLO_has_bfile_extension(file))
- uiItemStringO(col, BLI_path_basename(recent->filepath), ICON_FILE_BLEND, "WM_OT_open_mainfile", "filepath", recent->filepath);
- else
- uiItemStringO(col, BLI_path_basename(recent->filepath), ICON_FILE_BACKUP, "WM_OT_open_mainfile", "filepath", recent->filepath);
+ const char *filename = BLI_path_basename(recent->filepath);
+ uiItemStringO(col, filename,
+ BLO_has_bfile_extension(filename) ? ICON_FILE_BLEND : ICON_FILE_BACKUP,
+ "WM_OT_open_mainfile", "filepath", recent->filepath);
}
uiItemS(col);
@@ -2416,6 +2428,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Main *mainl = NULL;
BlendHandle *bh;
+ Library *lib;
PropertyRNA *prop;
char name[FILE_MAX], dir[FILE_MAX], libname[FILE_MAX], group[BLO_GROUP_MAX];
int idcode, totfiles = 0;
@@ -2490,6 +2503,9 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
/* here appending/linking starts */
mainl = BLO_library_append_begin(bmain, &bh, libname);
+ lib = mainl->curlib;
+ BLI_assert(lib);
+
if (totfiles == 0) {
BLO_library_append_named_part_ex(C, mainl, &bh, name, idcode, flag);
}
@@ -2509,9 +2525,8 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
/* append, rather than linking */
if ((flag & FILE_LINK) == 0) {
- Library *lib = BLI_findstring(&bmain->library, libname, offsetof(Library, filepath));
- if (lib) BKE_library_make_local(bmain, lib, true);
- else BLI_assert(!"cant find name of just added library!");
+ BLI_assert(BLI_findindex(&bmain->library, lib) != -1);
+ BKE_library_make_local(bmain, lib, true);
}
/* important we unset, otherwise these object wont
@@ -2553,7 +2568,7 @@ static void WM_OT_link_append(wmOperatorType *ot)
/* better not save _any_ settings for this operator */
/* properties */
prop = RNA_def_boolean(ot->srna, "link", 1, "Link", "Link the objects or datablocks rather than appending");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
prop = RNA_def_boolean(ot->srna, "autoselect", 1, "Select", "Select the linked objects");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna, "active_layer", 1, "Active Layer", "Put the linked objects on the active layer");
@@ -3326,7 +3341,7 @@ static void gesture_lasso_apply(bContext *C, wmOperator *op)
PointerRNA itemptr;
float loc[2];
int i;
- short *lasso = gesture->customdata;
+ const short *lasso = gesture->customdata;
/* operator storage as path. */
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index 16c424f4aec..b7452206b27 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -53,15 +53,12 @@
#include "BLI_fileops.h"
#include "BLI_listbase.h"
#include "BLI_path_util.h"
-#include "BLI_rect.h"
#include "BLI_string.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
-#include "BKE_blender.h"
#include "BKE_depsgraph.h"
-#include "BKE_global.h"
#include "BKE_image.h"
#include "BIF_gl.h"
@@ -99,6 +96,8 @@ typedef struct PlayState {
bool wait2;
bool stopped;
bool go;
+ /* waiting for images to load */
+ bool loading;
int fstep;
@@ -206,7 +205,7 @@ typedef struct PlayAnimPict {
struct PlayAnimPict *next, *prev;
char *mem;
int size;
- char *name;
+ const char *name;
struct ImBuf *ibuf;
struct anim *anim;
int frame;
@@ -306,7 +305,7 @@ static void playanim_toscreen(PlayState *ps, PlayAnimPict *picture, struct ImBuf
GHOST_SwapWindowBuffers(g_WS.ghost_window);
}
-static void build_pict_list(PlayState *ps, char *first, int totframes, int fstep, int fontid)
+static void build_pict_list_ex(PlayState *ps, const char *first, int totframes, int fstep, int fontid)
{
char *mem, filepath[FILE_MAX];
// short val;
@@ -360,6 +359,7 @@ static void build_pict_list(PlayState *ps, char *first, int totframes, int fstep
*/
while (IMB_ispic(filepath) && totframes) {
+ bool hasevent;
size_t size;
int file;
@@ -434,21 +434,28 @@ static void build_pict_list(PlayState *ps, char *first, int totframes, int fstep
BLI_newname(filepath, +fstep);
-#if 0 // XXX25
- while (qtest()) {
- switch (qreadN(&val)) {
- case ESCKEY:
- if (val) return;
- break;
+ while ((hasevent = GHOST_ProcessEvents(g_WS.ghost_system, 0))) {
+ if (hasevent) {
+ GHOST_DispatchEvents(g_WS.ghost_system);
+ }
+ if (ps->loading == false) {
+ return;
}
}
-#endif
+
totframes--;
}
}
return;
}
+static void build_pict_list(PlayState *ps, const char *first, int totframes, int fstep, int fontid)
+{
+ ps->loading = true;
+ build_pict_list_ex(ps, first, totframes, fstep, fontid);
+ ps->loading = false;
+}
+
static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
{
PlayState *ps = (PlayState *)ps_void;
@@ -462,6 +469,32 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
/* convert ghost event into value keyboard or mouse */
val = ELEM(type, GHOST_kEventKeyDown, GHOST_kEventButtonDown);
+
+ /* first check if we're busy loading files */
+ if (ps->loading) {
+ switch (type) {
+ case GHOST_kEventKeyDown:
+ case GHOST_kEventKeyUp:
+ {
+ GHOST_TEventKeyData *key_data;
+
+ key_data = (GHOST_TEventKeyData *)GHOST_GetEventData(evt);
+ switch (key_data->key) {
+ case GHOST_kKeyEsc:
+ ps->loading = false;
+ break;
+ default:
+ break;
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ return 1;
+ }
+
+
if (ps->wait2 && ps->stopped) {
ps->stopped = false;
}
@@ -853,6 +886,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
ps.sstep = false;
ps.wait2 = false;
ps.stopped = false;
+ ps.loading = false;
ps.picture = NULL;
ps.dropped_file[0] = 0;
ps.zoom = 1.0f;
@@ -1223,7 +1257,7 @@ void WM_main_playanim(int argc, const char **argv)
bool looping = true;
while (looping) {
- char *filepath = wm_main_playanim_intern(argc, argv);
+ const char *filepath = wm_main_playanim_intern(argc, argv);
if (filepath) { /* use simple args */
argv[1] = "-a";
diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c
index ecf22fea454..1792ea40a1a 100644
--- a/source/blender/windowmanager/intern/wm_subwindow.c
+++ b/source/blender/windowmanager/intern/wm_subwindow.c
@@ -45,9 +45,7 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
-
#include "BKE_context.h"
-#include "BKE_global.h"
#include "BIF_gl.h"
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 1bd9f15ba66..44e31f46167 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -375,7 +375,8 @@ static void wm_window_add_ghostwindow(const char *title, wmWindow *win)
#ifdef __APPLE__
/* set the state here, else OSX would not recognize changed screen resolution */
- GHOST_SetWindowState(ghostwin, (GHOST_TWindowState)win->windowstate);
+ /* we agreed to not set any fullscreen or iconized state on startup */
+ GHOST_SetWindowState(ghostwin, GHOST_kWindowStateNormal);
#endif
/* store actual window size in blender window */
bounds = GHOST_GetClientBounds(win->ghostwin);
@@ -830,7 +831,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
/* stop screencast if resize */
if (type == GHOST_kEventWindowSize) {
- WM_jobs_stop(CTX_wm_manager(C), win->screen, NULL);
+ WM_jobs_stop(wm, win->screen, NULL);
}
/* win32: gives undefined window size when minimized */
@@ -917,7 +918,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
{
PointerRNA props_ptr;
wmWindow *oldWindow;
- char *path = GHOST_GetEventData(evt);
+ const char *path = GHOST_GetEventData(evt);
if (path) {
/* operator needs a valid window in context, ensures
diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c
index 2c3e4677837..af6541e9008 100644
--- a/source/blenderplayer/bad_level_call_stubs/stubs.c
+++ b/source/blenderplayer/bad_level_call_stubs/stubs.c
@@ -226,6 +226,9 @@ void RE_zbuf_accumulate_vecblur(struct NodeBlurData *nbd, int xsize, int ysize,
/* imagetexture.c stub */
void ibuf_sample(struct ImBuf *ibuf, float fx, float fy, float dx, float dy, float *result) RET_NONE
+/* Freestyle */
+bool ED_texture_context_check_linestyle(const struct bContext *C) RET_ZERO
+
/* texture.c */
int multitex_ext(struct Tex *tex, float texvec[3], float dxt[3], float dyt[3], int osatex, struct TexResult *texres, struct ImagePool *pool, bool scene_color_manage) RET_ZERO
int multitex_ext_safe(struct Tex *tex, float texvec[3], struct TexResult *texres, struct ImagePool *pool, bool scene_color_manage) RET_ZERO
@@ -300,6 +303,7 @@ void WM_event_remove_timer(struct wmWindowManager *wm, struct wmWindow *win, str
void ED_armature_edit_bone_remove(struct bArmature *arm, struct EditBone *exBone) RET_NONE
void object_test_constraints(struct Object *owner) RET_NONE
void ED_armature_ebone_to_mat4(struct EditBone *ebone, float mat[4][4]) RET_NONE
+void ED_armature_ebone_from_mat4(EditBone *ebone, float mat[4][4]) RET_NONE
void ED_object_parent(struct Object *ob, struct Object *par, int type, const char *substr) RET_NONE
void ED_object_constraint_set_active(struct Object *ob, struct bConstraint *con) RET_NONE
void ED_node_composit_default(const struct bContext *C, struct Scene *scene) RET_NONE
@@ -308,8 +312,9 @@ void *ED_region_draw_cb_customdata(void *handle) RET_ZERO /* XXX This one looks
void ED_region_draw_cb_exit(struct ARegionType *art, void *handle) RET_NONE
void ED_area_headerprint(struct ScrArea *sa, const char *str) RET_NONE
void UI_view2d_region_to_view(struct View2D *v2d, float x, float y, float *viewx, float *viewy) RET_NONE
-void UI_view2d_view_to_region(struct View2D *v2d, float x, float y, int *regionx, int *regiony) RET_NONE
-void UI_view2d_to_region_no_clip(struct View2D *v2d, float x, float y, int *regionx, int *region_y) RET_NONE
+bool UI_view2d_view_to_region_clip(struct View2D *v2d, float x, float y, int *regionx, int *regiony) RET_ZERO
+void UI_view2d_view_to_region(struct View2D *v2d, float x, float y, int *regionx, int *region_y) RET_NONE
+void UI_view2d_sync(struct bScreen *screen, struct ScrArea *sa, struct View2D *v2dcur, int flag) RET_NONE
struct EditBone *ED_armature_bone_get_mirrored(const struct ListBase *edbo, EditBone *ebo) RET_NULL
struct EditBone *ED_armature_edit_bone_add(struct bArmature *arm, const char *name) RET_NULL
diff --git a/source/creator/creator.c b/source/creator/creator.c
index de320386bf8..0dad2fd6b75 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -89,7 +89,6 @@
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_modifier.h"
-#include "BKE_packedFile.h"
#include "BKE_scene.h"
#include "BKE_node.h"
#include "BKE_report.h"
diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp
index a28906254a1..3dd013dfd63 100644
--- a/source/gameengine/Converter/BL_ActionActuator.cpp
+++ b/source/gameengine/Converter/BL_ActionActuator.cpp
@@ -35,6 +35,7 @@
#include "BL_ArmatureObject.h"
#include "BL_SkinDeformer.h"
#include "BL_Action.h"
+#include "BL_ActionManager.h"
#include "KX_GameObject.h"
#include "STR_HashedString.h"
#include "MEM_guardedalloc.h"
@@ -93,9 +94,6 @@ BL_ActionActuator::BL_ActionActuator(SCA_IObject *gameobj,
m_priority(priority),
m_layer(layer),
m_ipo_flags(ipo_flags),
- m_pose(NULL),
- m_blendpose(NULL),
- m_userpose(NULL),
m_action(action),
m_propname(propname),
m_framepropname(framepropname)
@@ -106,20 +104,12 @@ BL_ActionActuator::BL_ActionActuator(SCA_IObject *gameobj,
BL_ActionActuator::~BL_ActionActuator()
{
- if (m_pose)
- game_free_pose(m_pose);
- if (m_userpose)
- game_free_pose(m_userpose);
- if (m_blendpose)
- game_free_pose(m_blendpose);
}
void BL_ActionActuator::ProcessReplica()
{
SCA_IActuator::ProcessReplica();
-
- m_pose = NULL;
- m_blendpose = NULL;
+
m_localtime=m_startframe;
m_lastUpdate=-1;
@@ -270,7 +260,8 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
if (m_playtype == ACT_ACTION_PINGPONG)
m_flag ^= ACT_FLAG_REVERSE;
- return false;
+ else
+ return false;
}
// If a different action is playing, we've been overruled and are no longer active
@@ -546,7 +537,7 @@ PyAttributeDef BL_ActionActuator::Attributes[] = {
KX_PYATTRIBUTE_RW_FUNCTION("action", BL_ActionActuator, pyattr_get_action, pyattr_set_action),
KX_PYATTRIBUTE_RO_FUNCTION("channelNames", BL_ActionActuator, pyattr_get_channel_names),
KX_PYATTRIBUTE_SHORT_RW("priority", 0, 100, false, BL_ActionActuator, m_priority),
- KX_PYATTRIBUTE_SHORT_RW("layer", 0, 7, true, BL_ActionActuator, m_layer),
+ KX_PYATTRIBUTE_SHORT_RW("layer", 0, MAX_ACTION_LAYERS-1, true, BL_ActionActuator, m_layer),
KX_PYATTRIBUTE_FLOAT_RW("layerWeight", 0, 1.0, BL_ActionActuator, m_layer_weight),
KX_PYATTRIBUTE_RW_FUNCTION("frame", BL_ActionActuator, pyattr_get_frame, pyattr_set_frame),
KX_PYATTRIBUTE_STRING_RW("propName", 0, MAX_PROP_NAME, false, BL_ActionActuator, m_propname),
diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h
index 4579a21f554..f488b0c76a6 100644
--- a/source/gameengine/Converter/BL_ActionActuator.h
+++ b/source/gameengine/Converter/BL_ActionActuator.h
@@ -134,9 +134,6 @@ protected:
short m_priority;
short m_layer;
short m_ipo_flags;
- struct bPose* m_pose;
- struct bPose* m_blendpose;
- struct bPose* m_userpose;
struct bAction *m_action;
STR_String m_propname;
STR_String m_framepropname;
diff --git a/source/gameengine/Converter/BL_ArmatureActuator.cpp b/source/gameengine/Converter/BL_ArmatureActuator.cpp
index f0c4b3d32bb..e38cb6eadaf 100644
--- a/source/gameengine/Converter/BL_ArmatureActuator.cpp
+++ b/source/gameengine/Converter/BL_ArmatureActuator.cpp
@@ -155,7 +155,7 @@ bool BL_ArmatureActuator::Update(double curtime, bool frame)
switch (m_type) {
case ACT_ARM_RUN:
result = true;
- obj->SetActiveAction(NULL, 0, curtime);
+ obj->UpdateTimestep(curtime);
break;
case ACT_ARM_ENABLE:
if (m_constraint)
diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp
index 619797a8c69..0392280444d 100644
--- a/source/gameengine/Converter/BL_ArmatureObject.cpp
+++ b/source/gameengine/Converter/BL_ArmatureObject.cpp
@@ -42,7 +42,13 @@
#include "BIK_api.h"
#include "BKE_action.h"
#include "BKE_armature.h"
+#include "BKE_object.h"
#include "BKE_library.h"
+#include "BKE_global.h"
+
+extern "C" {
+#include "BKE_animsys.h"
+}
#include "BKE_constraint.h"
#include "CTR_Map.h"
@@ -53,6 +59,7 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_constraint_types.h"
+#include "RNA_access.h"
#include "KX_PythonSeq.h"
#include "KX_PythonInit.h"
#include "KX_KetsjiEngine.h"
@@ -70,7 +77,7 @@
* When it is about to evaluate the pose, set the KX object position in the obmat of the corresponding
* Blender objects and restore after the evaluation.
*/
-void game_copy_pose(bPose **dst, bPose *src, int copy_constraint)
+static void game_copy_pose(bPose **dst, bPose *src, int copy_constraint)
{
bPose *out;
bPoseChannel *pchan, *outpchan;
@@ -85,7 +92,7 @@ void game_copy_pose(bPose **dst, bPose *src, int copy_constraint)
return;
}
else if (*dst==src) {
- printf("BKE_pose_copy_data source and target are the same\n");
+ printf("game_copy_pose source and target are the same\n");
*dst=NULL;
return;
}
@@ -113,8 +120,8 @@ void game_copy_pose(bPose **dst, bPose *src, int copy_constraint)
if (copy_constraint) {
ListBase listb;
// copy all constraint for backward compatibility
- // BKE_copy_constraints NULLs listb, no need to make extern for this operation.
- BKE_copy_constraints(&listb, &pchan->constraints, false);
+ // BKE_constraints_copy NULLs listb, no need to make extern for this operation.
+ BKE_constraints_copy(&listb, &pchan->constraints, false);
pchan->constraints= listb;
}
else {
@@ -142,7 +149,7 @@ void game_copy_pose(bPose **dst, bPose *src, int copy_constraint)
/* Only allowed for Poses with identical channels */
-void game_blend_poses(bPose *dst, bPose *src, float srcweight, short mode)
+static void game_blend_poses(bPose *dst, bPose *src, float srcweight, short mode)
{
bPoseChannel *dchan;
const bPoseChannel *schan;
@@ -202,23 +209,6 @@ void game_blend_poses(bPose *dst, bPose *src, float srcweight, short mode)
dst->ctime= src->ctime;
}
-void game_free_pose(bPose *pose)
-{
- if (pose) {
- /* free pose-channels and constraints */
- BKE_pose_channels_free(pose);
-
- /* free IK solver state */
- BIK_clear_data(pose);
-
- /* free IK solver param */
- if (pose->ikparam)
- MEM_freeN(pose->ikparam);
-
- MEM_freeN(pose);
- }
-}
-
BL_ArmatureObject::BL_ArmatureObject(
void* sgReplicationInfo,
SG_Callbacks callbacks,
@@ -229,26 +219,18 @@ BL_ArmatureObject::BL_ArmatureObject(
: KX_GameObject(sgReplicationInfo,callbacks),
m_controlledConstraints(),
m_poseChannels(),
- m_objArma(armature),
- m_framePose(NULL),
m_scene(scene), // maybe remove later. needed for BKE_pose_where_is
m_lastframe(0.0),
m_timestep(0.040),
- m_activeAct(NULL),
- m_activePriority(999),
m_vert_deform_type(vert_deform_type),
m_constraintNumber(0),
m_channelNumber(0),
m_lastapplyframe(0.0)
{
- m_armature = (bArmature *)armature->data;
-
- /* we make a copy of blender object's pose, and then always swap it with
- * the original pose before calling into blender functions, to deal with
- * replica's or other objects using the same blender object */
- m_pose = NULL;
- game_copy_pose(&m_pose, m_objArma->pose, 1);
- // store the original armature object matrix
+ m_origObjArma = armature; // Keep a copy of the original armature so we can fix drivers later
+ m_objArma = BKE_object_copy(armature);
+ m_objArma->data = BKE_armature_copy((bArmature *)armature->data);
+ m_pose = m_objArma->pose;
memcpy(m_obmat, m_objArma->obmat, sizeof(m_obmat));
}
@@ -262,10 +244,9 @@ BL_ArmatureObject::~BL_ArmatureObject()
while ((channel = static_cast<BL_ArmatureChannel*>(m_poseChannels.Remove())) != NULL) {
delete channel;
}
- if (m_pose)
- game_free_pose(m_pose);
- if (m_framePose)
- game_free_pose(m_framePose);
+
+ if (m_objArma)
+ BKE_libblock_free(G.main, m_objArma);
}
@@ -307,7 +288,7 @@ void BL_ArmatureObject::LoadConstraints(KX_BlenderSceneConverter* converter)
case CONSTRAINT_TYPE_TRANSFORM:
case CONSTRAINT_TYPE_DISTLIMIT:
case CONSTRAINT_TYPE_TRANSLIKE:
- cti = BKE_constraint_get_typeinfo(pcon);
+ cti = BKE_constraint_typeinfo_get(pcon);
gametarget = gamesubtarget = NULL;
if (cti && cti->get_constraint_targets) {
ListBase listb = { NULL, NULL };
@@ -431,12 +412,12 @@ CValue* BL_ArmatureObject::GetReplica()
void BL_ArmatureObject::ProcessReplica()
{
- bPose *pose= m_pose;
KX_GameObject::ProcessReplica();
- m_pose = NULL;
- m_framePose = NULL;
- game_copy_pose(&m_pose, pose, 1);
+ bArmature* tmp = (bArmature*)m_objArma->data;
+ m_objArma = BKE_object_copy(m_objArma);
+ m_objArma->data = BKE_armature_copy(tmp);
+ m_pose = m_objArma->pose;
}
void BL_ArmatureObject::ReParentLogic()
@@ -506,48 +487,32 @@ void BL_ArmatureObject::SetPose(bPose *pose)
m_lastapplyframe = -1.0;
}
-bool BL_ArmatureObject::SetActiveAction(BL_ActionActuator *act, short priority, double curtime)
+void BL_ArmatureObject::SetPoseByAction(bAction *action, float localtime)
+{
+ Object *arm = GetArmatureObject();
+
+ PointerRNA ptrrna;
+ RNA_id_pointer_create(&arm->id, &ptrrna);
+
+ animsys_evaluate_action(&ptrrna, action, NULL, localtime);
+}
+
+void BL_ArmatureObject::BlendInPose(bPose *blend_pose, float weight, short mode)
+{
+ game_blend_poses(m_pose, blend_pose, weight, mode);
+}
+
+bool BL_ArmatureObject::UpdateTimestep(double curtime)
{
if (curtime != m_lastframe) {
- m_activePriority = 9999;
// compute the timestep for the underlying IK algorithm
m_timestep = curtime-m_lastframe;
m_lastframe= curtime;
- m_activeAct = NULL;
- // remember the pose at the start of the frame
- GetPose(&m_framePose);
}
- if (act)
- {
- if (priority<=m_activePriority)
- {
- if (priority<m_activePriority) {
- // this action overwrites the previous ones, start from initial pose to cancel their effects
- SetPose(m_framePose);
- if (m_activeAct && (m_activeAct!=act))
- /* Reset the blend timer since this new action cancels the old one */
- m_activeAct->SetBlendTime(0.0);
- }
- m_activeAct = act;
- m_activePriority = priority;
- m_lastframe = curtime;
-
- return true;
- }
- else {
- act->SetBlendTime(0.0);
- return false;
- }
- }
return false;
}
-BL_ActionActuator * BL_ArmatureObject::GetActiveAction()
-{
- return m_activeAct;
-}
-
void BL_ArmatureObject::GetPose(bPose **pose)
{
/* If the caller supplies a null pose, create a new one. */
@@ -570,22 +535,6 @@ void BL_ArmatureObject::GetPose(bPose **pose)
}
}
-void BL_ArmatureObject::GetMRDPose(bPose **pose)
-{
- /* If the caller supplies a null pose, create a new one. */
- /* Otherwise, copy the armature's pose channels into the caller-supplied pose */
-
- if (!*pose)
- game_copy_pose(pose, m_pose, 0);
- else
- extract_pose_from_pose(*pose, m_pose);
-}
-
-short BL_ArmatureObject::GetActivePriority()
-{
- return m_activePriority;
-}
-
double BL_ArmatureObject::GetLastFrame()
{
return m_lastframe;
@@ -671,7 +620,7 @@ KX_PYMETHODDEF_DOC_NOARGS(BL_ArmatureObject, update,
"This is automatically done if a KX_ArmatureActuator with mode run is active\n"
"or if an action is playing. This function is useful in other cases.\n")
{
- SetActiveAction(NULL, 0, KX_GetActiveEngine()->GetFrameTime());
+ UpdateTimestep(KX_GetActiveEngine()->GetFrameTime());
Py_RETURN_NONE;
}
diff --git a/source/gameengine/Converter/BL_ArmatureObject.h b/source/gameengine/Converter/BL_ArmatureObject.h
index 81388355fc4..691e73d6bde 100644
--- a/source/gameengine/Converter/BL_ArmatureObject.h
+++ b/source/gameengine/Converter/BL_ArmatureObject.h
@@ -55,14 +55,11 @@ class BL_ArmatureObject : public KX_GameObject
public:
double GetLastFrame ();
- short GetActivePriority();
virtual void ProcessReplica();
virtual void ReParentLogic();
virtual void Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map);
virtual bool UnlinkObject(SCA_IObject* clientobj);
- class BL_ActionActuator * GetActiveAction();
-
BL_ArmatureObject(
void* sgReplicationInfo,
SG_Callbacks callbacks,
@@ -73,21 +70,23 @@ public:
virtual ~BL_ArmatureObject();
virtual CValue* GetReplica();
- void GetMRDPose(struct bPose **pose);
void GetPose(struct bPose **pose);
void SetPose (struct bPose *pose);
struct bPose *GetOrigPose() {return m_pose;} // never edit this, only for accessing names
void ApplyPose();
+ void SetPoseByAction(struct bAction* action, float localtime);
+ void BlendInPose(struct bPose *blend_pose, float weight, short mode);
void RestorePose();
- bool SetActiveAction(class BL_ActionActuator *act, short priority, double curtime);
+ bool UpdateTimestep(double curtime);
- struct bArmature *GetArmature() { return m_armature; }
- const struct bArmature * GetArmature() const { return m_armature; }
+ struct bArmature *GetArmature() { return (bArmature*)m_objArma->data; }
+ const struct bArmature * GetArmature() const { return (bArmature*)m_objArma->data; }
const struct Scene * GetScene() const { return m_scene; }
Object* GetArmatureObject() {return m_objArma;}
+ Object* GetOrigArmatureObject() {return m_origObjArma;}
int GetVertDeformType() {return m_vert_deform_type;}
@@ -128,15 +127,12 @@ protected:
/* list element: BL_ArmatureChannel. Use SG_DList to avoid list replication */
SG_DList m_poseChannels;
Object *m_objArma;
- struct bArmature *m_armature;
+ Object *m_origObjArma;
struct bPose *m_pose;
struct bPose *m_armpose;
- struct bPose *m_framePose;
struct Scene *m_scene; // need for BKE_pose_where_is
double m_lastframe;
double m_timestep; // delta since last pose evaluation.
- class BL_ActionActuator *m_activeAct;
- short m_activePriority;
int m_vert_deform_type;
size_t m_constraintNumber;
size_t m_channelNumber;
@@ -146,10 +142,4 @@ protected:
double m_lastapplyframe;
};
-/* Pose function specific to the game engine */
-void game_blend_poses(struct bPose *dst, struct bPose *src, float srcweight, short mode); /* was blend_poses */
-//void extract_pose_from_pose(struct bPose *pose, const struct bPose *src);
-void game_copy_pose(struct bPose **dst, struct bPose *src, int copy_con);
-void game_free_pose(struct bPose *pose);
-
#endif /* __BL_ARMATUREOBJECT_H__ */
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
index 4b55d73178c..e511f01e9c6 100644
--- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp
+++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
@@ -62,6 +62,8 @@
// Collision & Fuzzics LTD
#include "PHY_Pro.h"
+#include "PHY_IPhysicsEnvironment.h"
+#include "PHY_DynamicTypes.h"
#include "KX_Scene.h"
@@ -80,6 +82,7 @@
#include "SCA_TimeEventManager.h"
#include "KX_Light.h"
#include "KX_Camera.h"
+#include "KX_ClientObjectInfo.h"
#include "KX_EmptyObject.h"
#include "KX_FontObject.h"
#include "MT_Point3.h"
@@ -179,7 +182,6 @@ extern Material defmaterial; /* material.c */
#include "SG_BBox.h"
#include "SG_Tree.h"
-#include "KX_ConvertPhysicsObject.h"
#ifdef WITH_BULLET
#include "CcdPhysicsEnvironment.h"
#include "CcdGraphicController.h"
@@ -612,7 +614,7 @@ static bool ConvertMaterial(
material->ras_mode |= ( mat->game.flag & GEMAT_BACKCULL )?0:TWOSIDED;
// cast shadows?
- material->ras_mode |= ( mat->mode & MA_SHADBUF )?CAST_SHADOW:0;
+ material->ras_mode |= ( (mat->mode2 & MA_CASTSHADOW) && (mat->mode & MA_SHADBUF) )?CAST_SHADOW:0;
// only shadows?
material->ras_mode |= ( mat->mode & MA_ONLYCAST )?ONLY_SHADOW:0;
@@ -1312,121 +1314,6 @@ static float my_boundbox_mesh(Mesh *me, float *loc, float *size)
return sqrtf_signed(radius_sq);
}
-
-static void my_tex_space_mesh(Mesh *me)
-{
- KeyBlock *kb;
- float *fp, loc[3], size[3], min[3], max[3];
- int a;
-
- my_boundbox_mesh(me, loc, size);
-
- if (me->texflag & ME_AUTOSPACE) {
- if (me->key) {
- kb= me->key->refkey;
- if (kb) {
-
- INIT_MINMAX(min, max);
-
- fp= (float *)kb->data;
- for (a=0; a<kb->totelem; a++, fp += 3) {
- minmax_v3v3_v3(min, max, fp);
- }
- if (kb->totelem) {
- loc[0] = (min[0]+max[0])/2.0f; loc[1] = (min[1]+max[1])/2.0f; loc[2] = (min[2]+max[2])/2.0f;
- size[0] = (max[0]-min[0])/2.0f; size[1] = (max[1]-min[1])/2.0f; size[2] = (max[2]-min[2])/2.0f;
- }
- else {
- loc[0] = loc[1] = loc[2] = 0.0;
- size[0] = size[1] = size[2] = 0.0;
- }
-
- }
- }
-
- copy_v3_v3(me->loc, loc);
- copy_v3_v3(me->size, size);
- me->rot[0] = me->rot[1] = me->rot[2] = 0.0f;
-
- if (me->size[0] == 0.0f) me->size[0] = 1.0f;
- else if (me->size[0] > 0.0f && me->size[0]< 0.00001f) me->size[0] = 0.00001f;
- else if (me->size[0] < 0.0f && me->size[0]> -0.00001f) me->size[0] = -0.00001f;
-
- if (me->size[1] == 0.0f) me->size[1] = 1.0f;
- else if (me->size[1] > 0.0f && me->size[1]< 0.00001f) me->size[1] = 0.00001f;
- else if (me->size[1] < 0.0f && me->size[1]> -0.00001f) me->size[1] = -0.00001f;
-
- if (me->size[2] == 0.0f) me->size[2] = 1.0f;
- else if (me->size[2] > 0.0f && me->size[2]< 0.00001f) me->size[2] = 0.00001f;
- else if (me->size[2] < 0.0f && me->size[2]> -0.00001f) me->size[2] = -0.00001f;
- }
-
-}
-
-static void my_get_local_bounds(Object *ob, DerivedMesh *dm, float *center, float *size)
-{
- BoundBox *bb= NULL;
- /* uses boundbox, function used by Ketsji */
- switch (ob->type)
- {
- case OB_MESH:
- if (dm)
- {
- float min_r[3], max_r[3];
- INIT_MINMAX(min_r, max_r);
- dm->getMinMax(dm, min_r, max_r);
- size[0] = 0.5f * fabsf(max_r[0] - min_r[0]);
- size[1] = 0.5f * fabsf(max_r[1] - min_r[1]);
- size[2] = 0.5f * fabsf(max_r[2] - min_r[2]);
-
- center[0] = 0.5f * (max_r[0] + min_r[0]);
- center[1] = 0.5f * (max_r[1] + min_r[1]);
- center[2] = 0.5f * (max_r[2] + min_r[2]);
- return;
- } else
- {
- bb= ( (Mesh *)ob->data )->bb;
- if (bb==0)
- {
- my_tex_space_mesh((struct Mesh *)ob->data);
- bb= ( (Mesh *)ob->data )->bb;
- }
- }
- break;
- case OB_CURVE:
- case OB_SURF:
- center[0] = center[1] = center[2] = 0.0;
- size[0] = size[1]=size[2]=0.0;
- break;
- case OB_FONT:
- center[0] = center[1] = center[2] = 0.0;
- size[0] = size[1]=size[2]=1.0;
- break;
- case OB_MBALL:
- bb= ob->bb;
- break;
- }
-
- if (bb==NULL)
- {
- center[0] = center[1] = center[2] = 0.0;
- size[0] = size[1] = size[2] = 1.0;
- }
- else
- {
- size[0] = 0.5f * fabsf(bb->vec[0][0] - bb->vec[4][0]);
- size[1] = 0.5f * fabsf(bb->vec[0][1] - bb->vec[2][1]);
- size[2] = 0.5f * fabsf(bb->vec[0][2] - bb->vec[1][2]);
-
- center[0] = 0.5f * (bb->vec[0][0] + bb->vec[4][0]);
- center[1] = 0.5f * (bb->vec[0][1] + bb->vec[2][1]);
- center[2] = 0.5f * (bb->vec[0][2] + bb->vec[1][2]);
- }
-}
-
-
-
-
//////////////////////////////////////////////////////
@@ -1474,7 +1361,6 @@ static void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
RAS_MeshObject* meshobj,
KX_Scene* kxscene,
int activeLayerBitInfo,
- e_PhysicsEngine physics_engine,
KX_BlenderSceneConverter *converter,
bool processCompoundChildren
)
@@ -1524,237 +1410,35 @@ static void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
PHY_MaterialProps* smmaterial =
CreateMaterialFromBlenderObject(blenderobject);
-
- KX_ObjectProperties objprop;
- objprop.m_lockXaxis = (blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_X_AXIS) !=0;
- objprop.m_lockYaxis = (blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_Y_AXIS) !=0;
- objprop.m_lockZaxis = (blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_Z_AXIS) !=0;
- objprop.m_lockXRotaxis = (blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_X_ROT_AXIS) !=0;
- objprop.m_lockYRotaxis = (blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_Y_ROT_AXIS) !=0;
- objprop.m_lockZRotaxis = (blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_Z_ROT_AXIS) !=0;
-
- objprop.m_isCompoundChild = isCompoundChild;
- objprop.m_hasCompoundChildren = hasCompoundChildren;
- objprop.m_margin = blenderobject->margin;
-
- // ACTOR is now a separate feature
- objprop.m_isactor = (blenderobject->gameflag & OB_ACTOR)!=0;
- objprop.m_dyna = (blenderobject->gameflag & OB_DYNAMIC) != 0;
- objprop.m_softbody = (blenderobject->gameflag & OB_SOFT_BODY) != 0;
- objprop.m_angular_rigidbody = (blenderobject->gameflag & OB_RIGID_BODY) != 0;
- objprop.m_character = (blenderobject->gameflag & OB_CHARACTER) != 0;
- objprop.m_record_animation = (blenderobject->gameflag & OB_RECORD_ANIMATION) != 0;
-
- ///contact processing threshold is only for rigid bodies and static geometry, not 'dynamic'
- if (objprop.m_angular_rigidbody || !objprop.m_dyna )
- {
- objprop.m_contactProcessingThreshold = blenderobject->m_contactProcessingThreshold;
- } else
- {
- objprop.m_contactProcessingThreshold = 0.f;
- }
- objprop.m_sensor = (blenderobject->gameflag & OB_SENSOR) != 0;
-
- if (objprop.m_softbody)
- {
- ///for game soft bodies
- if (blenderobject->bsoft)
- {
- objprop.m_gamesoftFlag = blenderobject->bsoft->flag;
- ///////////////////
- objprop.m_soft_linStiff = blenderobject->bsoft->linStiff;
- objprop.m_soft_angStiff = blenderobject->bsoft->angStiff; /* angular stiffness 0..1 */
- objprop.m_soft_volume= blenderobject->bsoft->volume; /* volume preservation 0..1 */
-
- objprop.m_soft_viterations= blenderobject->bsoft->viterations; /* Velocities solver iterations */
- objprop.m_soft_piterations= blenderobject->bsoft->piterations; /* Positions solver iterations */
- objprop.m_soft_diterations= blenderobject->bsoft->diterations; /* Drift solver iterations */
- objprop.m_soft_citerations= blenderobject->bsoft->citerations; /* Cluster solver iterations */
-
- objprop.m_soft_kSRHR_CL= blenderobject->bsoft->kSRHR_CL; /* Soft vs rigid hardness [0,1] (cluster only) */
- objprop.m_soft_kSKHR_CL= blenderobject->bsoft->kSKHR_CL; /* Soft vs kinetic hardness [0,1] (cluster only) */
- objprop.m_soft_kSSHR_CL= blenderobject->bsoft->kSSHR_CL; /* Soft vs soft hardness [0,1] (cluster only) */
- objprop.m_soft_kSR_SPLT_CL= blenderobject->bsoft->kSR_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
-
- objprop.m_soft_kSK_SPLT_CL= blenderobject->bsoft->kSK_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
- objprop.m_soft_kSS_SPLT_CL= blenderobject->bsoft->kSS_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
- objprop.m_soft_kVCF= blenderobject->bsoft->kVCF; /* Velocities correction factor (Baumgarte) */
- objprop.m_soft_kDP= blenderobject->bsoft->kDP; /* Damping coefficient [0,1] */
-
- objprop.m_soft_kDG= blenderobject->bsoft->kDG; /* Drag coefficient [0,+inf] */
- objprop.m_soft_kLF= blenderobject->bsoft->kLF; /* Lift coefficient [0,+inf] */
- objprop.m_soft_kPR= blenderobject->bsoft->kPR; /* Pressure coefficient [-inf,+inf] */
- objprop.m_soft_kVC= blenderobject->bsoft->kVC; /* Volume conversation coefficient [0,+inf] */
-
- objprop.m_soft_kDF= blenderobject->bsoft->kDF; /* Dynamic friction coefficient [0,1] */
- objprop.m_soft_kMT= blenderobject->bsoft->kMT; /* Pose matching coefficient [0,1] */
- objprop.m_soft_kCHR= blenderobject->bsoft->kCHR; /* Rigid contacts hardness [0,1] */
- objprop.m_soft_kKHR= blenderobject->bsoft->kKHR; /* Kinetic contacts hardness [0,1] */
-
- objprop.m_soft_kSHR= blenderobject->bsoft->kSHR; /* Soft contacts hardness [0,1] */
- objprop.m_soft_kAHR= blenderobject->bsoft->kAHR; /* Anchors hardness [0,1] */
- objprop.m_soft_collisionflags= blenderobject->bsoft->collisionflags; /* Vertex/Face or Signed Distance Field(SDF) or Clusters, Soft versus Soft or Rigid */
- objprop.m_soft_numclusteriterations= blenderobject->bsoft->numclusteriterations; /* number of iterations to refine collision clusters*/
- //objprop.m_soft_welding = blenderobject->bsoft->welding; /* welding */
- /* disable welding: it doesn't bring any additional stability and it breaks the relation between soft body collision shape and graphic mesh */
- objprop.m_soft_welding = 0.f;
- objprop.m_margin = blenderobject->bsoft->margin;
- objprop.m_contactProcessingThreshold = 0.f;
- } else
- {
- objprop.m_gamesoftFlag = OB_BSB_BENDING_CONSTRAINTS | OB_BSB_SHAPE_MATCHING | OB_BSB_AERO_VPOINT;
-
- objprop.m_soft_linStiff = 0.5;
- objprop.m_soft_angStiff = 1.f; /* angular stiffness 0..1 */
- objprop.m_soft_volume= 1.f; /* volume preservation 0..1 */
-
-
- objprop.m_soft_viterations= 0;
- objprop.m_soft_piterations= 1;
- objprop.m_soft_diterations= 0;
- objprop.m_soft_citerations= 4;
-
- objprop.m_soft_kSRHR_CL= 0.1f;
- objprop.m_soft_kSKHR_CL= 1.f;
- objprop.m_soft_kSSHR_CL= 0.5;
- objprop.m_soft_kSR_SPLT_CL= 0.5f;
-
- objprop.m_soft_kSK_SPLT_CL= 0.5f;
- objprop.m_soft_kSS_SPLT_CL= 0.5f;
- objprop.m_soft_kVCF= 1;
- objprop.m_soft_kDP= 0;
-
- objprop.m_soft_kDG= 0;
- objprop.m_soft_kLF= 0;
- objprop.m_soft_kPR= 0;
- objprop.m_soft_kVC= 0;
-
- objprop.m_soft_kDF= 0.2f;
- objprop.m_soft_kMT= 0.05f;
- objprop.m_soft_kCHR= 1.0f;
- objprop.m_soft_kKHR= 0.1f;
-
- objprop.m_soft_kSHR= 1.f;
- objprop.m_soft_kAHR= 0.7f;
- objprop.m_soft_collisionflags= OB_BSB_COL_SDF_RS + OB_BSB_COL_VF_SS;
- objprop.m_soft_numclusteriterations= 16;
- objprop.m_soft_welding = 0.f;
- objprop.m_margin = 0.f;
- objprop.m_contactProcessingThreshold = 0.f;
- }
- }
-
- objprop.m_ghost = (blenderobject->gameflag & OB_GHOST) != 0;
- objprop.m_disableSleeping = (blenderobject->gameflag & OB_COLLISION_RESPONSE) != 0;//abuse the OB_COLLISION_RESPONSE flag
- //mmm, for now, taks this for the size of the dynamicobject
- // Blender uses inertia for radius of dynamic object
- objprop.m_radius = blenderobject->inertia;
- objprop.m_in_active_layer = (blenderobject->lay & activeLayerBitInfo) != 0;
- objprop.m_dynamic_parent=NULL;
- objprop.m_isdeformable = ((blenderobject->gameflag2 & 2)) != 0;
- objprop.m_boundclass = objprop.m_dyna?KX_BOUNDSPHERE:KX_BOUNDMESH;
-
- if ((blenderobject->gameflag & OB_SOFT_BODY) && !(blenderobject->gameflag & OB_BOUNDS))
- {
- objprop.m_boundclass = KX_BOUNDMESH;
- }
-
- if ((blenderobject->gameflag & OB_CHARACTER) && !(blenderobject->gameflag & OB_BOUNDS))
- {
- objprop.m_boundclass = KX_BOUNDSPHERE;
- }
-
- KX_BoxBounds bb;
DerivedMesh* dm = NULL;
if (gameobj->GetDeformer())
dm = gameobj->GetDeformer()->GetPhysicsMesh();
- my_get_local_bounds(blenderobject,dm,objprop.m_boundobject.box.m_center,bb.m_extends);
- if (blenderobject->gameflag & OB_BOUNDS)
- {
- switch (blenderobject->collision_boundtype)
- {
- case OB_BOUND_BOX:
- objprop.m_boundclass = KX_BOUNDBOX;
- //mmm, has to be divided by 2 to be proper extends
- objprop.m_boundobject.box.m_extends[0]=2.f*bb.m_extends[0];
- objprop.m_boundobject.box.m_extends[1]=2.f*bb.m_extends[1];
- objprop.m_boundobject.box.m_extends[2]=2.f*bb.m_extends[2];
- break;
- case OB_BOUND_CONVEX_HULL:
- if (blenderobject->type == OB_MESH)
- {
- objprop.m_boundclass = KX_BOUNDPOLYTOPE;
- break;
- }
- // Object is not a mesh... fall through OB_BOUND_TRIANGLE_MESH to
- // OB_BOUND_SPHERE
- case OB_BOUND_TRIANGLE_MESH:
- if (blenderobject->type == OB_MESH)
- {
- objprop.m_boundclass = KX_BOUNDMESH;
- break;
- }
- // Object is not a mesh... can't use polyhedron.
- // Fall through and become a sphere.
- case OB_BOUND_SPHERE:
- {
- objprop.m_boundclass = KX_BOUNDSPHERE;
- objprop.m_boundobject.c.m_radius = MT_max(bb.m_extends[0], MT_max(bb.m_extends[1], bb.m_extends[2]));
- break;
- }
- case OB_BOUND_CYLINDER:
- {
- objprop.m_boundclass = KX_BOUNDCYLINDER;
- objprop.m_boundobject.c.m_radius = MT_max(bb.m_extends[0], bb.m_extends[1]);
- objprop.m_boundobject.c.m_height = 2.f*bb.m_extends[2];
- break;
- }
- case OB_BOUND_CONE:
- {
- objprop.m_boundclass = KX_BOUNDCONE;
- objprop.m_boundobject.c.m_radius = MT_max(bb.m_extends[0], bb.m_extends[1]);
- objprop.m_boundobject.c.m_height = 2.f*bb.m_extends[2];
- break;
- }
- case OB_BOUND_CAPSULE:
- {
- objprop.m_boundclass = KX_BOUNDCAPSULE;
- objprop.m_boundobject.c.m_radius = MT_max(bb.m_extends[0], bb.m_extends[1]);
- objprop.m_boundobject.c.m_height = 2.f*(bb.m_extends[2]-objprop.m_boundobject.c.m_radius);
- if (objprop.m_boundobject.c.m_height < 0.f)
- objprop.m_boundobject.c.m_height = 0.f;
- break;
- }
- }
- }
-
- if (parent/* && (parent->gameflag & OB_DYNAMIC)*/) {
- // parented object cannot be dynamic
- KX_GameObject *parentgameobject = converter->FindGameObject(parent);
- objprop.m_dynamic_parent = parentgameobject;
- //cannot be dynamic:
- objprop.m_dyna = false;
- objprop.m_softbody = false;
- shapeprops->m_mass = 0.f;
- }
+ class PHY_IMotionState* motionstate = new KX_MotionState(gameobj->GetSGNode());
-
- objprop.m_concave = (blenderobject->collision_boundtype == OB_BOUND_TRIANGLE_MESH);
-
- switch (physics_engine)
- {
-#ifdef WITH_BULLET
- case UseBullet:
- KX_ConvertBulletObject(gameobj, meshobj, dm, kxscene, shapeprops, smmaterial, &objprop);
- break;
+ kxscene->GetPhysicsEnvironment()->ConvertObject(gameobj, meshobj, dm, kxscene, shapeprops, smmaterial, motionstate, activeLayerBitInfo, isCompoundChild, hasCompoundChildren);
-#endif
- case UseNone:
- default:
- break;
+ bool isActor = (blenderobject->gameflag & OB_ACTOR)!=0;
+ bool isSensor = (blenderobject->gameflag & OB_SENSOR) != 0;
+ gameobj->getClientInfo()->m_type =
+ (isSensor) ? ((isActor) ? KX_ClientObjectInfo::OBACTORSENSOR : KX_ClientObjectInfo::OBSENSOR) :
+ (isActor) ? KX_ClientObjectInfo::ACTOR : KX_ClientObjectInfo::STATIC;
+
+ // should we record animation for this object?
+ if ((blenderobject->gameflag & OB_RECORD_ANIMATION) != 0)
+ gameobj->SetRecordAnimation(true);
+
+ // store materialname in auxinfo, needed for touchsensors
+ if (meshobj)
+ {
+ const STR_String& matname=meshobj->GetMaterialName(0);
+ gameobj->getClientInfo()->m_auxilary_info = (matname.Length() ? (void*)(matname.ReadPtr()+2) : NULL);
+ } else
+ {
+ gameobj->getClientInfo()->m_auxilary_info = 0;
}
+
delete shapeprops;
delete smmaterial;
if (dm) {
@@ -1937,15 +1621,11 @@ static KX_GameObject *gameobject_from_blenderobject(
BL_ModifierDeformer *dcont = new BL_ModifierDeformer((BL_DeformableGameObject *)gameobj,
kxscene->GetBlenderScene(), ob, meshobj);
((BL_DeformableGameObject*)gameobj)->SetDeformer(dcont);
- if (bHasShapeKey && bHasArmature)
- dcont->LoadShapeDrivers(ob->parent);
} else if (bHasShapeKey) {
// not that we can have shape keys without dvert!
BL_ShapeDeformer *dcont = new BL_ShapeDeformer((BL_DeformableGameObject*)gameobj,
ob, meshobj);
((BL_DeformableGameObject*)gameobj)->SetDeformer(dcont);
- if (bHasArmature)
- dcont->LoadShapeDrivers(ob->parent);
} else if (bHasArmature) {
BL_SkinDeformer *dcont = new BL_SkinDeformer((BL_DeformableGameObject*)gameobj,
ob, meshobj);
@@ -2084,10 +1764,6 @@ static void UNUSED_FUNCTION(RBJconstraints)(Object *ob)//not used
}
}
-#include "PHY_IPhysicsEnvironment.h"
-#include "PHY_DynamicTypes.h"
-
-
static KX_GameObject* getGameOb(STR_String busc,CListValue* sumolist)
{
@@ -2640,12 +2316,25 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
gameobj->GetDeformer()->UpdateBuckets();
}
- // Set up armature constraints
+ // Set up armature constraints and shapekey drivers
for (i=0;i<sumolist->GetCount();++i)
{
KX_GameObject* gameobj = (KX_GameObject*) sumolist->GetValue(i);
if (gameobj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE)
- ((BL_ArmatureObject*)gameobj)->LoadConstraints(converter);
+ {
+ BL_ArmatureObject *armobj = (BL_ArmatureObject*)gameobj;
+ armobj->LoadConstraints(converter);
+
+ CListValue *children = armobj->GetChildren();
+ for (int j=0; j<children->GetCount();++j)
+ {
+ BL_ShapeDeformer *deform = dynamic_cast<BL_ShapeDeformer*>(((KX_GameObject*)children->GetValue(j))->GetDeformer());
+ if (deform)
+ deform->LoadShapeDrivers(armobj);
+ }
+
+ children->Release();
+ }
}
bool processCompoundChildren = false;
@@ -2662,7 +2351,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
meshobj = gameobj->GetMesh(0);
}
int layerMask = (groupobj.find(blenderobject) == groupobj.end()) ? activeLayerBitInfo : 0;
- BL_CreatePhysicsObjectNew(gameobj,blenderobject,meshobj,kxscene,layerMask,physics_engine,converter,processCompoundChildren);
+ BL_CreatePhysicsObjectNew(gameobj,blenderobject,meshobj,kxscene,layerMask,converter,processCompoundChildren);
}
processCompoundChildren = true;
@@ -2678,7 +2367,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
meshobj = gameobj->GetMesh(0);
}
int layerMask = (groupobj.find(blenderobject) == groupobj.end()) ? activeLayerBitInfo : 0;
- BL_CreatePhysicsObjectNew(gameobj,blenderobject,meshobj,kxscene,layerMask,physics_engine,converter,processCompoundChildren);
+ BL_CreatePhysicsObjectNew(gameobj,blenderobject,meshobj,kxscene,layerMask,converter,processCompoundChildren);
}
//set ini linearVel and int angularVel //rcruiz
@@ -2865,7 +2554,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
struct Object* blenderobj = gameobj->GetBlenderObject();
int layerMask = (groupobj.find(blenderobj) == groupobj.end()) ? activeLayerBitInfo : 0;
bool isInActiveLayer = (blenderobj->lay & layerMask)!=0;
- BL_ConvertControllers(blenderobj,gameobj,logicmgr, layerMask,isInActiveLayer,converter);
+ BL_ConvertControllers(blenderobj,gameobj,logicmgr, layerMask,isInActiveLayer,converter, libloading);
}
for ( i=0;i<logicbrick_conversionlist->GetCount();i++)
{
diff --git a/source/gameengine/Converter/BL_ModifierDeformer.cpp b/source/gameengine/Converter/BL_ModifierDeformer.cpp
index 7e64d16d012..71dc1bdec87 100644
--- a/source/gameengine/Converter/BL_ModifierDeformer.cpp
+++ b/source/gameengine/Converter/BL_ModifierDeformer.cpp
@@ -197,6 +197,15 @@ bool BL_ModifierDeformer::Update(void)
}
m_lastModifierUpdate=m_gameobj->GetLastFrame();
bShapeUpdate = true;
+
+ int nmat = m_pMeshObject->NumMaterials();
+ for (int imat=0; imat<nmat; imat++) {
+ RAS_MeshMaterial *mmat = m_pMeshObject->GetMeshMaterial(imat);
+ RAS_MeshSlot **slot = mmat->m_slots[(void*)m_gameobj];
+ if (!slot || !*slot)
+ continue;
+ (*slot)->m_pDerivedMesh = m_dm;
+ }
}
return bShapeUpdate;
}
@@ -206,14 +215,5 @@ bool BL_ModifierDeformer::Apply(RAS_IPolyMaterial *mat)
if (!Update())
return false;
- // drawing is based on derived mesh, must set it in the mesh slots
- int nmat = m_pMeshObject->NumMaterials();
- for (int imat=0; imat<nmat; imat++) {
- RAS_MeshMaterial *mmat = m_pMeshObject->GetMeshMaterial(imat);
- RAS_MeshSlot **slot = mmat->m_slots[(void*)m_gameobj];
- if (!slot || !*slot)
- continue;
- (*slot)->m_pDerivedMesh = m_dm;
- }
return true;
}
diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp
index ca5b26079b1..5e31dabfab1 100644
--- a/source/gameengine/Converter/BL_ShapeDeformer.cpp
+++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp
@@ -51,6 +51,7 @@
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_key.h"
+#include "BKE_fcurve.h"
#include "BKE_ipo.h"
#include "BKE_library.h"
#include "MT_Point3.h"
@@ -119,8 +120,35 @@ void BL_ShapeDeformer::ProcessReplica()
m_key = BKE_key_copy(m_key);
}
-bool BL_ShapeDeformer::LoadShapeDrivers(Object* arma)
+bool BL_ShapeDeformer::LoadShapeDrivers(KX_GameObject* parent)
{
+ // Only load shape drivers if we have a key
+ if (GetKey() == NULL) {
+ m_useShapeDrivers = false;
+ return false;
+ }
+
+ // Fix drivers since BL_ArmatureObject makes copies
+ if (parent->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE && GetKey()->adt) {
+ BL_ArmatureObject *arma = (BL_ArmatureObject*)parent;
+ FCurve *fcu;
+
+ for (fcu = (FCurve*)GetKey()->adt->drivers.first; fcu; fcu = (FCurve*)fcu->next) {
+
+ DriverVar *dvar;
+ for (dvar = (DriverVar*)fcu->driver->variables.first; dvar; dvar = (DriverVar*)dvar->next) {
+ DRIVER_TARGETS_USED_LOOPER(dvar)
+ {
+ if (dtar->id) {
+ if ((Object*)dtar->id == arma->GetOrigArmatureObject())
+ dtar->id = (ID*)arma->GetArmatureObject();
+ }
+ }
+ DRIVER_TARGETS_LOOPER_END
+ }
+ }
+ }
+
// This used to check if we had drivers from this armature,
// now we just assume we want to use shape drivers
// and let the animsys handle things.
@@ -132,15 +160,10 @@ bool BL_ShapeDeformer::LoadShapeDrivers(Object* arma)
bool BL_ShapeDeformer::ExecuteShapeDrivers(void)
{
if (m_useShapeDrivers && PoseUpdated()) {
- // the shape drivers use the bone matrix as input. Must
- // update the matrix now
- m_armobj->ApplyPose();
-
// We don't need an actual time, just use 0
BKE_animsys_evaluate_animdata(NULL, &GetKey()->id, GetKey()->adt, 0.f, ADT_RECALC_DRIVERS);
ForceUpdate();
- m_armobj->RestorePose();
m_bDynamic = true;
return true;
}
@@ -199,6 +222,9 @@ bool BL_ShapeDeformer::Update(void)
if (m_recalcNormal)
RecalcNormals();
#endif
+
+ // We also need to handle transverts now (used to be in BL_SkinDeformer::Apply())
+ UpdateTransverts();
bSkinUpdate = true;
}
diff --git a/source/gameengine/Converter/BL_ShapeDeformer.h b/source/gameengine/Converter/BL_ShapeDeformer.h
index a506fb9c7f6..f6746dd2302 100644
--- a/source/gameengine/Converter/BL_ShapeDeformer.h
+++ b/source/gameengine/Converter/BL_ShapeDeformer.h
@@ -61,7 +61,7 @@ public:
virtual ~BL_ShapeDeformer();
bool Update (void);
- bool LoadShapeDrivers(Object* arma);
+ bool LoadShapeDrivers(KX_GameObject* parent);
bool ExecuteShapeDrivers(void);
struct Key *GetKey();
diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp
index e068a91bf7e..e7137a5c379 100644
--- a/source/gameengine/Converter/BL_SkinDeformer.cpp
+++ b/source/gameengine/Converter/BL_SkinDeformer.cpp
@@ -152,44 +152,8 @@ void BL_SkinDeformer::Relink(CTR_Map<class CTR_HashedPtr, void*>*map)
bool BL_SkinDeformer::Apply(RAS_IPolyMaterial *mat)
{
- RAS_MeshSlot::iterator it;
- RAS_MeshMaterial *mmat;
- RAS_MeshSlot *slot;
- size_t i, nmat, imat;
-
- // update the vertex in m_transverts
- if (!Update())
- return false;
-
- if (m_transverts) {
- // the vertex cache is unique to this deformer, no need to update it
- // if it wasn't updated! We must update all the materials at once
- // because we will not get here again for the other material
- nmat = m_pMeshObject->NumMaterials();
- for (imat=0; imat<nmat; imat++) {
- mmat = m_pMeshObject->GetMeshMaterial(imat);
- if (!mmat->m_slots[(void*)m_gameobj])
- continue;
-
- slot = *mmat->m_slots[(void*)m_gameobj];
-
- // for each array
- for (slot->begin(it); !slot->end(it); slot->next(it)) {
- // for each vertex
- // copy the untransformed data from the original mvert
- for (i=it.startvertex; i<it.endvertex; i++) {
- RAS_TexVert& v = it.vertex[i];
- v.SetXYZ(m_transverts[v.getOrigIndex()]);
- if (m_copyNormals)
- v.SetNormal(m_transnors[v.getOrigIndex()]);
- }
- }
- }
-
- if (m_copyNormals)
- m_copyNormals = false;
- }
- return true;
+ // We do everything in UpdateInternal() now so we can thread it.
+ return false;
}
RAS_Deformer *BL_SkinDeformer::GetReplica()
@@ -323,6 +287,43 @@ void BL_SkinDeformer::BGEDeformVerts()
m_copyNormals = true;
}
+void BL_SkinDeformer::UpdateTransverts()
+{
+ RAS_MeshSlot::iterator it;
+ RAS_MeshMaterial *mmat;
+ RAS_MeshSlot *slot;
+ size_t i, nmat, imat;
+
+ if (m_transverts) {
+ // the vertex cache is unique to this deformer, no need to update it
+ // if it wasn't updated! We must update all the materials at once
+ // because we will not get here again for the other material
+ nmat = m_pMeshObject->NumMaterials();
+ for (imat=0; imat<nmat; imat++) {
+ mmat = m_pMeshObject->GetMeshMaterial(imat);
+ if (!mmat->m_slots[(void*)m_gameobj])
+ continue;
+
+ slot = *mmat->m_slots[(void*)m_gameobj];
+
+ // for each array
+ for (slot->begin(it); !slot->end(it); slot->next(it)) {
+ // for each vertex
+ // copy the untransformed data from the original mvert
+ for (i=it.startvertex; i<it.endvertex; i++) {
+ RAS_TexVert& v = it.vertex[i];
+ v.SetXYZ(m_transverts[v.getOrigIndex()]);
+ if (m_copyNormals)
+ v.SetNormal(m_transnors[v.getOrigIndex()]);
+ }
+ }
+ }
+
+ if (m_copyNormals)
+ m_copyNormals = false;
+ }
+}
+
bool BL_SkinDeformer::UpdateInternal(bool shape_applied)
{
/* See if the armature has been updated for this frame */
@@ -331,7 +332,7 @@ bool BL_SkinDeformer::UpdateInternal(bool shape_applied)
if (!shape_applied) {
/* store verts locally */
VerifyStorage();
-
+
/* duplicate */
for (int v =0; v<m_bmesh->totvert; v++)
{
@@ -342,15 +343,10 @@ bool BL_SkinDeformer::UpdateInternal(bool shape_applied)
m_armobj->ApplyPose();
- switch (m_armobj->GetVertDeformType())
- {
- case ARM_VDEF_BGE_CPU:
- BGEDeformVerts();
- break;
- case ARM_VDEF_BLENDER:
- default:
- BlenderDeformVerts();
- }
+ if (m_armobj->GetVertDeformType() == ARM_VDEF_BGE_CPU)
+ BGEDeformVerts();
+ else
+ BlenderDeformVerts();
/* Update the current frame */
m_lastArmaUpdate=m_armobj->GetLastFrame();
@@ -358,6 +354,9 @@ bool BL_SkinDeformer::UpdateInternal(bool shape_applied)
m_armobj->RestorePose();
/* dynamic vertex, cannot use display list */
m_bDynamic = true;
+
+ UpdateTransverts();
+
/* indicate that the m_transverts and normals are up to date */
return true;
}
diff --git a/source/gameengine/Converter/BL_SkinDeformer.h b/source/gameengine/Converter/BL_SkinDeformer.h
index 7495deb2257..79043f60db8 100644
--- a/source/gameengine/Converter/BL_SkinDeformer.h
+++ b/source/gameengine/Converter/BL_SkinDeformer.h
@@ -114,6 +114,8 @@ protected:
void BlenderDeformVerts();
void BGEDeformVerts();
+ void UpdateTransverts();
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_SkinDeformer")
diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
index 854e9fe7327..5930d5e90d2 100644
--- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
+++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
@@ -50,7 +50,6 @@
#include "DummyPhysicsEnvironment.h"
-#include "KX_ConvertPhysicsObject.h"
#ifdef WITH_BULLET
#include "CcdPhysicsEnvironment.h"
@@ -190,9 +189,6 @@ KX_BlenderSceneConverter::~KX_BlenderSceneConverter()
}
m_meshobjects.clear();
-#ifdef WITH_BULLET
- KX_ClearBulletSharedShapes();
-#endif
/* free any data that was dynamically loaded */
while (m_DynamicMaggie.size() != 0)
@@ -249,60 +245,6 @@ Scene *KX_BlenderSceneConverter::GetBlenderSceneForName(const STR_String& name)
}
-#ifdef WITH_BULLET
-
-#include "LinearMath/btIDebugDraw.h"
-
-
-struct BlenderDebugDraw : public btIDebugDraw
-{
- BlenderDebugDraw () :
- m_debugMode(0)
- {
- }
-
- int m_debugMode;
-
- virtual void drawLine(const btVector3& from,const btVector3& to,const btVector3& color)
- {
- if (m_debugMode >0)
- {
- MT_Vector3 kxfrom(from[0],from[1],from[2]);
- MT_Vector3 kxto(to[0],to[1],to[2]);
- MT_Vector3 kxcolor(color[0],color[1],color[2]);
-
- KX_RasterizerDrawDebugLine(kxfrom,kxto,kxcolor);
- }
- }
-
- virtual void reportErrorWarning(const char* warningString)
- {
-
- }
-
- virtual void drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,float distance,int lifeTime,const btVector3& color)
- {
- //not yet
- }
-
- virtual void setDebugMode(int debugMode)
- {
- m_debugMode = debugMode;
- }
- virtual int getDebugMode() const
- {
- return m_debugMode;
- }
- ///todo: find out if Blender can do this
- virtual void draw3dText(const btVector3& location,const char* textString)
- {
-
- }
-
-};
-
-#endif
-
void KX_BlenderSceneConverter::ConvertScene(class KX_Scene* destinationscene,
class RAS_IRasterizer* rendertools,
class RAS_ICanvas* canvas,
@@ -311,8 +253,9 @@ void KX_BlenderSceneConverter::ConvertScene(class KX_Scene* destinationscene,
//find out which physics engine
Scene *blenderscene = destinationscene->GetBlenderScene();
+ PHY_IPhysicsEnvironment *phy_env = NULL;
+
e_PhysicsEngine physics_engine = UseBullet;
- bool useDbvtCulling = false;
// hook for registration function during conversion.
m_currentScene = destinationscene;
destinationscene->SetSceneConverter(this);
@@ -321,56 +264,31 @@ void KX_BlenderSceneConverter::ConvertScene(class KX_Scene* destinationscene,
// when doing threaded conversion, so it's disabled for now.
// SG_SetActiveStage(SG_STAGE_CONVERTER);
- if (blenderscene)
+ switch (blenderscene->gm.physicsEngine)
{
-
- switch (blenderscene->gm.physicsEngine)
+#ifdef WITH_BULLET
+ case WOPHY_BULLET:
{
- case WOPHY_BULLET:
- {
- physics_engine = UseBullet;
- useDbvtCulling = (blenderscene->gm.mode & WO_DBVT_CULLING) != 0;
- break;
- }
- default:
- case WOPHY_NONE:
- {
- physics_engine = UseNone;
- break;
- }
- }
- }
+ SYS_SystemHandle syshandle = SYS_GetSystem(); /*unused*/
+ int visualizePhysics = SYS_GetCommandLineInt(syshandle,"show_physics",0);
- switch (physics_engine)
- {
-#ifdef WITH_BULLET
- case UseBullet:
- {
- CcdPhysicsEnvironment* ccdPhysEnv = new CcdPhysicsEnvironment(useDbvtCulling);
- ccdPhysEnv->SetDebugDrawer(new BlenderDebugDraw());
- ccdPhysEnv->SetDeactivationLinearTreshold(blenderscene->gm.lineardeactthreshold);
- ccdPhysEnv->SetDeactivationAngularTreshold(blenderscene->gm.angulardeactthreshold);
- ccdPhysEnv->SetDeactivationTime(blenderscene->gm.deactivationtime);
-
- SYS_SystemHandle syshandle = SYS_GetSystem(); /*unused*/
- int visualizePhysics = SYS_GetCommandLineInt(syshandle,"show_physics",0);
- if (visualizePhysics)
- ccdPhysEnv->SetDebugMode(btIDebugDraw::DBG_DrawWireframe|btIDebugDraw::DBG_DrawAabb|btIDebugDraw::DBG_DrawContactPoints|btIDebugDraw::DBG_DrawText|btIDebugDraw::DBG_DrawConstraintLimits|btIDebugDraw::DBG_DrawConstraints);
-
- //todo: get a button in blender ?
- //disable / enable debug drawing (contact points, aabb's etc)
- //ccdPhysEnv->setDebugMode(1);
- destinationscene->SetPhysicsEnvironment(ccdPhysEnv);
- break;
- }
+ phy_env = CcdPhysicsEnvironment::Create(blenderscene, visualizePhysics);
+ physics_engine = UseBullet;
+ break;
+ }
#endif
- default:
- case UseNone:
+ default:
+ case WOPHY_NONE:
+ {
+ // We should probably use some sort of factory here
+ phy_env = new DummyPhysicsEnvironment();
physics_engine = UseNone;
- destinationscene ->SetPhysicsEnvironment(new DummyPhysicsEnvironment());
break;
+ }
}
+ destinationscene->SetPhysicsEnvironment(phy_env);
+
BL_ConvertBlenderObjects(m_maggie,
destinationscene,
m_ketsjiEngine,
@@ -392,12 +310,6 @@ void KX_BlenderSceneConverter::ConvertScene(class KX_Scene* destinationscene,
//This cache mecanism is buggy so I leave it disable and the memory leak
//that would result from this is fixed in RemoveScene()
m_map_mesh_to_gamemesh.clear();
-
-#ifndef WITH_BULLET
- /* quiet compiler warning */
- (void)useDbvtCulling;
-#endif
-
}
// This function removes all entities stored in the converter for that scene
@@ -1546,6 +1458,20 @@ RAS_MeshObject *KX_BlenderSceneConverter::ConvertMeshSpecial(KX_Scene* kx_scene,
{
/* Find a mesh in the current main */
ID *me= static_cast<ID *>(BLI_findstring(&m_maggie->mesh, name, offsetof(ID, name) + 2));
+ Main *from_maggie = m_maggie;
+
+ if (me == NULL) {
+ // The mesh wasn't in the current main, try any dynamic (i.e., LibLoaded) ones
+ vector<Main*>::iterator it;
+
+ for (it = GetMainDynamic().begin(); it != GetMainDynamic().end(); it++) {
+ me = static_cast<ID *>(BLI_findstring(&(*it)->mesh, name, offsetof(ID, name) + 2));
+ from_maggie = *it;
+
+ if (me)
+ break;
+ }
+ }
if (me==NULL) {
printf("Could not be found \"%s\"\n", name);
@@ -1555,10 +1481,10 @@ RAS_MeshObject *KX_BlenderSceneConverter::ConvertMeshSpecial(KX_Scene* kx_scene,
/* Watch this!, if its used in the original scene can cause big troubles */
if (me->us > 0) {
printf("Mesh has a user \"%s\"\n", name);
- me = (ID*)BKE_mesh_copy((Mesh*)me);
+ me = (ID*)BKE_mesh_copy_ex(from_maggie, (Mesh*)me);
me->us--;
}
- BLI_remlink(&m_maggie->mesh, me); /* even if we made the copy it needs to be removed */
+ BLI_remlink(&from_maggie->mesh, me); /* even if we made the copy it needs to be removed */
BLI_addtail(&maggie->mesh, me);
@@ -1584,7 +1510,7 @@ RAS_MeshObject *KX_BlenderSceneConverter::ConvertMeshSpecial(KX_Scene* kx_scene,
mat_new->id.flag |= LIB_DOIT;
mat_old->id.us--;
- BLI_remlink(&m_maggie->mat, mat_new);
+ BLI_remlink(&G.main->mat, mat_new); // BKE_material_copy uses G.main, and there is no BKE_material_copy_ex
BLI_addtail(&maggie->mat, mat_new);
mesh->mat[i] = mat_new;
diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp
index 725e9815a67..b59c26ab90b 100644
--- a/source/gameengine/Converter/KX_ConvertActuators.cpp
+++ b/source/gameengine/Converter/KX_ConvertActuators.cpp
@@ -1106,7 +1106,7 @@ void BL_ConvertActuators(const char* maggiename,
; /* generate some error */
}
- if (baseact)
+ if (baseact && !(bact->flag & ACT_DEACTIVATE))
{
baseact->SetExecutePriority(executePriority++);
uniquename += "#ACT#";
@@ -1122,6 +1122,8 @@ void BL_ConvertActuators(const char* maggiename,
// done with baseact, release it
baseact->Release();
}
+ else if (baseact)
+ baseact->Release();
bact = bact->next;
}
diff --git a/source/gameengine/Converter/KX_ConvertControllers.cpp b/source/gameengine/Converter/KX_ConvertControllers.cpp
index 5d3d0f33bec..0215b604fdd 100644
--- a/source/gameengine/Converter/KX_ConvertControllers.cpp
+++ b/source/gameengine/Converter/KX_ConvertControllers.cpp
@@ -94,7 +94,8 @@ void BL_ConvertControllers(
SCA_LogicManager* logicmgr,
int activeLayerBitInfo,
bool isInActiveLayer,
- KX_BlenderSceneConverter* converter
+ KX_BlenderSceneConverter* converter,
+ bool libloading
) {
int uniqueint=0;
int count = 0;
@@ -157,8 +158,9 @@ void BL_ConvertControllers(
SCA_PythonController* pyctrl = new SCA_PythonController(gameobj, pycont->mode);
gamecontroller = pyctrl;
#ifdef WITH_PYTHON
- PyGILState_STATE gstate = PyGILState_Ensure();
- pyctrl->SetNamespace(converter->GetPyNamespace());
+ // When libloading, this is delayed to KX_Scene::MergeScene_LogicBrick to avoid GIL issues
+ if (!libloading)
+ pyctrl->SetNamespace(converter->GetPyNamespace());
if (pycont->mode==SCA_PythonController::SCA_PYEXEC_SCRIPT) {
if (pycont->text)
@@ -185,8 +187,6 @@ void BL_ConvertControllers(
pyctrl->SetDebug(true);
}
}
-
- PyGILState_Release(gstate);
#endif // WITH_PYTHON
break;
@@ -197,7 +197,7 @@ void BL_ConvertControllers(
}
}
- if (gamecontroller)
+ if (gamecontroller && !(bcontr->flag & CONT_DEACTIVATE))
{
LinkControllerToActuators(gamecontroller,bcontr,logicmgr,converter);
gamecontroller->SetExecutePriority(executePriority++);
@@ -219,8 +219,8 @@ void BL_ConvertControllers(
converter->RegisterGameController(gamecontroller, bcontr);
#ifdef WITH_PYTHON
- PyGILState_STATE gstate = PyGILState_Ensure();
- if (bcontr->type==CONT_PYTHON) {
+ // When libloading, this is delayed to KX_Scene::MergeScene_LogicBrick to avoid GIL issues
+ if (!libloading && bcontr->type==CONT_PYTHON) {
SCA_PythonController *pyctrl= static_cast<SCA_PythonController*>(gamecontroller);
/* not strictly needed but gives syntax errors early on and
* gives more predictable performance for larger scripts */
@@ -235,12 +235,13 @@ void BL_ConvertControllers(
}
}
- PyGILState_Release(gstate);
#endif // WITH_PYTHON
//done with gamecontroller
gamecontroller->Release();
}
+ else if (gamecontroller)
+ gamecontroller->Release();
bcontr = bcontr->next;
}
diff --git a/source/gameengine/Converter/KX_ConvertControllers.h b/source/gameengine/Converter/KX_ConvertControllers.h
index 817a49e1b2f..babe3e2e73f 100644
--- a/source/gameengine/Converter/KX_ConvertControllers.h
+++ b/source/gameengine/Converter/KX_ConvertControllers.h
@@ -40,7 +40,8 @@ void BL_ConvertControllers(
class SCA_LogicManager* logicmgr,
int activeLayerBitInfo,
bool isInActiveLayer,
- class KX_BlenderSceneConverter* converter
+ class KX_BlenderSceneConverter* converter,
+ bool libloading
);
#endif /* __KX_CONVERTCONTROLLERS_H__ */
diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp
index 2e2ebda47e2..b3c6f6ddd24 100644
--- a/source/gameengine/Converter/KX_ConvertSensors.cpp
+++ b/source/gameengine/Converter/KX_ConvertSensors.cpp
@@ -49,6 +49,7 @@
#include "DNA_object_types.h"
#include "DNA_material_types.h"
#include "DNA_sensor_types.h"
+#include "DNA_controller_types.h"
#include "DNA_actuator_types.h" /* for SENS_ALL_KEYS ? this define is
* probably misplaced */
/* end of blender include block */
@@ -575,7 +576,7 @@ void BL_ConvertSensors(struct Object* blenderobject,
}
}
- if (gamesensor)
+ if (gamesensor && !(sens->flag & SENS_DEACTIVATE))
{
gamesensor->SetExecutePriority(executePriority++);
STR_String uniquename = sens->name;
@@ -606,16 +607,19 @@ void BL_ConvertSensors(struct Object* blenderobject,
{
bController* linkedcont = (bController*) sens->links[i];
if (linkedcont) {
- SCA_IController* gamecont = converter->FindGameController(linkedcont);
+ // If the controller is deactived doesn't register it
+ if (!(linkedcont->flag & CONT_DEACTIVATE)) {
+ SCA_IController* gamecont = converter->FindGameController(linkedcont);
- if (gamecont) {
- logicmgr->RegisterToSensor(gamecont,gamesensor);
- }
- else {
- printf("Warning, sensor \"%s\" could not find its controller "
- "(link %d of %d) from object \"%s\"\n"
- "\tthere has been an error converting the blender controller for the game engine,"
- "logic may be incorrect\n", sens->name, i+1, sens->totlinks, blenderobject->id.name+2);
+ if (gamecont) {
+ logicmgr->RegisterToSensor(gamecont,gamesensor);
+ }
+ else {
+ printf("Warning, sensor \"%s\" could not find its controller "
+ "(link %d of %d) from object \"%s\"\n"
+ "\tthere has been an error converting the blender controller for the game engine,"
+ "logic may be incorrect\n", sens->name, i+1, sens->totlinks, blenderobject->id.name+2);
+ }
}
}
else {
@@ -636,6 +640,9 @@ void BL_ConvertSensors(struct Object* blenderobject,
gamesensor->Release();
}
+ else if (gamesensor)
+ gamesensor->Release();
+
sens=sens->next;
}
}
diff --git a/source/gameengine/Converter/KX_SoftBodyDeformer.cpp b/source/gameengine/Converter/KX_SoftBodyDeformer.cpp
index fcdaaaa761a..877aebff556 100644
--- a/source/gameengine/Converter/KX_SoftBodyDeformer.cpp
+++ b/source/gameengine/Converter/KX_SoftBodyDeformer.cpp
@@ -36,7 +36,6 @@
#include "MT_assert.h"
-#include "KX_ConvertPhysicsObject.h"
#include "KX_SoftBodyDeformer.h"
#include "RAS_MeshObject.h"
#include "CTR_Map.h"
diff --git a/source/gameengine/GameLogic/SCA_EventManager.h b/source/gameengine/GameLogic/SCA_EventManager.h
index 83322fe8243..eb9a6d9aca1 100644
--- a/source/gameengine/GameLogic/SCA_EventManager.h
+++ b/source/gameengine/GameLogic/SCA_EventManager.h
@@ -77,7 +77,6 @@ public:
void Replace_LogicManager(SCA_LogicManager* logicmgr) { m_logicmgr= logicmgr; }
- virtual void Replace_PhysicsScene(class PHY_IPhysicsEnvironment* env) { } /* only for event managers that use one */
protected:
EVENT_MANAGER_TYPE m_mgrtype;
diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
index 076b96601aa..31fafd86db7 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
@@ -195,7 +195,7 @@ static void usage(const char* program, bool isBlenderPlayer)
const char * example_pathname = "";
#ifdef _WIN32
- consoleoption = "-c ";
+ consoleoption = "[-c] ";
#else
consoleoption = "";
#endif
@@ -208,33 +208,40 @@ static void usage(const char* program, bool isBlenderPlayer)
example_pathname = "/home/user/";
#endif
}
-
- printf("usage: %s [-w [w h l t]] [-f [fw fh fb ff]] %s[-g gamengineoptions] "
- "[-s stereomode] [-m aasamples] %s\n", program, consoleoption, example_filename);
+ printf("\n");
+ printf("usage: %s [--options] %s\n\n", program, example_filename);
+ printf("Available options are: [-w [w h l t]] [-f [fw fh fb ff]] %s[-g gamengineoptions] ", consoleoption);
+ printf("[-s stereomode] [-m aasamples]\n");
+ printf("Optional parameters must be passed in order.\n");
+ printf("Default values are set in the blend file.\n\n");
printf(" -h: Prints this command summary\n\n");
printf(" -w: display in a window\n");
printf(" --Optional parameters--\n");
printf(" w = window width\n");
- printf(" h = window height\n\n");
+ printf(" h = window height\n");
printf(" l = window left coordinate\n");
printf(" t = window top coordinate\n");
- printf(" Note: If w or h is defined, both must be defined.\n");
- printf(" Also, if l or t is defined, all options must be used.\n\n");
- printf(" -f: start game in full screen mode\n");
+ printf(" Note: To define 'w' or 'h', both must be used.");
+ printf("Also, to define 'l' or 't', all four parameters must be used.\n");
+ printf(" Example: -w or -w 500 300 or -w 500 300 0 0\n\n");
+ printf(" -f: start game in fullscreen mode\n");
printf(" --Optional parameters--\n");
- printf(" fw = full screen mode pixel width\n");
- printf(" fh = full screen mode pixel height\n\n");
- printf(" fb = full screen mode bits per pixel\n");
- printf(" ff = full screen mode frequency\n");
- printf(" Note: If fw or fh is defined, both must be defined.\n");
- printf(" Also, if fb is used, fw and fh must be used. ff requires all options.\n\n");
- printf(" -s: start player in stereo\n");
- printf(" stereomode: hwpageflip (Quad buffered shutter glasses)\n");
- printf(" syncdoubling (Above Below)\n");
- printf(" sidebyside (Left Right)\n");
+ printf(" fw = fullscreen mode pixel width (use 0 to detect automatically)\n");
+ printf(" fh = fullscreen mode pixel height (use 0 to detect automatically)\n");
+ printf(" fb = fullscreen mode bits per pixel (default unless set in the blend file: 32)\n");
+ printf(" ff = fullscreen mode frequency (default unless set in the blend file: 60)\n");
+ printf(" Note: To define 'fw'' or 'fh'', both must be used.\n");
+ printf(" Example: -f or -f 1024 768 or -f 0 0 16 or -f 1024 728 16 30\n\n");
+ printf(" -s: start player in stereoscopy mode (requires 3D capable hardware)\n");
+ printf(" stereomode: nostereo (default unless stereo is set in the blend file)\n");
printf(" anaglyph (Red-Blue glasses)\n");
+ printf(" sidebyside (Left Right)\n");
+ printf(" syncdoubling (Above Below)\n");
+ printf(" 3dtvtopbottom (Squashed Top-Bottom for passive glasses)\n");
+ printf(" interlace (Interlace horizontally)\n");
printf(" vinterlace (Vertical interlace for autostereo display)\n");
- printf(" depending on the type of stereo you want\n\n");
+ printf(" hwpageflip (Quad buffered shutter glasses)\n");
+ printf(" Example: -s sidebyside or -s vinterlace\n\n");
printf(" -D: start player in dome mode\n");
printf(" --Optional parameters--\n");
printf(" angle = field of view in degrees\n");
@@ -245,9 +252,9 @@ static void usage(const char* program, bool isBlenderPlayer)
printf(" truncatedrear (Rear-Truncated)\n");
printf(" cubemap (Cube Map)\n");
printf(" sphericalpanoramic (Spherical Panoramic)\n");
- printf(" depending on the type of dome you are using\n\n");
+ printf(" Example: -D or -D mode cubemap\n\n");
printf(" -m: maximum anti-aliasing (eg. 2,4,8,16)\n\n");
- printf(" -i: parent windows ID\n\n");
+ printf(" -i: parent window's ID\n\n");
#ifdef _WIN32
printf(" -c: keep console window open\n\n");
#endif
@@ -265,7 +272,7 @@ static void usage(const char* program, bool isBlenderPlayer)
printf("\n");
printf(" - : all arguments after this are ignored, allowing python to access them from sys.argv\n");
printf("\n");
- printf("example: %s -w 320 200 10 10 -g noaudio%s%s\n", program, example_pathname, example_filename);
+ printf("example: %s -w 320 200 10 10 -g noaudio %s%s\n", program, example_pathname, example_filename);
printf("example: %s -g show_framerate = 0 %s%s\n", program, example_pathname, example_filename);
printf("example: %s -i 232421 -m 16 %s%s\n\n", program, example_pathname, example_filename);
}
@@ -412,7 +419,7 @@ int main(int argc, char** argv)
int fullScreenBpp = 32;
int fullScreenFrequency = 60;
GHOST_TEmbedderWindowID parentWindow = 0;
- bool isBlenderPlayer = false;
+ bool isBlenderPlayer = false; //true when lauching from blender or command line. false for bundled player
int validArguments=0;
bool samplesParFound = false;
GHOST_TUns16 aasamples = 0;
@@ -502,13 +509,20 @@ int main(int argc, char** argv)
set_free_windowmanager_cb(wm_free);
- /* if running blenderplayer the last argument can't be parsed since it has to be the filename. */
+ /* if running blenderplayer the last argument can't be parsed since it has to be the filename. else it is bundled */
isBlenderPlayer = !BLO_is_a_runtime(argv[0]);
if (isBlenderPlayer)
validArguments = argc - 1;
else
validArguments = argc;
+
+ /* Parsing command line arguments (can be set from WM_OT_blenderplayer_start) */
+#if defined(DEBUG)
+ printf("Parsing command line arguments...\n");
+ printf("Num of arguments is: %i\n", validArguments-1); //-1 because i starts at 1
+#endif
+
for (i = 1; (i < validArguments) && !error
#ifdef WIN32
&& scr_saver_mode == SCREEN_SAVER_MODE_NONE
@@ -517,7 +531,7 @@ int main(int argc, char** argv)
{
#if defined(DEBUG)
- printf("argv[%d] = '%s', %i\n", i, argv[i],argc);
+ printf("argv[%d] = '%s'\n", i, argv[i]);
#endif
if (argv[i][0] == '-')
{
@@ -529,44 +543,43 @@ int main(int argc, char** argv)
switch (argv[i][1])
{
- case 'g':
- // Parse game options
+ case 'g': //game engine options (show_framerate, fixedtime, etc)
+ {
+ i++;
+ if (i <= validArguments)
{
- i++;
- if (i <= validArguments)
+ char* paramname = argv[i];
+ // Check for single value versus assignment
+ if (i+1 <= validArguments && (*(argv[i+1]) == '='))
{
- char* paramname = argv[i];
- // Check for single value versus assignment
- if (i+1 <= validArguments && (*(argv[i+1]) == '='))
+ i++;
+ if (i + 1 <= validArguments)
{
i++;
- if (i + 1 <= validArguments)
- {
- i++;
- // Assignment
- SYS_WriteCommandLineInt(syshandle, paramname, atoi(argv[i]));
- SYS_WriteCommandLineFloat(syshandle, paramname, atof(argv[i]));
- SYS_WriteCommandLineString(syshandle, paramname, argv[i]);
+ // Assignment
+ SYS_WriteCommandLineInt(syshandle, paramname, atoi(argv[i]));
+ SYS_WriteCommandLineFloat(syshandle, paramname, atof(argv[i]));
+ SYS_WriteCommandLineString(syshandle, paramname, argv[i]);
#if defined(DEBUG)
- printf("%s = '%s'\n", paramname, argv[i]);
+ printf("%s = '%s'\n", paramname, argv[i]);
#endif
- i++;
- }
- else
- {
- error = true;
- printf("error: argument assignment %s without value.\n", paramname);
- }
+ i++;
}
else
{
-// SYS_WriteCommandLineInt(syshandle, argv[i++], 1);
+ error = true;
+ printf("error: argument assignment %s without value.\n", paramname);
}
}
+ else
+ {
+// SYS_WriteCommandLineInt(syshandle, argv[i++], 1);
+ }
}
break;
-
- case 'd':
+ }
+ case 'd': //debug on
+ {
i++;
G.debug |= G_DEBUG;
MEM_set_memory_debug();
@@ -574,8 +587,9 @@ int main(int argc, char** argv)
BLI_mempool_set_memory_debug();
#endif
break;
-
- case 'f':
+ }
+ case 'f': //fullscreen mode
+ {
i++;
fullScreen = true;
fullScreenParFound = true;
@@ -590,30 +604,51 @@ int main(int argc, char** argv)
fullScreenFrequency = atoi(argv[i++]);
}
}
+ else if ((i + 1) <= validArguments && argv[i][0] != '-' && argv[i+1][0] != '-')
+ {
+ error = true;
+ printf("error: to define fullscreen width or height, both options must be used.\n");
+ }
break;
- case 'w':
- // Parse window position and size options
+ }
+ case 'w': //display in a window
+ {
i++;
fullScreen = false;
windowParFound = true;
+ // Parse window position and size options
if ((i + 2) <= validArguments && argv[i][0] != '-' && argv[i+1][0] != '-')
{
windowWidth = atoi(argv[i++]);
windowHeight = atoi(argv[i++]);
+
if ((i + 2) <= validArguments && argv[i][0] != '-' && argv[i+1][0] != '-')
{
windowLeft = atoi(argv[i++]);
windowTop = atoi(argv[i++]);
}
+ else if ((i + 1) <= validArguments && argv[i][0] != '-' && argv[i+1][0] != '-')
+ {
+ error = true;
+ printf("error: to define the window left or right coordinates, both options must be used.\n");
+ }
+ }
+ else if ((i + 1) <= validArguments && argv[i][0] != '-' && argv[i+1][0] != '-')
+ {
+ error = true;
+ printf("error: to define the window's width or height, both options must be used.\n");
}
break;
-
- case 'h':
+ }
+ case 'h': //display help
+ {
usage(argv[0], isBlenderPlayer);
return 0;
break;
- case 'i':
+ }
+ case 'i': //parent window ID
+ {
i++;
if ( (i + 1) <= validArguments )
parentWindow = atoi(argv[i++]);
@@ -625,7 +660,9 @@ int main(int argc, char** argv)
printf("XWindows ID = %d\n", parentWindow);
#endif // defined(DEBUG)
break;
- case 'm':
+ }
+ case 'm': //maximum anti-aliasing (eg. 2,4,8,16)
+ {
i++;
samplesParFound = true;
if ((i+1) <= validArguments )
@@ -636,22 +673,28 @@ int main(int argc, char** argv)
printf("error: No argument supplied for -m");
}
break;
- case 'c':
+ }
+ case 'c': //keep console (windows only)
+ {
i++;
#ifdef WIN32
closeConsole = false;
#endif
break;
- case 's': // stereo
+ }
+ case 's': //stereo mode
+ {
i++;
if ((i + 1) <= validArguments)
{
- stereomode = (RAS_IRasterizer::StereoMode) atoi(argv[i]);
- if (stereomode < RAS_IRasterizer::RAS_STEREO_NOSTEREO || stereomode >= RAS_IRasterizer::RAS_STEREO_MAXSTEREO)
- stereomode = RAS_IRasterizer::RAS_STEREO_NOSTEREO;
+ stereoParFound = true;
+ stereoFlag = STEREO_ENABLED;
- if (!strcmp(argv[i], "nostereo")) // ok, redundant but clear
+ if (!strcmp(argv[i], "nostereo")) // may not be redundant if the file has different setting
+ {
stereomode = RAS_IRasterizer::RAS_STEREO_NOSTEREO;
+ stereoFlag = STEREO_NOSTEREO;
+ }
// only the hardware pageflip method needs a stereo window
else if (!strcmp(argv[i], "hwpageflip")) {
@@ -670,6 +713,9 @@ int main(int argc, char** argv)
else if (!strcmp(argv[i], "sidebyside"))
stereomode = RAS_IRasterizer::RAS_STEREO_SIDEBYSIDE;
+ else if (!strcmp(argv[i], "interlace"))
+ stereomode = RAS_IRasterizer::RAS_STEREO_INTERLACED;
+
else if (!strcmp(argv[i], "vinterlace"))
stereomode = RAS_IRasterizer::RAS_STEREO_VINTERLACE;
@@ -678,10 +724,13 @@ int main(int argc, char** argv)
// else if (!strcmp(argv[i], "stencil")
// stereomode = RAS_STEREO_STENCIL;
#endif
+ else
+ {
+ error = true;
+ printf("error: stereomode '%s' unrecognized.\n", argv[i]);
+ }
i++;
- stereoParFound = true;
- stereoFlag = STEREO_ENABLED;
}
else
{
@@ -689,7 +738,9 @@ int main(int argc, char** argv)
printf("error: too few options for stereo argument.\n");
}
break;
- case 'D':
+ }
+ case 'D': //dome mode
+ {
stereoFlag = STEREO_DOME;
stereomode = RAS_IRasterizer::RAS_STEREO_DOME;
i++;
@@ -730,10 +781,13 @@ int main(int argc, char** argv)
i++;
}
break;
- default:
+ }
+ default: //not recognized
+ {
printf("Unknown argument: %s\n", argv[i++]);
break;
}
+ }
}
else
{
@@ -825,8 +879,10 @@ int main(int argc, char** argv)
else {
bfd = load_game_data(BLI_program_path(), filename[0]? filename: NULL);
}
-
- //::printf("game data loaded from %s\n", filename);
+
+#if defined(DEBUG)
+ printf("Game data loaded from %s\n", filename);
+#endif
if (!bfd) {
usage(argv[0], isBlenderPlayer);
@@ -834,6 +890,7 @@ int main(int argc, char** argv)
exitcode = KX_EXIT_REQUEST_QUIT_GAME;
}
else {
+ /* Setting options according to the blend file if not overriden in the command line */
#ifdef WIN32
#if !defined(DEBUG)
if (closeConsole) {
@@ -877,8 +934,9 @@ int main(int argc, char** argv)
}
- // Check whether the game should be displayed in stereo
+ // Check whether the game should be displayed in stereo (dome included)
if (!stereoParFound) {
+ // Only use file settings when command line did not override
if (scene->gm.stereoflag == STEREO_ENABLED) {
stereomode = (RAS_IRasterizer::StereoMode) scene->gm.stereomode;
if (stereomode == RAS_IRasterizer::RAS_STEREO_QUADBUFFERED)
@@ -892,6 +950,7 @@ int main(int argc, char** argv)
if (!samplesParFound)
aasamples = scene->gm.aasamples;
+ // Dome specific settings
if (stereoFlag == STEREO_DOME) {
stereomode = RAS_IRasterizer::RAS_STEREO_DOME;
scene->gm.stereoflag = STEREO_DOME;
diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp
index a974ffbf672..a50c07a486a 100644
--- a/source/gameengine/Ketsji/BL_Action.cpp
+++ b/source/gameengine/Ketsji/BL_Action.cpp
@@ -51,10 +51,14 @@ extern "C" {
#include "DNA_material_types.h"
}
+#include "MEM_guardedalloc.h"
+#include "BKE_library.h"
+#include "BKE_global.h"
+
BL_Action::BL_Action(class KX_GameObject* gameobj)
:
m_action(NULL),
- m_pose(NULL),
+ m_tmpaction(NULL),
m_blendpose(NULL),
m_blendinpose(NULL),
m_obj(gameobj),
@@ -77,13 +81,16 @@ BL_Action::BL_Action(class KX_GameObject* gameobj)
BL_Action::~BL_Action()
{
- if (m_pose)
- game_free_pose(m_pose);
if (m_blendpose)
- game_free_pose(m_blendpose);
+ BKE_pose_free(m_blendpose);
if (m_blendinpose)
- game_free_pose(m_blendinpose);
+ BKE_pose_free(m_blendinpose);
ClearControllerList();
+
+ if (m_tmpaction) {
+ BKE_libblock_free(G.main, m_tmpaction);
+ m_tmpaction = NULL;
+ }
}
void BL_Action::ClearControllerList()
@@ -139,6 +146,13 @@ bool BL_Action::Play(const char* name,
&& m_priority == priority && m_speed == playback_speed)
return false;
+ // Keep a copy of the action for threading purposes
+ if (m_tmpaction) {
+ BKE_libblock_free(G.main, m_tmpaction);
+ m_tmpaction = NULL;
+ }
+ m_tmpaction = BKE_action_copy(m_action);
+
// First get rid of any old controllers
ClearControllerList();
@@ -208,7 +222,7 @@ bool BL_Action::Play(const char* name,
if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE)
{
BL_ArmatureObject *obj = (BL_ArmatureObject*)m_obj;
- obj->GetMRDPose(&m_blendinpose);
+ obj->GetPose(&m_blendinpose);
}
else
{
@@ -402,22 +416,12 @@ void BL_Action::Update(float curtime)
if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE)
{
BL_ArmatureObject *obj = (BL_ArmatureObject*)m_obj;
- obj->GetPose(&m_pose);
-
- // Extract the pose from the action
- {
- Object *arm = obj->GetArmatureObject();
- bPose *temp = arm->pose;
-
- arm->pose = m_pose;
-
- PointerRNA ptrrna;
- RNA_id_pointer_create(&arm->id, &ptrrna);
- animsys_evaluate_action(&ptrrna, m_action, NULL, m_localtime);
+ if (m_layer_weight >= 0)
+ obj->GetPose(&m_blendpose);
- arm->pose = temp;
- }
+ // Extract the pose from the action
+ obj->SetPoseByAction(m_tmpaction, m_localtime);
// Handle blending between armature actions
if (m_blendin && m_blendframe<m_blendin)
@@ -428,20 +432,15 @@ void BL_Action::Update(float curtime)
float weight = 1.f - (m_blendframe/m_blendin);
// Blend the poses
- game_blend_poses(m_pose, m_blendinpose, weight, ACT_BLEND_BLEND);
+ obj->BlendInPose(m_blendinpose, weight, ACT_BLEND_BLEND);
}
// Handle layer blending
if (m_layer_weight >= 0)
- {
- obj->GetMRDPose(&m_blendpose);
- game_blend_poses(m_pose, m_blendpose, m_layer_weight, m_blendmode);
- }
-
- obj->SetPose(m_pose);
+ obj->BlendInPose(m_blendpose, m_layer_weight, m_blendmode);
- obj->SetActiveAction(NULL, 0, curtime);
+ obj->UpdateTimestep(curtime);
}
else
{
@@ -456,7 +455,7 @@ void BL_Action::Update(float curtime)
PointerRNA ptrrna;
RNA_id_pointer_create(&key->id, &ptrrna);
- animsys_evaluate_action(&ptrrna, m_action, NULL, m_localtime);
+ animsys_evaluate_action(&ptrrna, m_tmpaction, NULL, m_localtime);
// Handle blending between shape actions
if (m_blendin && m_blendframe < m_blendin)
@@ -486,8 +485,15 @@ void BL_Action::Update(float curtime)
}
}
- m_obj->UpdateIPO(m_localtime, m_ipo_flags & ACT_IPOFLAG_CHILD);
+ // This isn't thread-safe, so we move it into it's own function for now
+ //m_obj->UpdateIPO(m_localtime, m_ipo_flags & ACT_IPOFLAG_CHILD);
if (m_done)
ClearControllerList();
}
+
+void BL_Action::UpdateIPOs()
+{
+ if (!m_done)
+ m_obj->UpdateIPO(m_localtime, m_ipo_flags & ACT_IPOFLAG_CHILD);
+}
diff --git a/source/gameengine/Ketsji/BL_Action.h b/source/gameengine/Ketsji/BL_Action.h
index e9d09916517..dd1cd1f69ff 100644
--- a/source/gameengine/Ketsji/BL_Action.h
+++ b/source/gameengine/Ketsji/BL_Action.h
@@ -38,7 +38,7 @@ class BL_Action
{
private:
struct bAction* m_action;
- struct bPose* m_pose;
+ struct bAction* m_tmpaction;
struct bPose* m_blendpose;
struct bPose* m_blendinpose;
std::vector<class SG_Controller*> m_sg_contr_list;
@@ -105,6 +105,10 @@ public:
* Update the action's frame, etc.
*/
void Update(float curtime);
+ /**
+ * Update object IPOs (note: not thread-safe!)
+ */
+ void UpdateIPOs();
// Accessors
float GetFrame();
diff --git a/source/gameengine/Ketsji/BL_ActionManager.cpp b/source/gameengine/Ketsji/BL_ActionManager.cpp
index 2e882ceba74..07adce73b4a 100644
--- a/source/gameengine/Ketsji/BL_ActionManager.cpp
+++ b/source/gameengine/Ketsji/BL_ActionManager.cpp
@@ -24,44 +24,72 @@
* \ingroup ketsji
*/
-#include "BL_ActionManager.h"
#include "BL_Action.h"
+#include "BL_ActionManager.h"
-BL_ActionManager::BL_ActionManager(class KX_GameObject *obj)
+BL_ActionManager::BL_ActionManager(class KX_GameObject *obj):
+ m_obj(obj)
{
- for (int i=0; i<MAX_ACTION_LAYERS; ++i)
- m_layers[i] = new BL_Action(obj);
}
BL_ActionManager::~BL_ActionManager()
{
- for (int i=0; i<MAX_ACTION_LAYERS; ++i)
- delete m_layers[i];
+ BL_ActionMap::iterator it;
+
+ for (it = m_layers.begin(); it != m_layers.end(); it++)
+ delete it->second;
+
+ m_layers.clear();
+}
+
+BL_Action *BL_ActionManager::GetAction(short layer)
+{
+ BL_ActionMap::iterator it = m_layers.find(layer);
+
+ return (it != m_layers.end()) ? it->second : 0;
+}
+
+BL_Action* BL_ActionManager::AddAction(short layer)
+{
+ BL_Action *action = new BL_Action(m_obj);
+ m_layers[layer] = action;
+
+ return action;
}
float BL_ActionManager::GetActionFrame(short layer)
{
- return m_layers[layer]->GetFrame();
+ BL_Action *action = GetAction(layer);
+
+ return action ? action->GetFrame() : 0.f;
}
void BL_ActionManager::SetActionFrame(short layer, float frame)
{
- m_layers[layer]->SetFrame(frame);
+ BL_Action *action = GetAction(layer);
+
+ if (action) action->SetFrame(frame);
}
struct bAction *BL_ActionManager::GetCurrentAction(short layer)
{
- return m_layers[layer]->GetAction();
+ BL_Action *action = GetAction(layer);
+
+ return action ? action->GetAction() : 0;
}
void BL_ActionManager::SetPlayMode(short layer, short mode)
{
- m_layers[layer]->SetPlayMode(mode);
+ BL_Action *action = GetAction(layer);
+
+ if (action) action->SetPlayMode(mode);
}
void BL_ActionManager::SetTimes(short layer, float start, float end)
{
- m_layers[layer]->SetTimes(start, end);
+ BL_Action *action = GetAction(layer);
+
+ if (action) action->SetTimes(start, end);
}
bool BL_ActionManager::PlayAction(const char* name,
@@ -76,29 +104,53 @@ bool BL_ActionManager::PlayAction(const char* name,
float playback_speed,
short blend_mode)
{
+ // Only this method will create layer if non-existent
+ BL_Action *action = GetAction(layer);
+ if (!action)
+ action = AddAction(layer);
+
// Disable layer blending on the first layer
if (layer == 0) layer_weight = -1.f;
- return m_layers[layer]->Play(name, start, end, priority, blendin, play_mode, layer_weight, ipo_flags, playback_speed, blend_mode);
+ return action->Play(name, start, end, priority, blendin, play_mode, layer_weight, ipo_flags, playback_speed, blend_mode);
}
void BL_ActionManager::StopAction(short layer)
{
- m_layers[layer]->Stop();
+ BL_Action *action = GetAction(layer);
+
+ if (action) action->Stop();
}
bool BL_ActionManager::IsActionDone(short layer)
{
- return m_layers[layer]->IsDone();
+ BL_Action *action = GetAction(layer);
+
+ return action ? action->IsDone() : true;
}
void BL_ActionManager::Update(float curtime)
{
- for (int i=0; i<MAX_ACTION_LAYERS; ++i)
+ BL_ActionMap::iterator it;
+ for (it = m_layers.begin(); it != m_layers.end(); )
{
- if (!m_layers[i]->IsDone())
- {
- m_layers[i]->Update(curtime);
+ if (it->second->IsDone()) {
+ delete it->second;
+ m_layers.erase(it++);
}
+ else {
+ it->second->Update(curtime);
+ ++it;
+ }
+ }
+}
+
+void BL_ActionManager::UpdateIPOs()
+{
+ BL_ActionMap::iterator it;
+ for (it = m_layers.begin(); it != m_layers.end(); ++it)
+ {
+ if (!it->second->IsDone())
+ it->second->UpdateIPOs();
}
}
diff --git a/source/gameengine/Ketsji/BL_ActionManager.h b/source/gameengine/Ketsji/BL_ActionManager.h
index 8c5b8e909da..5b340257881 100644
--- a/source/gameengine/Ketsji/BL_ActionManager.h
+++ b/source/gameengine/Ketsji/BL_ActionManager.h
@@ -31,7 +31,12 @@
#include "MEM_guardedalloc.h"
#endif
-#define MAX_ACTION_LAYERS 8
+#include <map>
+
+// Currently, we use the max value of a short.
+// We should switch to unsigned short; doesn't make sense to support negative layers.
+// This will also give us 64k layers instead of 32k.
+#define MAX_ACTION_LAYERS 32767
class BL_Action;
@@ -41,7 +46,20 @@ class BL_Action;
class BL_ActionManager
{
private:
- BL_Action* m_layers[MAX_ACTION_LAYERS];
+ typedef std::map<short,BL_Action*> BL_ActionMap;
+
+ class KX_GameObject* m_obj;
+ BL_ActionMap m_layers;
+
+ /**
+ * Check if an action exists
+ */
+ BL_Action* GetAction(short layer);
+
+ /**
+ * Add new action with given layer
+ */
+ BL_Action* AddAction(short layer);
public:
BL_ActionManager(class KX_GameObject* obj);
@@ -98,6 +116,11 @@ public:
*/
void Update(float);
+ /**
+ * Update object IPOs (note: not thread-safe!)
+ */
+ void UpdateIPOs();
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_ActionManager")
#endif
diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt
index 141dd5e25f3..09ef1677d7c 100644
--- a/source/gameengine/Ketsji/CMakeLists.txt
+++ b/source/gameengine/Ketsji/CMakeLists.txt
@@ -77,7 +77,6 @@ set(SRC
KX_CharacterWrapper.cpp
KX_ConstraintActuator.cpp
KX_ConstraintWrapper.cpp
- KX_ConvertPhysicsObjects.cpp
KX_Dome.cpp
KX_EmptyObject.cpp
KX_FontObject.cpp
@@ -151,7 +150,6 @@ set(SRC
KX_ClientObjectInfo.h
KX_ConstraintActuator.h
KX_ConstraintWrapper.h
- KX_ConvertPhysicsObject.h
KX_Dome.h
KX_EmptyObject.h
KX_FontObject.h
diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp
index 0c5e21322df..e5662b54b83 100644
--- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp
+++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp
@@ -342,7 +342,6 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame)
KX_GameObject *parent = obj->GetParent();
if (parent) {
spc = parent->GetPhysicsController();
- parent->Release();
}
}
KX_RayCast::Callback<KX_ConstraintActuator> callback(this,dynamic_cast<PHY_IPhysicsController*>(spc));
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
deleted file mode 100644
index 0ebaec9c3ab..00000000000
--- a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file KX_ConvertPhysicsObject.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_CONVERTPHYSICSOBJECT_H__
-#define __KX_CONVERTPHYSICSOBJECT_H__
-
-class RAS_MeshObject;
-class KX_Scene;
-struct DerivedMesh;
-
-typedef enum {
- KX_BOUNDBOX,
- KX_BOUNDSPHERE,
- KX_BOUNDCYLINDER,
- KX_BOUNDCONE,
- KX_BOUNDMESH,
- KX_BOUNDPOLYTOPE,
- KX_BOUND_DYN_MESH,
- KX_BOUNDCAPSULE
-} KX_BoundBoxClass;
-
-struct KX_BoxBounds
-{
- float m_center[3];
- float m_extends[3];
-};
-
-/* Cone/Cylinder */
-struct KX_CBounds
-{
- float m_radius;
- float m_height;
-};
-
-
-struct KX_ObjectProperties
-{
- bool m_dyna;
- bool m_softbody;
- double m_radius;
- bool m_angular_rigidbody;
- bool m_in_active_layer;
- bool m_ghost;
- class KX_GameObject* m_dynamic_parent;
- bool m_isactor;
- bool m_record_animation;
- bool m_sensor;
- bool m_character;
- bool m_concave;
- bool m_isdeformable;
- bool m_disableSleeping;
- bool m_hasCompoundChildren;
- bool m_isCompoundChild;
-
- /////////////////////////
-
- int m_gamesoftFlag;
- float m_soft_linStiff; /* linear stiffness 0..1 */
- float m_soft_angStiff; /* angular stiffness 0..1 */
- float m_soft_volume; /* volume preservation 0..1 */
-
- int m_soft_viterations; /* Velocities solver iterations */
- int m_soft_piterations; /* Positions solver iterations */
- int m_soft_diterations; /* Drift solver iterations */
- int m_soft_citerations; /* Cluster solver iterations */
-
- float m_soft_kSRHR_CL; /* Soft vs rigid hardness [0,1] (cluster only) */
- float m_soft_kSKHR_CL; /* Soft vs kinetic hardness [0,1] (cluster only) */
- float m_soft_kSSHR_CL; /* Soft vs soft hardness [0,1] (cluster only) */
- float m_soft_kSR_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
-
- float m_soft_kSK_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
- float m_soft_kSS_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
- float m_soft_kVCF; /* Velocities correction factor (Baumgarte) */
- float m_soft_kDP; /* Damping coefficient [0,1] */
-
- float m_soft_kDG; /* Drag coefficient [0,+inf] */
- float m_soft_kLF; /* Lift coefficient [0,+inf] */
- float m_soft_kPR; /* Pressure coefficient [-inf,+inf] */
- float m_soft_kVC; /* Volume conversation coefficient [0,+inf] */
-
- float m_soft_kDF; /* Dynamic friction coefficient [0,1] */
- float m_soft_kMT; /* Pose matching coefficient [0,1] */
- float m_soft_kCHR; /* Rigid contacts hardness [0,1] */
- float m_soft_kKHR; /* Kinetic contacts hardness [0,1] */
-
- float m_soft_kSHR; /* Soft contacts hardness [0,1] */
- float m_soft_kAHR; /* Anchors hardness [0,1] */
- int m_soft_collisionflags; /* Vertex/Face or Signed Distance Field(SDF) or Clusters, Soft versus Soft or Rigid */
- int m_soft_numclusteriterations; /* number of iterations to refine collision clusters*/
- float m_soft_welding; /* threshold to remove duplicate/nearby vertices */
-
- /////////////////////////
-
- bool m_lockXaxis;
- bool m_lockYaxis;
- bool m_lockZaxis;
- bool m_lockXRotaxis;
- bool m_lockYRotaxis;
- bool m_lockZRotaxis;
-
- /////////////////////////
- double m_margin;
- float m_contactProcessingThreshold;
-
- KX_BoundBoxClass m_boundclass;
- union {
- KX_BoxBounds box;
- KX_CBounds c;
- } m_boundobject;
-};
-
-#ifdef WITH_BULLET
-
-void KX_ConvertBulletObject( class KX_GameObject* gameobj,
- class RAS_MeshObject* meshobj,
- struct DerivedMesh* dm,
- class KX_Scene* kxscene,
- struct PHY_ShapeProps* shapeprops,
- struct PHY_MaterialProps* smmaterial,
- struct KX_ObjectProperties* objprop);
-
-void KX_ClearBulletSharedShapes();
-bool KX_ReInstanceBulletShapeFromMesh(KX_GameObject *gameobj, KX_GameObject *from_gameobj, RAS_MeshObject* from_meshobj);
-
-#endif
-#endif /* __KX_CONVERTPHYSICSOBJECT_H__ */
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
deleted file mode 100644
index ff5522ee7d2..00000000000
--- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
+++ /dev/null
@@ -1,584 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
- * \ingroup ketsji
- */
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786)
-#endif
-
-#include "MT_assert.h"
-
-#include "KX_SoftBodyDeformer.h"
-#include "KX_ConvertPhysicsObject.h"
-#include "BL_DeformableGameObject.h"
-#include "RAS_MeshObject.h"
-#include "KX_Scene.h"
-#include "BL_System.h"
-
-#include "PHY_Pro.h" //todo cleanup
-#include "KX_ClientObjectInfo.h"
-
-#include "CTR_Map.h"
-#include "CTR_HashedPtr.h"
-
-#include "KX_PhysicsEngineEnums.h"
-
-#include "KX_MotionState.h" // bridge between motionstate and scenegraph node
-
-extern "C"{
- #include "BLI_utildefines.h"
- #include "BKE_DerivedMesh.h"
-}
-
-#ifdef WITH_BULLET
-#include "BulletSoftBody/btSoftBody.h"
-
-#include "CcdPhysicsEnvironment.h"
-#include "CcdPhysicsController.h"
-#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h"
-
-#include "btBulletDynamicsCommon.h"
-
-#ifdef WIN32
-#if defined(_MSC_VER) && (_MSC_VER >= 1310)
-//only use SIMD Hull code under Win32
-//#define TEST_HULL 1
-#ifdef TEST_HULL
-#define USE_HULL 1
-//#define TEST_SIMD_HULL 1
-
-#include "NarrowPhaseCollision/Hull.h"
-#endif //#ifdef TEST_HULL
-
-#endif //_MSC_VER
-#endif //WIN32
-
-
-
-// forward declarations
-
-void KX_ConvertBulletObject( class KX_GameObject* gameobj,
- class RAS_MeshObject* meshobj,
- struct DerivedMesh* dm,
- class KX_Scene* kxscene,
- struct PHY_ShapeProps* shapeprops,
- struct PHY_MaterialProps* smmaterial,
- struct KX_ObjectProperties* objprop)
-{
-
- CcdPhysicsEnvironment* env = (CcdPhysicsEnvironment*)kxscene->GetPhysicsEnvironment();
- assert(env);
-
-
- bool isbulletdyna = false;
- bool isbulletsensor = false;
- bool isbulletchar = false;
- bool useGimpact = false;
- CcdConstructionInfo ci;
- class PHY_IMotionState* motionstate = new KX_MotionState(gameobj->GetSGNode());
- class CcdShapeConstructionInfo *shapeInfo = new CcdShapeConstructionInfo();
-
-
- if (!objprop->m_dyna)
- {
- ci.m_collisionFlags |= btCollisionObject::CF_STATIC_OBJECT;
- }
- if (objprop->m_ghost)
- {
- ci.m_collisionFlags |= btCollisionObject::CF_NO_CONTACT_RESPONSE;
- }
-
- ci.m_MotionState = motionstate;
- ci.m_gravity = btVector3(0,0,0);
- ci.m_linearFactor = btVector3(objprop->m_lockXaxis? 0 : 1,
- objprop->m_lockYaxis? 0 : 1,
- objprop->m_lockZaxis? 0 : 1);
- ci.m_angularFactor = btVector3(objprop->m_lockXRotaxis? 0 : 1,
- objprop->m_lockYRotaxis? 0 : 1,
- objprop->m_lockZRotaxis? 0 : 1);
- ci.m_localInertiaTensor =btVector3(0,0,0);
- ci.m_mass = objprop->m_dyna ? shapeprops->m_mass : 0.f;
- ci.m_clamp_vel_min = shapeprops->m_clamp_vel_min;
- ci.m_clamp_vel_max = shapeprops->m_clamp_vel_max;
- ci.m_margin = objprop->m_margin;
- ci.m_stepHeight = objprop->m_character ? shapeprops->m_step_height : 0.f;
- ci.m_jumpSpeed = objprop->m_character ? shapeprops->m_jump_speed : 0.f;
- ci.m_fallSpeed = objprop->m_character ? shapeprops->m_fall_speed : 0.f;
- shapeInfo->m_radius = objprop->m_radius;
- isbulletdyna = objprop->m_dyna;
- isbulletsensor = objprop->m_sensor;
- isbulletchar = objprop->m_character;
- useGimpact = ((isbulletdyna || isbulletsensor) && !objprop->m_softbody);
-
- ci.m_localInertiaTensor = btVector3(ci.m_mass/3.f,ci.m_mass/3.f,ci.m_mass/3.f);
-
- btCollisionShape* bm = 0;
-
- switch (objprop->m_boundclass)
- {
- case KX_BOUNDSPHERE:
- {
- //float radius = objprop->m_radius;
- //btVector3 inertiaHalfExtents (
- // radius,
- // radius,
- // radius);
-
- //blender doesn't support multisphere, but for testing:
-
- //bm = new MultiSphereShape(inertiaHalfExtents,,&trans.getOrigin(),&radius,1);
- shapeInfo->m_shapeType = PHY_SHAPE_SPHERE;
- bm = shapeInfo->CreateBulletShape(ci.m_margin);
- break;
- };
- case KX_BOUNDBOX:
- {
- shapeInfo->m_halfExtend.setValue(
- objprop->m_boundobject.box.m_extends[0],
- objprop->m_boundobject.box.m_extends[1],
- objprop->m_boundobject.box.m_extends[2]);
-
- shapeInfo->m_halfExtend /= 2.0;
- shapeInfo->m_halfExtend = shapeInfo->m_halfExtend.absolute();
- shapeInfo->m_shapeType = PHY_SHAPE_BOX;
- bm = shapeInfo->CreateBulletShape(ci.m_margin);
- break;
- };
- case KX_BOUNDCYLINDER:
- {
- shapeInfo->m_halfExtend.setValue(
- objprop->m_boundobject.c.m_radius,
- objprop->m_boundobject.c.m_radius,
- objprop->m_boundobject.c.m_height * 0.5f
- );
- shapeInfo->m_shapeType = PHY_SHAPE_CYLINDER;
- bm = shapeInfo->CreateBulletShape(ci.m_margin);
- break;
- }
-
- case KX_BOUNDCONE:
- {
- shapeInfo->m_radius = objprop->m_boundobject.c.m_radius;
- shapeInfo->m_height = objprop->m_boundobject.c.m_height;
- shapeInfo->m_shapeType = PHY_SHAPE_CONE;
- bm = shapeInfo->CreateBulletShape(ci.m_margin);
- break;
- }
- case KX_BOUNDPOLYTOPE:
- {
- shapeInfo->SetMesh(meshobj, dm,true);
- bm = shapeInfo->CreateBulletShape(ci.m_margin);
- break;
- }
- case KX_BOUNDCAPSULE:
- {
- shapeInfo->m_radius = objprop->m_boundobject.c.m_radius;
- shapeInfo->m_height = objprop->m_boundobject.c.m_height;
- shapeInfo->m_shapeType = PHY_SHAPE_CAPSULE;
- bm = shapeInfo->CreateBulletShape(ci.m_margin);
- break;
- }
- case KX_BOUNDMESH:
- {
- // mesh shapes can be shared, check first if we already have a shape on that mesh
- class CcdShapeConstructionInfo *sharedShapeInfo = CcdShapeConstructionInfo::FindMesh(meshobj, dm, false);
- if (sharedShapeInfo != NULL)
- {
- shapeInfo->Release();
- shapeInfo = sharedShapeInfo;
- shapeInfo->AddRef();
- } else
- {
- shapeInfo->SetMesh(meshobj, dm, false);
- }
-
- // Soft bodies can benefit from welding, don't do it on non-soft bodies
- if (objprop->m_softbody)
- {
- shapeInfo->setVertexWeldingThreshold1(objprop->m_soft_welding); //todo: expose this to the UI
- }
-
- bm = shapeInfo->CreateBulletShape(ci.m_margin, useGimpact, !objprop->m_softbody);
- //should we compute inertia for dynamic shape?
- //bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor);
-
- break;
- }
- case KX_BOUND_DYN_MESH:
- /* do nothing */
- break;
- }
-
-
-// ci.m_localInertiaTensor.setValue(0.1f,0.1f,0.1f);
-
- if (!bm)
- {
- delete motionstate;
- shapeInfo->Release();
- return;
- }
-
- //bm->setMargin(ci.m_margin);
-
-
- if (objprop->m_isCompoundChild)
- {
- //find parent, compound shape and add to it
- //take relative transform into account!
- CcdPhysicsController* parentCtrl = (CcdPhysicsController*)objprop->m_dynamic_parent->GetPhysicsController();
- assert(parentCtrl);
- CcdShapeConstructionInfo* parentShapeInfo = parentCtrl->GetShapeInfo();
- btRigidBody* rigidbody = parentCtrl->GetRigidBody();
- btCollisionShape* colShape = rigidbody->getCollisionShape();
- assert(colShape->isCompound());
- btCompoundShape* compoundShape = (btCompoundShape*)colShape;
-
- // compute the local transform from parent, this may include several node in the chain
- SG_Node* gameNode = gameobj->GetSGNode();
- SG_Node* parentNode = objprop->m_dynamic_parent->GetSGNode();
- // relative transform
- MT_Vector3 parentScale = parentNode->GetWorldScaling();
- parentScale[0] = MT_Scalar(1.0)/parentScale[0];
- parentScale[1] = MT_Scalar(1.0)/parentScale[1];
- parentScale[2] = MT_Scalar(1.0)/parentScale[2];
- MT_Vector3 relativeScale = gameNode->GetWorldScaling() * parentScale;
- MT_Matrix3x3 parentInvRot = parentNode->GetWorldOrientation().transposed();
- MT_Vector3 relativePos = parentInvRot*((gameNode->GetWorldPosition()-parentNode->GetWorldPosition())*parentScale);
- MT_Matrix3x3 relativeRot = parentInvRot*gameNode->GetWorldOrientation();
-
- shapeInfo->m_childScale.setValue(relativeScale[0],relativeScale[1],relativeScale[2]);
- bm->setLocalScaling(shapeInfo->m_childScale);
- shapeInfo->m_childTrans.getOrigin().setValue(relativePos[0],relativePos[1],relativePos[2]);
- float rot[12];
- relativeRot.getValue(rot);
- shapeInfo->m_childTrans.getBasis().setFromOpenGLSubMatrix(rot);
-
- parentShapeInfo->AddShape(shapeInfo);
- compoundShape->addChildShape(shapeInfo->m_childTrans,bm);
- //do some recalc?
- //recalc inertia for rigidbody
- if (!rigidbody->isStaticOrKinematicObject())
- {
- btVector3 localInertia;
- float mass = 1.f/rigidbody->getInvMass();
- compoundShape->calculateLocalInertia(mass,localInertia);
- rigidbody->setMassProps(mass,localInertia);
- }
- shapeInfo->Release();
- // delete motionstate as it's not used
- delete motionstate;
- return;
- }
-
- if (objprop->m_hasCompoundChildren)
- {
- // create a compound shape info
- CcdShapeConstructionInfo *compoundShapeInfo = new CcdShapeConstructionInfo();
- compoundShapeInfo->m_shapeType = PHY_SHAPE_COMPOUND;
- compoundShapeInfo->AddShape(shapeInfo);
- // create the compound shape manually as we already have the child shape
- btCompoundShape* compoundShape = new btCompoundShape();
- compoundShape->addChildShape(shapeInfo->m_childTrans,bm);
- // now replace the shape
- bm = compoundShape;
- shapeInfo->Release();
- shapeInfo = compoundShapeInfo;
- }
-
-
-
-
-
-
-#ifdef TEST_SIMD_HULL
- if (bm->IsPolyhedral())
- {
- PolyhedralConvexShape* polyhedron = static_cast<PolyhedralConvexShape*>(bm);
- if (!polyhedron->m_optionalHull)
- {
- //first convert vertices in 'Point3' format
- int numPoints = polyhedron->GetNumVertices();
- Point3* points = new Point3[numPoints+1];
- //first 4 points should not be co-planar, so add central point to satisfy MakeHull
- points[0] = Point3(0.f,0.f,0.f);
-
- btVector3 vertex;
- for (int p=0;p<numPoints;p++)
- {
- polyhedron->GetVertex(p,vertex);
- points[p+1] = Point3(vertex.getX(),vertex.getY(),vertex.getZ());
- }
-
- Hull* hull = Hull::MakeHull(numPoints+1,points);
- polyhedron->m_optionalHull = hull;
- }
-
- }
-#endif //TEST_SIMD_HULL
-
-
- ci.m_collisionShape = bm;
- ci.m_shapeInfo = shapeInfo;
- ci.m_friction = smmaterial->m_friction;//tweak the friction a bit, so the default 0.5 works nice
- ci.m_restitution = smmaterial->m_restitution;
- ci.m_physicsEnv = env;
- // drag / damping is inverted
- ci.m_linearDamping = 1.f - shapeprops->m_lin_drag;
- ci.m_angularDamping = 1.f - shapeprops->m_ang_drag;
- //need a bit of damping, else system doesn't behave well
- ci.m_inertiaFactor = shapeprops->m_inertia/0.4f;//defaults to 0.4, don't want to change behavior
-
- ci.m_do_anisotropic = shapeprops->m_do_anisotropic;
- ci.m_anisotropicFriction.setValue(shapeprops->m_friction_scaling[0],shapeprops->m_friction_scaling[1],shapeprops->m_friction_scaling[2]);
-
-
-//////////
- //do Fh, do Rot Fh
- ci.m_do_fh = shapeprops->m_do_fh;
- ci.m_do_rot_fh = shapeprops->m_do_rot_fh;
- ci.m_fh_damping = smmaterial->m_fh_damping;
- ci.m_fh_distance = smmaterial->m_fh_distance;
- ci.m_fh_normal = smmaterial->m_fh_normal;
- ci.m_fh_spring = smmaterial->m_fh_spring;
- ci.m_radius = objprop->m_radius;
-
-
- ///////////////////
- ci.m_gamesoftFlag = objprop->m_gamesoftFlag;
- ci.m_soft_linStiff = objprop->m_soft_linStiff;
- ci.m_soft_angStiff = objprop->m_soft_angStiff; /* angular stiffness 0..1 */
- ci.m_soft_volume= objprop->m_soft_volume; /* volume preservation 0..1 */
-
- ci.m_soft_viterations= objprop->m_soft_viterations; /* Velocities solver iterations */
- ci.m_soft_piterations= objprop->m_soft_piterations; /* Positions solver iterations */
- ci.m_soft_diterations= objprop->m_soft_diterations; /* Drift solver iterations */
- ci.m_soft_citerations= objprop->m_soft_citerations; /* Cluster solver iterations */
-
- ci.m_soft_kSRHR_CL= objprop->m_soft_kSRHR_CL; /* Soft vs rigid hardness [0,1] (cluster only) */
- ci.m_soft_kSKHR_CL= objprop->m_soft_kSKHR_CL; /* Soft vs kinetic hardness [0,1] (cluster only) */
- ci.m_soft_kSSHR_CL= objprop->m_soft_kSSHR_CL; /* Soft vs soft hardness [0,1] (cluster only) */
- ci.m_soft_kSR_SPLT_CL= objprop->m_soft_kSR_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
-
- ci.m_soft_kSK_SPLT_CL= objprop->m_soft_kSK_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
- ci.m_soft_kSS_SPLT_CL= objprop->m_soft_kSS_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
- ci.m_soft_kVCF= objprop->m_soft_kVCF; /* Velocities correction factor (Baumgarte) */
- ci.m_soft_kDP= objprop->m_soft_kDP; /* Damping coefficient [0,1] */
-
- ci.m_soft_kDG= objprop->m_soft_kDG; /* Drag coefficient [0,+inf] */
- ci.m_soft_kLF= objprop->m_soft_kLF; /* Lift coefficient [0,+inf] */
- ci.m_soft_kPR= objprop->m_soft_kPR; /* Pressure coefficient [-inf,+inf] */
- ci.m_soft_kVC= objprop->m_soft_kVC; /* Volume conversation coefficient [0,+inf] */
-
- ci.m_soft_kDF= objprop->m_soft_kDF; /* Dynamic friction coefficient [0,1] */
- ci.m_soft_kMT= objprop->m_soft_kMT; /* Pose matching coefficient [0,1] */
- ci.m_soft_kCHR= objprop->m_soft_kCHR; /* Rigid contacts hardness [0,1] */
- ci.m_soft_kKHR= objprop->m_soft_kKHR; /* Kinetic contacts hardness [0,1] */
-
- ci.m_soft_kSHR= objprop->m_soft_kSHR; /* Soft contacts hardness [0,1] */
- ci.m_soft_kAHR= objprop->m_soft_kAHR; /* Anchors hardness [0,1] */
- ci.m_soft_collisionflags= objprop->m_soft_collisionflags; /* Vertex/Face or Signed Distance Field(SDF) or Clusters, Soft versus Soft or Rigid */
- ci.m_soft_numclusteriterations= objprop->m_soft_numclusteriterations; /* number of iterations to refine collision clusters*/
-
- ////////////////////
- ci.m_collisionFilterGroup =
- (isbulletsensor) ? short(CcdConstructionInfo::SensorFilter) :
- (isbulletdyna) ? short(CcdConstructionInfo::DefaultFilter) :
- (isbulletchar) ? short(CcdConstructionInfo::CharacterFilter) :
- short(CcdConstructionInfo::StaticFilter);
- ci.m_collisionFilterMask =
- (isbulletsensor) ? short(CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter) :
- (isbulletdyna) ? short(CcdConstructionInfo::AllFilter) :
- (isbulletchar) ? short(CcdConstructionInfo::AllFilter) :
- short(CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::StaticFilter);
- ci.m_bRigid = objprop->m_dyna && objprop->m_angular_rigidbody;
-
- ci.m_contactProcessingThreshold = objprop->m_contactProcessingThreshold;//todo: expose this in advanced settings, just like margin, default to 10000 or so
- ci.m_bSoft = objprop->m_softbody;
- ci.m_bDyna = isbulletdyna;
- ci.m_bSensor = isbulletsensor;
- ci.m_bCharacter = isbulletchar;
- ci.m_bGimpact = useGimpact;
- MT_Vector3 scaling = gameobj->NodeGetWorldScaling();
- ci.m_scaling.setValue(scaling[0], scaling[1], scaling[2]);
- CcdPhysicsController* physicscontroller = new CcdPhysicsController(ci);
- // shapeInfo is reference counted, decrement now as we don't use it anymore
- if (shapeInfo)
- shapeInfo->Release();
-
- gameobj->SetPhysicsController(physicscontroller,isbulletdyna);
-
- // record animation for dynamic objects
- if (isbulletdyna)
- gameobj->SetRecordAnimation(true);
-
- // don't add automatically sensor object, they are added when a collision sensor is registered
- if (!isbulletsensor && objprop->m_in_active_layer)
- {
- env->AddCcdPhysicsController( physicscontroller);
- }
- physicscontroller->SetNewClientInfo(gameobj->getClientInfo());
- {
- btRigidBody* rbody = physicscontroller->GetRigidBody();
-
- if (rbody)
- {
- if (objprop->m_angular_rigidbody)
- {
- rbody->setLinearFactor(ci.m_linearFactor);
- rbody->setAngularFactor(ci.m_angularFactor);
- }
-
- if (rbody && objprop->m_disableSleeping)
- {
- rbody->setActivationState(DISABLE_DEACTIVATION);
- }
- }
- }
-
- CcdPhysicsController* parentCtrl = objprop->m_dynamic_parent ? (CcdPhysicsController*)objprop->m_dynamic_parent->GetPhysicsController() : 0;
- physicscontroller->SetParentCtrl(parentCtrl);
-
-
- //Now done directly in ci.m_collisionFlags so that it propagates to replica
- //if (objprop->m_ghost)
- //{
- // rbody->setCollisionFlags(rbody->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE);
- //}
-
- if (objprop->m_dyna && !objprop->m_angular_rigidbody)
- {
-#if 0
- //setting the inertia could achieve similar results to constraint the up
- //but it is prone to instability, so use special 'Angular' constraint
- btVector3 inertia = physicscontroller->GetRigidBody()->getInvInertiaDiagLocal();
- inertia.setX(0.f);
- inertia.setZ(0.f);
-
- physicscontroller->GetRigidBody()->setInvInertiaDiagLocal(inertia);
- physicscontroller->GetRigidBody()->updateInertiaTensor();
-#endif
-
- //env->createConstraint(physicscontroller,0,PHY_ANGULAR_CONSTRAINT,0,0,0,0,0,1);
-
- //Now done directly in ci.m_bRigid so that it propagates to replica
- //physicscontroller->GetRigidBody()->setAngularFactor(0.f);
- ;
- }
-
- bool isActor = objprop->m_isactor;
- gameobj->getClientInfo()->m_type =
- (isbulletsensor) ? ((isActor) ? KX_ClientObjectInfo::OBACTORSENSOR : KX_ClientObjectInfo::OBSENSOR) :
- (isActor) ? KX_ClientObjectInfo::ACTOR : KX_ClientObjectInfo::STATIC;
-
- // should we record animation for this object?
- if (objprop->m_record_animation)
- gameobj->SetRecordAnimation(true);
-
- // store materialname in auxinfo, needed for touchsensors
- if (meshobj)
- {
- const STR_String& matname=meshobj->GetMaterialName(0);
- gameobj->getClientInfo()->m_auxilary_info = (matname.Length() ? (void*)(matname.ReadPtr()+2) : NULL);
- } else
- {
- gameobj->getClientInfo()->m_auxilary_info = 0;
- }
-
-
-
- STR_String materialname;
- if (meshobj)
- materialname = meshobj->GetMaterialName(0);
-
-
-#if 0
- ///test for soft bodies
- if (objprop->m_softbody && physicscontroller)
- {
- btSoftBody* softBody = physicscontroller->GetSoftBody();
- if (softBody && gameobj->GetMesh(0))//only the first mesh, if any
- {
- //should be a mesh then, so add a soft body deformer
- KX_SoftBodyDeformer* softbodyDeformer = new KX_SoftBodyDeformer( gameobj->GetMesh(0),(BL_DeformableGameObject*)gameobj);
- gameobj->SetDeformer(softbodyDeformer);
- }
- }
-#endif
-
-}
-
-
-void KX_ClearBulletSharedShapes()
-{
-}
-
-/* Refresh the physics object from either an object or a mesh.
- * gameobj must be valid
- * from_gameobj and from_meshobj can be NULL
- *
- * when setting the mesh, the following vars get priority
- * 1) from_meshobj - creates the phys mesh from RAS_MeshObject
- * 2) from_gameobj - creates the phys mesh from the DerivedMesh where possible, else the RAS_MeshObject
- * 3) gameobj - update the phys mesh from DerivedMesh or RAS_MeshObject
- *
- * Most of the logic behind this is in shapeInfo->UpdateMesh(...)
- */
-bool KX_ReInstanceBulletShapeFromMesh(KX_GameObject *gameobj, KX_GameObject *from_gameobj, RAS_MeshObject* from_meshobj)
-{
- CcdPhysicsController *spc= static_cast<CcdPhysicsController*>(gameobj->GetPhysicsController());
- CcdShapeConstructionInfo *shapeInfo;
-
- /* if this is the child of a compound shape this can happen
- * don't support compound shapes for now */
- if (spc==NULL)
- return false;
-
- shapeInfo = spc->GetShapeInfo();
-
- if (shapeInfo->m_shapeType != PHY_SHAPE_MESH/* || spc->GetSoftBody()*/)
- return false;
-
- spc->DeleteControllerShape();
-
- if (from_gameobj==NULL && from_meshobj==NULL)
- from_gameobj= gameobj;
-
- /* updates the arrays used for making the new bullet mesh */
- shapeInfo->UpdateMesh(from_gameobj, from_meshobj);
-
- /* create the new bullet mesh */
- CcdConstructionInfo& cci = spc->GetConstructionInfo();
- btCollisionShape* bm= shapeInfo->CreateBulletShape(cci.m_margin, cci.m_bGimpact, !cci.m_bSoft);
-
- spc->ReplaceControllerShape(bm);
- return true;
-}
-#endif // WITH_BULLET
diff --git a/source/gameengine/Ketsji/KX_FontObject.cpp b/source/gameengine/Ketsji/KX_FontObject.cpp
index a0266a54411..9789a8294ee 100644
--- a/source/gameengine/Ketsji/KX_FontObject.cpp
+++ b/source/gameengine/Ketsji/KX_FontObject.cpp
@@ -166,7 +166,7 @@ int GetFontId(VFont *vfont)
return fontid;
}
-void KX_FontObject::DrawText()
+void KX_FontObject::DrawFontText()
{
/* Allow for some logic brick control */
if (this->GetProperty("Text"))
diff --git a/source/gameengine/Ketsji/KX_FontObject.h b/source/gameengine/Ketsji/KX_FontObject.h
index 8b66accb797..209ab6ca69f 100644
--- a/source/gameengine/Ketsji/KX_FontObject.h
+++ b/source/gameengine/Ketsji/KX_FontObject.h
@@ -45,7 +45,7 @@ public:
virtual ~KX_FontObject();
- void DrawText();
+ void DrawFontText();
/**
* Inherited from CValue -- return a new copy of this
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index f1f12caed19..9ea76980c20 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -63,7 +63,6 @@ typedef unsigned long uint_ptr;
#include "KX_PythonInit.h"
#include "KX_PyMath.h"
#include "KX_PythonSeq.h"
-#include "KX_ConvertPhysicsObject.h"
#include "SCA_IActuator.h"
#include "SCA_ISensor.h"
#include "SCA_IController.h"
@@ -307,9 +306,6 @@ KX_GameObject* KX_GameObject::GetParent()
if (node)
result = (KX_GameObject*)node->GetSGClientObject();
}
-
- if (result)
- result->AddRef();
return result;
@@ -466,6 +462,11 @@ void KX_GameObject::UpdateActionManager(float curtime)
GetActionManager()->Update(curtime);
}
+void KX_GameObject::UpdateActionIPOs()
+{
+ GetActionManager()->UpdateIPOs();
+}
+
float KX_GameObject::GetActionFrame(short layer)
{
return GetActionManager()->GetActionFrame(layer);
@@ -759,7 +760,7 @@ void KX_GameObject::UpdateLod(MT_Vector3 &cam_pos)
Object *bob = this->GetBlenderObject();
LodLevel *lod = (LodLevel*) bob->lodlevels.first;
for (; lod; lod = lod->next, level++) {
- if (!lod->source) level--;
+ if (!lod->source || lod->source->type != OB_MESH) level--;
if (!lod->next || lod->next->distance * lod->next->distance > distance2) break;
}
@@ -1908,11 +1909,11 @@ PyObject *KX_GameObject::PyReinstancePhysicsMesh(PyObject *args)
) {
return NULL;
}
-#ifdef WITH_BULLET
+
/* gameobj and mesh can be NULL */
- if (KX_ReInstanceBulletShapeFromMesh(this, gameobj, mesh))
+ if (GetPhysicsController() && GetPhysicsController()->ReinstancePhysicsShape(gameobj, mesh))
Py_RETURN_TRUE;
-#endif
+
Py_RETURN_FALSE;
}
@@ -2114,7 +2115,6 @@ PyObject *KX_GameObject::pyattr_get_parent(void *self_v, const KX_PYATTRIBUTE_DE
KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
KX_GameObject* parent = self->GetParent();
if (parent) {
- parent->Release(); /* self->GetParent() AddRef's */
return parent->GetProxy();
}
Py_RETURN_NONE;
diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h
index ac0afca91eb..7450be4fdef 100644
--- a/source/gameengine/Ketsji/KX_GameObject.h
+++ b/source/gameengine/Ketsji/KX_GameObject.h
@@ -300,6 +300,12 @@ public:
*/
void UpdateActionManager(float curtime);
+ /**
+ * Have the action manager update IPOs
+ * note: not thread-safe!
+ */
+ void UpdateActionIPOs();
+
/*********************************
* End Animation API
*********************************/
diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
index 231590cde83..96a3845a439 100644
--- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
+++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
@@ -37,6 +37,8 @@
#include <iostream>
#include <stdio.h>
+#include "BLI_task.h"
+
#include "KX_KetsjiEngine.h"
#include "ListValue.h"
@@ -185,6 +187,7 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system)
m_pyprofiledict = PyDict_New();
#endif
+ m_taskscheduler = BLI_task_scheduler_create(TASK_SCHEDULER_AUTO_THREADS);
}
@@ -201,6 +204,9 @@ KX_KetsjiEngine::~KX_KetsjiEngine()
#ifdef WITH_PYTHON
Py_CLEAR(m_pyprofiledict);
#endif
+
+ if (m_taskscheduler)
+ BLI_task_scheduler_free(m_taskscheduler);
}
diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h
index 85cd8bba2de..9e5d1893320 100644
--- a/source/gameengine/Ketsji/KX_KetsjiEngine.h
+++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h
@@ -42,6 +42,7 @@
#include "KX_WorldInfo.h"
#include <vector>
+struct TaskScheduler;
class KX_TimeCategoryLogger;
#define LEFT_EYE 1
@@ -195,6 +196,9 @@ private:
/** Settings that doesn't go away with Game Actuator */
GlobalSettings m_globalsettings;
+ /** Task scheduler for multi-threading */
+ TaskScheduler* m_taskscheduler;
+
void RenderFrame(KX_Scene* scene, KX_Camera* cam);
void PostRenderScene(KX_Scene* scene);
void RenderDebugProperties();
@@ -225,6 +229,8 @@ public:
SCA_IInputDevice* GetKeyboardDevice() { return m_keyboarddevice; }
SCA_IInputDevice* GetMouseDevice() { return m_mousedevice; }
+ TaskScheduler* GetTaskScheduler() { return m_taskscheduler; }
+
/// Dome functions
void InitDome(short res, short mode, short angle, float resbuf, short tilt, struct Text* text);
void EndDome();
diff --git a/source/gameengine/Ketsji/KX_LightIpoSGController.h b/source/gameengine/Ketsji/KX_LightIpoSGController.h
index 8f5e8ba7187..151ced6b8f8 100644
--- a/source/gameengine/Ketsji/KX_LightIpoSGController.h
+++ b/source/gameengine/Ketsji/KX_LightIpoSGController.h
@@ -37,7 +37,7 @@
#include "KX_IInterpolator.h"
-struct RAS_ILightObject;
+class RAS_ILightObject;
class KX_LightIpoSGController : public SG_Controller
{
diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp
index c288c647fa2..a6f2f728674 100644
--- a/source/gameengine/Ketsji/KX_MeshProxy.cpp
+++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp
@@ -42,7 +42,6 @@
#include "KX_BlenderMaterial.h"
#include "KX_PyMath.h"
-#include "KX_ConvertPhysicsObject.h"
#include "PyObjectPlus.h"
diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp
index 84e615b61ab..0f47dfd922b 100644
--- a/source/gameengine/Ketsji/KX_RaySensor.cpp
+++ b/source/gameengine/Ketsji/KX_RaySensor.cpp
@@ -265,9 +265,6 @@ bool KX_RaySensor::Evaluate()
if (!spc && parent)
spc = parent->GetPhysicsController();
- if (parent)
- parent->Release();
-
PHY_IPhysicsEnvironment* physics_environment = this->m_scene->GetPhysicsEnvironment();
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index a9ac13c755f..c826f39517a 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -49,6 +49,7 @@
//#include "SCA_RandomEventManager.h"
//#include "KX_RayEventManager.h"
#include "SCA_2DFilterActuator.h"
+#include "SCA_PythonController.h"
#include "KX_TouchEventManager.h"
#include "SCA_KeyboardManager.h"
#include "SCA_MouseManager.h"
@@ -83,6 +84,7 @@
#include "NG_NetworkScene.h"
#include "PHY_IPhysicsEnvironment.h"
#include "PHY_IGraphicController.h"
+#include "PHY_IPhysicsController.h"
#include "KX_BlenderSceneConverter.h"
#include "KX_MotionState.h"
@@ -93,15 +95,14 @@
#ifdef WITH_BULLET
#include "KX_SoftBodyDeformer.h"
-#include "KX_ConvertPhysicsObject.h"
-#include "CcdPhysicsEnvironment.h"
-#include "CcdPhysicsController.h"
#endif
#include "KX_Light.h"
#include <stdio.h>
+#include "BLI_task.h"
+
static void *KX_SceneReplicationFunc(SG_IObject* node,void* gameobj,void* scene)
{
KX_GameObject* replica = ((KX_Scene*)scene)->AddNodeReplicaObject(node,(KX_GameObject*)gameobj);
@@ -562,7 +563,6 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal
newobj->SetGraphicController(newctrl);
}
-#ifdef WITH_BULLET
// replicate physics controller
if (orgobj->GetPhysicsController())
{
@@ -575,11 +575,7 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal
newctrl->SetNewClientInfo(newobj->getClientInfo());
newobj->SetPhysicsController(newctrl, newobj->IsDynamic());
newctrl->PostProcessReplica(motionstate, parentctrl);
-
- if (parent)
- parent->Release();
}
-#endif
return newobj;
}
@@ -759,8 +755,6 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level)
KX_GameObject *parent = gameobj->GetParent();
if (parent != NULL)
{
- parent->Release(); // GetParent() increased the refcount
-
// this object is not a top parent. Either it is the child of another
// object in the group and it will be added automatically when the parent
// is added. Or it is the child of an object outside the group and the group
@@ -1196,7 +1190,7 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj, bool use_gfx, bool u
static_cast<BL_ArmatureObject*>( parentobj )
);
releaseParent= false;
- modifierDeformer->LoadShapeDrivers(blendobj->parent);
+ modifierDeformer->LoadShapeDrivers(parentobj);
}
else
{
@@ -1224,7 +1218,7 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj, bool use_gfx, bool u
static_cast<BL_ArmatureObject*>( parentobj )
);
releaseParent= false;
- shapeDeformer->LoadShapeDrivers(blendobj->parent);
+ shapeDeformer->LoadShapeDrivers(parentobj);
}
else
{
@@ -1276,11 +1270,10 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj, bool use_gfx, bool u
gameobj->AddMeshUser();
}
-#ifdef WITH_BULLET
if (use_phys) { /* update the new assigned mesh with the physics mesh */
- KX_ReInstanceBulletShapeFromMesh(gameobj, NULL, use_gfx?NULL:mesh);
+ if (gameobj->GetPhysicsController())
+ gameobj->GetPhysicsController()->ReinstancePhysicsShape(NULL, use_gfx?NULL:mesh);
}
-#endif
}
/* Font Object routines */
@@ -1596,51 +1589,81 @@ void KX_Scene::AddAnimatedObject(CValue* gameobj)
m_animatedlist->Add(gameobj);
}
-void KX_Scene::UpdateAnimations(double curtime)
+static void update_anim_thread_func(TaskPool *pool, void *taskdata, int UNUSED(threadid))
{
- KX_GameObject *gameobj;
+ KX_GameObject *gameobj, *child;
+ CListValue *children;
bool needs_update;
+ double curtime = *(double*)BLI_task_pool_userdata(pool);
- for (int i=0; i<m_animatedlist->GetCount(); ++i) {
- gameobj = (KX_GameObject*)m_animatedlist->GetValue(i);
-
- // Non-armature updates are fast enough, so just update them
- needs_update = gameobj->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE;
+ gameobj = (KX_GameObject*)taskdata;
- if (!needs_update) {
- // If we got here, we're looking to update an armature, so check its children meshes
- // to see if we need to bother with a more expensive pose update
- CListValue *children = gameobj->GetChildren();
- KX_GameObject *child;
+ // Non-armature updates are fast enough, so just update them
+ needs_update = gameobj->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE;
- bool has_mesh = false, has_non_mesh = false;
+ if (!needs_update) {
+ // If we got here, we're looking to update an armature, so check its children meshes
+ // to see if we need to bother with a more expensive pose update
+ children = gameobj->GetChildren();
- // Check for meshes that haven't been culled
- for (int j=0; j<children->GetCount(); ++j) {
- child = (KX_GameObject*)children->GetValue(j);
+ bool has_mesh = false, has_non_mesh = false;
- if (!child->GetCulled()) {
- needs_update = true;
- break;
- }
+ // Check for meshes that haven't been culled
+ for (int j=0; j<children->GetCount(); ++j) {
+ child = (KX_GameObject*)children->GetValue(j);
- if (child->GetMeshCount() == 0)
- has_non_mesh = true;
- else
- has_mesh = true;
+ if (!child->GetCulled()) {
+ needs_update = true;
+ break;
}
- // If we didn't find a non-culled mesh, check to see
- // if we even have any meshes, and update if this
- // armature has only non-mesh children.
- if (!needs_update && !has_mesh && has_non_mesh)
- needs_update = true;
+ if (child->GetMeshCount() == 0)
+ has_non_mesh = true;
+ else
+ has_mesh = true;
+ }
+
+ // If we didn't find a non-culled mesh, check to see
+ // if we even have any meshes, and update if this
+ // armature has only non-mesh children.
+ if (!needs_update && !has_mesh && has_non_mesh)
+ needs_update = true;
- children->Release();
+ children->Release();
+ }
+
+ if (needs_update) {
+ gameobj->UpdateActionManager(curtime);
+ children = gameobj->GetChildren();
+
+ if (gameobj->GetDeformer())
+ gameobj->GetDeformer()->Update();
+
+ for (int j=0; j<children->GetCount(); ++j) {
+ child = (KX_GameObject*)children->GetValue(j);
+
+ if (child->GetDeformer()) {
+ child->GetDeformer()->Update();
+ }
}
- if (needs_update)
- gameobj->UpdateActionManager(curtime);
+ children->Release();
+ }
+}
+
+void KX_Scene::UpdateAnimations(double curtime)
+{
+ TaskPool *pool = BLI_task_pool_create(KX_GetActiveEngine()->GetTaskScheduler(), &curtime);
+
+ for (int i=0; i<m_animatedlist->GetCount(); ++i) {
+ BLI_task_pool_push(pool, update_anim_thread_func, m_animatedlist->GetValue(i), false, TASK_PRIORITY_LOW);
+ }
+
+ BLI_task_pool_work_and_wait(pool);
+ BLI_task_pool_free(pool);
+
+ for (int i=0; i<m_animatedlist->GetCount(); ++i) {
+ ((KX_GameObject*)m_animatedlist->GetValue(i))->UpdateActionIPOs();
}
}
@@ -1721,7 +1744,7 @@ void KX_Scene::RenderFonts()
{
list<KX_FontObject*>::iterator it = m_fonts.begin();
while (it != m_fonts.end()) {
- (*it)->DrawText();
+ (*it)->DrawFontText();
++it;
}
}
@@ -1848,7 +1871,7 @@ short KX_Scene::GetAnimationFPS()
return m_blenderScene->r.frs_sec;
}
-static void MergeScene_LogicBrick(SCA_ILogicBrick* brick, KX_Scene *to)
+static void MergeScene_LogicBrick(SCA_ILogicBrick* brick, KX_Scene *from, KX_Scene *to)
{
SCA_LogicManager *logicmgr= to->GetLogicManager();
@@ -1856,12 +1879,13 @@ static void MergeScene_LogicBrick(SCA_ILogicBrick* brick, KX_Scene *to)
brick->Replace_NetworkScene(to->GetNetworkScene());
/* near sensors have physics controllers */
-#ifdef WITH_BULLET
KX_TouchSensor *touch_sensor = dynamic_cast<class KX_TouchSensor *>(brick);
if (touch_sensor) {
+ KX_TouchEventManager *tmgr = (KX_TouchEventManager*)from->GetLogicManager()->FindEventManager(SCA_EventManager::TOUCH_EVENTMGR);
+ touch_sensor->UnregisterSumo(tmgr);
touch_sensor->GetPhysicsController()->SetPhysicsEnvironment(to->GetPhysicsEnvironment());
+ touch_sensor->RegisterSumo(tmgr);
}
-#endif
// If we end up replacing a KX_TouchEventManager, we need to make sure
// physics controllers are properly in place. In other words, do this
@@ -1875,11 +1899,20 @@ static void MergeScene_LogicBrick(SCA_ILogicBrick* brick, KX_Scene *to)
if (filter_actuator) {
filter_actuator->SetScene(to);
}
-}
-#ifdef WITH_BULLET
-#include "CcdGraphicController.h" // XXX ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment());
+#ifdef WITH_PYTHON
+ // Python must be called from the main thread unless we want to deal
+ // with GIL issues. So, this is delayed until here in case of async
+ // libload (originally in KX_ConvertControllers)
+ SCA_PythonController *pyctrl = dynamic_cast<SCA_PythonController*>(brick);
+ if (pyctrl) {
+ pyctrl->SetNamespace(KX_GetActiveEngine()->GetPyNamespace());
+
+ if (pyctrl->m_mode==SCA_PythonController::SCA_PYEXEC_SCRIPT)
+ pyctrl->Compile();
+ }
#endif
+}
static void MergeScene_GameObject(KX_GameObject* gameobj, KX_Scene *to, KX_Scene *from)
{
@@ -1889,7 +1922,7 @@ static void MergeScene_GameObject(KX_GameObject* gameobj, KX_Scene *to, KX_Scene
for (ita = actuators.begin(); !(ita==actuators.end()); ++ita)
{
- MergeScene_LogicBrick(*ita, to);
+ MergeScene_LogicBrick(*ita, from, to);
}
}
@@ -1900,7 +1933,7 @@ static void MergeScene_GameObject(KX_GameObject* gameobj, KX_Scene *to, KX_Scene
for (its = sensors.begin(); !(its==sensors.end()); ++its)
{
- MergeScene_LogicBrick(*its, to);
+ MergeScene_LogicBrick(*its, from, to);
}
}
@@ -1911,17 +1944,17 @@ static void MergeScene_GameObject(KX_GameObject* gameobj, KX_Scene *to, KX_Scene
for (itc = controllers.begin(); !(itc==controllers.end()); ++itc)
{
SCA_IController *cont= *itc;
- MergeScene_LogicBrick(cont, to);
+ MergeScene_LogicBrick(cont, from, to);
vector<SCA_ISensor*> linkedsensors = cont->GetLinkedSensors();
vector<SCA_IActuator*> linkedactuators = cont->GetLinkedActuators();
for (vector<SCA_IActuator*>::iterator ita = linkedactuators.begin();!(ita==linkedactuators.end());++ita) {
- MergeScene_LogicBrick(*ita, to);
+ MergeScene_LogicBrick(*ita, from, to);
}
for (vector<SCA_ISensor*>::iterator its = linkedsensors.begin();!(its==linkedsensors.end());++its) {
- MergeScene_LogicBrick(*its, to);
+ MergeScene_LogicBrick(*its, from, to);
}
}
}
@@ -1933,12 +1966,10 @@ static void MergeScene_GameObject(KX_GameObject* gameobj, KX_Scene *to, KX_Scene
ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment());
}
-#ifdef WITH_BULLET
ctrl = gameobj->GetPhysicsController();
if (ctrl) {
ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment());
}
-#endif
/* SG_Node can hold a scene reference */
SG_Node *sg= gameobj->GetSGNode();
@@ -1969,9 +2000,8 @@ static void MergeScene_GameObject(KX_GameObject* gameobj, KX_Scene *to, KX_Scene
bool KX_Scene::MergeScene(KX_Scene *other)
{
-#ifdef WITH_BULLET
- CcdPhysicsEnvironment *env= dynamic_cast<CcdPhysicsEnvironment *>(this->GetPhysicsEnvironment());
- CcdPhysicsEnvironment *env_other= dynamic_cast<CcdPhysicsEnvironment *>(other->GetPhysicsEnvironment());
+ PHY_IPhysicsEnvironment *env = this->GetPhysicsEnvironment();
+ PHY_IPhysicsEnvironment *env_other = other->GetPhysicsEnvironment();
if ((env==NULL) != (env_other==NULL)) /* TODO - even when both scenes have NONE physics, the other is loaded with bullet enabled, ??? */
{
@@ -1979,7 +2009,6 @@ bool KX_Scene::MergeScene(KX_Scene *other)
printf("\tsource %d, terget %d\n", (int)(env!=NULL), (int)(env_other!=NULL));
return false;
}
-#endif // WITH_BULLET
if (GetSceneConverter() != other->GetSceneConverter()) {
printf("KX_Scene::MergeScene: converters differ, aborting\n");
@@ -2021,10 +2050,8 @@ bool KX_Scene::MergeScene(KX_Scene *other)
GetLightList()->MergeList(other->GetLightList());
other->GetLightList()->ReleaseAndRemoveAll();
-#ifdef WITH_BULLET
- if (env) /* bullet scene? - dummy scenes don't need touching */
+ if (env)
env->MergeEnvironment(env_other);
-#endif
/* move materials across, assume they both use the same scene-converters
* Do this after lights are merged so materials can use the lights in shaders
diff --git a/source/gameengine/Ketsji/KX_TouchEventManager.h b/source/gameengine/Ketsji/KX_TouchEventManager.h
index 63e9d15959e..bd4903c1545 100644
--- a/source/gameengine/Ketsji/KX_TouchEventManager.h
+++ b/source/gameengine/Ketsji/KX_TouchEventManager.h
@@ -77,7 +77,6 @@ public:
virtual void RemoveSensor(SCA_ISensor* sensor);
SCA_LogicManager* GetLogicManager() { return m_logicmgr;}
PHY_IPhysicsEnvironment *GetPhysicsEnvironment() { return m_physEnv; }
- virtual void Replace_PhysicsScene(PHY_IPhysicsEnvironment* env) { m_physEnv= env; }
#ifdef WITH_CXX_GUARDEDALLOC
diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp
index 1b8ef09aec8..5cb1d5f3620 100644
--- a/source/gameengine/Ketsji/KX_TouchSensor.cpp
+++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp
@@ -208,10 +208,6 @@ bool KX_TouchSensor::BroadPhaseSensorFilterCollision(void*obj1,void*obj2)
KX_ClientObjectInfo *my_client_info = static_cast<KX_ClientObjectInfo*>(m_physCtrl->GetNewClientInfo());
KX_GameObject* otherobj = ( client_info ? client_info->m_gameobject : NULL);
- // first, decrement refcount as GetParent() increases it
- if (myparent)
- myparent->Release();
-
// we can only check on persistent characteristic: m_link and m_suspended are not
// good candidate because they are transient. That must be handled at another level
if (!otherobj ||
diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp
index 44a6e2fd7ee..90b7850946b 100644
--- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp
+++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp
@@ -79,8 +79,6 @@ KX_TrackToActuator::KX_TrackToActuator(SCA_IObject *gameobj,
m_parentlocalmat = m_parentobj->GetSGNode()->GetLocalOrientation();
// use registration mechanism rather than AddRef, it creates zombie objects
m_parentobj->RegisterActuator(this);
- // GetParent did AddRef, undo here
- m_parentobj->Release();
}
}
}
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
index 33726018268..c98cf212265 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
@@ -1625,6 +1625,41 @@ PHY_IPhysicsController* CcdPhysicsController::GetReplicaForSensors()
return replica;
}
+/* Refresh the physics object from either an object or a mesh.
+ * from_gameobj and from_meshobj can be NULL
+ *
+ * when setting the mesh, the following vars get priority
+ * 1) from_meshobj - creates the phys mesh from RAS_MeshObject
+ * 2) from_gameobj - creates the phys mesh from the DerivedMesh where possible, else the RAS_MeshObject
+ * 3) this - update the phys mesh from DerivedMesh or RAS_MeshObject
+ *
+ * Most of the logic behind this is in shapeInfo->UpdateMesh(...)
+ */
+bool CcdPhysicsController::ReinstancePhysicsShape(KX_GameObject *from_gameobj, RAS_MeshObject *from_meshobj)
+{
+ CcdShapeConstructionInfo *shapeInfo;
+
+ shapeInfo = this->GetShapeInfo();
+
+ if (shapeInfo->m_shapeType != PHY_SHAPE_MESH/* || spc->GetSoftBody()*/)
+ return false;
+
+ this->DeleteControllerShape();
+
+ if (from_gameobj==NULL && from_meshobj==NULL)
+ from_gameobj = KX_GameObject::GetClientObject((KX_ClientObjectInfo*)this->GetNewClientInfo());
+
+ /* updates the arrays used for making the new bullet mesh */
+ shapeInfo->UpdateMesh(from_gameobj, from_meshobj);
+
+ /* create the new bullet mesh */
+ CcdConstructionInfo& cci = this->GetConstructionInfo();
+ btCollisionShape* bm= shapeInfo->CreateBulletShape(cci.m_margin, cci.m_bGimpact, !cci.m_bSoft);
+
+ this->ReplaceControllerShape(bm);
+ return true;
+}
+
///////////////////////////////////////////////////////////
///A small utility class, DefaultMotionState
///
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h
index 0d6d40861c5..25a8f0306bd 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h
@@ -287,8 +287,8 @@ struct CcdConstructionInfo
m_fh_spring(0.f),
m_fh_damping(0.f),
m_fh_distance(1.f),
- m_fh_normal(false),
- m_contactProcessingThreshold(1e10f)
+ m_fh_normal(false)
+ // m_contactProcessingThreshold(1e10f)
{
}
@@ -390,8 +390,7 @@ struct CcdConstructionInfo
///however, rigid body stacking is more stable when positive contacts are still passed into the constraint solver
///this might sometimes lead to collisions with 'internal edges' such as a sliding character controller
///so disable/set m_contactProcessingThreshold to zero for sliding characters etc.
- float m_contactProcessingThreshold;///< Process contacts with positive distance in range [0..INF]
-
+ // float m_contactProcessingThreshold;///< Process contacts with positive distance in range [0..INF]
};
class btRigidBody;
@@ -704,6 +703,8 @@ protected:
return GetConstructionInfo().m_shapeInfo->m_shapeType == PHY_SHAPE_COMPOUND;
}
+ virtual bool ReinstancePhysicsShape(KX_GameObject *from_gameobj, RAS_MeshObject* from_meshobj);
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:CcdPhysicsController")
#endif
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
index b6a46b4307e..bbc3968347c 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -39,11 +39,22 @@ subject to the following restrictions:
#include "PHY_IMotionState.h"
#include "PHY_ICharacter.h"
+#include "PHY_Pro.h"
#include "KX_GameObject.h"
+#include "KX_PythonInit.h" // for KX_RasterizerDrawDebugLine
#include "RAS_MeshObject.h"
#include "RAS_Polygon.h"
#include "RAS_TexVert.h"
+#include "DNA_scene_types.h"
+#include "DNA_world_types.h"
+#include "DNA_object_force.h"
+
+extern "C" {
+ #include "BLI_utildefines.h"
+ #include "BKE_object.h"
+}
+
#define CCD_CONSTRAINT_DISABLE_LINKED_COLLISION 0x80
#ifdef NEW_BULLET_VEHICLE_SUPPORT
@@ -57,6 +68,7 @@ static btRaycastVehicle::btVehicleTuning gTuning;
#include "LinearMath/btAabbUtil2.h"
#include "MT_Matrix4x4.h"
#include "MT_Vector3.h"
+#include "MT_MinMax.h"
#ifdef WIN32
void DrawRasterizerLine(const float* from,const float* to,int color);
@@ -69,6 +81,21 @@ void DrawRasterizerLine(const float* from,const float* to,int color);
#include <stdio.h>
#include <string.h> // for memset
+// This was copied from the old KX_ConvertPhysicsObjects
+#ifdef WIN32
+#if defined(_MSC_VER) && (_MSC_VER >= 1310)
+//only use SIMD Hull code under Win32
+//#define TEST_HULL 1
+#ifdef TEST_HULL
+#define USE_HULL 1
+//#define TEST_SIMD_HULL 1
+
+#include "NarrowPhaseCollision/Hull.h"
+#endif //#ifdef TEST_HULL
+
+#endif //_MSC_VER
+#endif //WIN32
+
#ifdef NEW_BULLET_VEHICLE_SUPPORT
class WrapperVehicle : public PHY_IVehicle
{
@@ -1871,8 +1898,14 @@ btDispatcher* CcdPhysicsEnvironment::GetDispatcher()
return m_dynamicsWorld->getDispatcher();
}
-void CcdPhysicsEnvironment::MergeEnvironment(CcdPhysicsEnvironment *other)
+void CcdPhysicsEnvironment::MergeEnvironment(PHY_IPhysicsEnvironment *other_env)
{
+ CcdPhysicsEnvironment *other = dynamic_cast<CcdPhysicsEnvironment*>(other_env);
+ if (other == NULL) {
+ printf("KX_Scene::MergeScene: Other scene is not using Bullet physics, not merging physics.\n");
+ return;
+ }
+
std::set<CcdPhysicsController*>::iterator it;
while (other->m_controllers.begin() != other->m_controllers.end())
@@ -2891,3 +2924,510 @@ void CcdPhysicsEnvironment::ExportFile(const char* filename)
}
}
+struct BlenderDebugDraw : public btIDebugDraw
+{
+ BlenderDebugDraw () :
+ m_debugMode(0)
+ {
+ }
+
+ int m_debugMode;
+
+ virtual void drawLine(const btVector3& from,const btVector3& to,const btVector3& color)
+ {
+ if (m_debugMode >0)
+ {
+ MT_Vector3 kxfrom(from[0],from[1],from[2]);
+ MT_Vector3 kxto(to[0],to[1],to[2]);
+ MT_Vector3 kxcolor(color[0],color[1],color[2]);
+
+ KX_RasterizerDrawDebugLine(kxfrom,kxto,kxcolor);
+ }
+ }
+
+ virtual void reportErrorWarning(const char* warningString)
+ {
+
+ }
+
+ virtual void drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,float distance,int lifeTime,const btVector3& color)
+ {
+ //not yet
+ }
+
+ virtual void setDebugMode(int debugMode)
+ {
+ m_debugMode = debugMode;
+ }
+ virtual int getDebugMode() const
+ {
+ return m_debugMode;
+ }
+ ///todo: find out if Blender can do this
+ virtual void draw3dText(const btVector3& location,const char* textString)
+ {
+
+ }
+
+};
+
+CcdPhysicsEnvironment *CcdPhysicsEnvironment::Create(Scene *blenderscene, bool visualizePhysics)
+{
+ CcdPhysicsEnvironment* ccdPhysEnv = new CcdPhysicsEnvironment((blenderscene->gm.mode & WO_DBVT_CULLING) != 0);
+ ccdPhysEnv->SetDebugDrawer(new BlenderDebugDraw());
+ ccdPhysEnv->SetDeactivationLinearTreshold(blenderscene->gm.lineardeactthreshold);
+ ccdPhysEnv->SetDeactivationAngularTreshold(blenderscene->gm.angulardeactthreshold);
+ ccdPhysEnv->SetDeactivationTime(blenderscene->gm.deactivationtime);
+
+ if (visualizePhysics)
+ ccdPhysEnv->SetDebugMode(btIDebugDraw::DBG_DrawWireframe|btIDebugDraw::DBG_DrawAabb|btIDebugDraw::DBG_DrawContactPoints|btIDebugDraw::DBG_DrawText|btIDebugDraw::DBG_DrawConstraintLimits|btIDebugDraw::DBG_DrawConstraints);
+
+ return ccdPhysEnv;
+}
+
+void CcdPhysicsEnvironment::ConvertObject(KX_GameObject *gameobj, RAS_MeshObject *meshobj, DerivedMesh *dm, KX_Scene *kxscene, PHY_ShapeProps *shapeprops, PHY_MaterialProps *smmaterial, PHY_IMotionState *motionstate, int activeLayerBitInfo, bool isCompoundChild, bool hasCompoundChildren)
+{
+ Object* blenderobject = gameobj->GetBlenderObject();
+
+ bool isbulletdyna = (blenderobject->gameflag & OB_DYNAMIC) != 0;;
+ bool isbulletsensor = (blenderobject->gameflag & OB_SENSOR) != 0;
+ bool isbulletchar = (blenderobject->gameflag & OB_CHARACTER) != 0;
+ bool isbulletsoftbody = (blenderobject->gameflag & OB_SOFT_BODY) != 0;
+ bool isbulletrigidbody = (blenderobject->gameflag & OB_RIGID_BODY) != 0;
+ bool useGimpact = false;
+ CcdConstructionInfo ci;
+ class CcdShapeConstructionInfo *shapeInfo = new CcdShapeConstructionInfo();
+
+ KX_GameObject *parent = gameobj->GetParent();
+ if (parent)
+ {
+ isbulletdyna = false;
+ isbulletsoftbody = false;
+ shapeprops->m_mass = 0.f;
+ }
+
+ if (!isbulletdyna)
+ {
+ ci.m_collisionFlags |= btCollisionObject::CF_STATIC_OBJECT;
+ }
+ if ((blenderobject->gameflag & (OB_GHOST | OB_SENSOR | OB_CHARACTER)) != 0)
+ {
+ ci.m_collisionFlags |= btCollisionObject::CF_NO_CONTACT_RESPONSE;
+ }
+
+ ci.m_MotionState = motionstate;
+ ci.m_gravity = btVector3(0,0,0);
+ ci.m_linearFactor = btVector3(((blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_X_AXIS) !=0)? 0 : 1,
+ ((blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_Y_AXIS) !=0)? 0 : 1,
+ ((blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_Z_AXIS) !=0)? 0 : 1);
+ ci.m_angularFactor = btVector3(((blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_X_ROT_AXIS) !=0)? 0 : 1,
+ ((blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_Y_ROT_AXIS) !=0)? 0 : 1,
+ ((blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_Z_ROT_AXIS) !=0)? 0 : 1);
+ ci.m_localInertiaTensor =btVector3(0,0,0);
+ ci.m_mass = isbulletdyna ? shapeprops->m_mass : 0.f;
+ ci.m_clamp_vel_min = shapeprops->m_clamp_vel_min;
+ ci.m_clamp_vel_max = shapeprops->m_clamp_vel_max;
+ ci.m_stepHeight = isbulletchar ? shapeprops->m_step_height : 0.f;
+ ci.m_jumpSpeed = isbulletchar ? shapeprops->m_jump_speed : 0.f;
+ ci.m_fallSpeed = isbulletchar ? shapeprops->m_fall_speed : 0.f;
+
+ //mmm, for now, take this for the size of the dynamicobject
+ // Blender uses inertia for radius of dynamic object
+ shapeInfo->m_radius = ci.m_radius = blenderobject->inertia;
+ useGimpact = ((isbulletdyna || isbulletsensor) && !isbulletsoftbody);
+
+ if (isbulletsoftbody)
+ {
+ if (blenderobject->bsoft)
+ {
+ ci.m_margin = blenderobject->bsoft->margin;
+ }
+ else
+ {
+ ci.m_margin = 0.f;
+ }
+ }
+ else
+ {
+ ci.m_margin = blenderobject->margin;
+ }
+
+ ci.m_localInertiaTensor = btVector3(ci.m_mass/3.f,ci.m_mass/3.f,ci.m_mass/3.f);
+
+ btCollisionShape* bm = 0;
+
+ char bounds;
+ if (blenderobject->gameflag & OB_BOUNDS)
+ {
+ bounds = blenderobject->collision_boundtype;
+ }
+ else
+ {
+ if (blenderobject->gameflag & OB_SOFT_BODY)
+ bounds = OB_BOUND_TRIANGLE_MESH;
+ else if (blenderobject->gameflag & OB_CHARACTER)
+ bounds = OB_BOUND_SPHERE;
+ else if (isbulletdyna)
+ bounds = OB_BOUND_SPHERE;
+ else
+ bounds = OB_BOUND_TRIANGLE_MESH;
+ }
+
+ // Can't use triangle mesh or convex hull on a non-mesh object, fall-back to sphere
+ if (ELEM(bounds, OB_BOUND_TRIANGLE_MESH, OB_BOUND_CONVEX_HULL) && blenderobject->type != OB_MESH)
+ bounds = OB_BOUND_SPHERE;
+
+ // Get bounds information
+ float bounds_center[3], bounds_extends[3];
+ BoundBox *bb= BKE_object_boundbox_get(blenderobject);
+ if (bb==NULL)
+ {
+ bounds_center[0] = bounds_center[1] = bounds_center[2] = 0.0;
+ bounds_extends[0] = bounds_extends[1] = bounds_extends[2] = 1.0;
+ }
+ else
+ {
+ bounds_extends[0] = 0.5f * fabsf(bb->vec[0][0] - bb->vec[4][0]);
+ bounds_extends[1] = 0.5f * fabsf(bb->vec[0][1] - bb->vec[2][1]);
+ bounds_extends[2] = 0.5f * fabsf(bb->vec[0][2] - bb->vec[1][2]);
+
+ bounds_center[0] = 0.5f * (bb->vec[0][0] + bb->vec[4][0]);
+ bounds_center[1] = 0.5f * (bb->vec[0][1] + bb->vec[2][1]);
+ bounds_center[2] = 0.5f * (bb->vec[0][2] + bb->vec[1][2]);
+ }
+
+ switch (bounds)
+ {
+ case OB_BOUND_SPHERE:
+ {
+ //float radius = objprop->m_radius;
+ //btVector3 inertiaHalfExtents (
+ // radius,
+ // radius,
+ // radius);
+
+ //blender doesn't support multisphere, but for testing:
+
+ //bm = new MultiSphereShape(inertiaHalfExtents,,&trans.getOrigin(),&radius,1);
+ shapeInfo->m_shapeType = PHY_SHAPE_SPHERE;
+ // XXX We calculated the radius but didn't use it?
+ // objprop.m_boundobject.c.m_radius = MT_max(bb.m_extends[0], MT_max(bb.m_extends[1], bb.m_extends[2]));
+ bm = shapeInfo->CreateBulletShape(ci.m_margin);
+ break;
+ };
+ case OB_BOUND_BOX:
+ {
+ shapeInfo->m_halfExtend.setValue(
+ 2.f * bounds_extends[0],
+ 2.f * bounds_extends[1],
+ 2.f * bounds_extends[2]);
+
+ shapeInfo->m_halfExtend /= 2.0;
+ shapeInfo->m_halfExtend = shapeInfo->m_halfExtend.absolute();
+ shapeInfo->m_shapeType = PHY_SHAPE_BOX;
+ bm = shapeInfo->CreateBulletShape(ci.m_margin);
+ break;
+ };
+ case OB_BOUND_CYLINDER:
+ {
+ float radius = MT_max(bounds_extends[0], bounds_extends[1]);
+ shapeInfo->m_halfExtend.setValue(
+ radius,
+ radius,
+ bounds_extends[2]
+ );
+ shapeInfo->m_shapeType = PHY_SHAPE_CYLINDER;
+ bm = shapeInfo->CreateBulletShape(ci.m_margin);
+ break;
+ }
+
+ case OB_BOUND_CONE:
+ {
+ shapeInfo->m_radius = MT_max(bounds_extends[0], bounds_extends[1]);
+ shapeInfo->m_height = 2.f * bounds_extends[2];
+ shapeInfo->m_shapeType = PHY_SHAPE_CONE;
+ bm = shapeInfo->CreateBulletShape(ci.m_margin);
+ break;
+ }
+ case OB_BOUND_CONVEX_HULL:
+ {
+ shapeInfo->SetMesh(meshobj, dm,true);
+ bm = shapeInfo->CreateBulletShape(ci.m_margin);
+ break;
+ }
+ case OB_BOUND_CAPSULE:
+ {
+ shapeInfo->m_radius = MT_max(bounds_extends[0], bounds_extends[1]);
+ shapeInfo->m_height = 2.f * (bounds_extends[2] - shapeInfo->m_radius);
+ if (shapeInfo->m_height < 0.f)
+ shapeInfo->m_height = 0.f;
+ shapeInfo->m_shapeType = PHY_SHAPE_CAPSULE;
+ bm = shapeInfo->CreateBulletShape(ci.m_margin);
+ break;
+ }
+ case OB_BOUND_TRIANGLE_MESH:
+ {
+ // mesh shapes can be shared, check first if we already have a shape on that mesh
+ class CcdShapeConstructionInfo *sharedShapeInfo = CcdShapeConstructionInfo::FindMesh(meshobj, dm, false);
+ if (sharedShapeInfo != NULL)
+ {
+ shapeInfo->Release();
+ shapeInfo = sharedShapeInfo;
+ shapeInfo->AddRef();
+ } else
+ {
+ shapeInfo->SetMesh(meshobj, dm, false);
+ }
+
+ // Soft bodies can benefit from welding, don't do it on non-soft bodies
+ if (isbulletsoftbody)
+ {
+ // disable welding: it doesn't bring any additional stability and it breaks the relation between soft body collision shape and graphic mesh
+ // shapeInfo->setVertexWeldingThreshold1((blenderobject->bsoft) ? blenderobject->bsoft->welding ? 0.f);
+ shapeInfo->setVertexWeldingThreshold1(0.f); //todo: expose this to the UI
+ }
+
+ bm = shapeInfo->CreateBulletShape(ci.m_margin, useGimpact, !isbulletsoftbody);
+ //should we compute inertia for dynamic shape?
+ //bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor);
+
+ break;
+ }
+ }
+
+
+// ci.m_localInertiaTensor.setValue(0.1f,0.1f,0.1f);
+
+ if (!bm)
+ {
+ delete motionstate;
+ shapeInfo->Release();
+ return;
+ }
+
+ //bm->setMargin(ci.m_margin);
+
+
+ if (isCompoundChild)
+ {
+ //find parent, compound shape and add to it
+ //take relative transform into account!
+ CcdPhysicsController* parentCtrl = (CcdPhysicsController*)parent->GetPhysicsController();
+ assert(parentCtrl);
+ CcdShapeConstructionInfo* parentShapeInfo = parentCtrl->GetShapeInfo();
+ btRigidBody* rigidbody = parentCtrl->GetRigidBody();
+ btCollisionShape* colShape = rigidbody->getCollisionShape();
+ assert(colShape->isCompound());
+ btCompoundShape* compoundShape = (btCompoundShape*)colShape;
+
+ // compute the local transform from parent, this may include several node in the chain
+ SG_Node* gameNode = gameobj->GetSGNode();
+ SG_Node* parentNode = parent->GetSGNode();
+ // relative transform
+ MT_Vector3 parentScale = parentNode->GetWorldScaling();
+ parentScale[0] = MT_Scalar(1.0)/parentScale[0];
+ parentScale[1] = MT_Scalar(1.0)/parentScale[1];
+ parentScale[2] = MT_Scalar(1.0)/parentScale[2];
+ MT_Vector3 relativeScale = gameNode->GetWorldScaling() * parentScale;
+ MT_Matrix3x3 parentInvRot = parentNode->GetWorldOrientation().transposed();
+ MT_Vector3 relativePos = parentInvRot*((gameNode->GetWorldPosition()-parentNode->GetWorldPosition())*parentScale);
+ MT_Matrix3x3 relativeRot = parentInvRot*gameNode->GetWorldOrientation();
+
+ shapeInfo->m_childScale.setValue(relativeScale[0],relativeScale[1],relativeScale[2]);
+ bm->setLocalScaling(shapeInfo->m_childScale);
+ shapeInfo->m_childTrans.getOrigin().setValue(relativePos[0],relativePos[1],relativePos[2]);
+ float rot[12];
+ relativeRot.getValue(rot);
+ shapeInfo->m_childTrans.getBasis().setFromOpenGLSubMatrix(rot);
+
+ parentShapeInfo->AddShape(shapeInfo);
+ compoundShape->addChildShape(shapeInfo->m_childTrans,bm);
+ //do some recalc?
+ //recalc inertia for rigidbody
+ if (!rigidbody->isStaticOrKinematicObject())
+ {
+ btVector3 localInertia;
+ float mass = 1.f/rigidbody->getInvMass();
+ compoundShape->calculateLocalInertia(mass,localInertia);
+ rigidbody->setMassProps(mass,localInertia);
+ }
+ shapeInfo->Release();
+ // delete motionstate as it's not used
+ delete motionstate;
+ return;
+ }
+
+ if (hasCompoundChildren)
+ {
+ // create a compound shape info
+ CcdShapeConstructionInfo *compoundShapeInfo = new CcdShapeConstructionInfo();
+ compoundShapeInfo->m_shapeType = PHY_SHAPE_COMPOUND;
+ compoundShapeInfo->AddShape(shapeInfo);
+ // create the compound shape manually as we already have the child shape
+ btCompoundShape* compoundShape = new btCompoundShape();
+ compoundShape->addChildShape(shapeInfo->m_childTrans,bm);
+ // now replace the shape
+ bm = compoundShape;
+ shapeInfo->Release();
+ shapeInfo = compoundShapeInfo;
+ }
+
+
+
+
+
+
+#ifdef TEST_SIMD_HULL
+ if (bm->IsPolyhedral())
+ {
+ PolyhedralConvexShape* polyhedron = static_cast<PolyhedralConvexShape*>(bm);
+ if (!polyhedron->m_optionalHull)
+ {
+ //first convert vertices in 'Point3' format
+ int numPoints = polyhedron->GetNumVertices();
+ Point3* points = new Point3[numPoints+1];
+ //first 4 points should not be co-planar, so add central point to satisfy MakeHull
+ points[0] = Point3(0.f,0.f,0.f);
+
+ btVector3 vertex;
+ for (int p=0;p<numPoints;p++)
+ {
+ polyhedron->GetVertex(p,vertex);
+ points[p+1] = Point3(vertex.getX(),vertex.getY(),vertex.getZ());
+ }
+
+ Hull* hull = Hull::MakeHull(numPoints+1,points);
+ polyhedron->m_optionalHull = hull;
+ }
+
+ }
+#endif //TEST_SIMD_HULL
+
+
+ ci.m_collisionShape = bm;
+ ci.m_shapeInfo = shapeInfo;
+ ci.m_friction = smmaterial->m_friction;//tweak the friction a bit, so the default 0.5 works nice
+ ci.m_restitution = smmaterial->m_restitution;
+ ci.m_physicsEnv = this;
+ // drag / damping is inverted
+ ci.m_linearDamping = 1.f - shapeprops->m_lin_drag;
+ ci.m_angularDamping = 1.f - shapeprops->m_ang_drag;
+ //need a bit of damping, else system doesn't behave well
+ ci.m_inertiaFactor = shapeprops->m_inertia/0.4f;//defaults to 0.4, don't want to change behavior
+
+ ci.m_do_anisotropic = shapeprops->m_do_anisotropic;
+ ci.m_anisotropicFriction.setValue(shapeprops->m_friction_scaling[0],shapeprops->m_friction_scaling[1],shapeprops->m_friction_scaling[2]);
+
+
+//////////
+ //do Fh, do Rot Fh
+ ci.m_do_fh = shapeprops->m_do_fh;
+ ci.m_do_rot_fh = shapeprops->m_do_rot_fh;
+ ci.m_fh_damping = smmaterial->m_fh_damping;
+ ci.m_fh_distance = smmaterial->m_fh_distance;
+ ci.m_fh_normal = smmaterial->m_fh_normal;
+ ci.m_fh_spring = smmaterial->m_fh_spring;
+
+ ci.m_collisionFilterGroup =
+ (isbulletsensor) ? short(CcdConstructionInfo::SensorFilter) :
+ (isbulletdyna) ? short(CcdConstructionInfo::DefaultFilter) :
+ (isbulletchar) ? short(CcdConstructionInfo::CharacterFilter) :
+ short(CcdConstructionInfo::StaticFilter);
+ ci.m_collisionFilterMask =
+ (isbulletsensor) ? short(CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter) :
+ (isbulletdyna) ? short(CcdConstructionInfo::AllFilter) :
+ (isbulletchar) ? short(CcdConstructionInfo::AllFilter) :
+ short(CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::StaticFilter);
+ ci.m_bRigid = isbulletdyna && isbulletrigidbody;
+ ci.m_bSoft = isbulletsoftbody;
+ ci.m_bDyna = isbulletdyna;
+ ci.m_bSensor = isbulletsensor;
+ ci.m_bCharacter = isbulletchar;
+ ci.m_bGimpact = useGimpact;
+ MT_Vector3 scaling = gameobj->NodeGetWorldScaling();
+ ci.m_scaling.setValue(scaling[0], scaling[1], scaling[2]);
+ CcdPhysicsController* physicscontroller = new CcdPhysicsController(ci);
+ // shapeInfo is reference counted, decrement now as we don't use it anymore
+ if (shapeInfo)
+ shapeInfo->Release();
+
+ gameobj->SetPhysicsController(physicscontroller,isbulletdyna);
+
+ // record animation for dynamic objects
+ if (isbulletdyna)
+ gameobj->SetRecordAnimation(true);
+
+ // don't add automatically sensor object, they are added when a collision sensor is registered
+ if (!isbulletsensor && (blenderobject->lay & activeLayerBitInfo) != 0)
+ {
+ this->AddCcdPhysicsController( physicscontroller);
+ }
+ physicscontroller->SetNewClientInfo(gameobj->getClientInfo());
+ {
+ btRigidBody* rbody = physicscontroller->GetRigidBody();
+
+ if (rbody)
+ {
+ if (isbulletrigidbody)
+ {
+ rbody->setLinearFactor(ci.m_linearFactor);
+ rbody->setAngularFactor(ci.m_angularFactor);
+ }
+
+ if (rbody && (blenderobject->gameflag & OB_COLLISION_RESPONSE) != 0)
+ {
+ rbody->setActivationState(DISABLE_DEACTIVATION);
+ }
+ }
+ }
+
+ CcdPhysicsController* parentCtrl = parent ? (CcdPhysicsController*)parent->GetPhysicsController() : 0;
+ physicscontroller->SetParentCtrl(parentCtrl);
+
+
+ //Now done directly in ci.m_collisionFlags so that it propagates to replica
+ //if (objprop->m_ghost)
+ //{
+ // rbody->setCollisionFlags(rbody->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE);
+ //}
+
+ if (isbulletdyna && !isbulletrigidbody)
+ {
+#if 0
+ //setting the inertia could achieve similar results to constraint the up
+ //but it is prone to instability, so use special 'Angular' constraint
+ btVector3 inertia = physicscontroller->GetRigidBody()->getInvInertiaDiagLocal();
+ inertia.setX(0.f);
+ inertia.setZ(0.f);
+
+ physicscontroller->GetRigidBody()->setInvInertiaDiagLocal(inertia);
+ physicscontroller->GetRigidBody()->updateInertiaTensor();
+#endif
+
+ //this->createConstraint(physicscontroller,0,PHY_ANGULAR_CONSTRAINT,0,0,0,0,0,1);
+
+ //Now done directly in ci.m_bRigid so that it propagates to replica
+ //physicscontroller->GetRigidBody()->setAngularFactor(0.f);
+ ;
+ }
+
+
+ STR_String materialname;
+ if (meshobj)
+ materialname = meshobj->GetMaterialName(0);
+
+
+#if 0
+ ///test for soft bodies
+ if (objprop->m_softbody && physicscontroller)
+ {
+ btSoftBody* softBody = physicscontroller->GetSoftBody();
+ if (softBody && gameobj->GetMesh(0))//only the first mesh, if any
+ {
+ //should be a mesh then, so add a soft body deformer
+ KX_SoftBodyDeformer* softbodyDeformer = new KX_SoftBodyDeformer( gameobj->GetMesh(0),(BL_DeformableGameObject*)gameobj);
+ gameobj->SetDeformer(softbodyDeformer);
+ }
+ }
+#endif
+}
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
index 0e8ac9417f0..a94e205b160 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
@@ -258,7 +258,20 @@ protected:
class btConstraintSolver* GetConstraintSolver();
- void MergeEnvironment(CcdPhysicsEnvironment *other);
+ void MergeEnvironment(PHY_IPhysicsEnvironment *other_env);
+
+ static CcdPhysicsEnvironment *Create(struct Scene *blenderscene, bool visualizePhysics);
+
+ virtual void ConvertObject(KX_GameObject* gameobj,
+ RAS_MeshObject* meshobj,
+ DerivedMesh* dm,
+ KX_Scene* kxscene,
+ PHY_ShapeProps* shapeprops,
+ PHY_MaterialProps* smmaterial,
+ PHY_IMotionState *motionstate,
+ int activeLayerBitInfo,
+ bool isCompoundChild,
+ bool hasCompoundChildren);
protected:
diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
index 41462f91840..a645af1e471 100644
--- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
+++ b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
@@ -33,6 +33,7 @@
#define __DUMMYPHYSICSENVIRONMENT_H__
#include "PHY_IPhysicsEnvironment.h"
+#include "PHY_IMotionState.h"
/**
* DummyPhysicsEnvironment is an empty placeholder
@@ -103,6 +104,25 @@ public:
return 0.f;
}
+ virtual void MergeEnvironment(PHY_IPhysicsEnvironment *other_env)
+ {
+ // Dummy, nothing to do here
+ }
+
+ virtual void ConvertObject(KX_GameObject* gameobj,
+ RAS_MeshObject* meshobj,
+ DerivedMesh* dm,
+ KX_Scene* kxscene,
+ PHY_ShapeProps* shapeprops,
+ PHY_MaterialProps* smmaterial,
+ PHY_IMotionState *motionstate,
+ int activeLayerBitInfo,
+ bool isCompoundChild,
+ bool hasCompoundChildren)
+ {
+ // All we need to do is handle the motionstate (we're supposed to own it)
+ delete motionstate;
+ }
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:DummyPhysicsEnvironment")
diff --git a/source/gameengine/Physics/common/PHY_IPhysicsController.h b/source/gameengine/Physics/common/PHY_IPhysicsController.h
index a1d0972a950..2ffb115e3b2 100644
--- a/source/gameengine/Physics/common/PHY_IPhysicsController.h
+++ b/source/gameengine/Physics/common/PHY_IPhysicsController.h
@@ -41,6 +41,9 @@ class MT_Vector3;
class MT_Point3;
class MT_Matrix3x3;
+class KX_GameObject;
+class RAS_MeshObject;
+
/**
* PHY_IPhysicsController is the abstract simplified Interface to a physical object.
* It contains the IMotionState and IDeformableMesh Interfaces.
@@ -124,6 +127,8 @@ class PHY_IPhysicsController : public PHY_IController
virtual bool IsDynamic() = 0;
virtual bool IsCompound() = 0;
+ virtual bool ReinstancePhysicsShape(KX_GameObject *from_gameobj, RAS_MeshObject* from_meshobj) = 0;
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:PHY_IPhysicsController")
diff --git a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
index b1a0480ab14..81a45f93993 100644
--- a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
+++ b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
@@ -46,6 +46,16 @@ class PHY_ICharacter;
class RAS_MeshObject;
class PHY_IPhysicsController;
+
+class RAS_MeshObject;
+struct DerivedMesh;
+class KX_GameObject;
+class KX_Scene;
+
+struct PHY_ShapeProps;
+struct PHY_MaterialProps;
+class PHY_IMotionState;
+
/**
* pass back information from rayTest
*/
@@ -188,6 +198,19 @@ class PHY_IPhysicsEnvironment
virtual void ExportFile(const char* filename) {};
+ virtual void MergeEnvironment(PHY_IPhysicsEnvironment *other_env) = 0;
+
+ virtual void ConvertObject(KX_GameObject* gameobj,
+ RAS_MeshObject* meshobj,
+ DerivedMesh* dm,
+ KX_Scene* kxscene,
+ PHY_ShapeProps* shapeprops,
+ PHY_MaterialProps* smmaterial,
+ PHY_IMotionState *motionstate,
+ int activeLayerBitInfo,
+ bool isCompoundChild,
+ bool hasCompoundChildren) = 0;
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:PHY_IPhysicsEnvironment")
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
index 1227fe892a3..0960fdaab4f 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
@@ -1375,8 +1375,6 @@ void RAS_OpenGLRasterizer::applyTransform(double* oglmatrix,int objectdrawmode )
KX_GameObject *parent = gameobj->GetParent();
if (!physics_controller && parent)
physics_controller = parent->GetPhysicsController();
- if (parent)
- parent->Release();
KX_RayCast::Callback<RAS_OpenGLRasterizer> callback(this, physics_controller, oglmatrix);
if (!KX_RayCast::RayTest(physics_environment, frompoint, topoint, callback))
diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp
index 44017f37d29..179f1ced03b 100644
--- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp
+++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp
@@ -1005,9 +1005,20 @@ AVFrame *VideoFFmpeg::grabFrame(long position)
{
if (packet.stream_index == m_videoStream)
{
- avcodec_decode_video2(m_codecCtx,
- m_frame, &frameFinished,
+ if (m_isImage)
+ {
+ // If we're an image, we're probably not going to be here often,
+ // so we don't want to deal with delayed frames from threading.
+ // There might be a better way to handle this, but I'll leave that
+ // for people more knowledgeable with ffmpeg than myself. We don't
+ // need threading for a single image anyways.
+ m_codecCtx->thread_count = 1;
+ }
+
+ avcodec_decode_video2(m_codecCtx,
+ m_frame, &frameFinished,
&packet);
+
// remember dts to compute exact frame number
dts = packet.dts;
if (frameFinished && !posFound)
diff --git a/source/tests/bl_rna_wiki_reference.py b/source/tests/bl_rna_wiki_reference.py
index c394107d8d1..8cb20aaf7f6 100644
--- a/source/tests/bl_rna_wiki_reference.py
+++ b/source/tests/bl_rna_wiki_reference.py
@@ -118,7 +118,7 @@ def test_urls():
print(" %s ... " % url_full, end="")
sys.stdout.flush()
try:
- urllib.request.urlopen(url_full)
+ urlopen(url_full)
print(color_green + "OK" + color_normal)
except urllib.error.HTTPError:
print(color_red + "FAIL!" + color_normal)
diff --git a/source/tests/bl_run_operators.py b/source/tests/bl_run_operators.py
index 13bf615b8dc..e14b0ce6d32 100644
--- a/source/tests/bl_run_operators.py
+++ b/source/tests/bl_run_operators.py
@@ -105,7 +105,7 @@ def blend_list(mainpath):
def is_blend(filename):
ext = splitext(filename)[1]
- return (ext in {".blend",})
+ return (ext in {".blend", })
return list(sorted(file_list(mainpath, is_blend)))
diff --git a/source/tests/pep8.py b/source/tests/pep8.py
index 3ae1828c59a..cca49d54ac0 100644
--- a/source/tests/pep8.py
+++ b/source/tests/pep8.py
@@ -20,15 +20,16 @@
import os
-# depends on pep8, pyflakes, pylint
+# depends on pep8, frosted, pylint
# for Ubuntu
#
-# sudo apt-get install pylint pyflakes
+# sudo apt-get install pylint
#
# sudo apt-get install python-setuptools python-pip
# sudo pip install pep8
+# sudo pip install frosted
#
-# in Debian install pylint pyflakes pep8 with apt-get/aptitude/etc
+# in Debian install pylint pep8 with apt-get/aptitude/etc
#
# on *nix run
# python source/tests/pep8.py > test_pep8.log 2>&1
@@ -54,7 +55,7 @@ def is_pep8(path):
print("\nfile contains BOM, remove first 3 bytes: %r\n" % path)
# templates don't have a header but should be pep8
- for d in ("presets", "templates", "examples"):
+ for d in ("presets", "templates_py", "examples"):
if ("%s%s%s" % (os.sep, d, os.sep)) in path:
return 1
@@ -118,10 +119,10 @@ def main():
os.system("pep8 --repeat --ignore=%s '%s'" % (",".join(ignore_tmp), f))
- # pyflakes
- print("\n\n\n# running pyflakes...")
+ # frosted
+ print("\n\n\n# running frosted...")
for f, pep8_type in files:
- os.system("pyflakes '%s'" % f)
+ os.system("frosted '%s'" % f)
print("\n\n\n# running pylint...")
for f, pep8_type in files:
diff --git a/source/tests/rst_to_doctree_mini.py b/source/tests/rst_to_doctree_mini.py
index cb7b0291296..6a885a108f8 100644
--- a/source/tests/rst_to_doctree_mini.py
+++ b/source/tests/rst_to_doctree_mini.py
@@ -50,7 +50,6 @@ def parse_rst_py(filepath):
indent_map = {}
indent_prev = 0
f = open(filepath, encoding="utf-8")
- indent_lists = []
for i, line in enumerate(f):
line_strip = line.lstrip()
# ^\.\.\s[a-zA-Z09\-]+::.*$